Commit 2e862a7b authored by Linus Walleij's avatar Linus Walleij

pinctrl: st: 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().

Cc: Srinivas Kandagatla <srinivas.kandagatla@gmail.com>
Cc: Patrice Chotard <patrice.chotard@st.com>
Acked-by: default avatarMaxime Coquelin <maxime.coquelin@st.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 03bf81f1
...@@ -203,9 +203,6 @@ ...@@ -203,9 +203,6 @@
#define gpio_range_to_bank(chip) \ #define gpio_range_to_bank(chip) \
container_of(chip, struct st_gpio_bank, range) container_of(chip, struct st_gpio_bank, range)
#define gpio_chip_to_bank(chip) \
container_of(chip, struct st_gpio_bank, gpio_chip)
#define pc_to_bank(pc) \ #define pc_to_bank(pc) \
container_of(pc, struct st_gpio_bank, pc) container_of(pc, struct st_gpio_bank, pc)
...@@ -744,14 +741,14 @@ static void st_gpio_direction(struct st_gpio_bank *bank, ...@@ -744,14 +741,14 @@ static void st_gpio_direction(struct st_gpio_bank *bank,
static int st_gpio_get(struct gpio_chip *chip, unsigned offset) static int st_gpio_get(struct gpio_chip *chip, unsigned offset)
{ {
struct st_gpio_bank *bank = gpio_chip_to_bank(chip); struct st_gpio_bank *bank = gpiochip_get_data(chip);
return !!(readl(bank->base + REG_PIO_PIN) & BIT(offset)); return !!(readl(bank->base + REG_PIO_PIN) & BIT(offset));
} }
static void st_gpio_set(struct gpio_chip *chip, unsigned offset, int value) static void st_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
{ {
struct st_gpio_bank *bank = gpio_chip_to_bank(chip); struct st_gpio_bank *bank = gpiochip_get_data(chip);
__st_gpio_set(bank, offset, value); __st_gpio_set(bank, offset, value);
} }
...@@ -765,7 +762,7 @@ static int st_gpio_direction_input(struct gpio_chip *chip, unsigned offset) ...@@ -765,7 +762,7 @@ static int st_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
static int st_gpio_direction_output(struct gpio_chip *chip, static int st_gpio_direction_output(struct gpio_chip *chip,
unsigned offset, int value) unsigned offset, int value)
{ {
struct st_gpio_bank *bank = gpio_chip_to_bank(chip); struct st_gpio_bank *bank = gpiochip_get_data(chip);
__st_gpio_set(bank, offset, value); __st_gpio_set(bank, offset, value);
pinctrl_gpio_direction_output(chip->base + offset); pinctrl_gpio_direction_output(chip->base + offset);
...@@ -775,7 +772,7 @@ static int st_gpio_direction_output(struct gpio_chip *chip, ...@@ -775,7 +772,7 @@ static int st_gpio_direction_output(struct gpio_chip *chip,
static int st_gpio_get_direction(struct gpio_chip *chip, unsigned offset) static int st_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
{ {
struct st_gpio_bank *bank = gpio_chip_to_bank(chip); struct st_gpio_bank *bank = gpiochip_get_data(chip);
struct st_pio_control pc = bank->pc; struct st_pio_control pc = bank->pc;
unsigned long config; unsigned long config;
unsigned int direction = 0; unsigned int direction = 0;
...@@ -1325,7 +1322,7 @@ static int st_pctl_parse_functions(struct device_node *np, ...@@ -1325,7 +1322,7 @@ static int st_pctl_parse_functions(struct device_node *np,
static void st_gpio_irq_mask(struct irq_data *d) static void st_gpio_irq_mask(struct irq_data *d)
{ {
struct gpio_chip *gc = irq_data_get_irq_chip_data(d); struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct st_gpio_bank *bank = gpio_chip_to_bank(gc); struct st_gpio_bank *bank = gpiochip_get_data(gc);
writel(BIT(d->hwirq), bank->base + REG_PIO_CLR_PMASK); writel(BIT(d->hwirq), bank->base + REG_PIO_CLR_PMASK);
} }
...@@ -1333,7 +1330,7 @@ static void st_gpio_irq_mask(struct irq_data *d) ...@@ -1333,7 +1330,7 @@ static void st_gpio_irq_mask(struct irq_data *d)
static void st_gpio_irq_unmask(struct irq_data *d) static void st_gpio_irq_unmask(struct irq_data *d)
{ {
struct gpio_chip *gc = irq_data_get_irq_chip_data(d); struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct st_gpio_bank *bank = gpio_chip_to_bank(gc); struct st_gpio_bank *bank = gpiochip_get_data(gc);
writel(BIT(d->hwirq), bank->base + REG_PIO_SET_PMASK); writel(BIT(d->hwirq), bank->base + REG_PIO_SET_PMASK);
} }
...@@ -1341,7 +1338,7 @@ static void st_gpio_irq_unmask(struct irq_data *d) ...@@ -1341,7 +1338,7 @@ static void st_gpio_irq_unmask(struct irq_data *d)
static int st_gpio_irq_set_type(struct irq_data *d, unsigned type) static int st_gpio_irq_set_type(struct irq_data *d, unsigned type)
{ {
struct gpio_chip *gc = irq_data_get_irq_chip_data(d); struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct st_gpio_bank *bank = gpio_chip_to_bank(gc); struct st_gpio_bank *bank = gpiochip_get_data(gc);
unsigned long flags; unsigned long flags;
int comp, pin = d->hwirq; int comp, pin = d->hwirq;
u32 val; u32 val;
...@@ -1455,7 +1452,7 @@ static void st_gpio_irq_handler(struct irq_desc *desc) ...@@ -1455,7 +1452,7 @@ static void st_gpio_irq_handler(struct irq_desc *desc)
/* interrupt dedicated per bank */ /* interrupt dedicated per bank */
struct irq_chip *chip = irq_desc_get_chip(desc); struct irq_chip *chip = irq_desc_get_chip(desc);
struct gpio_chip *gc = irq_desc_get_handler_data(desc); struct gpio_chip *gc = irq_desc_get_handler_data(desc);
struct st_gpio_bank *bank = gpio_chip_to_bank(gc); struct st_gpio_bank *bank = gpiochip_get_data(gc);
chained_irq_enter(chip, desc); chained_irq_enter(chip, desc);
__gpio_irq_handler(bank); __gpio_irq_handler(bank);
...@@ -1532,7 +1529,7 @@ static int st_gpiolib_register_bank(struct st_pinctrl *info, ...@@ -1532,7 +1529,7 @@ static int st_gpiolib_register_bank(struct st_pinctrl *info,
range->pin_base = range->base = range->id * ST_GPIO_PINS_PER_BANK; range->pin_base = range->base = range->id * ST_GPIO_PINS_PER_BANK;
range->npins = bank->gpio_chip.ngpio; range->npins = bank->gpio_chip.ngpio;
range->gc = &bank->gpio_chip; range->gc = &bank->gpio_chip;
err = gpiochip_add(&bank->gpio_chip); err = gpiochip_add_data(&bank->gpio_chip, bank);
if (err) { if (err) {
dev_err(dev, "Failed to add gpiochip(%d)!\n", bank_num); dev_err(dev, "Failed to add gpiochip(%d)!\n", bank_num);
return err; return err;
......
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