pwm: mediatek: Simplify using devm_pwmchip_add()
Subsystems (2)
PATCH 1/1 pwm: mediatek: Simplify using devm_pwmchip_add()
With devm_pwmchip_add() we can drop pwmchip_remove() from the device remove callback. The latter can then go away, too and as this is the only user of platform_get_drvdata(), the respective call to platform_set_drvdata() can go, too.
Signed-off-by zhaoxiao <[email protected]>
--- drivers/pwm/pwm-mediatek.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/pwm/pwm-mediatek.c +1 -11
@@ -253,13 +253,11 @@ static int pwm_mediatek_probe(struct platform_device *pdev) } } -platform_set_drvdata (pdev, pc); - pc->chip.dev = &pdev->dev; pc->chip.ops = &pwm_mediatek_ops; pc->chip.npwm = pc->soc->num_pwms; - ret =pwmchip_add (&pc->chip); + ret =devm_pwmchip_add (&pdev->dev, &pc->chip);if (ret <0 ) {dev_err (&pdev->dev,"pwmchip_add() failed: %d\n" , ret);return ret;
@@ -268,13 +266,6 @@ static int pwm_mediatek_probe(struct platform_device *pdev)return 0 ; } -static int pwm_mediatek_remove (struct platform_device *pdev) -{ -struct pwm_mediatek_chip *pc =platform_get_drvdata (pdev); - -return pwmchip_remove (&pc->chip); -} -static const struct pwm_mediatek_of_data mt2712_pwm_data = { .num_pwms =8 , .pwm45_fixup = false,
@@ -335,7 +326,6 @@ static struct platform_driver pwm_mediatek_driver = { .of_match_table = pwm_mediatek_of_match, }, .probe = pwm_mediatek_probe, - .remove = pwm_mediatek_remove, };module_platform_driver (pwm_mediatek_driver);
Signature · 1 line
2.20.1
Hello,
Quoted 44 lines · zhaoxiao
With
devm_pwmchip_add()we can droppwmchip_remove()from the device remove callback. The latter can then go away, too and as this is the only user ofplatform_get_drvdata(), the respective call toplatform_set_drvdata()can go, too.Signed-off-by zhaoxiao <[email protected]>--- drivers/pwm/pwm-mediatek.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)drivers/pwm/pwm-mediatek.c +1
-10@@ -253,13 +253,11 @@ static int pwm_mediatek_probe(struct platform_device *pdev) } } -platform_set_drvdata (pdev, pc); - pc->chip.dev = &pdev->dev; pc->chip.ops = &pwm_mediatek_ops; pc->chip.npwm = pc->soc->num_pwms; - ret =pwmchip_add (&pc->chip); + ret =devm_pwmchip_add (&pdev->dev, &pc->chip);if (ret <0 ) {dev_err (&pdev->dev,"pwmchip_add() failed: %d\n" , ret);return ret;@@ -268,13 +266,6 @@ static int pwm_mediatek_probe(struct platform_device *pdev)return 0 ; } -static int pwm_mediatek_remove (struct platform_device *pdev) -{ -struct pwm_mediatek_chip *pc =platform_get_drvdata (pdev); - -return pwmchip_remove (&pc->chip); -} -static const struct pwm_mediatek_of_data mt2712_pwm_data = { .num_pwms =8 , .pwm45_fixup = false,
drivers/pwm/pwm-mediatek.c static struct platform_driver pwm_mediatek_driver = { · line 330
Quoted 6 lines
drivers/pwm/pwm-mediatek.c +0
-1@@ -335,7 +326,6 @@ static struct platform_driver pwm_mediatek_driver = { .of_match_table = pwm_mediatek_of_match, }, .probe = pwm_mediatek_probe, - .remove = pwm_mediatek_remove, };module_platform_driver (pwm_mediatek_driver);
A patch like this is already in next, see e0150252a6437d12de3db84bb3af12bd5aa5cc70
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | https://www.pengutronix.de/ |