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] [day] [month] [year] [list]
Date:   Tue, 8 Mar 2022 09:53:18 +0100
From:   Bartosz Golaszewski <brgl@...ev.pl>
To:     Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc:     "open list:GPIO SUBSYSTEM" <linux-gpio@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Linus Walleij <linus.walleij@...aro.org>
Subject: Re: [PATCH v1 1/1] gpiolib: Use list_first_entry()/list_last_entry()

On Mon, Mar 7, 2022 at 11:54 AM Andy Shevchenko
<andriy.shevchenko@...ux.intel.com> wrote:
>
> Use list_first_entry()/list_last_entry() instead of open coded variants.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
> ---
>  drivers/gpio/gpiolib.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index 002bf4b1616b..f5e7443208d4 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -262,14 +262,14 @@ static int gpiodev_add_to_list(struct gpio_device *gdev)
>                 return 0;
>         }
>
> -       next = list_entry(gpio_devices.next, struct gpio_device, list);
> +       next = list_first_entry(&gpio_devices, struct gpio_device, list);
>         if (gdev->base + gdev->ngpio <= next->base) {
>                 /* add before first entry */
>                 list_add(&gdev->list, &gpio_devices);
>                 return 0;
>         }
>
> -       prev = list_entry(gpio_devices.prev, struct gpio_device, list);
> +       prev = list_last_entry(&gpio_devices, struct gpio_device, list);
>         if (prev->base + prev->ngpio <= gdev->base) {
>                 /* add behind last entry */
>                 list_add_tail(&gdev->list, &gpio_devices);
> @@ -4426,7 +4426,7 @@ static void *gpiolib_seq_next(struct seq_file *s, void *v, loff_t *pos)
>         if (list_is_last(&gdev->list, &gpio_devices))
>                 ret = NULL;
>         else
> -               ret = list_entry(gdev->list.next, struct gpio_device, list);
> +               ret = list_first_entry(&gdev->list, struct gpio_device, list);
>         spin_unlock_irqrestore(&gpio_lock, flags);
>
>         s->private = "\n";
> --
> 2.34.1
>

Applied, thanks!

Bart

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ