Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Bamvor Jian Zhang and committed by
Linus Walleij
d27c1728 cfb7428c

+11 -1
+11 -1
drivers/gpio/gpiolib-sysfs.c
··· 721 721 int gpiochip_sysfs_register(struct gpio_device *gdev) 722 722 { 723 723 struct device *dev; 724 + struct device *parent; 724 725 struct gpio_chip *chip = gdev->chip; 725 726 726 727 /* ··· 733 732 if (!gpio_class.p) 734 733 return 0; 735 734 735 + /* 736 + * For sysfs backward compatibility we need to preserve this 737 + * preferred parenting to the gpio_chip parent field, if set. 738 + */ 739 + if (chip->parent) 740 + parent = chip->parent; 741 + else 742 + parent = &gdev->dev; 743 + 736 744 /* use chip->base for the ID; it's already known to be unique */ 737 - dev = device_create_with_groups(&gpio_class, &gdev->dev, 745 + dev = device_create_with_groups(&gpio_class, parent, 738 746 MKDEV(0, 0), 739 747 chip, gpiochip_groups, 740 748 "gpiochip%d", chip->base);