summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBartosz Golaszewski <brgl@bgdev.pl>2022-09-22 11:51:24 +0200
committerBartosz Golaszewski <brgl@bgdev.pl>2022-09-26 14:15:38 +0200
commit0ae3109a839192920f09338e9abc4d5321107865 (patch)
tree26b0bc8c7d79a2dc4f3edf81d0ae1077972fb851
parent361c1ca384c93013e08bd117e4fe23ca9739e3f7 (diff)
downloadlinux-stable-0ae3109a839192920f09338e9abc4d5321107865.tar.gz
linux-stable-0ae3109a839192920f09338e9abc4d5321107865.tar.bz2
linux-stable-0ae3109a839192920f09338e9abc4d5321107865.zip
gpiolib: cdev: add fdinfo output for line request file descriptors
Add fdinfo output for file descriptors created for user-space line requests in GPIO uAPI v2. The fdinfo file now contains the name of the GPIO chip that is the "parent" of the request as well as offsets of the lines requested. This allows user-space to parse the /proc/$PID/fdinfo entries and deduce the PID of the process that requested a specific line. Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl> Reviewed-by: Kent Gibson <warthog618@gmail.com>
-rw-r--r--drivers/gpio/gpiolib-cdev.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c
index f8041d4898d1..01c15e9e6896 100644
--- a/drivers/gpio/gpiolib-cdev.c
+++ b/drivers/gpio/gpiolib-cdev.c
@@ -1497,6 +1497,21 @@ static int linereq_release(struct inode *inode, struct file *file)
return 0;
}
+#ifdef CONFIG_PROC_FS
+static void linereq_show_fdinfo(struct seq_file *out, struct file *file)
+{
+ struct linereq *lr = file->private_data;
+ struct device *dev = &lr->gdev->dev;
+ u16 i;
+
+ seq_printf(out, "gpio-chip:\t%s\n", dev_name(dev));
+
+ for (i = 0; i < lr->num_lines; i++)
+ seq_printf(out, "gpio-line:\t%d\n",
+ gpio_chip_hwgpio(lr->lines[i].desc));
+}
+#endif
+
static const struct file_operations line_fileops = {
.release = linereq_release,
.read = linereq_read,
@@ -1507,6 +1522,9 @@ static const struct file_operations line_fileops = {
#ifdef CONFIG_COMPAT
.compat_ioctl = linereq_ioctl_compat,
#endif
+#ifdef CONFIG_PROC_FS
+ .show_fdinfo = linereq_show_fdinfo,
+#endif
};
static int linereq_create(struct gpio_device *gdev, void __user *ip)