lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 5 Feb 2024 15:58:59 +0200
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Bartosz Golaszewski <brgl@...ev.pl>
Cc: Linus Walleij <linus.walleij@...aro.org>,
	Kent Gibson <warthog618@...il.com>, Alex Elder <elder@...aro.org>,
	Geert Uytterhoeven <geert+renesas@...der.be>,
	"Paul E . McKenney" <paulmck@...nel.org>,
	Wolfram Sang <wsa@...-dreams.de>, linux-gpio@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
Subject: Re: [PATCH v2 08/23] gpio: sysfs: use gpio_device_find() to iterate
 over existing devices

On Mon, Feb 05, 2024 at 02:50:18PM +0100, Bartosz Golaszewski wrote:
> On Mon, Feb 5, 2024 at 2:47 PM Andy Shevchenko
> <andriy.shevchenko@...ux.intel.com> wrote:
> > On Mon, Feb 05, 2024 at 02:39:40PM +0100, Bartosz Golaszewski wrote:
> > > On Mon, Feb 5, 2024 at 2:38 PM Andy Shevchenko
> > > <andriy.shevchenko@...ux.intel.com> wrote:
> > > > On Mon, Feb 05, 2024 at 02:19:10PM +0100, Bartosz Golaszewski wrote:
> > > > > On Mon, Feb 5, 2024 at 1:36 PM Andy Shevchenko
> > > > > <andriy.shevchenko@...ux.intel.com> wrote:
> > > > > > On Mon, Feb 05, 2024 at 10:34:03AM +0100, Bartosz Golaszewski wrote:

..

> > > > > > > +static int gpiofind_sysfs_register(struct gpio_chip *gc, void *data)
> > > > > > > +{
> > > > > > > +     struct gpio_device *gdev = gc->gpiodev;
> > > > > > > +     int ret;
> > > > > > > +
> > > > > > > +     if (gdev->mockdev)
> > > > > > > +             return 0;
> > > > > > > +
> > > > > > > +     ret = gpiochip_sysfs_register(gdev);
> > > > > > > +     if (ret)
> > > > > > > +             chip_err(gc, "failed to register the sysfs entry: %d\n", ret);
> > > > > >
> > > > > > > +     return 0;
> > > > > >
> > > > > > ???
> > > >
> > > > What the point of function to be int if you effectively ignore this by always
> > > > returning 0?
> > >
> > > Because the signature of the callback expects an int to be returned?
> >
> > But why do you return 0 instead of ret?
> >
> 
> Because we don't want to *find* a device really. We just want to
> iterate over all of them and call a callback. Any value other than 0
> will be interpreted as a match. Besides: failure to register one GPIO
> sysfs entry shouldn't maybe cause a failure for all subsequent
> devices?

To me it's not obvious, hence I would like to see a comment before return 0.

> > > > > Not sure what the ... and ??? mean? The commit message should have
> > > > > read "... traverse it from gpiofind_sysfs_register()" I agree but the
> > > > > latter?
> > > >
> > > > I didn't realize this may not be obvious :-(.
> > > >
> > > > > > > +}

-- 
With Best Regards,
Andy Shevchenko



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ