[lkml]   [2020]   [Sep]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH v9 01/20] gpiolib: cdev: gpio_desc_to_lineinfo() should set info offset
Set the value of the line info offset in gpio_desc_to_lineinfo(), rather
than relying on it being passed in the info. This makes the function
behave as you would expect from the name - it generates the line info
corresponding to a given GPIO desc.

Signed-off-by: Kent Gibson <>
Reviewed-by: Andy Shevchenko <>

There are some instances where this results in the offset being set when
it is already set in the info, but this is clearer especially considering
that, as part of the replacement of strncpy with strscpy and to ensure
kernel stack cannot be leaked to userspace, the info is initially zeroed
in a subsequent patch.

drivers/gpio/gpiolib-cdev.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c
index e6c9b78adfc2..81ce2020f17b 100644
--- a/drivers/gpio/gpiolib-cdev.c
+++ b/drivers/gpio/gpiolib-cdev.c
@@ -752,6 +752,8 @@ static void gpio_desc_to_lineinfo(struct gpio_desc *desc,
bool ok_for_pinctrl;
unsigned long flags;

+ info->line_offset = gpio_chip_hwgpio(desc);
* This function takes a mutex so we must check this before taking
* the spinlock.
@@ -933,7 +935,6 @@ static int lineinfo_changed_notify(struct notifier_block *nb,

memset(&chg, 0, sizeof(chg));
- = gpio_chip_hwgpio(desc);
chg.event_type = action;
chg.timestamp = ktime_get_ns();
gpio_desc_to_lineinfo(desc, &;
 \ /
  Last update: 2020-09-22 04:34    [W:0.328 / U:6.360 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site