Skip to content

Commit e106b1d

Browse files
andy-shevBartosz Golaszewski
authored andcommitted
gpiolib: cdev: use !mem_is_zero() instead of memchr_inv(s, 0, n)
Use the mem_is_zero() helper where possible. Signed-off-by: Andy Shevchenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent 10287f0 commit e106b1d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/gpio/gpiolib-cdev.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include <linux/hte.h>
1717
#include <linux/interrupt.h>
1818
#include <linux/irqreturn.h>
19-
#include <linux/kernel.h>
2019
#include <linux/kfifo.h>
2120
#include <linux/module.h>
2221
#include <linux/mutex.h>
@@ -25,6 +24,7 @@
2524
#include <linux/poll.h>
2625
#include <linux/seq_file.h>
2726
#include <linux/spinlock.h>
27+
#include <linux/string.h>
2828
#include <linux/timekeeping.h>
2929
#include <linux/uaccess.h>
3030
#include <linux/workqueue.h>
@@ -1215,7 +1215,7 @@ static int gpio_v2_line_config_validate(struct gpio_v2_line_config *lc,
12151215
if (lc->num_attrs > GPIO_V2_LINE_NUM_ATTRS_MAX)
12161216
return -EINVAL;
12171217

1218-
if (memchr_inv(lc->padding, 0, sizeof(lc->padding)))
1218+
if (!mem_is_zero(lc->padding, sizeof(lc->padding)))
12191219
return -EINVAL;
12201220

12211221
for (i = 0; i < num_lines; i++) {
@@ -1629,7 +1629,7 @@ static int linereq_create(struct gpio_device *gdev, void __user *ip)
16291629
if ((ulr.num_lines == 0) || (ulr.num_lines > GPIO_V2_LINES_MAX))
16301630
return -EINVAL;
16311631

1632-
if (memchr_inv(ulr.padding, 0, sizeof(ulr.padding)))
1632+
if (!mem_is_zero(ulr.padding, sizeof(ulr.padding)))
16331633
return -EINVAL;
16341634

16351635
lc = &ulr.config;
@@ -2411,7 +2411,7 @@ static int lineinfo_get(struct gpio_chardev_data *cdev, void __user *ip,
24112411
if (copy_from_user(&lineinfo, ip, sizeof(lineinfo)))
24122412
return -EFAULT;
24132413

2414-
if (memchr_inv(lineinfo.padding, 0, sizeof(lineinfo.padding)))
2414+
if (!mem_is_zero(lineinfo.padding, sizeof(lineinfo.padding)))
24152415
return -EINVAL;
24162416

24172417
desc = gpio_device_get_desc(cdev->gdev, lineinfo.offset);

0 commit comments

Comments
 (0)