From: Rosen Penev Date: Wed, 9 Oct 2024 20:44:56 +0000 (-0700) Subject: ramips: modernize pwm driver X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=0f5e5dee1d1d1283a6a11fc8a37b3b6be44225a4;p=openwrt%2Fstaging%2Flinusw.git ramips: modernize pwm driver Add more devm usage. Signed-off-by: Rosen Penev Link: https://github.com/openwrt/openwrt/pull/16649 Signed-off-by: Hauke Mehrtens --- diff --git a/target/linux/ramips/patches-6.6/845-pwm-add-mediatek-support.patch b/target/linux/ramips/patches-6.6/845-pwm-add-mediatek-support.patch index 67cc389fd5..e7d11a0429 100644 --- a/target/linux/ramips/patches-6.6/845-pwm-add-mediatek-support.patch +++ b/target/linux/ramips/patches-6.6/845-pwm-add-mediatek-support.patch @@ -41,7 +41,7 @@ Signed-off-by: John Crispin obj-$(CONFIG_PWM_MXS) += pwm-mxs.o --- /dev/null +++ b/drivers/pwm/pwm-mediatek-ramips.c -@@ -0,0 +1,197 @@ +@@ -0,0 +1,187 @@ +/* + * Mediatek Pulse Width Modulator driver + * @@ -178,30 +178,23 @@ Signed-off-by: John Crispin +static int mtk_pwm_probe(struct platform_device *pdev) +{ + struct mtk_pwm_chip *pc; -+ struct resource *r; -+ int ret; + + pc = devm_kzalloc(&pdev->dev, sizeof(*pc), GFP_KERNEL); + if (!pc) + return -ENOMEM; + -+ r = platform_get_resource(pdev, IORESOURCE_MEM, 0); -+ pc->mmio_base = devm_ioremap_resource(&pdev->dev, r); ++ pc->mmio_base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(pc->mmio_base)) + return PTR_ERR(pc->mmio_base); + -+ platform_set_drvdata(pdev, pc); -+ + pc->chip.dev = &pdev->dev; + pc->chip.ops = &mtk_pwm_ops; + pc->chip.base = -1; + pc->chip.npwm = NUM_PWM; + -+ ret = pwmchip_add(&pc->chip); -+ if (ret < 0) -+ dev_err(&pdev->dev, "pwmchip_add() failed: %d\n", ret); ++ platform_set_drvdata(pdev, pc); + -+ return ret; ++ return devm_pwmchip_add(&pdev->dev, &pc->chip); +} + +static int mtk_pwm_remove(struct platform_device *pdev) @@ -212,8 +205,6 @@ Signed-off-by: John Crispin + for (i = 0; i < NUM_PWM; i++) + pwm_disable(&pc->chip.pwms[i]); + -+ pwmchip_remove(&pc->chip); -+ + return 0; +} + @@ -227,7 +218,6 @@ Signed-off-by: John Crispin +static struct platform_driver mtk_pwm_driver = { + .driver = { + .name = "mtk-pwm", -+ .owner = THIS_MODULE, + .of_match_table = mtk_pwm_of_match, + }, + .probe = mtk_pwm_probe,