diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2013-05-16 16:35:10 -0400 |
---|---|---|
committer | Wolfram Sang <wsa@the-dreams.de> | 2013-06-05 17:06:45 -0400 |
commit | 2c911103040faad9d092a72b9f4503f92154c1dc (patch) | |
tree | 927f8668349bc67b629a3919656f4d704e7239c4 /drivers/i2c/busses | |
parent | 4c5c95f53b5cb5666906242a63d4d2c4fd0a0be8 (diff) |
I2C: mv64xxx: use devm_kzalloc()
As we're changing to using devm_* APIs to fix various problems
in this driver, lets also do devm_kzalloc() while we're here too.
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')
-rw-r--r-- | drivers/i2c/busses/i2c-mv64xxx.c | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c index 25e64c445e61..640b49df2ddd 100644 --- a/drivers/i2c/busses/i2c-mv64xxx.c +++ b/drivers/i2c/busses/i2c-mv64xxx.c | |||
@@ -580,16 +580,15 @@ mv64xxx_i2c_probe(struct platform_device *pd) | |||
580 | if ((!pdata && !pd->dev.of_node)) | 580 | if ((!pdata && !pd->dev.of_node)) |
581 | return -ENODEV; | 581 | return -ENODEV; |
582 | 582 | ||
583 | drv_data = kzalloc(sizeof(struct mv64xxx_i2c_data), GFP_KERNEL); | 583 | drv_data = devm_kzalloc(&pd->dev, sizeof(struct mv64xxx_i2c_data), |
584 | GFP_KERNEL); | ||
584 | if (!drv_data) | 585 | if (!drv_data) |
585 | return -ENOMEM; | 586 | return -ENOMEM; |
586 | 587 | ||
587 | r = platform_get_resource(pd, IORESOURCE_MEM, 0); | 588 | r = platform_get_resource(pd, IORESOURCE_MEM, 0); |
588 | drv_data->reg_base = devm_ioremap_resource(&pd->dev, r); | 589 | drv_data->reg_base = devm_ioremap_resource(&pd->dev, r); |
589 | if (IS_ERR(drv_data->reg_base)) { | 590 | if (IS_ERR(drv_data->reg_base)) |
590 | rc = PTR_ERR(drv_data->reg_base); | 591 | return PTR_ERR(drv_data->reg_base); |
591 | goto exit_kfree; | ||
592 | } | ||
593 | 592 | ||
594 | strlcpy(drv_data->adapter.name, MV64XXX_I2C_CTLR_NAME " adapter", | 593 | strlcpy(drv_data->adapter.name, MV64XXX_I2C_CTLR_NAME " adapter", |
595 | sizeof(drv_data->adapter.name)); | 594 | sizeof(drv_data->adapter.name)); |
@@ -613,11 +612,11 @@ mv64xxx_i2c_probe(struct platform_device *pd) | |||
613 | } else if (pd->dev.of_node) { | 612 | } else if (pd->dev.of_node) { |
614 | rc = mv64xxx_of_config(drv_data, pd->dev.of_node); | 613 | rc = mv64xxx_of_config(drv_data, pd->dev.of_node); |
615 | if (rc) | 614 | if (rc) |
616 | goto exit_unmap_regs; | 615 | goto exit_clk; |
617 | } | 616 | } |
618 | if (drv_data->irq < 0) { | 617 | if (drv_data->irq < 0) { |
619 | rc = -ENXIO; | 618 | rc = -ENXIO; |
620 | goto exit_unmap_regs; | 619 | goto exit_clk; |
621 | } | 620 | } |
622 | 621 | ||
623 | drv_data->adapter.dev.parent = &pd->dev; | 622 | drv_data->adapter.dev.parent = &pd->dev; |
@@ -637,7 +636,7 @@ mv64xxx_i2c_probe(struct platform_device *pd) | |||
637 | "mv64xxx: Can't register intr handler irq: %d\n", | 636 | "mv64xxx: Can't register intr handler irq: %d\n", |
638 | drv_data->irq); | 637 | drv_data->irq); |
639 | rc = -EINVAL; | 638 | rc = -EINVAL; |
640 | goto exit_unmap_regs; | 639 | goto exit_clk; |
641 | } else if ((rc = i2c_add_numbered_adapter(&drv_data->adapter)) != 0) { | 640 | } else if ((rc = i2c_add_numbered_adapter(&drv_data->adapter)) != 0) { |
642 | dev_err(&drv_data->adapter.dev, | 641 | dev_err(&drv_data->adapter.dev, |
643 | "mv64xxx: Can't add i2c adapter, rc: %d\n", -rc); | 642 | "mv64xxx: Can't add i2c adapter, rc: %d\n", -rc); |
@@ -648,9 +647,9 @@ mv64xxx_i2c_probe(struct platform_device *pd) | |||
648 | 647 | ||
649 | return 0; | 648 | return 0; |
650 | 649 | ||
651 | exit_free_irq: | 650 | exit_free_irq: |
652 | free_irq(drv_data->irq, drv_data); | 651 | free_irq(drv_data->irq, drv_data); |
653 | exit_unmap_regs: | 652 | exit_clk: |
654 | #if defined(CONFIG_HAVE_CLK) | 653 | #if defined(CONFIG_HAVE_CLK) |
655 | /* Not all platforms have a clk */ | 654 | /* Not all platforms have a clk */ |
656 | if (!IS_ERR(drv_data->clk)) { | 655 | if (!IS_ERR(drv_data->clk)) { |
@@ -658,8 +657,6 @@ mv64xxx_i2c_probe(struct platform_device *pd) | |||
658 | clk_unprepare(drv_data->clk); | 657 | clk_unprepare(drv_data->clk); |
659 | } | 658 | } |
660 | #endif | 659 | #endif |
661 | exit_kfree: | ||
662 | kfree(drv_data); | ||
663 | return rc; | 660 | return rc; |
664 | } | 661 | } |
665 | 662 | ||
@@ -677,7 +674,6 @@ mv64xxx_i2c_remove(struct platform_device *dev) | |||
677 | clk_unprepare(drv_data->clk); | 674 | clk_unprepare(drv_data->clk); |
678 | } | 675 | } |
679 | #endif | 676 | #endif |
680 | kfree(drv_data); | ||
681 | 677 | ||
682 | return 0; | 678 | return 0; |
683 | } | 679 | } |