diff options
author | Anton Vorontsov <avorontsov@ru.mvista.com> | 2010-06-08 09:48:16 -0400 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2010-07-05 18:14:30 -0400 |
commit | a19e3da5bc5fc6c10ab73f310bea80f3845b4531 (patch) | |
tree | 49b6e952f48e56d9701f92e0c24044a14b676a34 /arch/powerpc | |
parent | cedb1881ba32f7e9cd49250bd79debccbe52b094 (diff) |
of/gpio: Kill of_gpio_chip and add members directly to gpio_chip
The OF gpio infrastructure is great for describing GPIO connections within
the device tree. However, using a GPIO binding still requires changes to
the gpio controller just to add an of_gpio structure. In most cases, the
gpio controller doesn't actually need any special support and the simple
OF gpio mapping function is more than sufficient. Additional, the current
scheme of using of_gpio_chip requires a convoluted scheme to maintain
1:1 mappings between of_gpio_chip and gpio_chip instances.
If the struct of_gpio_chip data members were moved into struct gpio_chip,
then it would simplify the processing of OF gpio bindings, and it would
make it trivial to use device tree OF connections on existing gpiolib
controller drivers.
This patch eliminates the of_gpio_chip structure and moves the relevant
fields into struct gpio_chip (conditional on CONFIG_OF_GPIO). This move
simplifies the existing code and prepares for adding automatic device tree
support to existing drivers.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Anton Vorontsov <avorontsov@ru.mvista.com>
Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Cc: Bill Gatliff <bgat@billgatliff.com>
Cc: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'arch/powerpc')
-rw-r--r-- | arch/powerpc/platforms/52xx/mpc52xx_gpio.c | 32 | ||||
-rw-r--r-- | arch/powerpc/platforms/52xx/mpc52xx_gpt.c | 29 | ||||
-rw-r--r-- | arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c | 15 | ||||
-rw-r--r-- | arch/powerpc/platforms/86xx/gef_gpio.c | 24 | ||||
-rw-r--r-- | arch/powerpc/sysdev/cpm1.c | 12 | ||||
-rw-r--r-- | arch/powerpc/sysdev/cpm_common.c | 6 | ||||
-rw-r--r-- | arch/powerpc/sysdev/mpc8xxx_gpio.c | 6 | ||||
-rw-r--r-- | arch/powerpc/sysdev/ppc4xx_gpio.c | 6 | ||||
-rw-r--r-- | arch/powerpc/sysdev/qe_lib/gpio.c | 32 | ||||
-rw-r--r-- | arch/powerpc/sysdev/simple_gpio.c | 6 |
10 files changed, 75 insertions, 93 deletions
diff --git a/arch/powerpc/platforms/52xx/mpc52xx_gpio.c b/arch/powerpc/platforms/52xx/mpc52xx_gpio.c index ca5305a5bd61..fd0912eeffe2 100644 --- a/arch/powerpc/platforms/52xx/mpc52xx_gpio.c +++ b/arch/powerpc/platforms/52xx/mpc52xx_gpio.c | |||
@@ -152,21 +152,21 @@ static int __devinit mpc52xx_wkup_gpiochip_probe(struct of_device *ofdev, | |||
152 | { | 152 | { |
153 | struct mpc52xx_gpiochip *chip; | 153 | struct mpc52xx_gpiochip *chip; |
154 | struct mpc52xx_gpio_wkup __iomem *regs; | 154 | struct mpc52xx_gpio_wkup __iomem *regs; |
155 | struct of_gpio_chip *ofchip; | 155 | struct gpio_chip *gc; |
156 | int ret; | 156 | int ret; |
157 | 157 | ||
158 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); | 158 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); |
159 | if (!chip) | 159 | if (!chip) |
160 | return -ENOMEM; | 160 | return -ENOMEM; |
161 | 161 | ||
162 | ofchip = &chip->mmchip.of_gc; | 162 | gc = &chip->mmchip.gc; |
163 | 163 | ||
164 | ofchip->gpio_cells = 2; | 164 | gc->of_gpio_n_cells = 2; |
165 | ofchip->gc.ngpio = 8; | 165 | gc->ngpio = 8; |
166 | ofchip->gc.direction_input = mpc52xx_wkup_gpio_dir_in; | 166 | gc->direction_input = mpc52xx_wkup_gpio_dir_in; |
167 | ofchip->gc.direction_output = mpc52xx_wkup_gpio_dir_out; | 167 | gc->direction_output = mpc52xx_wkup_gpio_dir_out; |
168 | ofchip->gc.get = mpc52xx_wkup_gpio_get; | 168 | gc->get = mpc52xx_wkup_gpio_get; |
169 | ofchip->gc.set = mpc52xx_wkup_gpio_set; | 169 | gc->set = mpc52xx_wkup_gpio_set; |
170 | 170 | ||
171 | ret = of_mm_gpiochip_add(ofdev->dev.of_node, &chip->mmchip); | 171 | ret = of_mm_gpiochip_add(ofdev->dev.of_node, &chip->mmchip); |
172 | if (ret) | 172 | if (ret) |
@@ -315,7 +315,7 @@ static int __devinit mpc52xx_simple_gpiochip_probe(struct of_device *ofdev, | |||
315 | const struct of_device_id *match) | 315 | const struct of_device_id *match) |
316 | { | 316 | { |
317 | struct mpc52xx_gpiochip *chip; | 317 | struct mpc52xx_gpiochip *chip; |
318 | struct of_gpio_chip *ofchip; | 318 | struct gpio_chip *gc; |
319 | struct mpc52xx_gpio __iomem *regs; | 319 | struct mpc52xx_gpio __iomem *regs; |
320 | int ret; | 320 | int ret; |
321 | 321 | ||
@@ -323,14 +323,14 @@ static int __devinit mpc52xx_simple_gpiochip_probe(struct of_device *ofdev, | |||
323 | if (!chip) | 323 | if (!chip) |
324 | return -ENOMEM; | 324 | return -ENOMEM; |
325 | 325 | ||
326 | ofchip = &chip->mmchip.of_gc; | 326 | gc = &chip->mmchip.gc; |
327 | 327 | ||
328 | ofchip->gpio_cells = 2; | 328 | gc->of_gpio_n_cells = 2; |
329 | ofchip->gc.ngpio = 32; | 329 | gc->ngpio = 32; |
330 | ofchip->gc.direction_input = mpc52xx_simple_gpio_dir_in; | 330 | gc->direction_input = mpc52xx_simple_gpio_dir_in; |
331 | ofchip->gc.direction_output = mpc52xx_simple_gpio_dir_out; | 331 | gc->direction_output = mpc52xx_simple_gpio_dir_out; |
332 | ofchip->gc.get = mpc52xx_simple_gpio_get; | 332 | gc->get = mpc52xx_simple_gpio_get; |
333 | ofchip->gc.set = mpc52xx_simple_gpio_set; | 333 | gc->set = mpc52xx_simple_gpio_set; |
334 | 334 | ||
335 | ret = of_mm_gpiochip_add(ofdev->dev.of_node, &chip->mmchip); | 335 | ret = of_mm_gpiochip_add(ofdev->dev.of_node, &chip->mmchip); |
336 | if (ret) | 336 | if (ret) |
diff --git a/arch/powerpc/platforms/52xx/mpc52xx_gpt.c b/arch/powerpc/platforms/52xx/mpc52xx_gpt.c index 46c93578cbf0..3f2ee47f1d01 100644 --- a/arch/powerpc/platforms/52xx/mpc52xx_gpt.c +++ b/arch/powerpc/platforms/52xx/mpc52xx_gpt.c | |||
@@ -78,7 +78,7 @@ MODULE_LICENSE("GPL"); | |||
78 | * @dev: pointer to device structure | 78 | * @dev: pointer to device structure |
79 | * @regs: virtual address of GPT registers | 79 | * @regs: virtual address of GPT registers |
80 | * @lock: spinlock to coordinate between different functions. | 80 | * @lock: spinlock to coordinate between different functions. |
81 | * @of_gc: of_gpio_chip instance structure; used when GPIO is enabled | 81 | * @gc: gpio_chip instance structure; used when GPIO is enabled |
82 | * @irqhost: Pointer to irq_host instance; used when IRQ mode is supported | 82 | * @irqhost: Pointer to irq_host instance; used when IRQ mode is supported |
83 | * @wdt_mode: only relevant for gpt0: bit 0 (MPC52xx_GPT_CAN_WDT) indicates | 83 | * @wdt_mode: only relevant for gpt0: bit 0 (MPC52xx_GPT_CAN_WDT) indicates |
84 | * if the gpt may be used as wdt, bit 1 (MPC52xx_GPT_IS_WDT) indicates | 84 | * if the gpt may be used as wdt, bit 1 (MPC52xx_GPT_IS_WDT) indicates |
@@ -94,7 +94,7 @@ struct mpc52xx_gpt_priv { | |||
94 | u8 wdt_mode; | 94 | u8 wdt_mode; |
95 | 95 | ||
96 | #if defined(CONFIG_GPIOLIB) | 96 | #if defined(CONFIG_GPIOLIB) |
97 | struct of_gpio_chip of_gc; | 97 | struct gpio_chip gc; |
98 | #endif | 98 | #endif |
99 | }; | 99 | }; |
100 | 100 | ||
@@ -280,7 +280,7 @@ mpc52xx_gpt_irq_setup(struct mpc52xx_gpt_priv *gpt, struct device_node *node) | |||
280 | #if defined(CONFIG_GPIOLIB) | 280 | #if defined(CONFIG_GPIOLIB) |
281 | static inline struct mpc52xx_gpt_priv *gc_to_mpc52xx_gpt(struct gpio_chip *gc) | 281 | static inline struct mpc52xx_gpt_priv *gc_to_mpc52xx_gpt(struct gpio_chip *gc) |
282 | { | 282 | { |
283 | return container_of(to_of_gpio_chip(gc), struct mpc52xx_gpt_priv,of_gc); | 283 | return container_of(gc, struct mpc52xx_gpt_priv, gc); |
284 | } | 284 | } |
285 | 285 | ||
286 | static int mpc52xx_gpt_gpio_get(struct gpio_chip *gc, unsigned int gpio) | 286 | static int mpc52xx_gpt_gpio_get(struct gpio_chip *gc, unsigned int gpio) |
@@ -336,28 +336,27 @@ mpc52xx_gpt_gpio_setup(struct mpc52xx_gpt_priv *gpt, struct device_node *node) | |||
336 | if (!of_find_property(node, "gpio-controller", NULL)) | 336 | if (!of_find_property(node, "gpio-controller", NULL)) |
337 | return; | 337 | return; |
338 | 338 | ||
339 | gpt->of_gc.gc.label = kstrdup(node->full_name, GFP_KERNEL); | 339 | gpt->gc.label = kstrdup(node->full_name, GFP_KERNEL); |
340 | if (!gpt->of_gc.gc.label) { | 340 | if (!gpt->gc.label) { |
341 | dev_err(gpt->dev, "out of memory\n"); | 341 | dev_err(gpt->dev, "out of memory\n"); |
342 | return; | 342 | return; |
343 | } | 343 | } |
344 | 344 | ||
345 | gpt->of_gc.gpio_cells = 2; | 345 | gpt->gc.ngpio = 1; |
346 | gpt->of_gc.gc.ngpio = 1; | 346 | gpt->gc.direction_input = mpc52xx_gpt_gpio_dir_in; |
347 | gpt->of_gc.gc.direction_input = mpc52xx_gpt_gpio_dir_in; | 347 | gpt->gc.direction_output = mpc52xx_gpt_gpio_dir_out; |
348 | gpt->of_gc.gc.direction_output = mpc52xx_gpt_gpio_dir_out; | 348 | gpt->gc.get = mpc52xx_gpt_gpio_get; |
349 | gpt->of_gc.gc.get = mpc52xx_gpt_gpio_get; | 349 | gpt->gc.set = mpc52xx_gpt_gpio_set; |
350 | gpt->of_gc.gc.set = mpc52xx_gpt_gpio_set; | 350 | gpt->gc.base = -1; |
351 | gpt->of_gc.gc.base = -1; | 351 | gpt->gc.of_gpio_n_cells = 2; |
352 | gpt->of_gc.xlate = of_gpio_simple_xlate; | 352 | gpt->gc.of_xlate = of_gpio_simple_xlate; |
353 | node->data = &gpt->of_gc; | ||
354 | of_node_get(node); | 353 | of_node_get(node); |
355 | 354 | ||
356 | /* Setup external pin in GPIO mode */ | 355 | /* Setup external pin in GPIO mode */ |
357 | clrsetbits_be32(&gpt->regs->mode, MPC52xx_GPT_MODE_MS_MASK, | 356 | clrsetbits_be32(&gpt->regs->mode, MPC52xx_GPT_MODE_MS_MASK, |
358 | MPC52xx_GPT_MODE_MS_GPIO); | 357 | MPC52xx_GPT_MODE_MS_GPIO); |
359 | 358 | ||
360 | rc = gpiochip_add(&gpt->of_gc.gc); | 359 | rc = gpiochip_add(&gpt->gc); |
361 | if (rc) | 360 | if (rc) |
362 | dev_err(gpt->dev, "gpiochip_add() failed; rc=%i\n", rc); | 361 | dev_err(gpt->dev, "gpiochip_add() failed; rc=%i\n", rc); |
363 | 362 | ||
diff --git a/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c b/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c index d119a7c1c17a..e49f4bd2f991 100644 --- a/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c +++ b/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c | |||
@@ -37,7 +37,7 @@ struct mcu { | |||
37 | struct mutex lock; | 37 | struct mutex lock; |
38 | struct device_node *np; | 38 | struct device_node *np; |
39 | struct i2c_client *client; | 39 | struct i2c_client *client; |
40 | struct of_gpio_chip of_gc; | 40 | struct gpio_chip gc; |
41 | u8 reg_ctrl; | 41 | u8 reg_ctrl; |
42 | }; | 42 | }; |
43 | 43 | ||
@@ -56,8 +56,7 @@ static void mcu_power_off(void) | |||
56 | 56 | ||
57 | static void mcu_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val) | 57 | static void mcu_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val) |
58 | { | 58 | { |
59 | struct of_gpio_chip *of_gc = to_of_gpio_chip(gc); | 59 | struct mcu *mcu = container_of(gc, struct mcu, gc); |
60 | struct mcu *mcu = container_of(of_gc, struct mcu, of_gc); | ||
61 | u8 bit = 1 << (4 + gpio); | 60 | u8 bit = 1 << (4 + gpio); |
62 | 61 | ||
63 | mutex_lock(&mcu->lock); | 62 | mutex_lock(&mcu->lock); |
@@ -79,8 +78,7 @@ static int mcu_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) | |||
79 | static int mcu_gpiochip_add(struct mcu *mcu) | 78 | static int mcu_gpiochip_add(struct mcu *mcu) |
80 | { | 79 | { |
81 | struct device_node *np; | 80 | struct device_node *np; |
82 | struct of_gpio_chip *of_gc = &mcu->of_gc; | 81 | struct gpio_chip *gc = &mcu->gc; |
83 | struct gpio_chip *gc = &of_gc->gc; | ||
84 | int ret; | 82 | int ret; |
85 | 83 | ||
86 | np = of_find_compatible_node(NULL, NULL, "fsl,mcu-mpc8349emitx"); | 84 | np = of_find_compatible_node(NULL, NULL, "fsl,mcu-mpc8349emitx"); |
@@ -94,10 +92,9 @@ static int mcu_gpiochip_add(struct mcu *mcu) | |||
94 | gc->base = -1; | 92 | gc->base = -1; |
95 | gc->set = mcu_gpio_set; | 93 | gc->set = mcu_gpio_set; |
96 | gc->direction_output = mcu_gpio_dir_out; | 94 | gc->direction_output = mcu_gpio_dir_out; |
97 | of_gc->gpio_cells = 2; | 95 | gc->of_gpio_n_cells = 2; |
98 | of_gc->xlate = of_gpio_simple_xlate; | 96 | gc->of_xlate = of_gpio_simple_xlate; |
99 | 97 | ||
100 | np->data = of_gc; | ||
101 | mcu->np = np; | 98 | mcu->np = np; |
102 | 99 | ||
103 | /* | 100 | /* |
@@ -114,7 +111,7 @@ static int mcu_gpiochip_remove(struct mcu *mcu) | |||
114 | { | 111 | { |
115 | int ret; | 112 | int ret; |
116 | 113 | ||
117 | ret = gpiochip_remove(&mcu->of_gc.gc); | 114 | ret = gpiochip_remove(&mcu->gc); |
118 | if (ret) | 115 | if (ret) |
119 | return ret; | 116 | return ret; |
120 | of_node_put(mcu->np); | 117 | of_node_put(mcu->np); |
diff --git a/arch/powerpc/platforms/86xx/gef_gpio.c b/arch/powerpc/platforms/86xx/gef_gpio.c index b8cb08dbd89c..4ff7b1e7bbad 100644 --- a/arch/powerpc/platforms/86xx/gef_gpio.c +++ b/arch/powerpc/platforms/86xx/gef_gpio.c | |||
@@ -118,12 +118,12 @@ static int __init gef_gpio_init(void) | |||
118 | } | 118 | } |
119 | 119 | ||
120 | /* Setup pointers to chip functions */ | 120 | /* Setup pointers to chip functions */ |
121 | gef_gpio_chip->of_gc.gpio_cells = 2; | 121 | gef_gpio_chip->gc.of_gpio_n_cells = 2; |
122 | gef_gpio_chip->of_gc.gc.ngpio = 19; | 122 | gef_gpio_chip->gc.ngpio = 19; |
123 | gef_gpio_chip->of_gc.gc.direction_input = gef_gpio_dir_in; | 123 | gef_gpio_chip->gc.direction_input = gef_gpio_dir_in; |
124 | gef_gpio_chip->of_gc.gc.direction_output = gef_gpio_dir_out; | 124 | gef_gpio_chip->gc.direction_output = gef_gpio_dir_out; |
125 | gef_gpio_chip->of_gc.gc.get = gef_gpio_get; | 125 | gef_gpio_chip->gc.get = gef_gpio_get; |
126 | gef_gpio_chip->of_gc.gc.set = gef_gpio_set; | 126 | gef_gpio_chip->gc.set = gef_gpio_set; |
127 | 127 | ||
128 | /* This function adds a memory mapped GPIO chip */ | 128 | /* This function adds a memory mapped GPIO chip */ |
129 | retval = of_mm_gpiochip_add(np, gef_gpio_chip); | 129 | retval = of_mm_gpiochip_add(np, gef_gpio_chip); |
@@ -146,12 +146,12 @@ static int __init gef_gpio_init(void) | |||
146 | } | 146 | } |
147 | 147 | ||
148 | /* Setup pointers to chip functions */ | 148 | /* Setup pointers to chip functions */ |
149 | gef_gpio_chip->of_gc.gpio_cells = 2; | 149 | gef_gpio_chip->gc.of_gpio_n_cells = 2; |
150 | gef_gpio_chip->of_gc.gc.ngpio = 6; | 150 | gef_gpio_chip->gc.ngpio = 6; |
151 | gef_gpio_chip->of_gc.gc.direction_input = gef_gpio_dir_in; | 151 | gef_gpio_chip->gc.direction_input = gef_gpio_dir_in; |
152 | gef_gpio_chip->of_gc.gc.direction_output = gef_gpio_dir_out; | 152 | gef_gpio_chip->gc.direction_output = gef_gpio_dir_out; |
153 | gef_gpio_chip->of_gc.gc.get = gef_gpio_get; | 153 | gef_gpio_chip->gc.get = gef_gpio_get; |
154 | gef_gpio_chip->of_gc.gc.set = gef_gpio_set; | 154 | gef_gpio_chip->gc.set = gef_gpio_set; |
155 | 155 | ||
156 | /* This function adds a memory mapped GPIO chip */ | 156 | /* This function adds a memory mapped GPIO chip */ |
157 | retval = of_mm_gpiochip_add(np, gef_gpio_chip); | 157 | retval = of_mm_gpiochip_add(np, gef_gpio_chip); |
diff --git a/arch/powerpc/sysdev/cpm1.c b/arch/powerpc/sysdev/cpm1.c index 8d103ca6d6ab..d5cf7d4ccf81 100644 --- a/arch/powerpc/sysdev/cpm1.c +++ b/arch/powerpc/sysdev/cpm1.c | |||
@@ -621,7 +621,6 @@ int cpm1_gpiochip_add16(struct device_node *np) | |||
621 | { | 621 | { |
622 | struct cpm1_gpio16_chip *cpm1_gc; | 622 | struct cpm1_gpio16_chip *cpm1_gc; |
623 | struct of_mm_gpio_chip *mm_gc; | 623 | struct of_mm_gpio_chip *mm_gc; |
624 | struct of_gpio_chip *of_gc; | ||
625 | struct gpio_chip *gc; | 624 | struct gpio_chip *gc; |
626 | 625 | ||
627 | cpm1_gc = kzalloc(sizeof(*cpm1_gc), GFP_KERNEL); | 626 | cpm1_gc = kzalloc(sizeof(*cpm1_gc), GFP_KERNEL); |
@@ -631,11 +630,10 @@ int cpm1_gpiochip_add16(struct device_node *np) | |||
631 | spin_lock_init(&cpm1_gc->lock); | 630 | spin_lock_init(&cpm1_gc->lock); |
632 | 631 | ||
633 | mm_gc = &cpm1_gc->mm_gc; | 632 | mm_gc = &cpm1_gc->mm_gc; |
634 | of_gc = &mm_gc->of_gc; | 633 | gc = &mm_gc->gc; |
635 | gc = &of_gc->gc; | ||
636 | 634 | ||
637 | mm_gc->save_regs = cpm1_gpio16_save_regs; | 635 | mm_gc->save_regs = cpm1_gpio16_save_regs; |
638 | of_gc->gpio_cells = 2; | 636 | gc->of_gpio_n_cells = 2; |
639 | gc->ngpio = 16; | 637 | gc->ngpio = 16; |
640 | gc->direction_input = cpm1_gpio16_dir_in; | 638 | gc->direction_input = cpm1_gpio16_dir_in; |
641 | gc->direction_output = cpm1_gpio16_dir_out; | 639 | gc->direction_output = cpm1_gpio16_dir_out; |
@@ -745,7 +743,6 @@ int cpm1_gpiochip_add32(struct device_node *np) | |||
745 | { | 743 | { |
746 | struct cpm1_gpio32_chip *cpm1_gc; | 744 | struct cpm1_gpio32_chip *cpm1_gc; |
747 | struct of_mm_gpio_chip *mm_gc; | 745 | struct of_mm_gpio_chip *mm_gc; |
748 | struct of_gpio_chip *of_gc; | ||
749 | struct gpio_chip *gc; | 746 | struct gpio_chip *gc; |
750 | 747 | ||
751 | cpm1_gc = kzalloc(sizeof(*cpm1_gc), GFP_KERNEL); | 748 | cpm1_gc = kzalloc(sizeof(*cpm1_gc), GFP_KERNEL); |
@@ -755,11 +752,10 @@ int cpm1_gpiochip_add32(struct device_node *np) | |||
755 | spin_lock_init(&cpm1_gc->lock); | 752 | spin_lock_init(&cpm1_gc->lock); |
756 | 753 | ||
757 | mm_gc = &cpm1_gc->mm_gc; | 754 | mm_gc = &cpm1_gc->mm_gc; |
758 | of_gc = &mm_gc->of_gc; | 755 | gc = &mm_gc->gc; |
759 | gc = &of_gc->gc; | ||
760 | 756 | ||
761 | mm_gc->save_regs = cpm1_gpio32_save_regs; | 757 | mm_gc->save_regs = cpm1_gpio32_save_regs; |
762 | of_gc->gpio_cells = 2; | 758 | gc->of_gpio_n_cells = 2; |
763 | gc->ngpio = 32; | 759 | gc->ngpio = 32; |
764 | gc->direction_input = cpm1_gpio32_dir_in; | 760 | gc->direction_input = cpm1_gpio32_dir_in; |
765 | gc->direction_output = cpm1_gpio32_dir_out; | 761 | gc->direction_output = cpm1_gpio32_dir_out; |
diff --git a/arch/powerpc/sysdev/cpm_common.c b/arch/powerpc/sysdev/cpm_common.c index 88b9812c854f..67e9b47dcf8e 100644 --- a/arch/powerpc/sysdev/cpm_common.c +++ b/arch/powerpc/sysdev/cpm_common.c | |||
@@ -325,7 +325,6 @@ int cpm2_gpiochip_add32(struct device_node *np) | |||
325 | { | 325 | { |
326 | struct cpm2_gpio32_chip *cpm2_gc; | 326 | struct cpm2_gpio32_chip *cpm2_gc; |
327 | struct of_mm_gpio_chip *mm_gc; | 327 | struct of_mm_gpio_chip *mm_gc; |
328 | struct of_gpio_chip *of_gc; | ||
329 | struct gpio_chip *gc; | 328 | struct gpio_chip *gc; |
330 | 329 | ||
331 | cpm2_gc = kzalloc(sizeof(*cpm2_gc), GFP_KERNEL); | 330 | cpm2_gc = kzalloc(sizeof(*cpm2_gc), GFP_KERNEL); |
@@ -335,11 +334,10 @@ int cpm2_gpiochip_add32(struct device_node *np) | |||
335 | spin_lock_init(&cpm2_gc->lock); | 334 | spin_lock_init(&cpm2_gc->lock); |
336 | 335 | ||
337 | mm_gc = &cpm2_gc->mm_gc; | 336 | mm_gc = &cpm2_gc->mm_gc; |
338 | of_gc = &mm_gc->of_gc; | 337 | gc = &mm_gc->gc; |
339 | gc = &of_gc->gc; | ||
340 | 338 | ||
341 | mm_gc->save_regs = cpm2_gpio32_save_regs; | 339 | mm_gc->save_regs = cpm2_gpio32_save_regs; |
342 | of_gc->gpio_cells = 2; | 340 | gc->of_gpio_n_cells = 2; |
343 | gc->ngpio = 32; | 341 | gc->ngpio = 32; |
344 | gc->direction_input = cpm2_gpio32_dir_in; | 342 | gc->direction_input = cpm2_gpio32_dir_in; |
345 | gc->direction_output = cpm2_gpio32_dir_out; | 343 | gc->direction_output = cpm2_gpio32_dir_out; |
diff --git a/arch/powerpc/sysdev/mpc8xxx_gpio.c b/arch/powerpc/sysdev/mpc8xxx_gpio.c index 83f519655fac..ec8fcd42101e 100644 --- a/arch/powerpc/sysdev/mpc8xxx_gpio.c +++ b/arch/powerpc/sysdev/mpc8xxx_gpio.c | |||
@@ -257,7 +257,6 @@ static void __init mpc8xxx_add_controller(struct device_node *np) | |||
257 | { | 257 | { |
258 | struct mpc8xxx_gpio_chip *mpc8xxx_gc; | 258 | struct mpc8xxx_gpio_chip *mpc8xxx_gc; |
259 | struct of_mm_gpio_chip *mm_gc; | 259 | struct of_mm_gpio_chip *mm_gc; |
260 | struct of_gpio_chip *of_gc; | ||
261 | struct gpio_chip *gc; | 260 | struct gpio_chip *gc; |
262 | unsigned hwirq; | 261 | unsigned hwirq; |
263 | int ret; | 262 | int ret; |
@@ -271,11 +270,10 @@ static void __init mpc8xxx_add_controller(struct device_node *np) | |||
271 | spin_lock_init(&mpc8xxx_gc->lock); | 270 | spin_lock_init(&mpc8xxx_gc->lock); |
272 | 271 | ||
273 | mm_gc = &mpc8xxx_gc->mm_gc; | 272 | mm_gc = &mpc8xxx_gc->mm_gc; |
274 | of_gc = &mm_gc->of_gc; | 273 | gc = &mm_gc->gc; |
275 | gc = &of_gc->gc; | ||
276 | 274 | ||
277 | mm_gc->save_regs = mpc8xxx_gpio_save_regs; | 275 | mm_gc->save_regs = mpc8xxx_gpio_save_regs; |
278 | of_gc->gpio_cells = 2; | 276 | gc->of_gpio_n_cells = 2; |
279 | gc->ngpio = MPC8XXX_GPIO_PINS; | 277 | gc->ngpio = MPC8XXX_GPIO_PINS; |
280 | gc->direction_input = mpc8xxx_gpio_dir_in; | 278 | gc->direction_input = mpc8xxx_gpio_dir_in; |
281 | gc->direction_output = mpc8xxx_gpio_dir_out; | 279 | gc->direction_output = mpc8xxx_gpio_dir_out; |
diff --git a/arch/powerpc/sysdev/ppc4xx_gpio.c b/arch/powerpc/sysdev/ppc4xx_gpio.c index 3812fc366bec..42e7a5eea665 100644 --- a/arch/powerpc/sysdev/ppc4xx_gpio.c +++ b/arch/powerpc/sysdev/ppc4xx_gpio.c | |||
@@ -181,7 +181,6 @@ static int __init ppc4xx_add_gpiochips(void) | |||
181 | int ret; | 181 | int ret; |
182 | struct ppc4xx_gpio_chip *ppc4xx_gc; | 182 | struct ppc4xx_gpio_chip *ppc4xx_gc; |
183 | struct of_mm_gpio_chip *mm_gc; | 183 | struct of_mm_gpio_chip *mm_gc; |
184 | struct of_gpio_chip *of_gc; | ||
185 | struct gpio_chip *gc; | 184 | struct gpio_chip *gc; |
186 | 185 | ||
187 | ppc4xx_gc = kzalloc(sizeof(*ppc4xx_gc), GFP_KERNEL); | 186 | ppc4xx_gc = kzalloc(sizeof(*ppc4xx_gc), GFP_KERNEL); |
@@ -193,10 +192,9 @@ static int __init ppc4xx_add_gpiochips(void) | |||
193 | spin_lock_init(&ppc4xx_gc->lock); | 192 | spin_lock_init(&ppc4xx_gc->lock); |
194 | 193 | ||
195 | mm_gc = &ppc4xx_gc->mm_gc; | 194 | mm_gc = &ppc4xx_gc->mm_gc; |
196 | of_gc = &mm_gc->of_gc; | 195 | gc = &mm_gc->gc; |
197 | gc = &of_gc->gc; | ||
198 | 196 | ||
199 | of_gc->gpio_cells = 2; | 197 | gc->of_gpio_n_cells = 2; |
200 | gc->ngpio = 32; | 198 | gc->ngpio = 32; |
201 | gc->direction_input = ppc4xx_gpio_dir_in; | 199 | gc->direction_input = ppc4xx_gpio_dir_in; |
202 | gc->direction_output = ppc4xx_gpio_dir_out; | 200 | gc->direction_output = ppc4xx_gpio_dir_out; |
diff --git a/arch/powerpc/sysdev/qe_lib/gpio.c b/arch/powerpc/sysdev/qe_lib/gpio.c index dc8f8d618074..194478c2f4b4 100644 --- a/arch/powerpc/sysdev/qe_lib/gpio.c +++ b/arch/powerpc/sysdev/qe_lib/gpio.c | |||
@@ -138,8 +138,8 @@ struct qe_pin { | |||
138 | struct qe_pin *qe_pin_request(struct device_node *np, int index) | 138 | struct qe_pin *qe_pin_request(struct device_node *np, int index) |
139 | { | 139 | { |
140 | struct qe_pin *qe_pin; | 140 | struct qe_pin *qe_pin; |
141 | struct device_node *gc; | 141 | struct device_node *gpio_np; |
142 | struct of_gpio_chip *of_gc = NULL; | 142 | struct gpio_chip *gc; |
143 | struct of_mm_gpio_chip *mm_gc; | 143 | struct of_mm_gpio_chip *mm_gc; |
144 | struct qe_gpio_chip *qe_gc; | 144 | struct qe_gpio_chip *qe_gc; |
145 | int err; | 145 | int err; |
@@ -155,40 +155,40 @@ struct qe_pin *qe_pin_request(struct device_node *np, int index) | |||
155 | } | 155 | } |
156 | 156 | ||
157 | err = of_parse_phandles_with_args(np, "gpios", "#gpio-cells", index, | 157 | err = of_parse_phandles_with_args(np, "gpios", "#gpio-cells", index, |
158 | &gc, &gpio_spec); | 158 | &gpio_np, &gpio_spec); |
159 | if (err) { | 159 | if (err) { |
160 | pr_debug("%s: can't parse gpios property\n", __func__); | 160 | pr_debug("%s: can't parse gpios property\n", __func__); |
161 | goto err0; | 161 | goto err0; |
162 | } | 162 | } |
163 | 163 | ||
164 | if (!of_device_is_compatible(gc, "fsl,mpc8323-qe-pario-bank")) { | 164 | if (!of_device_is_compatible(gpio_np, "fsl,mpc8323-qe-pario-bank")) { |
165 | pr_debug("%s: tried to get a non-qe pin\n", __func__); | 165 | pr_debug("%s: tried to get a non-qe pin\n", __func__); |
166 | err = -EINVAL; | 166 | err = -EINVAL; |
167 | goto err1; | 167 | goto err1; |
168 | } | 168 | } |
169 | 169 | ||
170 | of_gc = gc->data; | 170 | gc = gpio_np->data; |
171 | if (!of_gc) { | 171 | if (!gc) { |
172 | pr_debug("%s: gpio controller %s isn't registered\n", | 172 | pr_debug("%s: gpio controller %s isn't registered\n", |
173 | np->full_name, gc->full_name); | 173 | np->full_name, gpio_np->full_name); |
174 | err = -ENODEV; | 174 | err = -ENODEV; |
175 | goto err1; | 175 | goto err1; |
176 | } | 176 | } |
177 | 177 | ||
178 | gpio_cells = of_get_property(gc, "#gpio-cells", &size); | 178 | gpio_cells = of_get_property(gpio_np, "#gpio-cells", &size); |
179 | if (!gpio_cells || size != sizeof(*gpio_cells) || | 179 | if (!gpio_cells || size != sizeof(*gpio_cells) || |
180 | *gpio_cells != of_gc->gpio_cells) { | 180 | *gpio_cells != gc->of_gpio_n_cells) { |
181 | pr_debug("%s: wrong #gpio-cells for %s\n", | 181 | pr_debug("%s: wrong #gpio-cells for %s\n", |
182 | np->full_name, gc->full_name); | 182 | np->full_name, gpio_np->full_name); |
183 | err = -EINVAL; | 183 | err = -EINVAL; |
184 | goto err1; | 184 | goto err1; |
185 | } | 185 | } |
186 | 186 | ||
187 | err = of_gc->xlate(of_gc, np, gpio_spec, NULL); | 187 | err = gc->of_xlate(gc, np, gpio_spec, NULL); |
188 | if (err < 0) | 188 | if (err < 0) |
189 | goto err1; | 189 | goto err1; |
190 | 190 | ||
191 | mm_gc = to_of_mm_gpio_chip(&of_gc->gc); | 191 | mm_gc = to_of_mm_gpio_chip(gc); |
192 | qe_gc = to_qe_gpio_chip(mm_gc); | 192 | qe_gc = to_qe_gpio_chip(mm_gc); |
193 | 193 | ||
194 | spin_lock_irqsave(&qe_gc->lock, flags); | 194 | spin_lock_irqsave(&qe_gc->lock, flags); |
@@ -206,7 +206,7 @@ struct qe_pin *qe_pin_request(struct device_node *np, int index) | |||
206 | if (!err) | 206 | if (!err) |
207 | return qe_pin; | 207 | return qe_pin; |
208 | err1: | 208 | err1: |
209 | of_node_put(gc); | 209 | of_node_put(gpio_np); |
210 | err0: | 210 | err0: |
211 | kfree(qe_pin); | 211 | kfree(qe_pin); |
212 | pr_debug("%s failed with status %d\n", __func__, err); | 212 | pr_debug("%s failed with status %d\n", __func__, err); |
@@ -307,7 +307,6 @@ static int __init qe_add_gpiochips(void) | |||
307 | int ret; | 307 | int ret; |
308 | struct qe_gpio_chip *qe_gc; | 308 | struct qe_gpio_chip *qe_gc; |
309 | struct of_mm_gpio_chip *mm_gc; | 309 | struct of_mm_gpio_chip *mm_gc; |
310 | struct of_gpio_chip *of_gc; | ||
311 | struct gpio_chip *gc; | 310 | struct gpio_chip *gc; |
312 | 311 | ||
313 | qe_gc = kzalloc(sizeof(*qe_gc), GFP_KERNEL); | 312 | qe_gc = kzalloc(sizeof(*qe_gc), GFP_KERNEL); |
@@ -319,11 +318,10 @@ static int __init qe_add_gpiochips(void) | |||
319 | spin_lock_init(&qe_gc->lock); | 318 | spin_lock_init(&qe_gc->lock); |
320 | 319 | ||
321 | mm_gc = &qe_gc->mm_gc; | 320 | mm_gc = &qe_gc->mm_gc; |
322 | of_gc = &mm_gc->of_gc; | 321 | gc = &mm_gc->gc; |
323 | gc = &of_gc->gc; | ||
324 | 322 | ||
325 | mm_gc->save_regs = qe_gpio_save_regs; | 323 | mm_gc->save_regs = qe_gpio_save_regs; |
326 | of_gc->gpio_cells = 2; | 324 | gc->of_gpio_n_cells = 2; |
327 | gc->ngpio = QE_PIO_PINS; | 325 | gc->ngpio = QE_PIO_PINS; |
328 | gc->direction_input = qe_gpio_dir_in; | 326 | gc->direction_input = qe_gpio_dir_in; |
329 | gc->direction_output = qe_gpio_dir_out; | 327 | gc->direction_output = qe_gpio_dir_out; |
diff --git a/arch/powerpc/sysdev/simple_gpio.c b/arch/powerpc/sysdev/simple_gpio.c index d5fb173e588c..b7559aa0c165 100644 --- a/arch/powerpc/sysdev/simple_gpio.c +++ b/arch/powerpc/sysdev/simple_gpio.c | |||
@@ -91,7 +91,6 @@ static int __init u8_simple_gpiochip_add(struct device_node *np) | |||
91 | int ret; | 91 | int ret; |
92 | struct u8_gpio_chip *u8_gc; | 92 | struct u8_gpio_chip *u8_gc; |
93 | struct of_mm_gpio_chip *mm_gc; | 93 | struct of_mm_gpio_chip *mm_gc; |
94 | struct of_gpio_chip *of_gc; | ||
95 | struct gpio_chip *gc; | 94 | struct gpio_chip *gc; |
96 | 95 | ||
97 | u8_gc = kzalloc(sizeof(*u8_gc), GFP_KERNEL); | 96 | u8_gc = kzalloc(sizeof(*u8_gc), GFP_KERNEL); |
@@ -101,11 +100,10 @@ static int __init u8_simple_gpiochip_add(struct device_node *np) | |||
101 | spin_lock_init(&u8_gc->lock); | 100 | spin_lock_init(&u8_gc->lock); |
102 | 101 | ||
103 | mm_gc = &u8_gc->mm_gc; | 102 | mm_gc = &u8_gc->mm_gc; |
104 | of_gc = &mm_gc->of_gc; | 103 | gc = &mm_gc->gc; |
105 | gc = &of_gc->gc; | ||
106 | 104 | ||
107 | mm_gc->save_regs = u8_gpio_save_regs; | 105 | mm_gc->save_regs = u8_gpio_save_regs; |
108 | of_gc->gpio_cells = 2; | 106 | gc->of_gpio_n_cells = 2; |
109 | gc->ngpio = 8; | 107 | gc->ngpio = 8; |
110 | gc->direction_input = u8_gpio_dir_in; | 108 | gc->direction_input = u8_gpio_dir_in; |
111 | gc->direction_output = u8_gpio_dir_out; | 109 | gc->direction_output = u8_gpio_dir_out; |