diff options
author | Joachim Eastwood <manabian@gmail.com> | 2013-06-06 04:24:16 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-06-06 15:57:42 -0400 |
commit | 54fe15918bb7ad8aac994bf69f6d2f8c23fbdc34 (patch) | |
tree | f17519585fa68470e5caadfbc5315fa3229649f5 /drivers/pcmcia/at91_cf.c | |
parent | 40ca0209bae06eeede0f861e988b4bb38ae9cf98 (diff) |
pcmcia: at91_cf: use devm_ functions for allocations
Signed-off-by: Joachim Eastwood <manabian@gmail.com>
Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Acked-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/pcmcia/at91_cf.c')
-rw-r--r-- | drivers/pcmcia/at91_cf.c | 77 |
1 files changed, 24 insertions, 53 deletions
diff --git a/drivers/pcmcia/at91_cf.c b/drivers/pcmcia/at91_cf.c index 4eec14bcb7b8..43bc342e6c03 100644 --- a/drivers/pcmcia/at91_cf.c +++ b/drivers/pcmcia/at91_cf.c | |||
@@ -227,7 +227,7 @@ static int __init at91_cf_probe(struct platform_device *pdev) | |||
227 | if (!io) | 227 | if (!io) |
228 | return -ENODEV; | 228 | return -ENODEV; |
229 | 229 | ||
230 | cf = kzalloc(sizeof *cf, GFP_KERNEL); | 230 | cf = devm_kzalloc(&pdev->dev, sizeof(*cf), GFP_KERNEL); |
231 | if (!cf) | 231 | if (!cf) |
232 | return -ENOMEM; | 232 | return -ENOMEM; |
233 | 233 | ||
@@ -237,22 +237,25 @@ static int __init at91_cf_probe(struct platform_device *pdev) | |||
237 | platform_set_drvdata(pdev, cf); | 237 | platform_set_drvdata(pdev, cf); |
238 | 238 | ||
239 | /* must be a GPIO; ergo must trigger on both edges */ | 239 | /* must be a GPIO; ergo must trigger on both edges */ |
240 | status = gpio_request(board->det_pin, "cf_det"); | 240 | status = devm_gpio_request(&pdev->dev, board->det_pin, "cf_det"); |
241 | if (status < 0) | 241 | if (status < 0) |
242 | goto fail0; | 242 | return status; |
243 | status = request_irq(gpio_to_irq(board->det_pin), at91_cf_irq, 0, "at91_cf detect", cf); | 243 | |
244 | status = devm_request_irq(&pdev->dev, gpio_to_irq(board->det_pin), | ||
245 | at91_cf_irq, 0, "at91_cf detect", cf); | ||
244 | if (status < 0) | 246 | if (status < 0) |
245 | goto fail00; | 247 | return status; |
248 | |||
246 | device_init_wakeup(&pdev->dev, 1); | 249 | device_init_wakeup(&pdev->dev, 1); |
247 | 250 | ||
248 | status = gpio_request(board->rst_pin, "cf_rst"); | 251 | status = devm_gpio_request(&pdev->dev, board->rst_pin, "cf_rst"); |
249 | if (status < 0) | 252 | if (status < 0) |
250 | goto fail0a; | 253 | goto fail0a; |
251 | 254 | ||
252 | if (gpio_is_valid(board->vcc_pin)) { | 255 | if (gpio_is_valid(board->vcc_pin)) { |
253 | status = gpio_request(board->vcc_pin, "cf_vcc"); | 256 | status = devm_gpio_request(&pdev->dev, board->vcc_pin, "cf_vcc"); |
254 | if (status < 0) | 257 | if (status < 0) |
255 | goto fail0b; | 258 | goto fail0a; |
256 | } | 259 | } |
257 | 260 | ||
258 | /* | 261 | /* |
@@ -262,29 +265,30 @@ static int __init at91_cf_probe(struct platform_device *pdev) | |||
262 | * (Note: DK board doesn't wire the IRQ pin...) | 265 | * (Note: DK board doesn't wire the IRQ pin...) |
263 | */ | 266 | */ |
264 | if (gpio_is_valid(board->irq_pin)) { | 267 | if (gpio_is_valid(board->irq_pin)) { |
265 | status = gpio_request(board->irq_pin, "cf_irq"); | 268 | status = devm_gpio_request(&pdev->dev, board->irq_pin, "cf_irq"); |
266 | if (status < 0) | 269 | if (status < 0) |
267 | goto fail0c; | 270 | goto fail0a; |
268 | status = request_irq(gpio_to_irq(board->irq_pin), at91_cf_irq, | 271 | |
269 | IRQF_SHARED, "at91_cf", cf); | 272 | status = devm_request_irq(&pdev->dev, gpio_to_irq(board->irq_pin), |
273 | at91_cf_irq, IRQF_SHARED, "at91_cf", cf); | ||
270 | if (status < 0) | 274 | if (status < 0) |
271 | goto fail0d; | 275 | goto fail0a; |
272 | cf->socket.pci_irq = gpio_to_irq(board->irq_pin); | 276 | cf->socket.pci_irq = gpio_to_irq(board->irq_pin); |
273 | } else | 277 | } else |
274 | cf->socket.pci_irq = nr_irqs + 1; | 278 | cf->socket.pci_irq = nr_irqs + 1; |
275 | 279 | ||
276 | /* pcmcia layer only remaps "real" memory not iospace */ | 280 | /* pcmcia layer only remaps "real" memory not iospace */ |
277 | cf->socket.io_offset = (unsigned long) | 281 | cf->socket.io_offset = (unsigned long) devm_ioremap(&pdev->dev, |
278 | ioremap(cf->phys_baseaddr + CF_IO_PHYS, SZ_2K); | 282 | cf->phys_baseaddr + CF_IO_PHYS, SZ_2K); |
279 | if (!cf->socket.io_offset) { | 283 | if (!cf->socket.io_offset) { |
280 | status = -ENXIO; | 284 | status = -ENXIO; |
281 | goto fail1; | 285 | goto fail0a; |
282 | } | 286 | } |
283 | 287 | ||
284 | /* reserve chip-select regions */ | 288 | /* reserve chip-select regions */ |
285 | if (!request_mem_region(io->start, resource_size(io), "at91_cf")) { | 289 | if (!devm_request_mem_region(&pdev->dev, io->start, resource_size(io), "at91_cf")) { |
286 | status = -ENXIO; | 290 | status = -ENXIO; |
287 | goto fail1; | 291 | goto fail0a; |
288 | } | 292 | } |
289 | 293 | ||
290 | dev_info(&pdev->dev, "irqs det #%d, io #%d\n", | 294 | dev_info(&pdev->dev, "irqs det #%d, io #%d\n", |
@@ -301,55 +305,22 @@ static int __init at91_cf_probe(struct platform_device *pdev) | |||
301 | 305 | ||
302 | status = pcmcia_register_socket(&cf->socket); | 306 | status = pcmcia_register_socket(&cf->socket); |
303 | if (status < 0) | 307 | if (status < 0) |
304 | goto fail2; | 308 | goto fail0a; |
305 | 309 | ||
306 | return 0; | 310 | return 0; |
307 | 311 | ||
308 | fail2: | ||
309 | release_mem_region(io->start, resource_size(io)); | ||
310 | fail1: | ||
311 | if (cf->socket.io_offset) | ||
312 | iounmap((void __iomem *) cf->socket.io_offset); | ||
313 | if (gpio_is_valid(board->irq_pin)) { | ||
314 | free_irq(gpio_to_irq(board->irq_pin), cf); | ||
315 | fail0d: | ||
316 | gpio_free(board->irq_pin); | ||
317 | } | ||
318 | fail0c: | ||
319 | if (gpio_is_valid(board->vcc_pin)) | ||
320 | gpio_free(board->vcc_pin); | ||
321 | fail0b: | ||
322 | gpio_free(board->rst_pin); | ||
323 | fail0a: | 312 | fail0a: |
324 | device_init_wakeup(&pdev->dev, 0); | 313 | device_init_wakeup(&pdev->dev, 0); |
325 | free_irq(gpio_to_irq(board->det_pin), cf); | ||
326 | fail00: | ||
327 | gpio_free(board->det_pin); | ||
328 | fail0: | ||
329 | kfree(cf); | ||
330 | return status; | 314 | return status; |
331 | } | 315 | } |
332 | 316 | ||
333 | static int __exit at91_cf_remove(struct platform_device *pdev) | 317 | static int __exit at91_cf_remove(struct platform_device *pdev) |
334 | { | 318 | { |
335 | struct at91_cf_socket *cf = platform_get_drvdata(pdev); | 319 | struct at91_cf_socket *cf = platform_get_drvdata(pdev); |
336 | struct at91_cf_data *board = cf->board; | ||
337 | struct resource *io = cf->socket.io[0].res; | ||
338 | 320 | ||
339 | pcmcia_unregister_socket(&cf->socket); | 321 | pcmcia_unregister_socket(&cf->socket); |
340 | release_mem_region(io->start, resource_size(io)); | ||
341 | iounmap((void __iomem *) cf->socket.io_offset); | ||
342 | if (gpio_is_valid(board->irq_pin)) { | ||
343 | free_irq(gpio_to_irq(board->irq_pin), cf); | ||
344 | gpio_free(board->irq_pin); | ||
345 | } | ||
346 | if (gpio_is_valid(board->vcc_pin)) | ||
347 | gpio_free(board->vcc_pin); | ||
348 | gpio_free(board->rst_pin); | ||
349 | device_init_wakeup(&pdev->dev, 0); | 322 | device_init_wakeup(&pdev->dev, 0); |
350 | free_irq(gpio_to_irq(board->det_pin), cf); | 323 | |
351 | gpio_free(board->det_pin); | ||
352 | kfree(cf); | ||
353 | return 0; | 324 | return 0; |
354 | } | 325 | } |
355 | 326 | ||