Message ID | 1439561466-14350-7-git-send-email-mpa@pengutronix.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Fri, Aug 14, 2015 at 7:11 AM, Markus Pargmann <mpa@pengutronix.de> wrote: > This patch adds a sysfs attribute 'name' to gpios that were exported. It > exposes the newly added name property of gpio descriptors. > > Signed-off-by: Markus Pargmann <mpa@pengutronix.de> The previous hunk adding the name to the sysfs ABI should be in this patch. But I have a problem with this. What is the rationale? The directory that contains the file already has this name. Why should this information be duplicated? Yours, Linus Walleij
On Mon, Sep 21, 2015 at 06:07:51PM -0700, Linus Walleij wrote: > On Fri, Aug 14, 2015 at 7:11 AM, Markus Pargmann <mpa@pengutronix.de> wrote: > > > This patch adds a sysfs attribute 'name' to gpios that were exported. It > > exposes the newly added name property of gpio descriptors. > > > > Signed-off-by: Markus Pargmann <mpa@pengutronix.de> > > The previous hunk adding the name to the sysfs ABI should > be in this patch. > > But I have a problem with this. What is the rationale? The directory > that contains the file already has this name. Why should this > information be duplicated? No reason for that. As described in the summary, I wasn't sure if this makes sense but included it anyway from the last series version. So it can simply be dropped. Thanks, Markus
diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c index 3e81f28e3aee..2022cfb00aeb 100644 --- a/drivers/gpio/gpiolib-sysfs.c +++ b/drivers/gpio/gpiolib-sysfs.c @@ -139,6 +139,17 @@ static ssize_t value_store(struct device *dev, } static DEVICE_ATTR_RW(value); +static ssize_t name_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct gpiod_data *data = dev_get_drvdata(dev); + struct gpio_desc *desc = data->desc; + + return sprintf(buf, "%s\n", desc->name ? : ""); +} + +static DEVICE_ATTR_RO(name); + static irqreturn_t gpio_sysfs_irq(int irq, void *priv) { struct gpiod_data *data = priv; @@ -377,6 +388,7 @@ static struct attribute *gpio_attrs[] = { &dev_attr_edge.attr, &dev_attr_value.attr, &dev_attr_active_low.attr, + &dev_attr_name.attr, NULL, };
This patch adds a sysfs attribute 'name' to gpios that were exported. It exposes the newly added name property of gpio descriptors. Signed-off-by: Markus Pargmann <mpa@pengutronix.de> --- drivers/gpio/gpiolib-sysfs.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)