[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75Vdny6Q3iyO1_Qyz7C+AZ268xRixL6GvCE93f_vfS3bESw@mail.gmail.com>
Date: Mon, 11 Jul 2022 10:31:50 +0200
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Horatiu Vultur <horatiu.vultur@...rochip.com>
Cc: "open list:GPIO SUBSYSTEM" <linux-gpio@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Linus Walleij <linus.walleij@...aro.org>,
kavyasree.kotagiri@...rochip.com,
Alexandre Belloni <alexandre.belloni@...tlin.com>,
Colin Foster <colin.foster@...advantage.com>,
Microchip Linux Driver Support <UNGLinuxDriver@...rochip.com>,
Maxime Chevallier <maxime.chevallier@...tlin.com>,
Michael Walle <michael@...le.cc>
Subject: Re: [PATCH v2 1/2] pinctrl: ocelot: Fix pincfg for lan966x
On Mon, Jul 11, 2022 at 8:45 AM Horatiu Vultur
<horatiu.vultur@...rochip.com> wrote:
> The 07/08/2022 23:58, Andy Shevchenko wrote:
> > On Fri, Jul 8, 2022 at 10:10 PM Horatiu Vultur
> > <horatiu.vultur@...rochip.com> wrote:
Please, remove unneeded context when replying!
...
> > > + struct ocelot_match_data *data;
> >
> > Any specific reason why this is not const?
> >
> > > + data = (struct ocelot_match_data *)device_get_match_data(dev);
> >
> > And here you drop the qualifier...
> >
> > I would recommend making it const and dropping the cast completely.
>
> If I make this const, but then few lines after I will get the following
> warnings:
>
> drivers/pinctrl/pinctrl-ocelot.c:1983:13: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
> 1983 | info->desc = &data->desc;
> | ^
> drivers/pinctrl/pinctrl-ocelot.c:1984:20: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
> 1984 | info->pincfg_data = &data->pincfg_data;
> | ^
>
> Of course I can make also info->desc and info->pincfg_data const but
> then I will get the following warning:
>
> drivers/pinctrl/pinctrl-ocelot.c: In function ‘ocelot_pinctrl_register’:
> drivers/pinctrl/pinctrl-ocelot.c:1723:53: warning: passing argument 2 of ‘devm_pinctrl_register’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
> 1723 | info->pctl = devm_pinctrl_register(&pdev->dev, info->desc, info);
> | ~~~~^~~~~~
> In file included from include/linux/gpio/driver.h:10,
> from drivers/pinctrl/pinctrl-ocelot.c:10:
> include/linux/pinctrl/pinctrl.h:166:26: note: expected ‘struct pinctrl_desc *’ but argument is of type ‘const struct pinctrl_desc *’
> 166 | struct pinctrl_desc *pctldesc,
> | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
>
> > > + if (!data)
> > > + return -EINVAL;
This is not good. Any chances to make it const?
One way is to copy data in a newly allocated buffer (devm_kmemdup() for that).
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists