mirror of https://github.com/hak5/openwrt.git
parent
da7312105d
commit
98af79bc2b
|
@ -281,7 +281,7 @@ Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
|
||||||
|
|
||||||
#ifdef CONFIG_DEBUG_FS
|
#ifdef CONFIG_DEBUG_FS
|
||||||
const char *label;
|
const char *label;
|
||||||
@@ -151,6 +156,482 @@
|
@@ -151,6 +156,486 @@
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -558,7 +558,7 @@ Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
|
||||||
+ int status = -EINVAL;
|
+ int status = -EINVAL;
|
||||||
+
|
+
|
||||||
+ /* can't export until sysfs is available ... */
|
+ /* 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__);
|
+ pr_debug("%s: called too early!\n", __func__);
|
||||||
+ return -ENOENT;
|
+ return -ENOENT;
|
||||||
+ }
|
+ }
|
||||||
|
@ -583,8 +583,9 @@ Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
|
||||||
+ struct device *dev;
|
+ struct device *dev;
|
||||||
+
|
+
|
||||||
+ dev = device_create(&gpio_class, desc->chip->dev, MKDEV(0, 0),
|
+ dev = device_create(&gpio_class, desc->chip->dev, MKDEV(0, 0),
|
||||||
+ desc, "gpio%d", gpio);
|
+ "gpio%d", gpio);
|
||||||
+ if (dev) {
|
+ if (dev) {
|
||||||
|
+ dev_set_drvdata(dev, desc);
|
||||||
+ if (direction_may_change)
|
+ if (direction_may_change)
|
||||||
+ status = sysfs_create_group(&dev->kobj,
|
+ status = sysfs_create_group(&dev->kobj,
|
||||||
+ &gpio_attr_group);
|
+ &gpio_attr_group);
|
||||||
|
@ -634,8 +635,9 @@ Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
|
||||||
+ if (test_bit(FLAG_EXPORT, &desc->flags)) {
|
+ if (test_bit(FLAG_EXPORT, &desc->flags)) {
|
||||||
+ struct device *dev = NULL;
|
+ 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) {
|
+ if (dev) {
|
||||||
|
+ dev_set_drvdata(dev, NULL);
|
||||||
+ clear_bit(FLAG_EXPORT, &desc->flags);
|
+ clear_bit(FLAG_EXPORT, &desc->flags);
|
||||||
+ put_device(dev);
|
+ put_device(dev);
|
||||||
+ device_unregister(dev);
|
+ device_unregister(dev);
|
||||||
|
@ -661,14 +663,15 @@ Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
|
||||||
+ * export this later, in gpiolib_sysfs_init() ... here we just
|
+ * export this later, in gpiolib_sysfs_init() ... here we just
|
||||||
+ * verify that _some_ field of gpio_class got initialized.
|
+ * verify that _some_ field of gpio_class got initialized.
|
||||||
+ */
|
+ */
|
||||||
+ if (!gpio_class.p)
|
+ if (!gpio_class.subsys.kobj.ktype)
|
||||||
+ return 0;
|
+ return 0;
|
||||||
+
|
+
|
||||||
+ /* use chip->base for the ID; it's already known to be unique */
|
+ /* use chip->base for the ID; it's already known to be unique */
|
||||||
+ mutex_lock(&sysfs_lock);
|
+ 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);
|
+ "gpiochip%d", chip->base);
|
||||||
+ if (dev) {
|
+ if (dev) {
|
||||||
|
+ dev_set_drvdata(dev, chip);
|
||||||
+ status = sysfs_create_group(&dev->kobj,
|
+ status = sysfs_create_group(&dev->kobj,
|
||||||
+ &gpiochip_attr_group);
|
+ &gpiochip_attr_group);
|
||||||
+ } else
|
+ } else
|
||||||
|
@ -699,8 +702,9 @@ Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
|
||||||
+ struct device *dev;
|
+ struct device *dev;
|
||||||
+
|
+
|
||||||
+ mutex_lock(&sysfs_lock);
|
+ 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) {
|
+ if (dev) {
|
||||||
|
+ dev_set_drvdata(dev, NULL);
|
||||||
+ put_device(dev);
|
+ put_device(dev);
|
||||||
+ device_unregister(dev);
|
+ device_unregister(dev);
|
||||||
+ chip->exported = 0;
|
+ chip->exported = 0;
|
||||||
|
@ -764,7 +768,7 @@ Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
|
||||||
/**
|
/**
|
||||||
* gpiochip_add() - register a gpio_chip
|
* gpiochip_add() - register a gpio_chip
|
||||||
* @chip: the chip to register, with chip->base initialized
|
* @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
|
* because the chip->base is invalid or already associated with a
|
||||||
* different chip. Otherwise it returns zero as a success code.
|
* different chip. Otherwise it returns zero as a success code.
|
||||||
*
|
*
|
||||||
|
@ -776,7 +780,7 @@ Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
|
||||||
* If chip->base is negative, this requests dynamic assignment of
|
* If chip->base is negative, this requests dynamic assignment of
|
||||||
* a range of valid GPIOs.
|
* a range of valid GPIOs.
|
||||||
*/
|
*/
|
||||||
@@ -182,7 +668,7 @@
|
@@ -182,7 +672,7 @@
|
||||||
base = gpiochip_find_base(chip->ngpio);
|
base = gpiochip_find_base(chip->ngpio);
|
||||||
if (base < 0) {
|
if (base < 0) {
|
||||||
status = base;
|
status = base;
|
||||||
|
@ -785,7 +789,7 @@ Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
|
||||||
}
|
}
|
||||||
chip->base = base;
|
chip->base = base;
|
||||||
}
|
}
|
||||||
@@ -197,12 +683,23 @@
|
@@ -197,12 +687,23 @@
|
||||||
if (status == 0) {
|
if (status == 0) {
|
||||||
for (id = base; id < base + chip->ngpio; id++) {
|
for (id = base; id < base + chip->ngpio; id++) {
|
||||||
gpio_desc[id].chip = chip;
|
gpio_desc[id].chip = chip;
|
||||||
|
@ -811,7 +815,7 @@ Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
|
||||||
fail:
|
fail:
|
||||||
/* failures here can mean systems won't boot... */
|
/* failures here can mean systems won't boot... */
|
||||||
if (status)
|
if (status)
|
||||||
@@ -239,6 +736,10 @@
|
@@ -239,6 +740,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_unlock_irqrestore(&gpio_lock, flags);
|
spin_unlock_irqrestore(&gpio_lock, flags);
|
||||||
|
@ -822,7 +826,7 @@ Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(gpiochip_remove);
|
EXPORT_SYMBOL_GPL(gpiochip_remove);
|
||||||
@@ -296,6 +797,8 @@
|
@@ -296,6 +801,8 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -831,7 +835,7 @@ Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
|
||||||
spin_lock_irqsave(&gpio_lock, flags);
|
spin_lock_irqsave(&gpio_lock, flags);
|
||||||
|
|
||||||
desc = &gpio_desc[gpio];
|
desc = &gpio_desc[gpio];
|
||||||
@@ -534,10 +1037,6 @@
|
@@ -534,10 +1041,6 @@
|
||||||
|
|
||||||
#ifdef CONFIG_DEBUG_FS
|
#ifdef CONFIG_DEBUG_FS
|
||||||
|
|
||||||
|
@ -842,7 +846,7 @@ Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
|
||||||
static void gpiolib_dbg_show(struct seq_file *s, struct gpio_chip *chip)
|
static void gpiolib_dbg_show(struct seq_file *s, struct gpio_chip *chip)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
@@ -614,17 +1113,28 @@
|
@@ -614,17 +1117,28 @@
|
||||||
/* REVISIT this isn't locked against gpio_chip removal ... */
|
/* REVISIT this isn't locked against gpio_chip removal ... */
|
||||||
|
|
||||||
for (gpio = 0; gpio_is_valid(gpio); gpio++) {
|
for (gpio = 0; gpio_is_valid(gpio); gpio++) {
|
||||||
|
|
Loading…
Reference in New Issue