[openwrt/openwrt] ramips: modernize pwm driver
LEDE Commits
lede-commits at lists.infradead.org
Sun Oct 27 07:21:37 PDT 2024
hauke pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/0f5e5dee1d1d1283a6a11fc8a37b3b6be44225a4
commit 0f5e5dee1d1d1283a6a11fc8a37b3b6be44225a4
Author: Rosen Penev <rosenp at gmail.com>
AuthorDate: Wed Oct 9 13:44:56 2024 -0700
ramips: modernize pwm driver
Add more devm usage.
Signed-off-by: Rosen Penev <rosenp at gmail.com>
Link: https://github.com/openwrt/openwrt/pull/16649
Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
---
.../patches-6.6/845-pwm-add-mediatek-support.patch | 18 ++++--------------
1 file changed, 4 insertions(+), 14 deletions(-)
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 <blogic at openwrt.org>
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 <blogic at openwrt.org>
+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 <blogic at openwrt.org>
+ 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 <blogic at openwrt.org>
+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,
More information about the lede-commits
mailing list