[PATCH v2 1/3] i2c: s3c2410: Keep a copy of platform data and use it.
Grant Likely
grant.likely at secretlab.ca
Sun Jul 31 13:51:05 EST 2011
On Fri, Jul 22, 2011 at 03:48:36PM +0530, Thomas Abraham wrote:
> 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.
>
> Signed-off-by: Thomas Abraham <thomas.abraham at linaro.org>
> ---
> drivers/i2c/busses/i2c-s3c2410.c | 7 +++++--
> 1 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
> index 6c00c10..e132168 100644
> --- a/drivers/i2c/busses/i2c-s3c2410.c
> +++ b/drivers/i2c/busses/i2c-s3c2410.c
> @@ -78,6 +78,7 @@ struct s3c24xx_i2c {
> struct resource *ioarea;
> struct i2c_adapter adap;
>
> + struct s3c2410_platform_i2c pdata;
After looking at a bunch of patches, there is another way do do this
I think. Instead of copying pdata into the private data structure, it
can remain as a pointer if the DT code uses devm_kzmalloc to allocate
a s3c2410_platform_i2c structure when needed.
I leave it up to you (and Ben) though as to which you prefer. I'm
okay either way, and you can add:
Acked-by: Grant Likely <grant.likely at secretlab.ca>
> #ifdef CONFIG_CPU_FREQ
> struct notifier_block freq_transition;
> #endif
> @@ -626,7 +627,7 @@ static int s3c24xx_i2c_calcdivisor(unsigned long clkin, unsigned int wanted,
>
> static int s3c24xx_i2c_clockrate(struct s3c24xx_i2c *i2c, unsigned int *got)
> {
> - struct s3c2410_platform_i2c *pdata = i2c->dev->platform_data;
> + struct s3c2410_platform_i2c *pdata = &i2c->pdata;
> unsigned long clkin = clk_get_rate(i2c->clk);
> unsigned int divs, div1;
> unsigned long target_frequency;
> @@ -755,7 +756,7 @@ static int s3c24xx_i2c_init(struct s3c24xx_i2c *i2c)
>
> /* get the plafrom data */
>
> - pdata = i2c->dev->platform_data;
> + pdata = &i2c->pdata;
>
> /* inititalise the gpio */
>
> @@ -810,6 +811,8 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
> return -ENOMEM;
> }
>
> + memcpy(&i2c->pdata, pdata, sizeof(*pdata));
> +
> strlcpy(i2c->adap.name, "s3c2410-i2c", sizeof(i2c->adap.name));
> i2c->adap.owner = THIS_MODULE;
> i2c->adap.algo = &s3c24xx_i2c_algorithm;
> --
> 1.6.6.rc2
>
More information about the devicetree-discuss
mailing list