OSDN Git Service

Merge branch 'regulator-4.20' into regulator-next
authorMark Brown <broonie@kernel.org>
Sun, 21 Oct 2018 16:00:02 +0000 (17:00 +0100)
committerMark Brown <broonie@kernel.org>
Sun, 21 Oct 2018 16:00:02 +0000 (17:00 +0100)
1  2 
drivers/gpio/gpiolib.c

diff --combined drivers/gpio/gpiolib.c
@@@ -571,7 -571,7 +571,7 @@@ static int linehandle_create(struct gpi
                if (ret)
                        goto out_free_descs;
                lh->descs[i] = desc;
 -              count = i;
 +              count = i + 1;
  
                if (lflags & GPIOHANDLE_REQUEST_ACTIVE_LOW)
                        set_bit(FLAG_ACTIVE_LOW, &desc->flags);
@@@ -1682,8 -1682,7 +1682,8 @@@ static void gpiochip_set_cascaded_irqch
                irq_set_chained_handler_and_data(parent_irq, parent_handler,
                                                 gpiochip);
  
 -              gpiochip->irq.parents = &parent_irq;
 +              gpiochip->irq.parent_irq = parent_irq;
 +              gpiochip->irq.parents = &gpiochip->irq.parent_irq;
                gpiochip->irq.num_parents = 1;
        }
  
@@@ -3909,8 -3908,23 +3909,23 @@@ struct gpio_desc *__must_check gpiod_ge
         * the device name as label
         */
        status = gpiod_request(desc, con_id ? con_id : devname);
-       if (status < 0)
-               return ERR_PTR(status);
+       if (status < 0) {
+               if (status == -EBUSY && flags & GPIOD_FLAGS_BIT_NONEXCLUSIVE) {
+                       /*
+                        * This happens when there are several consumers for
+                        * the same GPIO line: we just return here without
+                        * further initialization. It is a bit if a hack.
+                        * This is necessary to support fixed regulators.
+                        *
+                        * FIXME: Make this more sane and safe.
+                        */
+                       dev_info(dev, "nonexclusive access to GPIO for %s\n",
+                                con_id ? con_id : devname);
+                       return desc;
+               } else {
+                       return ERR_PTR(status);
+               }
+       }
  
        status = gpiod_configure_flags(desc, con_id, lookupflags, flags);
        if (status < 0) {