static void of_gpiochip_add_pin_range(struct gpio_chip *chip)
{
struct device_node *np = chip->of_node;
- struct gpio_pin_range *pin_range;
struct of_phandle_args pinspec;
+ struct pinctrl_dev *pctldev;
int index = 0, ret;
if (!np)
if (ret)
break;
- pin_range = devm_kzalloc(chip->dev, sizeof(*pin_range),
- GFP_KERNEL);
- if (!pin_range) {
- pr_err("%s: GPIO chip: failed to allocate pin ranges\n",
- chip->label);
+ pctldev = of_pinctrl_get(pinspec.np);
+ if (!pctldev)
break;
- }
- pin_range->range.name = chip->label;
- pin_range->range.base = chip->base;
- pin_range->range.pin_base = pinspec.args[0];
- pin_range->range.npins = pinspec.args[1];
- pin_range->pctldev = of_pinctrl_add_gpio_range(pinspec.np,
- &pin_range->range);
+ ret = gpiochip_add_pin_range(chip,
+ pinctrl_dev_get_name(pctldev),
+ pinspec.args[0],
+ pinspec.args[1]);
- list_add_tail(&pin_range->node, &chip->pin_ranges);
+ if (ret)
+ break;
} while (index++);
}
#ifdef CONFIG_PINCTRL
-void gpiochip_add_pin_range(struct gpio_chip *chip, const char *pinctl_name,
- unsigned int pin_base, unsigned int npins)
+int gpiochip_add_pin_range(struct gpio_chip *chip, const char *pinctl_name,
+ unsigned int pin_base, unsigned int npins)
{
struct gpio_pin_range *pin_range;
if (!pin_range) {
pr_err("%s: GPIO chip: failed to allocate pin ranges\n",
chip->label);
- return;
+ return -ENOMEM;
}
pin_range->range.name = chip->label;
&pin_range->range);
list_add_tail(&pin_range->node, &chip->pin_ranges);
+
+ return 0;
}
EXPORT_SYMBOL_GPL(gpiochip_add_pin_range);
return NULL;
}
-struct pinctrl_dev *of_pinctrl_add_gpio_range(struct device_node *np,
- struct pinctrl_gpio_range *range)
+struct pinctrl_dev *of_pinctrl_get(struct device_node *np)
{
struct pinctrl_dev *pctldev;
if (!pctldev)
return NULL;
- pinctrl_add_gpio_range(pctldev, range);
return pctldev;
}
struct pinctrl_gpio_range range;
};
-void gpiochip_add_pin_range(struct gpio_chip *chip, const char *pinctl_name,
- unsigned int pin_base, unsigned int npins);
+int gpiochip_add_pin_range(struct gpio_chip *chip, const char *pinctl_name,
+ unsigned int pin_base, unsigned int npins);
void gpiochip_remove_pin_ranges(struct gpio_chip *chip);
#endif
#ifdef CONFIG_PINCTRL
-static inline void
+static inline int
gpiochip_add_pin_range(struct gpio_chip *chip, const char *pinctl_name,
unsigned int pin_base, unsigned int npins)
{
struct pinctrl_gpio_range *range);
#ifdef CONFIG_OF
-extern struct pinctrl_dev *of_pinctrl_add_gpio_range(struct device_node *np,
- struct pinctrl_gpio_range *range);
+extern struct pinctrl_dev *of_pinctrl_get(struct device_node *np);
#else
static inline
-struct pinctrl_dev *of_pinctrl_add_gpio_range(struct device_node *np,
- struct pinctrl_gpio_range *range)
+struct pinctrl_dev *of_pinctrl_get(struct device_node *np)
{
return NULL;
}
-
#endif /* CONFIG_OF */
extern const char *pinctrl_dev_get_name(struct pinctrl_dev *pctldev);