All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kent Gibson <warthog618@gmail.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>,
	linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
	Bartosz Golaszewski <brgl@bgdev.pl>,
	Linus Walleij <linus.walleij@linaro.org>
Subject: Re: [PATCH v1 1/1] gpiolib: cdev: use !mem_is_zero() instead of memchr_inv(s, 0, n)
Date: Thu, 5 Sep 2024 09:15:49 +0800	[thread overview]
Message-ID: <20240905011549.GA7299@rigel> (raw)
In-Reply-To: <20240904090743.1204593-1-andy.shevchenko@gmail.com>

On Wed, Sep 04, 2024 at 12:07:43PM +0300, Andy Shevchenko wrote:
> Use the mem_is_zero() helper where possible.
>
> Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>

Somehow I still don't receive mail directly from you, so I only picked
this up via the list. Weird. It should be gmail to gmail, right - WTH?
Unless it isn't - and that is the problem.

I'm ok with the change, though mem_is_zero() hasn't hit any of the trees
I have in front of me, and I had to find the corresponding patch on lore.
Given this is explicitly the use case for it, I would've embedded the
negation in the function and the name, so mem_not_zero() rather than
!mem_is_zero(), as that reads better for me, but ok.

Acked-by: Kent Gibson <warthog618@gmail.com>

> ---
>  drivers/gpio/gpiolib-cdev.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c
> index 5aac59de0d76..e98d75dd8acd 100644
> --- a/drivers/gpio/gpiolib-cdev.c
> +++ b/drivers/gpio/gpiolib-cdev.c
> @@ -16,7 +16,6 @@
>  #include <linux/hte.h>
>  #include <linux/interrupt.h>
>  #include <linux/irqreturn.h>
> -#include <linux/kernel.h>
>  #include <linux/kfifo.h>
>  #include <linux/module.h>
>  #include <linux/mutex.h>
> @@ -26,6 +25,7 @@
>  #include <linux/rbtree.h>
>  #include <linux/seq_file.h>
>  #include <linux/spinlock.h>
> +#include <linux/string.h>
>  #include <linux/timekeeping.h>
>  #include <linux/uaccess.h>
>  #include <linux/workqueue.h>
> @@ -1331,7 +1331,7 @@ static int gpio_v2_line_config_validate(struct gpio_v2_line_config *lc,
>  	if (lc->num_attrs > GPIO_V2_LINE_NUM_ATTRS_MAX)
>  		return -EINVAL;
>
> -	if (memchr_inv(lc->padding, 0, sizeof(lc->padding)))
> +	if (!mem_is_zero(lc->padding, sizeof(lc->padding)))
>  		return -EINVAL;
>
>  	for (i = 0; i < num_lines; i++) {
> @@ -1746,7 +1746,7 @@ static int linereq_create(struct gpio_device *gdev, void __user *ip)
>  	if ((ulr.num_lines == 0) || (ulr.num_lines > GPIO_V2_LINES_MAX))
>  		return -EINVAL;
>
> -	if (memchr_inv(ulr.padding, 0, sizeof(ulr.padding)))
> +	if (!mem_is_zero(ulr.padding, sizeof(ulr.padding)))
>  		return -EINVAL;
>
>  	lc = &ulr.config;
> @@ -2516,7 +2516,7 @@ static int lineinfo_get(struct gpio_chardev_data *cdev, void __user *ip,
>  	if (copy_from_user(&lineinfo, ip, sizeof(lineinfo)))
>  		return -EFAULT;
>
> -	if (memchr_inv(lineinfo.padding, 0, sizeof(lineinfo.padding)))
> +	if (!mem_is_zero(lineinfo.padding, sizeof(lineinfo.padding)))
>  		return -EINVAL;
>
>  	desc = gpio_device_get_desc(cdev->gdev, lineinfo.offset);
> --
> 2.46.0
>

  reply	other threads:[~2024-09-05  1:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-04  9:07 [PATCH v1 1/1] gpiolib: cdev: use !mem_is_zero() instead of memchr_inv(s, 0, n) Andy Shevchenko
2024-09-05  1:15 ` Kent Gibson [this message]
2024-09-05  7:36 ` Bartosz Golaszewski
2024-09-05 13:01   ` Kent Gibson
2024-09-05 13:04     ` Bartosz Golaszewski
2024-09-05 13:19       ` Kent Gibson
2024-09-05 16:11       ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240905011549.GA7299@rigel \
    --to=warthog618@gmail.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=brgl@bgdev.pl \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.