pwm: Use device_get_match_data()
Subsystems (2)
PATCH 1/1 pwm: Use device_get_match_data()
Use preferred device_get_match_data() instead of of_match_device() to get the driver match data. With this, adjust the includes to explicitly include the correct headers.
--- drivers/pwm/pwm-img.c | 8 ++------ drivers/pwm/pwm-rockchip.c | 9 ++------- 2 files changed, 4 insertions(+), 13 deletions(-)
drivers/pwm/pwm-img.c +2 -6
@@ -13,9 +13,9 @@#include <linux/mfd/syscon.h> #include <linux/module.h> #include <linux/of.h> -#include <linux/of_device.h> #include <linux/platform_device.h> #include <linux/pm_runtime.h> +#include <linux/property.h> #include <linux/pwm.h> #include <linux/regmap.h> #include <linux/slab.h>
@@ -261,7 +261,6 @@ static int img_pwm_probe(struct platform_device *pdev)u64 val;unsigned long clk_rate;struct img_pwm_chip *imgchip; -const struct of_device_id *of_dev_id; imgchip =devm_kzalloc (&pdev->dev,sizeof (*imgchip),GFP_KERNEL );if (!imgchip)
@@ -273,10 +272,7 @@ static int img_pwm_probe(struct platform_device *pdev)if (IS_ERR (imgchip->base))return PTR_ERR (imgchip->base); - of_dev_id =of_match_device (img_pwm_of_match, &pdev->dev); -if (!of_dev_id) -return -ENODEV ; - imgchip->data = of_dev_id->data; + imgchip->data =device_get_match_data (&pdev->dev); imgchip->periph_regs =syscon_regmap_lookup_by_phandle (pdev->dev.of_node,"img,cr-periph" );
drivers/pwm/pwm-rockchip.c +2 -7
@@ -10,8 +10,8 @@#include <linux/io.h> #include <linux/module.h> #include <linux/of.h> -#include <linux/of_device.h> #include <linux/platform_device.h> +#include <linux/property.h> #include <linux/pwm.h> #include <linux/time.h>
@@ -297,16 +297,11 @@ MODULE_DEVICE_TABLE(of, rockchip_pwm_dt_ids);static int rockchip_pwm_probe (struct platform_device *pdev) { -const struct of_device_id *id;struct rockchip_pwm_chip *pc;u32 enable_conf, ctrl;bool enabled;int ret, count; - id =of_match_device (rockchip_pwm_dt_ids, &pdev->dev); -if (!id) -return -EINVAL ; - pc =devm_kzalloc (&pdev->dev,sizeof (*pc),GFP_KERNEL );if (!pc)return -ENOMEM ;
@@ -345,7 +340,7 @@ static int rockchip_pwm_probe(struct platform_device *pdev)platform_set_drvdata (pdev, pc); - pc->data = id->data; + pc->data =device_get_match_data (&pdev->dev); pc->chip.dev = &pdev->dev; pc->chip.ops = &rockchip_pwm_ops; pc->chip.npwm =1 ;
Signature · 7 lines
2.42.0 _______________________________________________ Linux-rockchip mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-rockchip
Quoted 34 lines · Rob Herring
Use preferred
device_get_match_data()instead ofof_match_device()to get the driver match data. With this, adjust the includes to explicitly include the correct headers.Signed-off-by Rob Herring <[email protected]>--- drivers/pwm/pwm-img.c | 8 ++------ drivers/pwm/pwm-rockchip.c | 9 ++------- 2 files changed, 4 insertions(+), 13 deletions(-)drivers/pwm/pwm-img.c +1
-2@@ -13,9 +13,9 @@#include <linux/mfd/syscon.h> #include <linux/module.h> #include <linux/of.h> -#include <linux/of_device.h> #include <linux/platform_device.h> #include <linux/pm_runtime.h> +#include <linux/property.h> #include <linux/pwm.h> #include <linux/regmap.h> #include <linux/slab.h> @@ -261,7 +261,6 @@ static int img_pwm_probe(struct platform_device *pdev)u64 val;unsigned long clk_rate;struct img_pwm_chip *imgchip; -const struct of_device_id *of_dev_id; imgchip =devm_kzalloc (&pdev->dev,sizeof (*imgchip),GFP_KERNEL );if (!imgchip)
drivers/pwm/pwm-img.c static int img_pwm_probe(struct platform_device *pdev) · line 275
Quoted 8 lines
drivers/pwm/pwm-img.c +1
-4@@ -273,10 +272,7 @@ static int img_pwm_probe(struct platform_device *pdev)if (IS_ERR (imgchip->base))return PTR_ERR (imgchip->base); - of_dev_id =of_match_device (img_pwm_of_match, &pdev->dev); -if (!of_dev_id) -return -ENODEV ; - imgchip->data = of_dev_id->data; + imgchip->data =device_get_match_data (&pdev->dev);
Is this a semantical change? If there is a match, the code is equivalent. Otherwise it was:
return -ENODEV;
before and now it's
imgchip->data = NULL;
isn't it?
Quoted 34 lines
drivers/pwm/pwm-img.c +0
-0imgchip->periph_regs =syscon_regmap_lookup_by_phandle (pdev->dev.of_node,"img,cr-periph" );drivers/pwm/pwm-rockchip.c +1
-6@@ -10,8 +10,8 @@#include <linux/io.h> #include <linux/module.h> #include <linux/of.h> -#include <linux/of_device.h> #include <linux/platform_device.h> +#include <linux/property.h> #include <linux/pwm.h> #include <linux/time.h> @@ -297,16 +297,11 @@ MODULE_DEVICE_TABLE(of, rockchip_pwm_dt_ids);static int rockchip_pwm_probe (struct platform_device *pdev) { -const struct of_device_id *id;struct rockchip_pwm_chip *pc;u32 enable_conf, ctrl;bool enabled;int ret, count; - id =of_match_device (rockchip_pwm_dt_ids, &pdev->dev); -if (!id) -return -EINVAL ; - pc =devm_kzalloc (&pdev->dev,sizeof (*pc),GFP_KERNEL );if (!pc)return -ENOMEM ;
drivers/pwm/pwm-rockchip.c static int rockchip_pwm_probe(struct platform_device *pdev) · line 346
Quoted 8 lines
drivers/pwm/pwm-rockchip.c +1
-1@@ -345,7 +340,7 @@ static int rockchip_pwm_probe(struct platform_device *pdev)platform_set_drvdata (pdev, pc); - pc->data = id->data; + pc->data =device_get_match_data (&pdev->dev); pc->chip.dev = &pdev->dev; pc->chip.ops = &rockchip_pwm_ops; pc->chip.npwm =1 ;
This has the same semantical change.
If this change is ok, it IMHO needs a more verbose commit log.
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | https://www.pengutronix.de/ |
Quoted 48 lines · Uwe Kleine-König
Quoted 34 lines · Rob Herring
Use preferred
device_get_match_data()instead ofof_match_device()to get the driver match data. With this, adjust the includes to explicitly include the correct headers.Signed-off-by Rob Herring <[email protected]>--- drivers/pwm/pwm-img.c | 8 ++------ drivers/pwm/pwm-rockchip.c | 9 ++------- 2 files changed, 4 insertions(+), 13 deletions(-)drivers/pwm/pwm-img.c +1
-2@@ -13,9 +13,9 @@#include <linux/mfd/syscon.h> #include <linux/module.h> #include <linux/of.h> -#include <linux/of_device.h> #include <linux/platform_device.h> #include <linux/pm_runtime.h> +#include <linux/property.h> #include <linux/pwm.h> #include <linux/regmap.h> #include <linux/slab.h> @@ -261,7 +261,6 @@ static int img_pwm_probe(struct platform_device *pdev)u64 val;unsigned long clk_rate;struct img_pwm_chip *imgchip; -const struct of_device_id *of_dev_id; imgchip =devm_kzalloc (&pdev->dev,sizeof (*imgchip),GFP_KERNEL );if (!imgchip)drivers/pwm/pwm-img.c static int img_pwm_probe(struct platform_device *pdev) · line 275
Quoted 8 lines
drivers/pwm/pwm-img.c +1
-4@@ -273,10 +272,7 @@ static int img_pwm_probe(struct platform_device *pdev)if (IS_ERR (imgchip->base))return PTR_ERR (imgchip->base); - of_dev_id =of_match_device (img_pwm_of_match, &pdev->dev); -if (!of_dev_id) -return -ENODEV ; - imgchip->data = of_dev_id->data; + imgchip->data =device_get_match_data (&pdev->dev);Is this a semantical change? If there is a match, the code is equivalent. Otherwise it was:
Quoted 7 lines
return -ENODEV;before and now it's
imgchip->data = NULL;isn't it?
As this driver only does DT matching, then of_match_device will never return NULL if we've gotten to probe().
Will update the commit log.
Rob