Commit 097d88e9 authored by Linus Walleij's avatar Linus Walleij

gpio: xilinx: 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: Michal Simek <michal.simek@xilinx.com>
Cc: Sören Brinkmann <soren.brinkmann@xilinx.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent ac9dc85e
...@@ -92,8 +92,7 @@ static inline int xgpio_offset(struct xgpio_instance *chip, int gpio) ...@@ -92,8 +92,7 @@ static inline int xgpio_offset(struct xgpio_instance *chip, int gpio)
static int xgpio_get(struct gpio_chip *gc, unsigned int gpio) static int xgpio_get(struct gpio_chip *gc, unsigned int gpio)
{ {
struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
struct xgpio_instance *chip = struct xgpio_instance *chip = gpiochip_get_data(gc);
container_of(mm_gc, struct xgpio_instance, mmchip);
u32 val; u32 val;
val = xgpio_readreg(mm_gc->regs + XGPIO_DATA_OFFSET + val = xgpio_readreg(mm_gc->regs + XGPIO_DATA_OFFSET +
...@@ -115,8 +114,7 @@ static void xgpio_set(struct gpio_chip *gc, unsigned int gpio, int val) ...@@ -115,8 +114,7 @@ static void xgpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
{ {
unsigned long flags; unsigned long flags;
struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
struct xgpio_instance *chip = struct xgpio_instance *chip = gpiochip_get_data(gc);
container_of(mm_gc, struct xgpio_instance, mmchip);
int index = xgpio_index(chip, gpio); int index = xgpio_index(chip, gpio);
int offset = xgpio_offset(chip, gpio); int offset = xgpio_offset(chip, gpio);
...@@ -147,8 +145,7 @@ static int xgpio_dir_in(struct gpio_chip *gc, unsigned int gpio) ...@@ -147,8 +145,7 @@ static int xgpio_dir_in(struct gpio_chip *gc, unsigned int gpio)
{ {
unsigned long flags; unsigned long flags;
struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
struct xgpio_instance *chip = struct xgpio_instance *chip = gpiochip_get_data(gc);
container_of(mm_gc, struct xgpio_instance, mmchip);
int index = xgpio_index(chip, gpio); int index = xgpio_index(chip, gpio);
int offset = xgpio_offset(chip, gpio); int offset = xgpio_offset(chip, gpio);
...@@ -180,8 +177,7 @@ static int xgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) ...@@ -180,8 +177,7 @@ static int xgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
{ {
unsigned long flags; unsigned long flags;
struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
struct xgpio_instance *chip = struct xgpio_instance *chip = gpiochip_get_data(gc);
container_of(mm_gc, struct xgpio_instance, mmchip);
int index = xgpio_index(chip, gpio); int index = xgpio_index(chip, gpio);
int offset = xgpio_offset(chip, gpio); int offset = xgpio_offset(chip, gpio);
...@@ -211,8 +207,7 @@ static int xgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) ...@@ -211,8 +207,7 @@ static int xgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
*/ */
static void xgpio_save_regs(struct of_mm_gpio_chip *mm_gc) static void xgpio_save_regs(struct of_mm_gpio_chip *mm_gc)
{ {
struct xgpio_instance *chip = struct xgpio_instance *chip = gpiochip_get_data(&mm_gc->gc);
container_of(mm_gc, struct xgpio_instance, mmchip);
xgpio_writereg(mm_gc->regs + XGPIO_DATA_OFFSET, chip->gpio_state[0]); xgpio_writereg(mm_gc->regs + XGPIO_DATA_OFFSET, chip->gpio_state[0]);
xgpio_writereg(mm_gc->regs + XGPIO_TRI_OFFSET, chip->gpio_dir[0]); xgpio_writereg(mm_gc->regs + XGPIO_TRI_OFFSET, chip->gpio_dir[0]);
...@@ -314,7 +309,7 @@ static int xgpio_probe(struct platform_device *pdev) ...@@ -314,7 +309,7 @@ static int xgpio_probe(struct platform_device *pdev)
chip->mmchip.save_regs = xgpio_save_regs; chip->mmchip.save_regs = xgpio_save_regs;
/* Call the OF gpio helper to setup and register the GPIO device */ /* Call the OF gpio helper to setup and register the GPIO device */
status = of_mm_gpiochip_add(np, &chip->mmchip); status = of_mm_gpiochip_add_data(np, &chip->mmchip, chip);
if (status) { if (status) {
pr_err("%s: error in probe function with status %d\n", pr_err("%s: error in probe function with status %d\n",
np->full_name, status); np->full_name, status);
......
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