diff options
author | Jingoo Han <jg1.han@samsung.com> | 2013-12-09 05:18:18 -0500 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-12-17 17:43:30 -0500 |
commit | 7519459da294680bbab1bd20a4e378d83a1c6d45 (patch) | |
tree | 00674c513348a3b5396639436b93dd691d071e72 /drivers/spi | |
parent | 6ce4eac1f600b34f2f7f58f9cd8f0503d79e42ae (diff) |
spi: nuc900: Use devm_*() functions
Use devm_*() functions to make cleanup paths simpler.
Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Acked-by: Wan ZongShun <mcuos.com@gmail.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/spi')
-rw-r--r-- | drivers/spi/spi-nuc900.c | 50 |
1 files changed, 10 insertions, 40 deletions
diff --git a/drivers/spi/spi-nuc900.c b/drivers/spi/spi-nuc900.c index e0c32bc69ee2..43d340ca0730 100644 --- a/drivers/spi/spi-nuc900.c +++ b/drivers/spi/spi-nuc900.c | |||
@@ -57,7 +57,6 @@ struct nuc900_spi { | |||
57 | const unsigned char *tx; | 57 | const unsigned char *tx; |
58 | unsigned char *rx; | 58 | unsigned char *rx; |
59 | struct clk *clk; | 59 | struct clk *clk; |
60 | struct resource *ioarea; | ||
61 | struct spi_master *master; | 60 | struct spi_master *master; |
62 | struct spi_device *curdev; | 61 | struct spi_device *curdev; |
63 | struct device *dev; | 62 | struct device *dev; |
@@ -344,8 +343,7 @@ static int nuc900_spi_probe(struct platform_device *pdev) | |||
344 | master = spi_alloc_master(&pdev->dev, sizeof(struct nuc900_spi)); | 343 | master = spi_alloc_master(&pdev->dev, sizeof(struct nuc900_spi)); |
345 | if (master == NULL) { | 344 | if (master == NULL) { |
346 | dev_err(&pdev->dev, "No memory for spi_master\n"); | 345 | dev_err(&pdev->dev, "No memory for spi_master\n"); |
347 | err = -ENOMEM; | 346 | return -ENOMEM; |
348 | goto err_nomem; | ||
349 | } | 347 | } |
350 | 348 | ||
351 | hw = spi_master_get_devdata(master); | 349 | hw = spi_master_get_devdata(master); |
@@ -376,40 +374,31 @@ static int nuc900_spi_probe(struct platform_device *pdev) | |||
376 | goto err_pdata; | 374 | goto err_pdata; |
377 | } | 375 | } |
378 | 376 | ||
379 | hw->ioarea = request_mem_region(hw->res->start, | 377 | hw->regs = devm_ioremap_resource(&pdev->dev, hw->res); |
380 | resource_size(hw->res), pdev->name); | 378 | if (IS_ERR(hw->regs)) { |
381 | 379 | err = PTR_ERR(hw->regs); | |
382 | if (hw->ioarea == NULL) { | ||
383 | dev_err(&pdev->dev, "Cannot reserve region\n"); | ||
384 | err = -ENXIO; | ||
385 | goto err_pdata; | 380 | goto err_pdata; |
386 | } | 381 | } |
387 | 382 | ||
388 | hw->regs = ioremap(hw->res->start, resource_size(hw->res)); | ||
389 | if (hw->regs == NULL) { | ||
390 | dev_err(&pdev->dev, "Cannot map IO\n"); | ||
391 | err = -ENXIO; | ||
392 | goto err_iomap; | ||
393 | } | ||
394 | |||
395 | hw->irq = platform_get_irq(pdev, 0); | 383 | hw->irq = platform_get_irq(pdev, 0); |
396 | if (hw->irq < 0) { | 384 | if (hw->irq < 0) { |
397 | dev_err(&pdev->dev, "No IRQ specified\n"); | 385 | dev_err(&pdev->dev, "No IRQ specified\n"); |
398 | err = -ENOENT; | 386 | err = -ENOENT; |
399 | goto err_irq; | 387 | goto err_pdata; |
400 | } | 388 | } |
401 | 389 | ||
402 | err = request_irq(hw->irq, nuc900_spi_irq, 0, pdev->name, hw); | 390 | err = devm_request_irq(&pdev->dev, hw->irq, nuc900_spi_irq, 0, |
391 | pdev->name, hw); | ||
403 | if (err) { | 392 | if (err) { |
404 | dev_err(&pdev->dev, "Cannot claim IRQ\n"); | 393 | dev_err(&pdev->dev, "Cannot claim IRQ\n"); |
405 | goto err_irq; | 394 | goto err_pdata; |
406 | } | 395 | } |
407 | 396 | ||
408 | hw->clk = clk_get(&pdev->dev, "spi"); | 397 | hw->clk = devm_clk_get(&pdev->dev, "spi"); |
409 | if (IS_ERR(hw->clk)) { | 398 | if (IS_ERR(hw->clk)) { |
410 | dev_err(&pdev->dev, "No clock for device\n"); | 399 | dev_err(&pdev->dev, "No clock for device\n"); |
411 | err = PTR_ERR(hw->clk); | 400 | err = PTR_ERR(hw->clk); |
412 | goto err_clk; | 401 | goto err_pdata; |
413 | } | 402 | } |
414 | 403 | ||
415 | mfp_set_groupg(&pdev->dev, NULL); | 404 | mfp_set_groupg(&pdev->dev, NULL); |
@@ -425,17 +414,8 @@ static int nuc900_spi_probe(struct platform_device *pdev) | |||
425 | 414 | ||
426 | err_register: | 415 | err_register: |
427 | clk_disable(hw->clk); | 416 | clk_disable(hw->clk); |
428 | clk_put(hw->clk); | ||
429 | err_clk: | ||
430 | free_irq(hw->irq, hw); | ||
431 | err_irq: | ||
432 | iounmap(hw->regs); | ||
433 | err_iomap: | ||
434 | release_mem_region(hw->res->start, resource_size(hw->res)); | ||
435 | kfree(hw->ioarea); | ||
436 | err_pdata: | 417 | err_pdata: |
437 | spi_master_put(hw->master); | 418 | spi_master_put(hw->master); |
438 | err_nomem: | ||
439 | return err; | 419 | return err; |
440 | } | 420 | } |
441 | 421 | ||
@@ -443,18 +423,8 @@ static int nuc900_spi_remove(struct platform_device *dev) | |||
443 | { | 423 | { |
444 | struct nuc900_spi *hw = platform_get_drvdata(dev); | 424 | struct nuc900_spi *hw = platform_get_drvdata(dev); |
445 | 425 | ||
446 | free_irq(hw->irq, hw); | ||
447 | |||
448 | spi_bitbang_stop(&hw->bitbang); | 426 | spi_bitbang_stop(&hw->bitbang); |
449 | |||
450 | clk_disable(hw->clk); | 427 | clk_disable(hw->clk); |
451 | clk_put(hw->clk); | ||
452 | |||
453 | iounmap(hw->regs); | ||
454 | |||
455 | release_mem_region(hw->res->start, resource_size(hw->res)); | ||
456 | kfree(hw->ioarea); | ||
457 | |||
458 | spi_master_put(hw->master); | 428 | spi_master_put(hw->master); |
459 | return 0; | 429 | return 0; |
460 | } | 430 | } |