diff options
author | Thomas Abraham <thomas.abraham@linaro.org> | 2011-09-13 00:16:04 -0400 |
---|---|---|
committer | Ben Dooks <ben-linux@fluff.org> | 2011-10-29 06:21:16 -0400 |
commit | 4fd81eb2d64295ab038a3ea9d44e0eac85a6648c (patch) | |
tree | 2f548809a45ddc7f862970d93675f3676399dce0 /drivers/i2c/busses/i2c-s3c2410.c | |
parent | 1fdb24e969110fafea36d3b393bea438f702c87f (diff) |
i2c-s3c2410: Keep a copy of platform data and use it
The platform data is copied into driver's private data and the copy is
used for all access to the platform data. This simpifies the addition
of device tree support for the i2c-s3c2410 driver.
Cc: Ben Dooks <ben-linux@fluff.org>
Signed-off-by: Thomas Abraham <thomas.abraham@linaro.org>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Diffstat (limited to 'drivers/i2c/busses/i2c-s3c2410.c')
-rw-r--r-- | drivers/i2c/busses/i2c-s3c2410.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c index f84a63c6dd97..266dd83a3ec2 100644 --- a/drivers/i2c/busses/i2c-s3c2410.c +++ b/drivers/i2c/busses/i2c-s3c2410.c | |||
@@ -78,6 +78,7 @@ struct s3c24xx_i2c { | |||
78 | struct resource *ioarea; | 78 | struct resource *ioarea; |
79 | struct i2c_adapter adap; | 79 | struct i2c_adapter adap; |
80 | 80 | ||
81 | struct s3c2410_platform_i2c *pdata; | ||
81 | #ifdef CONFIG_CPU_FREQ | 82 | #ifdef CONFIG_CPU_FREQ |
82 | struct notifier_block freq_transition; | 83 | struct notifier_block freq_transition; |
83 | #endif | 84 | #endif |
@@ -625,7 +626,7 @@ static int s3c24xx_i2c_calcdivisor(unsigned long clkin, unsigned int wanted, | |||
625 | 626 | ||
626 | static int s3c24xx_i2c_clockrate(struct s3c24xx_i2c *i2c, unsigned int *got) | 627 | static int s3c24xx_i2c_clockrate(struct s3c24xx_i2c *i2c, unsigned int *got) |
627 | { | 628 | { |
628 | struct s3c2410_platform_i2c *pdata = i2c->dev->platform_data; | 629 | struct s3c2410_platform_i2c *pdata = i2c->pdata; |
629 | unsigned long clkin = clk_get_rate(i2c->clk); | 630 | unsigned long clkin = clk_get_rate(i2c->clk); |
630 | unsigned int divs, div1; | 631 | unsigned int divs, div1; |
631 | unsigned long target_frequency; | 632 | unsigned long target_frequency; |
@@ -754,7 +755,7 @@ static int s3c24xx_i2c_init(struct s3c24xx_i2c *i2c) | |||
754 | 755 | ||
755 | /* get the plafrom data */ | 756 | /* get the plafrom data */ |
756 | 757 | ||
757 | pdata = i2c->dev->platform_data; | 758 | pdata = i2c->pdata; |
758 | 759 | ||
759 | /* inititalise the gpio */ | 760 | /* inititalise the gpio */ |
760 | 761 | ||
@@ -793,7 +794,7 @@ static int s3c24xx_i2c_init(struct s3c24xx_i2c *i2c) | |||
793 | static int s3c24xx_i2c_probe(struct platform_device *pdev) | 794 | static int s3c24xx_i2c_probe(struct platform_device *pdev) |
794 | { | 795 | { |
795 | struct s3c24xx_i2c *i2c; | 796 | struct s3c24xx_i2c *i2c; |
796 | struct s3c2410_platform_i2c *pdata; | 797 | struct s3c2410_platform_i2c *pdata = NULL; |
797 | struct resource *res; | 798 | struct resource *res; |
798 | int ret; | 799 | int ret; |
799 | 800 | ||
@@ -809,6 +810,15 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev) | |||
809 | return -ENOMEM; | 810 | return -ENOMEM; |
810 | } | 811 | } |
811 | 812 | ||
813 | i2c->pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); | ||
814 | if (!i2c->pdata) { | ||
815 | ret = -ENOMEM; | ||
816 | goto err_noclk; | ||
817 | } | ||
818 | |||
819 | if (pdata) | ||
820 | memcpy(i2c->pdata, pdata, sizeof(*pdata)); | ||
821 | |||
812 | strlcpy(i2c->adap.name, "s3c2410-i2c", sizeof(i2c->adap.name)); | 822 | strlcpy(i2c->adap.name, "s3c2410-i2c", sizeof(i2c->adap.name)); |
813 | i2c->adap.owner = THIS_MODULE; | 823 | i2c->adap.owner = THIS_MODULE; |
814 | i2c->adap.algo = &s3c24xx_i2c_algorithm; | 824 | i2c->adap.algo = &s3c24xx_i2c_algorithm; |
@@ -903,7 +913,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev) | |||
903 | * being bus 0. | 913 | * being bus 0. |
904 | */ | 914 | */ |
905 | 915 | ||
906 | i2c->adap.nr = pdata->bus_num; | 916 | i2c->adap.nr = i2c->pdata->bus_num; |
907 | 917 | ||
908 | ret = i2c_add_numbered_adapter(&i2c->adap); | 918 | ret = i2c_add_numbered_adapter(&i2c->adap); |
909 | if (ret < 0) { | 919 | if (ret < 0) { |