Merge tag 'gpio-v5.5-updates-for-linus-part-1' of git://git.kernel.org/pub/scm/linux...
authorLinus Walleij <linus.walleij@linaro.org>
Wed, 23 Oct 2019 11:31:36 +0000 (13:31 +0200)
committerLinus Walleij <linus.walleij@linaro.org>
Wed, 23 Oct 2019 11:31:36 +0000 (13:31 +0200)
gpio updates for v5.5

- only get the second IRQ when there is more than one IRQ in mxc
- move the code around in lineevent_create() for some shrinkage
- fix formatting for GPIO docs
- add DT binding for r8a774b1
- convert drivers that prevously used nocache ioremap() to using regular
  devm_platform_ioremap_resource()
- remove some redundant error messages
- shrink object code in 104-idi-48e
- drop an unneeded warning from gpiolib-of

1  2 
drivers/gpio/gpiolib-of.c
drivers/gpio/gpiolib.c

@@@ -84,9 -84,8 +84,9 @@@ static struct gpio_desc *of_xlate_and_g
  /**
   * of_gpio_need_valid_mask() - figure out if the OF GPIO driver needs
   * to set the .valid_mask
 - * @dev: the device for the GPIO provider
 - * @return: true if the valid mask needs to be set
 + * @gc: the target gpio_chip
 + *
 + * Return: true if the valid mask needs to be set
   */
  bool of_gpio_need_valid_mask(const struct gpio_chip *gc)
  {
@@@ -135,18 -134,20 +135,20 @@@ static void of_gpio_flags_quirks(struc
             (!(strcmp(propname, "enable-gpio") &&
                strcmp(propname, "enable-gpios")) &&
              of_device_is_compatible(np, "regulator-gpio")))) {
+               bool active_low = !of_property_read_bool(np,
+                                                        "enable-active-high");
                /*
                 * The regulator GPIO handles are specified such that the
                 * presence or absence of "enable-active-high" solely controls
                 * the polarity of the GPIO line. Any phandle flags must
                 * be actively ignored.
                 */
-               if (*flags & OF_GPIO_ACTIVE_LOW) {
+               if ((*flags & OF_GPIO_ACTIVE_LOW) && !active_low) {
                        pr_warn("%s GPIO handle specifies active low - ignored\n",
                                of_node_full_name(np));
                        *flags &= ~OF_GPIO_ACTIVE_LOW;
                }
-               if (!of_property_read_bool(np, "enable-active-high"))
+               if (active_low)
                        *flags |= OF_GPIO_ACTIVE_LOW;
        }
        /*
diff --combined drivers/gpio/gpiolib.c
@@@ -421,8 -421,6 +421,8 @@@ struct linehandle_state 
        (GPIOHANDLE_REQUEST_INPUT | \
        GPIOHANDLE_REQUEST_OUTPUT | \
        GPIOHANDLE_REQUEST_ACTIVE_LOW | \
 +      GPIOHANDLE_REQUEST_PULL_UP | \
 +      GPIOHANDLE_REQUEST_PULL_DOWN | \
        GPIOHANDLE_REQUEST_OPEN_DRAIN | \
        GPIOHANDLE_REQUEST_OPEN_SOURCE)
  
@@@ -594,10 -592,6 +594,10 @@@ static int linehandle_create(struct gpi
                        set_bit(FLAG_OPEN_DRAIN, &desc->flags);
                if (lflags & GPIOHANDLE_REQUEST_OPEN_SOURCE)
                        set_bit(FLAG_OPEN_SOURCE, &desc->flags);
 +              if (lflags & GPIOHANDLE_REQUEST_PULL_DOWN)
 +                      set_bit(FLAG_PULL_DOWN, &desc->flags);
 +              if (lflags & GPIOHANDLE_REQUEST_PULL_UP)
 +                      set_bit(FLAG_PULL_UP, &desc->flags);
  
                ret = gpiod_set_transitory(desc, false);
                if (ret < 0)
@@@ -900,6 -894,24 +900,24 @@@ static int lineevent_create(struct gpio
        if (copy_from_user(&eventreq, ip, sizeof(eventreq)))
                return -EFAULT;
  
+       offset = eventreq.lineoffset;
+       lflags = eventreq.handleflags;
+       eflags = eventreq.eventflags;
+       if (offset >= gdev->ngpio)
+               return -EINVAL;
+       /* Return an error if a unknown flag is set */
+       if ((lflags & ~GPIOHANDLE_REQUEST_VALID_FLAGS) ||
+           (eflags & ~GPIOEVENT_REQUEST_VALID_FLAGS))
+               return -EINVAL;
+       /* This is just wrong: we don't look for events on output lines */
+       if ((lflags & GPIOHANDLE_REQUEST_OUTPUT) ||
+           (lflags & GPIOHANDLE_REQUEST_OPEN_DRAIN) ||
+           (lflags & GPIOHANDLE_REQUEST_OPEN_SOURCE))
+               return -EINVAL;
        le = kzalloc(sizeof(*le), GFP_KERNEL);
        if (!le)
                return -ENOMEM;
                }
        }
  
-       offset = eventreq.lineoffset;
-       lflags = eventreq.handleflags;
-       eflags = eventreq.eventflags;
-       if (offset >= gdev->ngpio) {
-               ret = -EINVAL;
-               goto out_free_label;
-       }
-       /* Return an error if a unknown flag is set */
-       if ((lflags & ~GPIOHANDLE_REQUEST_VALID_FLAGS) ||
-           (eflags & ~GPIOEVENT_REQUEST_VALID_FLAGS)) {
-               ret = -EINVAL;
-               goto out_free_label;
-       }
-       /* This is just wrong: we don't look for events on output lines */
-       if ((lflags & GPIOHANDLE_REQUEST_OUTPUT) ||
-           (lflags & GPIOHANDLE_REQUEST_OPEN_DRAIN) ||
-           (lflags & GPIOHANDLE_REQUEST_OPEN_SOURCE)) {
-               ret = -EINVAL;
-               goto out_free_label;
-       }
        desc = &gdev->descs[offset];
        ret = gpiod_request(desc, le->label);
        if (ret)
@@@ -1103,10 -1091,6 +1097,10 @@@ static long gpio_ioctl(struct file *fil
                if (test_bit(FLAG_OPEN_SOURCE, &desc->flags))
                        lineinfo.flags |= (GPIOLINE_FLAG_OPEN_SOURCE |
                                           GPIOLINE_FLAG_IS_OUT);
 +              if (test_bit(FLAG_PULL_DOWN, &desc->flags))
 +                      lineinfo.flags |= GPIOLINE_FLAG_PULL_DOWN;
 +              if (test_bit(FLAG_PULL_UP, &desc->flags))
 +                      lineinfo.flags |= GPIOLINE_FLAG_PULL_UP;
  
                if (copy_to_user(ip, &lineinfo, sizeof(lineinfo)))
                        return -EFAULT;
@@@ -2780,8 -2764,6 +2774,8 @@@ static bool gpiod_free_commit(struct gp
                clear_bit(FLAG_REQUESTED, &desc->flags);
                clear_bit(FLAG_OPEN_DRAIN, &desc->flags);
                clear_bit(FLAG_OPEN_SOURCE, &desc->flags);
 +              clear_bit(FLAG_PULL_UP, &desc->flags);
 +              clear_bit(FLAG_PULL_DOWN, &desc->flags);
                clear_bit(FLAG_IS_HOGGED, &desc->flags);
                ret = true;
        }
@@@ -4336,54 -4318,6 +4330,54 @@@ static int platform_gpio_count(struct d
        return count;
  }
  
 +/**
 + * fwnode_gpiod_get_index - obtain a GPIO from firmware node
 + * @fwnode:   handle of the firmware node
 + * @con_id:   function within the GPIO consumer
 + * @index:    index of the GPIO to obtain for the consumer
 + * @flags:    GPIO initialization flags
 + * @label:    label to attach to the requested GPIO
 + *
 + * This function can be used for drivers that get their configuration
 + * from opaque firmware.
 + *
 + * The function properly finds the corresponding GPIO using whatever is the
 + * underlying firmware interface and then makes sure that the GPIO
 + * descriptor is requested before it is returned to the caller.
 + *
 + * Returns:
 + * On successful request the GPIO pin is configured in accordance with
 + * provided @flags.
 + *
 + * In case of error an ERR_PTR() is returned.
 + */
 +struct gpio_desc *fwnode_gpiod_get_index(struct fwnode_handle *fwnode,
 +                                       const char *con_id, int index,
 +                                       enum gpiod_flags flags,
 +                                       const char *label)
 +{
 +      struct gpio_desc *desc;
 +      char prop_name[32]; /* 32 is max size of property name */
 +      unsigned int i;
 +
 +      for (i = 0; i < ARRAY_SIZE(gpio_suffixes); i++) {
 +              if (con_id)
 +                      snprintf(prop_name, sizeof(prop_name), "%s-%s",
 +                                          con_id, gpio_suffixes[i]);
 +              else
 +                      snprintf(prop_name, sizeof(prop_name), "%s",
 +                                          gpio_suffixes[i]);
 +
 +              desc = fwnode_get_named_gpiod(fwnode, prop_name, index, flags,
 +                                            label);
 +              if (!IS_ERR(desc) || (PTR_ERR(desc) != -ENOENT))
 +                      break;
 +      }
 +
 +      return desc;
 +}
 +EXPORT_SYMBOL_GPL(fwnode_gpiod_get_index);
 +
  /**
   * gpiod_count - return the number of GPIOs associated with a device / function
   *            or -ENOENT if no GPIO has been assigned to the requested function