Commit 3d18fb5c authored by Linus Walleij's avatar Linus Walleij

pinctrl: pistachio: use gpiochip data pointer

This makes the driver use the data pointer added to the gpio_chip
to store a pointer to the state container instead of relying on
container_of().
Acked-by: default avatarAndrew Bresticker <abrestic@chromium.org>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 57371833
...@@ -842,14 +842,9 @@ static inline void pctl_writel(struct pistachio_pinctrl *pctl, u32 val, u32 reg) ...@@ -842,14 +842,9 @@ static inline void pctl_writel(struct pistachio_pinctrl *pctl, u32 val, u32 reg)
writel(val, pctl->base + reg); writel(val, pctl->base + reg);
} }
static inline struct pistachio_gpio_bank *gc_to_bank(struct gpio_chip *gc)
{
return container_of(gc, struct pistachio_gpio_bank, gpio_chip);
}
static inline struct pistachio_gpio_bank *irqd_to_bank(struct irq_data *d) static inline struct pistachio_gpio_bank *irqd_to_bank(struct irq_data *d)
{ {
return gc_to_bank(irq_data_get_irq_chip_data(d)); return gpiochip_get_data(irq_data_get_irq_chip_data(d));
} }
static inline u32 gpio_readl(struct pistachio_gpio_bank *bank, u32 reg) static inline u32 gpio_readl(struct pistachio_gpio_bank *bank, u32 reg)
...@@ -992,7 +987,7 @@ static int pistachio_pinmux_enable(struct pinctrl_dev *pctldev, ...@@ -992,7 +987,7 @@ static int pistachio_pinmux_enable(struct pinctrl_dev *pctldev,
range = pinctrl_find_gpio_range_from_pin(pctl->pctldev, pg->pin); range = pinctrl_find_gpio_range_from_pin(pctl->pctldev, pg->pin);
if (range) if (range)
gpio_disable(gc_to_bank(range->gc), pg->pin - range->pin_base); gpio_disable(gpiochip_get_data(range->gc), pg->pin - range->pin_base);
return 0; return 0;
} }
...@@ -1173,14 +1168,14 @@ static struct pinctrl_desc pistachio_pinctrl_desc = { ...@@ -1173,14 +1168,14 @@ static struct pinctrl_desc pistachio_pinctrl_desc = {
static int pistachio_gpio_get_direction(struct gpio_chip *chip, unsigned offset) static int pistachio_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
{ {
struct pistachio_gpio_bank *bank = gc_to_bank(chip); struct pistachio_gpio_bank *bank = gpiochip_get_data(chip);
return !(gpio_readl(bank, GPIO_OUTPUT_EN) & BIT(offset)); return !(gpio_readl(bank, GPIO_OUTPUT_EN) & BIT(offset));
} }
static int pistachio_gpio_get(struct gpio_chip *chip, unsigned offset) static int pistachio_gpio_get(struct gpio_chip *chip, unsigned offset)
{ {
struct pistachio_gpio_bank *bank = gc_to_bank(chip); struct pistachio_gpio_bank *bank = gpiochip_get_data(chip);
u32 reg; u32 reg;
if (gpio_readl(bank, GPIO_OUTPUT_EN) & BIT(offset)) if (gpio_readl(bank, GPIO_OUTPUT_EN) & BIT(offset))
...@@ -1194,7 +1189,7 @@ static int pistachio_gpio_get(struct gpio_chip *chip, unsigned offset) ...@@ -1194,7 +1189,7 @@ static int pistachio_gpio_get(struct gpio_chip *chip, unsigned offset)
static void pistachio_gpio_set(struct gpio_chip *chip, unsigned offset, static void pistachio_gpio_set(struct gpio_chip *chip, unsigned offset,
int value) int value)
{ {
struct pistachio_gpio_bank *bank = gc_to_bank(chip); struct pistachio_gpio_bank *bank = gpiochip_get_data(chip);
gpio_mask_writel(bank, GPIO_OUTPUT, offset, !!value); gpio_mask_writel(bank, GPIO_OUTPUT, offset, !!value);
} }
...@@ -1202,7 +1197,7 @@ static void pistachio_gpio_set(struct gpio_chip *chip, unsigned offset, ...@@ -1202,7 +1197,7 @@ static void pistachio_gpio_set(struct gpio_chip *chip, unsigned offset,
static int pistachio_gpio_direction_input(struct gpio_chip *chip, static int pistachio_gpio_direction_input(struct gpio_chip *chip,
unsigned offset) unsigned offset)
{ {
struct pistachio_gpio_bank *bank = gc_to_bank(chip); struct pistachio_gpio_bank *bank = gpiochip_get_data(chip);
gpio_mask_writel(bank, GPIO_OUTPUT_EN, offset, 0); gpio_mask_writel(bank, GPIO_OUTPUT_EN, offset, 0);
gpio_enable(bank, offset); gpio_enable(bank, offset);
...@@ -1213,7 +1208,7 @@ static int pistachio_gpio_direction_input(struct gpio_chip *chip, ...@@ -1213,7 +1208,7 @@ static int pistachio_gpio_direction_input(struct gpio_chip *chip,
static int pistachio_gpio_direction_output(struct gpio_chip *chip, static int pistachio_gpio_direction_output(struct gpio_chip *chip,
unsigned offset, int value) unsigned offset, int value)
{ {
struct pistachio_gpio_bank *bank = gc_to_bank(chip); struct pistachio_gpio_bank *bank = gpiochip_get_data(chip);
pistachio_gpio_set(chip, offset, value); pistachio_gpio_set(chip, offset, value);
gpio_mask_writel(bank, GPIO_OUTPUT_EN, offset, 1); gpio_mask_writel(bank, GPIO_OUTPUT_EN, offset, 1);
...@@ -1303,7 +1298,7 @@ static int pistachio_gpio_irq_set_type(struct irq_data *data, unsigned int type) ...@@ -1303,7 +1298,7 @@ static int pistachio_gpio_irq_set_type(struct irq_data *data, unsigned int type)
static void pistachio_gpio_irq_handler(struct irq_desc *desc) static void pistachio_gpio_irq_handler(struct irq_desc *desc)
{ {
struct gpio_chip *gc = irq_desc_get_handler_data(desc); struct gpio_chip *gc = irq_desc_get_handler_data(desc);
struct pistachio_gpio_bank *bank = gc_to_bank(gc); struct pistachio_gpio_bank *bank = gpiochip_get_data(gc);
struct irq_chip *chip = irq_desc_get_chip(desc); struct irq_chip *chip = irq_desc_get_chip(desc);
unsigned long pending; unsigned long pending;
unsigned int pin; unsigned int pin;
...@@ -1390,7 +1385,7 @@ static int pistachio_gpio_register(struct pistachio_pinctrl *pctl) ...@@ -1390,7 +1385,7 @@ static int pistachio_gpio_register(struct pistachio_pinctrl *pctl)
bank->gpio_chip.parent = pctl->dev; bank->gpio_chip.parent = pctl->dev;
bank->gpio_chip.of_node = child; bank->gpio_chip.of_node = child;
ret = gpiochip_add(&bank->gpio_chip); ret = gpiochip_add_data(&bank->gpio_chip, bank);
if (ret < 0) { if (ret < 0) {
dev_err(pctl->dev, "Failed to add GPIO chip %u: %d\n", dev_err(pctl->dev, "Failed to add GPIO chip %u: %d\n",
i, ret); i, ret);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment