Re: [PATCH v9 4/4] clk: meson: add sub MMC clock controller driver

From: Stephen Boyd
Date: Tue Jan 18 2022 - 21:22:24 EST


Quoting Liang Yang (2022-01-16 22:24:28)
>
>
> On 2022/1/15 7:01, Stephen Boyd wrote:
> > [ EXTERNAL EMAIL ]
> >
> > Quoting Liang Yang (2022-01-13 21:14:46)
> >> On 2022/1/14 5:35, Stephen Boyd wrote:
> >>> Quoting Liang Yang (2022-01-13 03:57:45)
> >>>> diff --git a/drivers/clk/meson/mmc-clkc.c b/drivers/clk/meson/mmc-clkc.c
> >>>> new file mode 100644
> >>>> index 000000000000..f53977f61390
> >>>> --- /dev/null
> >>>> +++ b/drivers/clk/meson/mmc-clkc.c
> >>>> @@ -0,0 +1,300 @@
> > [..]
> >>>> +
> >>>> +static int mmc_clkc_probe(struct platform_device *pdev)
> >>>> +{
> >>>> + struct clk_hw_onecell_data *onecell_data;
> >>>> + struct device *dev = &pdev->dev;
> >>>> + struct mmc_clkc_data *data;
> >>>> + struct regmap *map;
> >>>> + struct clk_regmap *clk, *core;
> >>>> + struct meson_sclk_div_data *div_data;
> >>>> +
> >>>> + /*cast to drop the const in match->data*/
> >>>
> >>> Space after *, also why do we need to cast away const? The user of this
> >>> pointer passes it all the way down to mmc_clkc_register_clk() which
> >>> could take the data as const void pointer and decide to cast away const
> >>> there.
> >>
> >> if use 'const' here, it will report a warning:
> >> drivers/clk/meson/mmc-clkc.c:224:7: error: assignment discards ‘const’
> >> qualifier from pointer targe
> >> t type [-Werror=discarded-qualifiers]
> >>
> >> data = (const struct mmc_clkc_data *)of_device_get_match_data(dev);
> >
> > Of course. The type declaration up above needs const added to it.The parm of mmc_clkc_register_clk_with_parent(...., void *data) does not
> have 'const', so make the type declaration cause a further 'const' cast
> warning. Could i copy these infos just like below:

Why can't you push const down to the function that really cares to
remove const?