Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gpio: move the pin ranges into gpio_device

Instead of keeping this reference to the pin ranges in the
client driver-supplied gpio_chip, move it to the internal
gpio_device as the drivers have no need to inspect this.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

+24 -23
+9 -9
drivers/gpio/gpiolib-acpi.c
··· 71 71 * controller uses pin controller and the mapping is not contiguous the 72 72 * offset might be different. 73 73 */ 74 - static int acpi_gpiochip_pin_to_gpio_offset(struct gpio_chip *chip, int pin) 74 + static int acpi_gpiochip_pin_to_gpio_offset(struct gpio_device *gdev, int pin) 75 75 { 76 76 struct gpio_pin_range *pin_range; 77 77 78 78 /* If there are no ranges in this chip, use 1:1 mapping */ 79 - if (list_empty(&chip->pin_ranges)) 79 + if (list_empty(&gdev->pin_ranges)) 80 80 return pin; 81 81 82 - list_for_each_entry(pin_range, &chip->pin_ranges, node) { 82 + list_for_each_entry(pin_range, &gdev->pin_ranges, node) { 83 83 const struct pinctrl_gpio_range *range = &pin_range->range; 84 84 int i; 85 85 86 86 if (range->pins) { 87 87 for (i = 0; i < range->npins; i++) { 88 88 if (range->pins[i] == pin) 89 - return range->base + i - chip->base; 89 + return range->base + i - gdev->base; 90 90 } 91 91 } else { 92 92 if (pin >= range->pin_base && 93 93 pin < range->pin_base + range->npins) { 94 94 unsigned gpio_base; 95 95 96 - gpio_base = range->base - chip->base; 96 + gpio_base = range->base - gdev->base; 97 97 return gpio_base + pin - range->pin_base; 98 98 } 99 99 } ··· 102 102 return -EINVAL; 103 103 } 104 104 #else 105 - static inline int acpi_gpiochip_pin_to_gpio_offset(struct gpio_chip *chip, 105 + static inline int acpi_gpiochip_pin_to_gpio_offset(struct gpio_device *gdev, 106 106 int pin) 107 107 { 108 108 return pin; ··· 134 134 if (!chip) 135 135 return ERR_PTR(-EPROBE_DEFER); 136 136 137 - offset = acpi_gpiochip_pin_to_gpio_offset(chip, pin); 137 + offset = acpi_gpiochip_pin_to_gpio_offset(chip->gpiodev, pin); 138 138 if (offset < 0) 139 139 return ERR_PTR(offset); 140 140 ··· 202 202 if (!handler) 203 203 return AE_BAD_PARAMETER; 204 204 205 - pin = acpi_gpiochip_pin_to_gpio_offset(chip, pin); 205 + pin = acpi_gpiochip_pin_to_gpio_offset(chip->gpiodev, pin); 206 206 if (pin < 0) 207 207 return AE_BAD_PARAMETER; 208 208 ··· 673 673 struct gpio_desc *desc; 674 674 bool found; 675 675 676 - pin = acpi_gpiochip_pin_to_gpio_offset(chip, pin); 676 + pin = acpi_gpiochip_pin_to_gpio_offset(chip->gpiodev, pin); 677 677 if (pin < 0) { 678 678 status = AE_BAD_PARAMETER; 679 679 goto out;
+5 -5
drivers/gpio/gpiolib.c
··· 532 532 spin_unlock_irqrestore(&gpio_lock, flags); 533 533 534 534 #ifdef CONFIG_PINCTRL 535 - /* FIXME: move pin ranges to gpio_device */ 536 - INIT_LIST_HEAD(&chip->pin_ranges); 535 + INIT_LIST_HEAD(&gdev->pin_ranges); 537 536 #endif 538 537 539 538 status = gpiochip_set_desc_names(chip); ··· 1035 1036 gpio_offset, gpio_offset + pin_range->range.npins - 1, 1036 1037 pinctrl_dev_get_devname(pctldev), pin_group); 1037 1038 1038 - list_add_tail(&pin_range->node, &chip->pin_ranges); 1039 + list_add_tail(&pin_range->node, &gdev->pin_ranges); 1039 1040 1040 1041 return 0; 1041 1042 } ··· 1084 1085 pinctl_name, 1085 1086 pin_offset, pin_offset + npins - 1); 1086 1087 1087 - list_add_tail(&pin_range->node, &chip->pin_ranges); 1088 + list_add_tail(&pin_range->node, &gdev->pin_ranges); 1088 1089 1089 1090 return 0; 1090 1091 } ··· 1097 1098 void gpiochip_remove_pin_ranges(struct gpio_chip *chip) 1098 1099 { 1099 1100 struct gpio_pin_range *pin_range, *tmp; 1101 + struct gpio_device *gdev = chip->gpiodev; 1100 1102 1101 - list_for_each_entry_safe(pin_range, tmp, &chip->pin_ranges, node) { 1103 + list_for_each_entry_safe(pin_range, tmp, &gdev->pin_ranges, node) { 1102 1104 list_del(&pin_range->node); 1103 1105 pinctrl_remove_gpio_range(pin_range->pctldev, 1104 1106 &pin_range->range);
+10
drivers/gpio/gpiolib.h
··· 55 55 int base; 56 56 u16 ngpio; 57 57 struct list_head list; 58 + 59 + #ifdef CONFIG_PINCTRL 60 + /* 61 + * If CONFIG_PINCTRL is enabled, then gpio controllers can optionally 62 + * describe the actual pin range which they serve in an SoC. This 63 + * information would be used by pinctrl subsystem to configure 64 + * corresponding pins for gpio usage. 65 + */ 66 + struct list_head pin_ranges; 67 + #endif 58 68 }; 59 69 60 70 /**
-9
include/linux/gpio/driver.h
··· 181 181 int (*of_xlate)(struct gpio_chip *gc, 182 182 const struct of_phandle_args *gpiospec, u32 *flags); 183 183 #endif 184 - #ifdef CONFIG_PINCTRL 185 - /* 186 - * If CONFIG_PINCTRL is enabled, then gpio controllers can optionally 187 - * describe the actual pin range which they serve in an SoC. This 188 - * information would be used by pinctrl subsystem to configure 189 - * corresponding pins for gpio usage. 190 - */ 191 - struct list_head pin_ranges; 192 - #endif 193 184 }; 194 185 195 186 extern const char *gpiochip_is_requested(struct gpio_chip *chip,