]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - drivers/gpio/gpiolib.c
Merge remote-tracking branch 'pinctrl/for-next'
[karo-tx-linux.git] / drivers / gpio / gpiolib.c
index b83b7e491f760a1d549d420f872c1c35a2872df8..4a34ca9c1768ea75fe7c8155bf8c07e2a7a11e7e 100644 (file)
@@ -136,7 +136,7 @@ static struct gpio_desc *gpio_to_desc(unsigned gpio)
  */
 static int desc_to_gpio(const struct gpio_desc *desc)
 {
-       return desc->chip->base + gpio_chip_hwgpio(desc);
+       return desc - &gpio_desc[0];
 }
 
 
@@ -408,7 +408,7 @@ static int gpio_setup_irq(struct gpio_desc *desc, struct device *dev,
                        IRQF_TRIGGER_FALLING : IRQF_TRIGGER_RISING;
 
        if (!value_sd) {
-               value_sd = sysfs_get_dirent(dev->kobj.sd, NULL, "value");
+               value_sd = sysfs_get_dirent(dev->kobj.sd, "value");
                if (!value_sd) {
                        ret = -ENODEV;
                        goto err_out;
@@ -1445,7 +1445,7 @@ static int gpiod_request(struct gpio_desc *desc, const char *label)
        int                     status = -EPROBE_DEFER;
        unsigned long           flags;
 
-       if (!desc || !desc->chip) {
+       if (!desc) {
                pr_warn("%s: invalid GPIO\n", __func__);
                return -EINVAL;
        }
@@ -1453,6 +1453,8 @@ static int gpiod_request(struct gpio_desc *desc, const char *label)
        spin_lock_irqsave(&gpio_lock, flags);
 
        chip = desc->chip;
+       if (chip == NULL)
+               goto done;
 
        if (!try_module_get(chip->owner))
                goto done;