[PATCH 3/3] gpiolib: use chip->names for symlinks, always use gpioN for device names

Jani Nikula
2009-12-09T13:50:28Z

Restore gpiolib sysfs device naming back to /sys/class/gpio/gpioN, where
N is the GPIO number. Use the chip->names mechanism for creating
symlinks to those devices instead of creating the devices using
chip->names. All GPIO naming (other than gpioN) in gpiolib sysfs is now
done using symlinks.

While the device names are now unique again, collisions in chip->names
will still prevent duplicates from being exported to sysfs.

Signed-off-by: Jani Nikula <ext-jani.1.nikula@nokia.com>
---
drivers/gpio/gpiolib.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index f254195..fe7ffad 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -740,7 +740,7 @@ int gpio_export(unsigned gpio, bool direction_may_change)
struct device *dev;

dev = device_create(&gpio_class, desc->chip->dev, MKDEV(0, 0),
- desc, ioname ? ioname : "gpio%d", gpio);
+ desc, "gpio%d", gpio);
if (!IS_ERR(dev)) {
if (direction_may_change)
status = sysfs_create_group(&dev->kobj,
@@ -756,6 +756,10 @@ int gpio_export(unsigned gpio, bool direction_may_change)
status = device_create_file(dev,
&dev_attr_edge);

+ if (!status && ioname != NULL)
+ status = create_link(gpio, NULL, &dev->kobj,
+ ioname);
+
if (status != 0)
device_unregister(dev);
} else
--
1.6.5.2