lkml.org 
[lkml]   [2021]   [Nov]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH RFC 2/2] gpiolib: check the 'ngpios' property in core gpiolib code
On Thu, Nov 11, 2021 at 10:26 PM Bartosz Golaszewski <brgl@bgdev.pl> 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!

...

> + ret = fwnode_property_read_u32(gdev->dev.fwnode, "ngpios",
> + &ngpios);

I'm wondering if there is any obstacle to call

ret = device_property_read_u32(&gdev->dev, "ngpios", &ngpios);

?

Rationale (the main one) is to avoid direct dereference of fwnode from
struct device (it might be changed in the future). I really prefer API
calls here.

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

I would prefer the other way around and without 'else' being involved.

> }


--
With Best Regards,
Andy Shevchenko

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