diff options
author | Atsushi Nemoto <anemo@mba.ocn.ne.jp> | 2007-11-14 19:59:23 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-11-14 21:45:39 -0500 |
commit | ba0a7f39ce8cd54a1b2f3adb03509ff251a91bde (patch) | |
tree | a4f84d499145e2a5c8d1c9312ac7b7f6912530a1 /drivers/spi/spi_txx9.c | |
parent | 350d0076c5763ca2b88ca05e3889bfa7c1905f21 (diff) |
spi: fix error paths on txx9spi_probe
Some error paths in txx9spi_probe wrongly return 0. This patch fixes them by
using the devres interfaces.
Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Acked-by: David Brownell <david-b@pacbell.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/spi/spi_txx9.c')
-rw-r--r-- | drivers/spi/spi_txx9.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/drivers/spi/spi_txx9.c b/drivers/spi/spi_txx9.c index cc5094f37dd3..363ac8e68821 100644 --- a/drivers/spi/spi_txx9.c +++ b/drivers/spi/spi_txx9.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/spi/spi.h> | 24 | #include <linux/spi/spi.h> |
25 | #include <linux/err.h> | 25 | #include <linux/err.h> |
26 | #include <linux/clk.h> | 26 | #include <linux/clk.h> |
27 | #include <linux/io.h> | ||
27 | #include <asm/gpio.h> | 28 | #include <asm/gpio.h> |
28 | 29 | ||
29 | 30 | ||
@@ -74,7 +75,6 @@ struct txx9spi { | |||
74 | struct list_head queue; | 75 | struct list_head queue; |
75 | wait_queue_head_t waitq; | 76 | wait_queue_head_t waitq; |
76 | void __iomem *membase; | 77 | void __iomem *membase; |
77 | int irq; | ||
78 | int baseclk; | 78 | int baseclk; |
79 | struct clk *clk; | 79 | struct clk *clk; |
80 | u32 max_speed_hz, min_speed_hz; | 80 | u32 max_speed_hz, min_speed_hz; |
@@ -350,12 +350,12 @@ static int __init txx9spi_probe(struct platform_device *dev) | |||
350 | struct resource *res; | 350 | struct resource *res; |
351 | int ret = -ENODEV; | 351 | int ret = -ENODEV; |
352 | u32 mcr; | 352 | u32 mcr; |
353 | int irq; | ||
353 | 354 | ||
354 | master = spi_alloc_master(&dev->dev, sizeof(*c)); | 355 | master = spi_alloc_master(&dev->dev, sizeof(*c)); |
355 | if (!master) | 356 | if (!master) |
356 | return ret; | 357 | return ret; |
357 | c = spi_master_get_devdata(master); | 358 | c = spi_master_get_devdata(master); |
358 | c->irq = -1; | ||
359 | platform_set_drvdata(dev, master); | 359 | platform_set_drvdata(dev, master); |
360 | 360 | ||
361 | INIT_WORK(&c->work, txx9spi_work); | 361 | INIT_WORK(&c->work, txx9spi_work); |
@@ -381,32 +381,36 @@ static int __init txx9spi_probe(struct platform_device *dev) | |||
381 | 381 | ||
382 | res = platform_get_resource(dev, IORESOURCE_MEM, 0); | 382 | res = platform_get_resource(dev, IORESOURCE_MEM, 0); |
383 | if (!res) | 383 | if (!res) |
384 | goto exit; | 384 | goto exit_busy; |
385 | c->membase = ioremap(res->start, res->end - res->start + 1); | 385 | if (!devm_request_mem_region(&dev->dev, |
386 | res->start, res->end - res->start + 1, | ||
387 | "spi_txx9")) | ||
388 | goto exit_busy; | ||
389 | c->membase = devm_ioremap(&dev->dev, | ||
390 | res->start, res->end - res->start + 1); | ||
386 | if (!c->membase) | 391 | if (!c->membase) |
387 | goto exit; | 392 | goto exit_busy; |
388 | 393 | ||
389 | /* enter config mode */ | 394 | /* enter config mode */ |
390 | mcr = txx9spi_rd(c, TXx9_SPMCR); | 395 | mcr = txx9spi_rd(c, TXx9_SPMCR); |
391 | mcr &= ~(TXx9_SPMCR_OPMODE | TXx9_SPMCR_SPSTP | TXx9_SPMCR_BCLR); | 396 | mcr &= ~(TXx9_SPMCR_OPMODE | TXx9_SPMCR_SPSTP | TXx9_SPMCR_BCLR); |
392 | txx9spi_wr(c, mcr | TXx9_SPMCR_CONFIG | TXx9_SPMCR_BCLR, TXx9_SPMCR); | 397 | txx9spi_wr(c, mcr | TXx9_SPMCR_CONFIG | TXx9_SPMCR_BCLR, TXx9_SPMCR); |
393 | 398 | ||
394 | c->irq = platform_get_irq(dev, 0); | 399 | irq = platform_get_irq(dev, 0); |
395 | if (c->irq < 0) | 400 | if (irq < 0) |
396 | goto exit; | 401 | goto exit_busy; |
397 | ret = request_irq(c->irq, txx9spi_interrupt, 0, dev->name, c); | 402 | ret = devm_request_irq(&dev->dev, irq, txx9spi_interrupt, 0, |
398 | if (ret) { | 403 | "spi_txx9", c); |
399 | c->irq = -1; | 404 | if (ret) |
400 | goto exit; | 405 | goto exit; |
401 | } | ||
402 | 406 | ||
403 | c->workqueue = create_singlethread_workqueue(master->dev.parent->bus_id); | 407 | c->workqueue = create_singlethread_workqueue(master->dev.parent->bus_id); |
404 | if (!c->workqueue) | 408 | if (!c->workqueue) |
405 | goto exit; | 409 | goto exit_busy; |
406 | c->last_chipselect = -1; | 410 | c->last_chipselect = -1; |
407 | 411 | ||
408 | dev_info(&dev->dev, "at %#llx, irq %d, %dMHz\n", | 412 | dev_info(&dev->dev, "at %#llx, irq %d, %dMHz\n", |
409 | (unsigned long long)res->start, c->irq, | 413 | (unsigned long long)res->start, irq, |
410 | (c->baseclk + 500000) / 1000000); | 414 | (c->baseclk + 500000) / 1000000); |
411 | 415 | ||
412 | master->bus_num = dev->id; | 416 | master->bus_num = dev->id; |
@@ -418,13 +422,11 @@ static int __init txx9spi_probe(struct platform_device *dev) | |||
418 | if (ret) | 422 | if (ret) |
419 | goto exit; | 423 | goto exit; |
420 | return 0; | 424 | return 0; |
425 | exit_busy: | ||
426 | ret = -EBUSY; | ||
421 | exit: | 427 | exit: |
422 | if (c->workqueue) | 428 | if (c->workqueue) |
423 | destroy_workqueue(c->workqueue); | 429 | destroy_workqueue(c->workqueue); |
424 | if (c->irq >= 0) | ||
425 | free_irq(c->irq, c); | ||
426 | if (c->membase) | ||
427 | iounmap(c->membase); | ||
428 | if (c->clk) { | 430 | if (c->clk) { |
429 | clk_disable(c->clk); | 431 | clk_disable(c->clk); |
430 | clk_put(c->clk); | 432 | clk_put(c->clk); |
@@ -442,8 +444,6 @@ static int __exit txx9spi_remove(struct platform_device *dev) | |||
442 | spi_unregister_master(master); | 444 | spi_unregister_master(master); |
443 | platform_set_drvdata(dev, NULL); | 445 | platform_set_drvdata(dev, NULL); |
444 | destroy_workqueue(c->workqueue); | 446 | destroy_workqueue(c->workqueue); |
445 | free_irq(c->irq, c); | ||
446 | iounmap(c->membase); | ||
447 | clk_disable(c->clk); | 447 | clk_disable(c->clk); |
448 | clk_put(c->clk); | 448 | clk_put(c->clk); |
449 | spi_master_put(master); | 449 | spi_master_put(master); |