diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2015-12-08 03:45:18 -0500 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2016-01-05 08:14:57 -0500 |
commit | 2e862a7bd63f57fcaa4a3a4929f51c56289f1f80 (patch) | |
tree | 5af22c37bb062042ecdf85839a4cb15f06568113 | |
parent | 03bf81f1cb49a580d70b7514366760146c3da017 (diff) |
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: Maxime Coquelin <maxime.coquelin@st.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r-- | drivers/pinctrl/pinctrl-st.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c index 52639e65ea67..fac844a85cb4 100644 --- a/drivers/pinctrl/pinctrl-st.c +++ b/drivers/pinctrl/pinctrl-st.c | |||
@@ -203,9 +203,6 @@ | |||
203 | #define gpio_range_to_bank(chip) \ | 203 | #define gpio_range_to_bank(chip) \ |
204 | container_of(chip, struct st_gpio_bank, range) | 204 | container_of(chip, struct st_gpio_bank, range) |
205 | 205 | ||
206 | #define gpio_chip_to_bank(chip) \ | ||
207 | container_of(chip, struct st_gpio_bank, gpio_chip) | ||
208 | |||
209 | #define pc_to_bank(pc) \ | 206 | #define pc_to_bank(pc) \ |
210 | container_of(pc, struct st_gpio_bank, pc) | 207 | container_of(pc, struct st_gpio_bank, pc) |
211 | 208 | ||
@@ -744,14 +741,14 @@ static void st_gpio_direction(struct st_gpio_bank *bank, | |||
744 | 741 | ||
745 | static int st_gpio_get(struct gpio_chip *chip, unsigned offset) | 742 | static int st_gpio_get(struct gpio_chip *chip, unsigned offset) |
746 | { | 743 | { |
747 | struct st_gpio_bank *bank = gpio_chip_to_bank(chip); | 744 | struct st_gpio_bank *bank = gpiochip_get_data(chip); |
748 | 745 | ||
749 | return !!(readl(bank->base + REG_PIO_PIN) & BIT(offset)); | 746 | return !!(readl(bank->base + REG_PIO_PIN) & BIT(offset)); |
750 | } | 747 | } |
751 | 748 | ||
752 | static void st_gpio_set(struct gpio_chip *chip, unsigned offset, int value) | 749 | static void st_gpio_set(struct gpio_chip *chip, unsigned offset, int value) |
753 | { | 750 | { |
754 | struct st_gpio_bank *bank = gpio_chip_to_bank(chip); | 751 | struct st_gpio_bank *bank = gpiochip_get_data(chip); |
755 | __st_gpio_set(bank, offset, value); | 752 | __st_gpio_set(bank, offset, value); |
756 | } | 753 | } |
757 | 754 | ||
@@ -765,7 +762,7 @@ static int st_gpio_direction_input(struct gpio_chip *chip, unsigned offset) | |||
765 | static int st_gpio_direction_output(struct gpio_chip *chip, | 762 | static int st_gpio_direction_output(struct gpio_chip *chip, |
766 | unsigned offset, int value) | 763 | unsigned offset, int value) |
767 | { | 764 | { |
768 | struct st_gpio_bank *bank = gpio_chip_to_bank(chip); | 765 | struct st_gpio_bank *bank = gpiochip_get_data(chip); |
769 | 766 | ||
770 | __st_gpio_set(bank, offset, value); | 767 | __st_gpio_set(bank, offset, value); |
771 | pinctrl_gpio_direction_output(chip->base + offset); | 768 | pinctrl_gpio_direction_output(chip->base + offset); |
@@ -775,7 +772,7 @@ static int st_gpio_direction_output(struct gpio_chip *chip, | |||
775 | 772 | ||
776 | static int st_gpio_get_direction(struct gpio_chip *chip, unsigned offset) | 773 | static int st_gpio_get_direction(struct gpio_chip *chip, unsigned offset) |
777 | { | 774 | { |
778 | struct st_gpio_bank *bank = gpio_chip_to_bank(chip); | 775 | struct st_gpio_bank *bank = gpiochip_get_data(chip); |
779 | struct st_pio_control pc = bank->pc; | 776 | struct st_pio_control pc = bank->pc; |
780 | unsigned long config; | 777 | unsigned long config; |
781 | unsigned int direction = 0; | 778 | unsigned int direction = 0; |
@@ -1325,7 +1322,7 @@ static int st_pctl_parse_functions(struct device_node *np, | |||
1325 | static void st_gpio_irq_mask(struct irq_data *d) | 1322 | static void st_gpio_irq_mask(struct irq_data *d) |
1326 | { | 1323 | { |
1327 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); | 1324 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); |
1328 | struct st_gpio_bank *bank = gpio_chip_to_bank(gc); | 1325 | struct st_gpio_bank *bank = gpiochip_get_data(gc); |
1329 | 1326 | ||
1330 | writel(BIT(d->hwirq), bank->base + REG_PIO_CLR_PMASK); | 1327 | writel(BIT(d->hwirq), bank->base + REG_PIO_CLR_PMASK); |
1331 | } | 1328 | } |
@@ -1333,7 +1330,7 @@ static void st_gpio_irq_mask(struct irq_data *d) | |||
1333 | static void st_gpio_irq_unmask(struct irq_data *d) | 1330 | static void st_gpio_irq_unmask(struct irq_data *d) |
1334 | { | 1331 | { |
1335 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); | 1332 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); |
1336 | struct st_gpio_bank *bank = gpio_chip_to_bank(gc); | 1333 | struct st_gpio_bank *bank = gpiochip_get_data(gc); |
1337 | 1334 | ||
1338 | writel(BIT(d->hwirq), bank->base + REG_PIO_SET_PMASK); | 1335 | writel(BIT(d->hwirq), bank->base + REG_PIO_SET_PMASK); |
1339 | } | 1336 | } |
@@ -1341,7 +1338,7 @@ static void st_gpio_irq_unmask(struct irq_data *d) | |||
1341 | static int st_gpio_irq_set_type(struct irq_data *d, unsigned type) | 1338 | static int st_gpio_irq_set_type(struct irq_data *d, unsigned type) |
1342 | { | 1339 | { |
1343 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); | 1340 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); |
1344 | struct st_gpio_bank *bank = gpio_chip_to_bank(gc); | 1341 | struct st_gpio_bank *bank = gpiochip_get_data(gc); |
1345 | unsigned long flags; | 1342 | unsigned long flags; |
1346 | int comp, pin = d->hwirq; | 1343 | int comp, pin = d->hwirq; |
1347 | u32 val; | 1344 | u32 val; |
@@ -1455,7 +1452,7 @@ static void st_gpio_irq_handler(struct irq_desc *desc) | |||
1455 | /* interrupt dedicated per bank */ | 1452 | /* interrupt dedicated per bank */ |
1456 | struct irq_chip *chip = irq_desc_get_chip(desc); | 1453 | struct irq_chip *chip = irq_desc_get_chip(desc); |
1457 | struct gpio_chip *gc = irq_desc_get_handler_data(desc); | 1454 | struct gpio_chip *gc = irq_desc_get_handler_data(desc); |
1458 | struct st_gpio_bank *bank = gpio_chip_to_bank(gc); | 1455 | struct st_gpio_bank *bank = gpiochip_get_data(gc); |
1459 | 1456 | ||
1460 | chained_irq_enter(chip, desc); | 1457 | chained_irq_enter(chip, desc); |
1461 | __gpio_irq_handler(bank); | 1458 | __gpio_irq_handler(bank); |
@@ -1532,7 +1529,7 @@ static int st_gpiolib_register_bank(struct st_pinctrl *info, | |||
1532 | range->pin_base = range->base = range->id * ST_GPIO_PINS_PER_BANK; | 1529 | range->pin_base = range->base = range->id * ST_GPIO_PINS_PER_BANK; |
1533 | range->npins = bank->gpio_chip.ngpio; | 1530 | range->npins = bank->gpio_chip.ngpio; |
1534 | range->gc = &bank->gpio_chip; | 1531 | range->gc = &bank->gpio_chip; |
1535 | err = gpiochip_add(&bank->gpio_chip); | 1532 | err = gpiochip_add_data(&bank->gpio_chip, bank); |
1536 | if (err) { | 1533 | if (err) { |
1537 | dev_err(dev, "Failed to add gpiochip(%d)!\n", bank_num); | 1534 | dev_err(dev, "Failed to add gpiochip(%d)!\n", bank_num); |
1538 | return err; | 1535 | return err; |