aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpiolib.c
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2016-02-12 14:48:23 +0100
committerLinus Walleij <linus.walleij@linaro.org>2016-02-19 09:48:41 +0100
commitdf4878e969ccc047da45d2cd3af5d08031da1593 (patch)
tree2677387492b60fd5c6a42a317bde0e7e965aa8fa /drivers/gpio/gpiolib.c
parentgpio: tps65218: remove unused #include (diff)
downloadlinux-dev-df4878e969ccc047da45d2cd3af5d08031da1593.tar.xz
linux-dev-df4878e969ccc047da45d2cd3af5d08031da1593.zip
gpio: store reflect the label to userspace
The gpio_chip label is useful for userspace to understand what kind of GPIO chip it is dealing with. Let's store a copy of this label in the gpio_device, add it to the struct passed to userspace for GPIO_GET_CHIPINFO_IOCTL and modify lsgpio to show it. Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpiolib.c')
-rw-r--r--drivers/gpio/gpiolib.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 59f0045c5950..797c790aa750 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -342,6 +342,9 @@ static long gpio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
strncpy(chipinfo.name, dev_name(&gdev->dev),
sizeof(chipinfo.name));
chipinfo.name[sizeof(chipinfo.name)-1] = '\0';
+ strncpy(chipinfo.label, gdev->label,
+ sizeof(chipinfo.label));
+ chipinfo.label[sizeof(chipinfo.label)-1] = '\0';
chipinfo.lines = gdev->ngpio;
if (copy_to_user(ip, &chipinfo, sizeof(chipinfo)))
return -EFAULT;
@@ -479,6 +482,16 @@ int gpiochip_add_data(struct gpio_chip *chip, void *data)
status = -EINVAL;
goto err_free_gdev;
}
+
+ if (chip->label)
+ gdev->label = devm_kstrdup(&gdev->dev, chip->label, GFP_KERNEL);
+ else
+ gdev->label = devm_kstrdup(&gdev->dev, "unknown", GFP_KERNEL);
+ if (!gdev->label) {
+ status = -ENOMEM;
+ goto err_free_gdev;
+ }
+
gdev->ngpio = chip->ngpio;
gdev->data = data;