diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-01-07 15:15:36 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-01-07 15:15:36 -0500 |
commit | fbce1c234feedb5270468aa4b1770c1cab58a960 (patch) | |
tree | 7391d7bcce50eab43c750c4055b056ab1892d6b2 /arch/powerpc | |
parent | 7affca3537d74365128e477b40c529d6f2fe86c8 (diff) | |
parent | d0ad5e89256c351ddd40167152c24a88efcb0f6d (diff) |
Merge tag 'gpio-for-linus' of git://git.secretlab.ca/git/linux-2.6
Changes queued in gpio/next for the start of the 3.3 merge window
* tag 'gpio-for-linus-20120104' of git://git.secretlab.ca/git/linux-2.6:
gpio: Add decode of WM8994 GPIO configuration
gpio: Convert GPIO drivers to module_platform_driver
gpio: Fix typo in comment in Samsung driver
gpio: Explicitly index samsung_gpio_cfgs
gpio: Add Linus Walleij as gpio co-maintainer
of: Add device tree selftests
of: create of_phandle_args to simplify return of phandle parsing data
gpio/powerpc: Eliminate duplication of of_get_named_gpio_flags()
gpio/microblaze: Eliminate duplication of of_get_named_gpio_flags()
gpiolib: output basic details and consolidate gpio device drivers
pch_gpio: Change company name OKI SEMICONDUCTOR to LAPIS Semiconductor
pch_gpio: Support new device LAPIS Semiconductor ML7831 IOH
spi/pl022: make the chip deselect handling thread safe
spi/pl022: add support for pm_runtime autosuspend
spi/pl022: disable the PL022 block when unused
spi/pl022: move device disable to workqueue thread
spi/pl022: skip default configuration before suspending
spi/pl022: fix build warnings
spi/pl022: only enable RX interrupts when TX is complete
Diffstat (limited to 'arch/powerpc')
-rw-r--r-- | arch/powerpc/sysdev/qe_lib/gpio.c | 42 |
1 files changed, 8 insertions, 34 deletions
diff --git a/arch/powerpc/sysdev/qe_lib/gpio.c b/arch/powerpc/sysdev/qe_lib/gpio.c index e23f23cf9f5c..521e67a49dc4 100644 --- a/arch/powerpc/sysdev/qe_lib/gpio.c +++ b/arch/powerpc/sysdev/qe_lib/gpio.c | |||
@@ -139,14 +139,10 @@ struct qe_pin { | |||
139 | struct qe_pin *qe_pin_request(struct device_node *np, int index) | 139 | struct qe_pin *qe_pin_request(struct device_node *np, int index) |
140 | { | 140 | { |
141 | struct qe_pin *qe_pin; | 141 | struct qe_pin *qe_pin; |
142 | struct device_node *gpio_np; | ||
143 | struct gpio_chip *gc; | 142 | struct gpio_chip *gc; |
144 | struct of_mm_gpio_chip *mm_gc; | 143 | struct of_mm_gpio_chip *mm_gc; |
145 | struct qe_gpio_chip *qe_gc; | 144 | struct qe_gpio_chip *qe_gc; |
146 | int err; | 145 | int err; |
147 | int size; | ||
148 | const void *gpio_spec; | ||
149 | const u32 *gpio_cells; | ||
150 | unsigned long flags; | 146 | unsigned long flags; |
151 | 147 | ||
152 | qe_pin = kzalloc(sizeof(*qe_pin), GFP_KERNEL); | 148 | qe_pin = kzalloc(sizeof(*qe_pin), GFP_KERNEL); |
@@ -155,45 +151,25 @@ struct qe_pin *qe_pin_request(struct device_node *np, int index) | |||
155 | return ERR_PTR(-ENOMEM); | 151 | return ERR_PTR(-ENOMEM); |
156 | } | 152 | } |
157 | 153 | ||
158 | err = of_parse_phandles_with_args(np, "gpios", "#gpio-cells", index, | 154 | err = of_get_gpio(np, index); |
159 | &gpio_np, &gpio_spec); | 155 | if (err < 0) |
160 | if (err) { | 156 | goto err0; |
161 | pr_debug("%s: can't parse gpios property\n", __func__); | 157 | gc = gpio_to_chip(err); |
158 | if (WARN_ON(!gc)) | ||
162 | goto err0; | 159 | goto err0; |
163 | } | ||
164 | 160 | ||
165 | if (!of_device_is_compatible(gpio_np, "fsl,mpc8323-qe-pario-bank")) { | 161 | if (!of_device_is_compatible(gc->of_node, "fsl,mpc8323-qe-pario-bank")) { |
166 | pr_debug("%s: tried to get a non-qe pin\n", __func__); | 162 | pr_debug("%s: tried to get a non-qe pin\n", __func__); |
167 | err = -EINVAL; | 163 | err = -EINVAL; |
168 | goto err1; | 164 | goto err0; |
169 | } | ||
170 | |||
171 | gc = of_node_to_gpiochip(gpio_np); | ||
172 | if (!gc) { | ||
173 | pr_debug("%s: gpio controller %s isn't registered\n", | ||
174 | np->full_name, gpio_np->full_name); | ||
175 | err = -ENODEV; | ||
176 | goto err1; | ||
177 | } | ||
178 | |||
179 | gpio_cells = of_get_property(gpio_np, "#gpio-cells", &size); | ||
180 | if (!gpio_cells || size != sizeof(*gpio_cells) || | ||
181 | *gpio_cells != gc->of_gpio_n_cells) { | ||
182 | pr_debug("%s: wrong #gpio-cells for %s\n", | ||
183 | np->full_name, gpio_np->full_name); | ||
184 | err = -EINVAL; | ||
185 | goto err1; | ||
186 | } | 165 | } |
187 | 166 | ||
188 | err = gc->of_xlate(gc, np, gpio_spec, NULL); | ||
189 | if (err < 0) | ||
190 | goto err1; | ||
191 | |||
192 | mm_gc = to_of_mm_gpio_chip(gc); | 167 | mm_gc = to_of_mm_gpio_chip(gc); |
193 | qe_gc = to_qe_gpio_chip(mm_gc); | 168 | qe_gc = to_qe_gpio_chip(mm_gc); |
194 | 169 | ||
195 | spin_lock_irqsave(&qe_gc->lock, flags); | 170 | spin_lock_irqsave(&qe_gc->lock, flags); |
196 | 171 | ||
172 | err -= gc->base; | ||
197 | if (test_and_set_bit(QE_PIN_REQUESTED, &qe_gc->pin_flags[err]) == 0) { | 173 | if (test_and_set_bit(QE_PIN_REQUESTED, &qe_gc->pin_flags[err]) == 0) { |
198 | qe_pin->controller = qe_gc; | 174 | qe_pin->controller = qe_gc; |
199 | qe_pin->num = err; | 175 | qe_pin->num = err; |
@@ -206,8 +182,6 @@ struct qe_pin *qe_pin_request(struct device_node *np, int index) | |||
206 | 182 | ||
207 | if (!err) | 183 | if (!err) |
208 | return qe_pin; | 184 | return qe_pin; |
209 | err1: | ||
210 | of_node_put(gpio_np); | ||
211 | err0: | 185 | err0: |
212 | kfree(qe_pin); | 186 | kfree(qe_pin); |
213 | pr_debug("%s failed with status %d\n", __func__, err); | 187 | pr_debug("%s failed with status %d\n", __func__, err); |