nfsd4: setclientid_confirm callback-change fixes
[safe/jmp/linux-2.6] / drivers / gpio / gpiolib.c
index 9112830..51a8d41 100644 (file)
@@ -69,20 +69,24 @@ static inline void desc_set_label(struct gpio_desc *d, const char *label)
  * those calls have no teeth) we can't avoid autorequesting.  This nag
  * message should motivate switching to explicit requests... so should
  * the weaker cleanup after faults, compared to gpio_request().
+ *
+ * NOTE: the autorequest mechanism is going away; at this point it's
+ * only "legal" in the sense that (old) code using it won't break yet,
+ * but instead only triggers a WARN() stack dump.
  */
 static int gpio_ensure_requested(struct gpio_desc *desc, unsigned offset)
 {
-       if (test_and_set_bit(FLAG_REQUESTED, &desc->flags) == 0) {
-               struct gpio_chip *chip = desc->chip;
-               int gpio = chip->base + offset;
+       const struct gpio_chip *chip = desc->chip;
+       const int gpio = chip->base + offset;
 
+       if (WARN(test_and_set_bit(FLAG_REQUESTED, &desc->flags) == 0,
+                       "autorequest GPIO-%d\n", gpio)) {
                if (!try_module_get(chip->owner)) {
                        pr_err("GPIO-%d: module can't be gotten \n", gpio);
                        clear_bit(FLAG_REQUESTED, &desc->flags);
                        /* lose */
                        return -EIO;
                }
-               pr_warning("GPIO-%d autorequested\n", gpio);
                desc_set_label(desc, "[auto]");
                /* caller must chip->request() w/o spinlock */
                if (chip->request)
@@ -248,7 +252,7 @@ static ssize_t gpio_value_show(struct device *dev,
        if (!test_bit(FLAG_EXPORT, &desc->flags))
                status = -EIO;
        else
-               status = sprintf(buf, "%d\n", gpio_get_value_cansleep(gpio));
+               status = sprintf(buf, "%d\n", !!gpio_get_value_cansleep(gpio));
 
        mutex_unlock(&sysfs_lock);
        return status;
@@ -438,6 +442,7 @@ int gpio_export(unsigned gpio, bool direction_may_change)
        unsigned long           flags;
        struct gpio_desc        *desc;
        int                     status = -EINVAL;
+       char                    *ioname = NULL;
 
        /* can't export until sysfs is available ... */
        if (!gpio_class.p) {
@@ -461,11 +466,14 @@ int gpio_export(unsigned gpio, bool direction_may_change)
        }
        spin_unlock_irqrestore(&gpio_lock, flags);
 
+       if (desc->chip->names && desc->chip->names[gpio - desc->chip->base])
+               ioname = desc->chip->names[gpio - desc->chip->base];
+
        if (status == 0) {
                struct device   *dev;
 
                dev = device_create(&gpio_class, desc->chip->dev, MKDEV(0, 0),
-                                       desc, "gpio%d", gpio);
+                                   desc, ioname ? ioname : "gpio%d", gpio);
                if (dev) {
                        if (direction_may_change)
                                status = sysfs_create_group(&dev->kobj,
@@ -513,6 +521,7 @@ void gpio_unexport(unsigned gpio)
        mutex_lock(&sysfs_lock);
 
        desc = &gpio_desc[gpio];
+
        if (test_bit(FLAG_EXPORT, &desc->flags)) {
                struct device   *dev = NULL;
 
@@ -789,6 +798,7 @@ int gpio_request(unsigned gpio, const char *label)
        } else {
                status = -EBUSY;
                module_put(chip->owner);
+               goto done;
        }
 
        if (chip->request) {
@@ -1105,7 +1115,7 @@ int gpio_get_value_cansleep(unsigned gpio)
 
        might_sleep_if(extra_checks);
        chip = gpio_to_chip(gpio);
-       return chip->get(chip, gpio - chip->base);
+       return chip->get ? chip->get(chip, gpio - chip->base) : 0;
 }
 EXPORT_SYMBOL_GPL(gpio_get_value_cansleep);
 
@@ -1134,7 +1144,7 @@ static void gpiolib_dbg_show(struct seq_file *s, struct gpio_chip *chip)
                        continue;
 
                is_out = test_bit(FLAG_IS_OUT, &gdesc->flags);
-               seq_printf(s, " gpio-%-3d (%-12s) %s %s",
+               seq_printf(s, " gpio-%-3d (%-20.20s) %s %s",
                        gpio, gdesc->label,
                        is_out ? "out" : "in ",
                        chip->get
@@ -1143,7 +1153,7 @@ static void gpiolib_dbg_show(struct seq_file *s, struct gpio_chip *chip)
 
                if (!is_out) {
                        int             irq = gpio_to_irq(gpio);
-                       struct irq_desc *desc = irq_desc + irq;
+                       struct irq_desc *desc = irq_to_desc(irq);
 
                        /* This races with request_irq(), set_irq_type(),
                         * and set_irq_wake() ... but those are "rare".
@@ -1213,7 +1223,7 @@ static int gpiolib_show(struct seq_file *s, void *unused)
                if (dev)
                        seq_printf(s, ", %s/%s",
                                dev->bus ? dev->bus->name : "no-bus",
-                               dev->bus_id);
+                               dev_name(dev));
                if (chip->label)
                        seq_printf(s, ", %s", chip->label);
                if (chip->can_sleep)