summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorBamvor Jian Zhang <bamvor.zhangjian@linaro.org>2016-02-24 17:17:19 +0300
committerLinus Walleij <linus.walleij@linaro.org>2016-02-25 18:08:45 +0300
commitd27c17285eb7ebb6aa513da7a3338e2a507b1216 (patch)
tree85a94c1c9fb59dff61db96b24f19d2a7107c0775 /drivers
parentcfb7428c3d156e45bb4092864551439e65176db3 (diff)
downloadlinux-d27c17285eb7ebb6aa513da7a3338e2a507b1216.tar.xz
gpio: fix abi regression in sysfs
We started to assign the gpio_device as parent for the sysfs but this changes the expected layout of sysfs. Restore the previous behaviour. Signed-off-by: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpio/gpiolib-sysfs.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c
index c56309491e8b..932e510aec50 100644
--- a/drivers/gpio/gpiolib-sysfs.c
+++ b/drivers/gpio/gpiolib-sysfs.c
@@ -721,6 +721,7 @@ EXPORT_SYMBOL_GPL(gpiod_unexport);
int gpiochip_sysfs_register(struct gpio_device *gdev)
{
struct device *dev;
+ struct device *parent;
struct gpio_chip *chip = gdev->chip;
/*
@@ -732,8 +733,17 @@ int gpiochip_sysfs_register(struct gpio_device *gdev)
if (!gpio_class.p)
return 0;
+ /*
+ * For sysfs backward compatibility we need to preserve this
+ * preferred parenting to the gpio_chip parent field, if set.
+ */
+ if (chip->parent)
+ parent = chip->parent;
+ else
+ parent = &gdev->dev;
+
/* use chip->base for the ID; it's already known to be unique */
- dev = device_create_with_groups(&gpio_class, &gdev->dev,
+ dev = device_create_with_groups(&gpio_class, parent,
MKDEV(0, 0),
chip, gpiochip_groups,
"gpiochip%d", chip->base);