Skip to content

Commit 7ae57b1

Browse files
author
Uwe Kleine-König
committed
gpio: mvebu: Make use of devm_pwmchip_alloc() function
This prepares the pwm sub-driver to further changes of the pwm core outlined in the commit introducing devm_pwmchip_alloc(). There is no intended semantical change and the driver should behave as before. Acked-by: Linus Walleij <[email protected]> Link: https://lore.kernel.org/r/2edc3adbb2c40b76b3b3dac82de82f3036bec1d5.1707900770.git.u.kleine-koenig@pengutronix.de Signed-off-by: Uwe Kleine-König <[email protected]>
1 parent dda59d2 commit 7ae57b1

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

drivers/gpio/gpio-mvebu.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ struct mvebu_pwm {
9999
u32 offset;
100100
unsigned long clk_rate;
101101
struct gpio_desc *gpiod;
102-
struct pwm_chip chip;
103102
spinlock_t lock;
104103
struct mvebu_gpio_chip *mvchip;
105104

@@ -615,7 +614,7 @@ static const struct regmap_config mvebu_gpio_regmap_config = {
615614
*/
616615
static struct mvebu_pwm *to_mvebu_pwm(struct pwm_chip *chip)
617616
{
618-
return container_of(chip, struct mvebu_pwm, chip);
617+
return pwmchip_get_drvdata(chip);
619618
}
620619

621620
static int mvebu_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
@@ -789,6 +788,7 @@ static int mvebu_pwm_probe(struct platform_device *pdev,
789788
{
790789
struct device *dev = &pdev->dev;
791790
struct mvebu_pwm *mvpwm;
791+
struct pwm_chip *chip;
792792
void __iomem *base;
793793
u32 offset;
794794
u32 set;
@@ -813,9 +813,11 @@ static int mvebu_pwm_probe(struct platform_device *pdev,
813813
if (IS_ERR(mvchip->clk))
814814
return PTR_ERR(mvchip->clk);
815815

816-
mvpwm = devm_kzalloc(dev, sizeof(struct mvebu_pwm), GFP_KERNEL);
817-
if (!mvpwm)
818-
return -ENOMEM;
816+
chip = devm_pwmchip_alloc(dev, mvchip->chip.ngpio, sizeof(*mvpwm));
817+
if (IS_ERR(chip))
818+
return PTR_ERR(chip);
819+
mvpwm = to_mvebu_pwm(chip);
820+
819821
mvchip->mvpwm = mvpwm;
820822
mvpwm->mvchip = mvchip;
821823
mvpwm->offset = offset;
@@ -868,13 +870,11 @@ static int mvebu_pwm_probe(struct platform_device *pdev,
868870
return -EINVAL;
869871
}
870872

871-
mvpwm->chip.dev = dev;
872-
mvpwm->chip.ops = &mvebu_pwm_ops;
873-
mvpwm->chip.npwm = mvchip->chip.ngpio;
873+
chip->ops = &mvebu_pwm_ops;
874874

875875
spin_lock_init(&mvpwm->lock);
876876

877-
return devm_pwmchip_add(dev, &mvpwm->chip);
877+
return devm_pwmchip_add(dev, chip);
878878
}
879879

880880
#ifdef CONFIG_DEBUG_FS

0 commit comments

Comments
 (0)