Re: [PATCH] clk/rockchip: Use of_device_get_match_data()

From: Stephen Boyd
Date: Wed Mar 09 2022 - 13:57:46 EST


Quoting cgel.zte@xxxxxxxxx (2022-03-03 17:17:03)
> From: Minghao Chi (CGEL ZTE) <chi.minghao@xxxxxxxxxx>
>
> Use of_device_get_match_data() to simplify the code.
>
> Reported-by: Zeal Robot <zealci@xxxxxxxxxx>
> Signed-off-by: Minghao Chi (CGEL ZTE) <chi.minghao@xxxxxxxxxx>
> ---
> 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);
>