lkml.org 
[lkml]   [2021]   [Nov]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 2/2] gpiolib: check the 'ngpios' property in core gpiolib code
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.

...

> 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;
> + goto err_free_descs;
> + }
> +
> + gc->ngpio = ngpios;
> }

This should be

if (gc->ngpio == 0) {
ret = device_property_read_u32(&gdev->dev, "ngpios", &ngpios);
if (ret)
return ret;

gc->ngpio = ngpios;
}

if (gc->ngpio == 0) {
chip_err(gc, "tried to insert a GPIO chip with zero lines\n");
ret = -EINVAL;
goto err_free_descs;
}

--
With Best Regards,
Andy Shevchenko


\
 
 \ /
  Last update: 2021-11-18 18:06    [W:0.083 / U:0.976 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site