#ifdef CONFIG_DEBUG_FS
const char *label;
-@@ -151,6 +156,482 @@
+@@ -151,6 +156,486 @@
return ret;
}
+ int status = -EINVAL;
+
+ /* can't export until sysfs is available ... */
-+ if (!gpio_class.p) {
++ if (!gpio_class.subsys.kobj.ktype) {
+ pr_debug("%s: called too early!\n", __func__);
+ return -ENOENT;
+ }
+ struct device *dev;
+
+ dev = device_create(&gpio_class, desc->chip->dev, MKDEV(0, 0),
-+ desc, "gpio%d", gpio);
++ "gpio%d", gpio);
+ if (dev) {
++ dev_set_drvdata(dev, desc);
+ if (direction_may_change)
+ status = sysfs_create_group(&dev->kobj,
+ &gpio_attr_group);
+ if (test_bit(FLAG_EXPORT, &desc->flags)) {
+ struct device *dev = NULL;
+
-+ dev = class_find_device(&gpio_class, NULL, desc, match_export);
++ dev = class_find_device(&gpio_class, desc, match_export);
+ if (dev) {
++ dev_set_drvdata(dev, NULL);
+ clear_bit(FLAG_EXPORT, &desc->flags);
+ put_device(dev);
+ device_unregister(dev);
+ * export this later, in gpiolib_sysfs_init() ... here we just
+ * verify that _some_ field of gpio_class got initialized.
+ */
-+ if (!gpio_class.p)
++ if (!gpio_class.subsys.kobj.ktype)
+ return 0;
+
+ /* use chip->base for the ID; it's already known to be unique */
+ mutex_lock(&sysfs_lock);
-+ dev = device_create(&gpio_class, chip->dev, MKDEV(0, 0), chip,
++ dev = device_create(&gpio_class, chip->dev, MKDEV(0, 0),
+ "gpiochip%d", chip->base);
+ if (dev) {
++ dev_set_drvdata(dev, chip);
+ status = sysfs_create_group(&dev->kobj,
+ &gpiochip_attr_group);
+ } else
+ struct device *dev;
+
+ mutex_lock(&sysfs_lock);
-+ dev = class_find_device(&gpio_class, NULL, chip, match_export);
++ dev = class_find_device(&gpio_class, chip, match_export);
+ if (dev) {
++ dev_set_drvdata(dev, NULL);
+ put_device(dev);
+ device_unregister(dev);
+ chip->exported = 0;
/**
* gpiochip_add() - register a gpio_chip
* @chip: the chip to register, with chip->base initialized
-@@ -160,6 +641,11 @@
+@@ -160,6 +645,11 @@
* because the chip->base is invalid or already associated with a
* different chip. Otherwise it returns zero as a success code.
*
* If chip->base is negative, this requests dynamic assignment of
* a range of valid GPIOs.
*/
-@@ -182,7 +668,7 @@
+@@ -182,7 +672,7 @@
base = gpiochip_find_base(chip->ngpio);
if (base < 0) {
status = base;
}
chip->base = base;
}
-@@ -197,12 +683,23 @@
+@@ -197,12 +687,23 @@
if (status == 0) {
for (id = base; id < base + chip->ngpio; id++) {
gpio_desc[id].chip = chip;
fail:
/* failures here can mean systems won't boot... */
if (status)
-@@ -239,6 +736,10 @@
+@@ -239,6 +740,10 @@
}
spin_unlock_irqrestore(&gpio_lock, flags);
return status;
}
EXPORT_SYMBOL_GPL(gpiochip_remove);
-@@ -296,6 +797,8 @@
+@@ -296,6 +801,8 @@
return;
}
spin_lock_irqsave(&gpio_lock, flags);
desc = &gpio_desc[gpio];
-@@ -534,10 +1037,6 @@
+@@ -534,10 +1041,6 @@
#ifdef CONFIG_DEBUG_FS
static void gpiolib_dbg_show(struct seq_file *s, struct gpio_chip *chip)
{
unsigned i;
-@@ -614,17 +1113,28 @@
+@@ -614,17 +1117,28 @@
/* REVISIT this isn't locked against gpio_chip removal ... */
for (gpio = 0; gpio_is_valid(gpio); gpio++) {