diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2013-05-16 16:33:09 -0400 |
---|---|---|
committer | Wolfram Sang <wsa@the-dreams.de> | 2013-06-05 17:06:43 -0400 |
commit | 16874b0709c7c78489de1f502edd33acad2918e8 (patch) | |
tree | c5c1e862508128e35d039e9e7ac40349373713a6 /drivers/i2c/busses/i2c-mv64xxx.c | |
parent | d5ac456144413950d2d32ec4f22542e45be13cd7 (diff) |
I2C: mv64xxx: use devm_ioremap_resource()
Eliminate reg_base_p and reg_size, mv64xxx_i2c_unmap_regs() and an
unchecked ioremap() return from this driver by using the devm_*
API for requesting and ioremapping resources.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Acked-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Diffstat (limited to 'drivers/i2c/busses/i2c-mv64xxx.c')
-rw-r--r-- | drivers/i2c/busses/i2c-mv64xxx.c | 46 |
1 files changed, 6 insertions, 40 deletions
diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c index 940a190b1a53..54b8cf6b6dd0 100644 --- a/drivers/i2c/busses/i2c-mv64xxx.c +++ b/drivers/i2c/busses/i2c-mv64xxx.c | |||
@@ -92,8 +92,6 @@ struct mv64xxx_i2c_data { | |||
92 | u32 aborting; | 92 | u32 aborting; |
93 | u32 cntl_bits; | 93 | u32 cntl_bits; |
94 | void __iomem *reg_base; | 94 | void __iomem *reg_base; |
95 | u32 reg_base_p; | ||
96 | u32 reg_size; | ||
97 | u32 addr1; | 95 | u32 addr1; |
98 | u32 addr2; | 96 | u32 addr2; |
99 | u32 bytes_left; | 97 | u32 bytes_left; |
@@ -495,40 +493,6 @@ static const struct i2c_algorithm mv64xxx_i2c_algo = { | |||
495 | * | 493 | * |
496 | ***************************************************************************** | 494 | ***************************************************************************** |
497 | */ | 495 | */ |
498 | static int | ||
499 | mv64xxx_i2c_map_regs(struct platform_device *pd, | ||
500 | struct mv64xxx_i2c_data *drv_data) | ||
501 | { | ||
502 | int size; | ||
503 | struct resource *r = platform_get_resource(pd, IORESOURCE_MEM, 0); | ||
504 | |||
505 | if (!r) | ||
506 | return -ENODEV; | ||
507 | |||
508 | size = resource_size(r); | ||
509 | |||
510 | if (!request_mem_region(r->start, size, drv_data->adapter.name)) | ||
511 | return -EBUSY; | ||
512 | |||
513 | drv_data->reg_base = ioremap(r->start, size); | ||
514 | drv_data->reg_base_p = r->start; | ||
515 | drv_data->reg_size = size; | ||
516 | |||
517 | return 0; | ||
518 | } | ||
519 | |||
520 | static void | ||
521 | mv64xxx_i2c_unmap_regs(struct mv64xxx_i2c_data *drv_data) | ||
522 | { | ||
523 | if (drv_data->reg_base) { | ||
524 | iounmap(drv_data->reg_base); | ||
525 | release_mem_region(drv_data->reg_base_p, drv_data->reg_size); | ||
526 | } | ||
527 | |||
528 | drv_data->reg_base = NULL; | ||
529 | drv_data->reg_base_p = 0; | ||
530 | } | ||
531 | |||
532 | #ifdef CONFIG_OF | 496 | #ifdef CONFIG_OF |
533 | static int | 497 | static int |
534 | mv64xxx_calc_freq(const int tclk, const int n, const int m) | 498 | mv64xxx_calc_freq(const int tclk, const int n, const int m) |
@@ -610,6 +574,7 @@ mv64xxx_i2c_probe(struct platform_device *pd) | |||
610 | { | 574 | { |
611 | struct mv64xxx_i2c_data *drv_data; | 575 | struct mv64xxx_i2c_data *drv_data; |
612 | struct mv64xxx_i2c_pdata *pdata = pd->dev.platform_data; | 576 | struct mv64xxx_i2c_pdata *pdata = pd->dev.platform_data; |
577 | struct resource *r; | ||
613 | int rc; | 578 | int rc; |
614 | 579 | ||
615 | if ((!pdata && !pd->dev.of_node)) | 580 | if ((!pdata && !pd->dev.of_node)) |
@@ -619,9 +584,12 @@ mv64xxx_i2c_probe(struct platform_device *pd) | |||
619 | if (!drv_data) | 584 | if (!drv_data) |
620 | return -ENOMEM; | 585 | return -ENOMEM; |
621 | 586 | ||
622 | rc = mv64xxx_i2c_map_regs(pd, drv_data); | 587 | r = platform_get_resource(pd, IORESOURCE_MEM, 0); |
623 | if (rc) | 588 | drv_data->reg_base = devm_ioremap_resource(&pd->dev, r); |
589 | if (IS_ERR(drv_data->reg_base)) { | ||
590 | rc = PTR_ERR(drv_data->reg_base); | ||
624 | goto exit_kfree; | 591 | goto exit_kfree; |
592 | } | ||
625 | 593 | ||
626 | strlcpy(drv_data->adapter.name, MV64XXX_I2C_CTLR_NAME " adapter", | 594 | strlcpy(drv_data->adapter.name, MV64XXX_I2C_CTLR_NAME " adapter", |
627 | sizeof(drv_data->adapter.name)); | 595 | sizeof(drv_data->adapter.name)); |
@@ -690,7 +658,6 @@ mv64xxx_i2c_probe(struct platform_device *pd) | |||
690 | clk_unprepare(drv_data->clk); | 658 | clk_unprepare(drv_data->clk); |
691 | } | 659 | } |
692 | #endif | 660 | #endif |
693 | mv64xxx_i2c_unmap_regs(drv_data); | ||
694 | exit_kfree: | 661 | exit_kfree: |
695 | kfree(drv_data); | 662 | kfree(drv_data); |
696 | return rc; | 663 | return rc; |
@@ -703,7 +670,6 @@ mv64xxx_i2c_remove(struct platform_device *dev) | |||
703 | 670 | ||
704 | i2c_del_adapter(&drv_data->adapter); | 671 | i2c_del_adapter(&drv_data->adapter); |
705 | free_irq(drv_data->irq, drv_data); | 672 | free_irq(drv_data->irq, drv_data); |
706 | mv64xxx_i2c_unmap_regs(drv_data); | ||
707 | #if defined(CONFIG_HAVE_CLK) | 673 | #if defined(CONFIG_HAVE_CLK) |
708 | /* Not all platforms have a clk */ | 674 | /* Not all platforms have a clk */ |
709 | if (!IS_ERR(drv_data->clk)) { | 675 | if (!IS_ERR(drv_data->clk)) { |