Thread (13 messages) flat view 13 messages, 3 authors, 2021-11-22

Re: [PATCH v2 2/2] gpiolib: check the 'ngpios' property in core gpiolib code

From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date: 2021-11-18 15:46:34
Also in: lkml

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?
+			goto err_free_descs;
+		}
+
+		gc->ngpio = ngpios;
 	}
-- 
With Best Regards,
Andy Shevchenko

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help