linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clk/rockchip: Use of_device_get_match_data()
@ 2022-03-04  1:17 cgel.zte
  2022-03-09 18:57 ` Stephen Boyd
  0 siblings, 1 reply; 5+ messages in thread
From: cgel.zte @ 2022-03-04  1:17 UTC (permalink / raw)
  To: mturquette
  Cc: sboyd, heiko, linux-clk, linux-arm-kernel, linux-rockchip,
	linux-kernel, Minghao Chi, Zeal Robot

From: Minghao Chi (CGEL ZTE) <chi.minghao@zte.com.cn>

Use of_device_get_match_data() to simplify the code.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Minghao Chi (CGEL ZTE) <chi.minghao@zte.com.cn>
---
 drivers/clk/rockchip/clk-rk3399.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/clk/rockchip/clk-rk3399.c b/drivers/clk/rockchip/clk-rk3399.c
index 306910a3a0d3..b1b67bfb63b8 100644
--- a/drivers/clk/rockchip/clk-rk3399.c
+++ b/drivers/clk/rockchip/clk-rk3399.c
@@ -1634,14 +1634,8 @@ static const struct of_device_id clk_rk3399_match_table[] = {
 static int __init clk_rk3399_probe(struct platform_device *pdev)
 {
 	struct device_node *np = pdev->dev.of_node;
-	const struct of_device_id *match;
 	const struct clk_rk3399_inits *init_data;
-
-	match = of_match_device(clk_rk3399_match_table, &pdev->dev);
-	if (!match || !match->data)
-		return -EINVAL;
-
-	init_data = match->data;
+	init_data = of_device_get_match_data(&pdev->dev);
 	if (init_data->inits)
 		init_data->inits(np);
 
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] clk/rockchip: Use of_device_get_match_data()
  2022-03-04  1:17 [PATCH] clk/rockchip: Use of_device_get_match_data() cgel.zte
@ 2022-03-09 18:57 ` Stephen Boyd
  2022-03-10 16:22   ` Heiko Stübner
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen Boyd @ 2022-03-09 18:57 UTC (permalink / raw)
  To: cgel.zte, mturquette
  Cc: heiko, linux-clk, linux-arm-kernel, linux-rockchip, linux-kernel,
	Minghao Chi, Zeal Robot

Quoting cgel.zte@gmail.com (2022-03-03 17:17:03)
> From: Minghao Chi (CGEL ZTE) <chi.minghao@zte.com.cn>
> 
> Use of_device_get_match_data() to simplify the code.
> 
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: Minghao Chi (CGEL ZTE) <chi.minghao@zte.com.cn>
> ---
>  drivers/clk/rockchip/clk-rk3399.c | 8 +-------
>  1 file changed, 1 insertion(+), 7 deletions(-)
> 
> diff --git a/drivers/clk/rockchip/clk-rk3399.c b/drivers/clk/rockchip/clk-rk3399.c
> index 306910a3a0d3..b1b67bfb63b8 100644
> --- a/drivers/clk/rockchip/clk-rk3399.c
> +++ b/drivers/clk/rockchip/clk-rk3399.c
> @@ -1634,14 +1634,8 @@ static const struct of_device_id clk_rk3399_match_table[] = {
>  static int __init clk_rk3399_probe(struct platform_device *pdev)
>  {
>         struct device_node *np = pdev->dev.of_node;
> -       const struct of_device_id *match;
>         const struct clk_rk3399_inits *init_data;
> -
> -       match = of_match_device(clk_rk3399_match_table, &pdev->dev);
> -       if (!match || !match->data)
> -               return -EINVAL;
> -
> -       init_data = match->data;
> +       init_data = of_device_get_match_data(&pdev->dev);

The translation doesn't look equivalent. Before we would bail out of
probe if match data isn't there with an error. That isn't possible of
course with further investigation but please make a note of this in the
commit text to aid review. Also, please don't send new versions of
patches in reply to previous versions of patches. It breaks my patch
workflow. Thanks in advance.

>         if (init_data->inits)
>                 init_data->inits(np);
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] clk/rockchip: Use of_device_get_match_data()
  2022-03-09 18:57 ` Stephen Boyd
@ 2022-03-10 16:22   ` Heiko Stübner
  0 siblings, 0 replies; 5+ messages in thread
From: Heiko Stübner @ 2022-03-10 16:22 UTC (permalink / raw)
  To: cgel.zte, mturquette, Stephen Boyd
  Cc: linux-clk, linux-arm-kernel, linux-rockchip, linux-kernel,
	Minghao Chi, Zeal Robot

Am Mittwoch, 9. März 2022, 19:57:36 CET schrieb Stephen Boyd:
> Quoting cgel.zte@gmail.com (2022-03-03 17:17:03)
> > From: Minghao Chi (CGEL ZTE) <chi.minghao@zte.com.cn>
> > 
> > Use of_device_get_match_data() to simplify the code.
> > 
> > Reported-by: Zeal Robot <zealci@zte.com.cn>
> > Signed-off-by: Minghao Chi (CGEL ZTE) <chi.minghao@zte.com.cn>
> > ---
> >  drivers/clk/rockchip/clk-rk3399.c | 8 +-------
> >  1 file changed, 1 insertion(+), 7 deletions(-)
> > 
> > diff --git a/drivers/clk/rockchip/clk-rk3399.c b/drivers/clk/rockchip/clk-rk3399.c
> > index 306910a3a0d3..b1b67bfb63b8 100644
> > --- a/drivers/clk/rockchip/clk-rk3399.c
> > +++ b/drivers/clk/rockchip/clk-rk3399.c
> > @@ -1634,14 +1634,8 @@ static const struct of_device_id clk_rk3399_match_table[] = {
> >  static int __init clk_rk3399_probe(struct platform_device *pdev)
> >  {
> >         struct device_node *np = pdev->dev.of_node;
> > -       const struct of_device_id *match;
> >         const struct clk_rk3399_inits *init_data;
> > -
> > -       match = of_match_device(clk_rk3399_match_table, &pdev->dev);
> > -       if (!match || !match->data)
> > -               return -EINVAL;
> > -
> > -       init_data = match->data;
> > +       init_data = of_device_get_match_data(&pdev->dev);
> 
> The translation doesn't look equivalent. Before we would bail out of
> probe if match data isn't there with an error. That isn't possible of
> course with further investigation but please make a note of this in the
> commit text to aid review.

We _do have_ Rockchip clock drivers serving multiple socs already
(rk3188+rk3066 for example) and as patterns are duplicated often from
one existing driver to a new one, I think it makes sense to have the
error handling done correctly.

So doing
	init_data = of_device_get_match_data(&pdev->dev);
	if (init_data)
		return -EINVAL;
as before.

If due to some strange coincidence the condition is triggered
this would cause a null-ptr-dereference with the direct call to
	init_data->scripts
below, which might or might not be hidden due to the (early-)console
being up yet, where with correct error handling a system might at
least come up to a point to complain about a missing clock driver.



> Also, please don't send new versions of
> patches in reply to previous versions of patches. It breaks my patch
> workflow. Thanks in advance.
> 
> >         if (init_data->inits)
> >                 init_data->inits(np);
> >
> 





_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] clk/rockchip: Use of_device_get_match_data()
  2022-02-21  2:01 cgel.zte
@ 2022-02-23 23:44 ` Heiko Stuebner
  0 siblings, 0 replies; 5+ messages in thread
From: Heiko Stuebner @ 2022-02-23 23:44 UTC (permalink / raw)
  To: mturquette, cgel.zte
  Cc: Heiko Stuebner, sboyd, linux-rockchip, linux-clk, Minghao Chi,
	linux-arm-kernel, linux-kernel, Zeal Robot

On Mon, 21 Feb 2022 02:01:03 +0000, cgel.zte@gmail.com wrote:
> Use of_device_get_match_data() to simplify the code.

Applied, thanks!

[1/1] clk/rockchip: Use of_device_get_match_data()
      commit: 9f565399ad0739dbdeac868e40e86e80f54dc77b

Best regards,
-- 
Heiko Stuebner <heiko@sntech.de>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] clk/rockchip: Use of_device_get_match_data()
@ 2022-02-21  2:01 cgel.zte
  2022-02-23 23:44 ` Heiko Stuebner
  0 siblings, 1 reply; 5+ messages in thread
From: cgel.zte @ 2022-02-21  2:01 UTC (permalink / raw)
  To: mturquette
  Cc: sboyd, heiko, linux-clk, linux-arm-kernel, linux-rockchip,
	linux-kernel, Minghao Chi, Zeal Robot

From: Minghao Chi (CGEL ZTE) <chi.minghao@zte.com.cn>

Use of_device_get_match_data() to simplify the code.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Minghao Chi (CGEL ZTE) <chi.minghao@zte.com.cn>
---
 drivers/clk/rockchip/clk-rk3568.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/clk/rockchip/clk-rk3568.c b/drivers/clk/rockchip/clk-rk3568.c
index 69a9e8069a48..9ca1a26a2533 100644
--- a/drivers/clk/rockchip/clk-rk3568.c
+++ b/drivers/clk/rockchip/clk-rk3568.c
@@ -1697,14 +1697,12 @@ static const struct of_device_id clk_rk3568_match_table[] = {
 static int __init clk_rk3568_probe(struct platform_device *pdev)
 {
 	struct device_node *np = pdev->dev.of_node;
-	const struct of_device_id *match;
 	const struct clk_rk3568_inits *init_data;
 
-	match = of_match_device(clk_rk3568_match_table, &pdev->dev);
-	if (!match || !match->data)
+	init_data = (struct clk_rk3568_inits *)of_device_get_match_data(&pdev->dev);
+	if (!init_data)
 		return -EINVAL;
 
-	init_data = match->data;
 	if (init_data->inits)
 		init_data->inits(np);
 
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-03-10 16:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-04  1:17 [PATCH] clk/rockchip: Use of_device_get_match_data() cgel.zte
2022-03-09 18:57 ` Stephen Boyd
2022-03-10 16:22   ` Heiko Stübner
  -- strict thread matches above, loose matches on Subject: below --
2022-02-21  2:01 cgel.zte
2022-02-23 23:44 ` Heiko Stuebner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).