diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2015-12-08 08:15:03 -0500 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2016-02-19 03:51:43 -0500 |
commit | 1b2766fb496c462b3f6e1d1c52c72f8601ac8540 (patch) | |
tree | aea5d6ecd201063c31ecb98ecf35fc67c3f0a292 /arch/mips/ar7 | |
parent | 948e0ed86dc7eca2a5d4b6ff0abbca23e6501c85 (diff) |
MIPS: ar7: 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: linux-mips@linux-mips.org
Cc: Alban Bedel <albeu@free.fr>
Acked-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'arch/mips/ar7')
-rw-r--r-- | arch/mips/ar7/gpio.c | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/arch/mips/ar7/gpio.c b/arch/mips/ar7/gpio.c index f969f583c68c..ed5b3d297caf 100644 --- a/arch/mips/ar7/gpio.c +++ b/arch/mips/ar7/gpio.c | |||
@@ -33,8 +33,7 @@ struct ar7_gpio_chip { | |||
33 | 33 | ||
34 | static int ar7_gpio_get_value(struct gpio_chip *chip, unsigned gpio) | 34 | static int ar7_gpio_get_value(struct gpio_chip *chip, unsigned gpio) |
35 | { | 35 | { |
36 | struct ar7_gpio_chip *gpch = | 36 | struct ar7_gpio_chip *gpch = gpiochip_get_data(chip); |
37 | container_of(chip, struct ar7_gpio_chip, chip); | ||
38 | void __iomem *gpio_in = gpch->regs + AR7_GPIO_INPUT; | 37 | void __iomem *gpio_in = gpch->regs + AR7_GPIO_INPUT; |
39 | 38 | ||
40 | return !!(readl(gpio_in) & (1 << gpio)); | 39 | return !!(readl(gpio_in) & (1 << gpio)); |
@@ -42,8 +41,7 @@ static int ar7_gpio_get_value(struct gpio_chip *chip, unsigned gpio) | |||
42 | 41 | ||
43 | static int titan_gpio_get_value(struct gpio_chip *chip, unsigned gpio) | 42 | static int titan_gpio_get_value(struct gpio_chip *chip, unsigned gpio) |
44 | { | 43 | { |
45 | struct ar7_gpio_chip *gpch = | 44 | struct ar7_gpio_chip *gpch = gpiochip_get_data(chip); |
46 | container_of(chip, struct ar7_gpio_chip, chip); | ||
47 | void __iomem *gpio_in0 = gpch->regs + TITAN_GPIO_INPUT_0; | 45 | void __iomem *gpio_in0 = gpch->regs + TITAN_GPIO_INPUT_0; |
48 | void __iomem *gpio_in1 = gpch->regs + TITAN_GPIO_INPUT_1; | 46 | void __iomem *gpio_in1 = gpch->regs + TITAN_GPIO_INPUT_1; |
49 | 47 | ||
@@ -53,8 +51,7 @@ static int titan_gpio_get_value(struct gpio_chip *chip, unsigned gpio) | |||
53 | static void ar7_gpio_set_value(struct gpio_chip *chip, | 51 | static void ar7_gpio_set_value(struct gpio_chip *chip, |
54 | unsigned gpio, int value) | 52 | unsigned gpio, int value) |
55 | { | 53 | { |
56 | struct ar7_gpio_chip *gpch = | 54 | struct ar7_gpio_chip *gpch = gpiochip_get_data(chip); |
57 | container_of(chip, struct ar7_gpio_chip, chip); | ||
58 | void __iomem *gpio_out = gpch->regs + AR7_GPIO_OUTPUT; | 55 | void __iomem *gpio_out = gpch->regs + AR7_GPIO_OUTPUT; |
59 | unsigned tmp; | 56 | unsigned tmp; |
60 | 57 | ||
@@ -67,8 +64,7 @@ static void ar7_gpio_set_value(struct gpio_chip *chip, | |||
67 | static void titan_gpio_set_value(struct gpio_chip *chip, | 64 | static void titan_gpio_set_value(struct gpio_chip *chip, |
68 | unsigned gpio, int value) | 65 | unsigned gpio, int value) |
69 | { | 66 | { |
70 | struct ar7_gpio_chip *gpch = | 67 | struct ar7_gpio_chip *gpch = gpiochip_get_data(chip); |
71 | container_of(chip, struct ar7_gpio_chip, chip); | ||
72 | void __iomem *gpio_out0 = gpch->regs + TITAN_GPIO_OUTPUT_0; | 68 | void __iomem *gpio_out0 = gpch->regs + TITAN_GPIO_OUTPUT_0; |
73 | void __iomem *gpio_out1 = gpch->regs + TITAN_GPIO_OUTPUT_1; | 69 | void __iomem *gpio_out1 = gpch->regs + TITAN_GPIO_OUTPUT_1; |
74 | unsigned tmp; | 70 | unsigned tmp; |
@@ -81,8 +77,7 @@ static void titan_gpio_set_value(struct gpio_chip *chip, | |||
81 | 77 | ||
82 | static int ar7_gpio_direction_input(struct gpio_chip *chip, unsigned gpio) | 78 | static int ar7_gpio_direction_input(struct gpio_chip *chip, unsigned gpio) |
83 | { | 79 | { |
84 | struct ar7_gpio_chip *gpch = | 80 | struct ar7_gpio_chip *gpch = gpiochip_get_data(chip); |
85 | container_of(chip, struct ar7_gpio_chip, chip); | ||
86 | void __iomem *gpio_dir = gpch->regs + AR7_GPIO_DIR; | 81 | void __iomem *gpio_dir = gpch->regs + AR7_GPIO_DIR; |
87 | 82 | ||
88 | writel(readl(gpio_dir) | (1 << gpio), gpio_dir); | 83 | writel(readl(gpio_dir) | (1 << gpio), gpio_dir); |
@@ -92,8 +87,7 @@ static int ar7_gpio_direction_input(struct gpio_chip *chip, unsigned gpio) | |||
92 | 87 | ||
93 | static int titan_gpio_direction_input(struct gpio_chip *chip, unsigned gpio) | 88 | static int titan_gpio_direction_input(struct gpio_chip *chip, unsigned gpio) |
94 | { | 89 | { |
95 | struct ar7_gpio_chip *gpch = | 90 | struct ar7_gpio_chip *gpch = gpiochip_get_data(chip); |
96 | container_of(chip, struct ar7_gpio_chip, chip); | ||
97 | void __iomem *gpio_dir0 = gpch->regs + TITAN_GPIO_DIR_0; | 91 | void __iomem *gpio_dir0 = gpch->regs + TITAN_GPIO_DIR_0; |
98 | void __iomem *gpio_dir1 = gpch->regs + TITAN_GPIO_DIR_1; | 92 | void __iomem *gpio_dir1 = gpch->regs + TITAN_GPIO_DIR_1; |
99 | 93 | ||
@@ -108,8 +102,7 @@ static int titan_gpio_direction_input(struct gpio_chip *chip, unsigned gpio) | |||
108 | static int ar7_gpio_direction_output(struct gpio_chip *chip, | 102 | static int ar7_gpio_direction_output(struct gpio_chip *chip, |
109 | unsigned gpio, int value) | 103 | unsigned gpio, int value) |
110 | { | 104 | { |
111 | struct ar7_gpio_chip *gpch = | 105 | struct ar7_gpio_chip *gpch = gpiochip_get_data(chip); |
112 | container_of(chip, struct ar7_gpio_chip, chip); | ||
113 | void __iomem *gpio_dir = gpch->regs + AR7_GPIO_DIR; | 106 | void __iomem *gpio_dir = gpch->regs + AR7_GPIO_DIR; |
114 | 107 | ||
115 | ar7_gpio_set_value(chip, gpio, value); | 108 | ar7_gpio_set_value(chip, gpio, value); |
@@ -121,8 +114,7 @@ static int ar7_gpio_direction_output(struct gpio_chip *chip, | |||
121 | static int titan_gpio_direction_output(struct gpio_chip *chip, | 114 | static int titan_gpio_direction_output(struct gpio_chip *chip, |
122 | unsigned gpio, int value) | 115 | unsigned gpio, int value) |
123 | { | 116 | { |
124 | struct ar7_gpio_chip *gpch = | 117 | struct ar7_gpio_chip *gpch = gpiochip_get_data(chip); |
125 | container_of(chip, struct ar7_gpio_chip, chip); | ||
126 | void __iomem *gpio_dir0 = gpch->regs + TITAN_GPIO_DIR_0; | 118 | void __iomem *gpio_dir0 = gpch->regs + TITAN_GPIO_DIR_0; |
127 | void __iomem *gpio_dir1 = gpch->regs + TITAN_GPIO_DIR_1; | 119 | void __iomem *gpio_dir1 = gpch->regs + TITAN_GPIO_DIR_1; |
128 | 120 | ||
@@ -335,7 +327,7 @@ int __init ar7_gpio_init(void) | |||
335 | return -ENOMEM; | 327 | return -ENOMEM; |
336 | } | 328 | } |
337 | 329 | ||
338 | ret = gpiochip_add(&gpch->chip); | 330 | ret = gpiochip_add_data(&gpch->chip, gpch); |
339 | if (ret) { | 331 | if (ret) { |
340 | printk(KERN_ERR "%s: failed to add gpiochip\n", | 332 | printk(KERN_ERR "%s: failed to add gpiochip\n", |
341 | gpch->chip.label); | 333 | gpch->chip.label); |