[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMRc=McHCUsO430t618EW92G-B_mgxXucYye3qb85697MHW_KQ@mail.gmail.com>
Date: Thu, 18 Nov 2021 17:38:14 +0100
From: Bartosz Golaszewski <brgl@...ev.pl>
To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc: Linus Walleij <linus.walleij@...aro.org>,
"open list:GPIO SUBSYSTEM" <linux-gpio@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2 2/2] gpiolib: check the 'ngpios' property in core
gpiolib code
On Thu, Nov 18, 2021 at 4:46 PM Andy Shevchenko
<andriy.shevchenko@...ux.intel.com> wrote:
>
> On Thu, Nov 18, 2021 at 02:23:17PM +0100, Bartosz Golaszewski wrote:
> > Several drivers read the 'ngpios' device property on their own, but
> > since it's defined as a standard GPIO property in the device tree bindings
> > anyway, it's a good candidate for generalization. If the driver didn't
> > set its gc->ngpio, try to read the 'ngpios' property from the GPIO
> > device's firmware node before bailing out.
>
> Thanks for update, my comment below.
>
> ...
>
> > if (gc->ngpio == 0) {
> > - chip_err(gc, "tried to insert a GPIO chip with zero lines\n");
> > - ret = -EINVAL;
> > - goto err_free_descs;
> > + ret = device_property_read_u32(&gdev->dev, "ngpios", &ngpios);
> > + if (ret) {
> > + chip_err(gc, "tried to insert a GPIO chip with zero lines\n");
>
> > + ret = -EINVAL;
>
> Sorry, forgot to ask, why this is needed?
>
What do you mean? 0 lines doesn't sound like a valid value so -EINVAL
is in order.
Bart
Powered by blists - more mailing lists