Re: [PATCH v2 1/4] pinctrl: s32: use of_device_get_match_data() to get device data

From: Andy Shevchenko
Date: Tue Mar 21 2023 - 03:33:15 EST


On Tue, Mar 21, 2023 at 6:44 AM Chester Lin <clin@xxxxxxxx> wrote:
> On Mon, Mar 20, 2023 at 06:59:41PM +0200, Andy Shevchenko wrote:
> > On Mon, Mar 20, 2023 at 6:39 PM Chester Lin <clin@xxxxxxxx> wrote:

...

> > > + soc_info = (struct s32_pinctrl_soc_info *)
> > > + of_device_get_match_data(&pdev->dev);
> >
> > Drop the ugly casting, it's not needed.
>
> Actually it's used for suppressing the compiler warning since some members in
> this soc_info need to be filled by pinctrl-s32cc.

Yes, that's one way to solve this.

...

> + info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
> + if (!info)
> + return -ENOMEM;
> +
> + memcpy(info, soc_data, sizeof(*info));

Right, but use devm_kmemdup() instead.

--
With Best Regards,
Andy Shevchenko