ramips: modernize pwm driver
authorRosen Penev <rosenp@gmail.com>
Wed, 9 Oct 2024 20:44:56 +0000 (13:44 -0700)
committerHauke Mehrtens <hauke@hauke-m.de>
Sun, 27 Oct 2024 14:21:03 +0000 (15:21 +0100)
Add more devm usage.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/16649
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
target/linux/ramips/patches-6.6/845-pwm-add-mediatek-support.patch

index 67cc389fd5df9a4f8d414a47e18d6aa2b17b1371..e7d11a04297cb84b169881e9d554f20745d3ffe1 100644 (file)
@@ -41,7 +41,7 @@ Signed-off-by: John Crispin <blogic@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@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@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@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,