Hi Vishwanath,

On Thu, Jul 22, 2010 at 14:25:45, Kamalapur, Vishwanath wrote:
> From: vishwa <[email protected]>
>
> With current implementation, when I2C is used as a module,
> for slave devices which operate at different frequencies,
> the bus frequency needs to be modified in the board
> configuration file and kernel needs to be re-built.
>
> This patch addresses this issue by adding bus frequency as
> module parameter.
>
> Signed-off-by: vishwa <[email protected]>
> ---
>  drivers/i2c/busses/i2c-davinci.c |   11 +++++++++++
>  1 files changed, 11 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-davinci.c 
> b/drivers/i2c/busses/i2c-davinci.c
> index 2222c87..ba0817c 100644
> --- a/drivers/i2c/busses/i2c-davinci.c
> +++ b/drivers/i2c/busses/i2c-davinci.c
> @@ -98,6 +98,13 @@
>  #define DAVINCI_I2C_IMR_NACK BIT(1)
>  #define DAVINCI_I2C_IMR_AL   BIT(0)
>
> +/*
> + * Following are the default values for the module parameters
> + * If user didn't specify the bus frequency, driver will
> + * take the bus freq from board configuration.
> + */

No need of this comment, I think.

> +static int i2c_davinci_busfreq;
> +
>  struct davinci_i2c_dev {
>       struct device           *dev;
>       void __iomem            *base;
> @@ -217,6 +224,9 @@ static void i2c_davinci_calc_clk_dividers(struct 
> davinci_i2c_dev *dev)
>               psc++;  /* better to run under spec than over */
>       d = (psc >= 2) ? 5 : 7 - psc;
>
> +     if (i2c_davinci_busfreq != 0)
> +             pdata->bus_freq = i2c_davinci_busfreq;
> +

This is rather done in davinci_i2c_init() right after the pdata is sanitized.

>       clk = ((input_clock / (psc + 1)) / (pdata->bus_freq * 1000)) - (d << 1);
>       clkh = clk >> 1;
>       clkl = clk - clkh;
> @@ -818,6 +828,7 @@ static void __exit davinci_i2c_exit_driver(void)
>       platform_driver_unregister(&davinci_i2c_driver);
>  }
>  module_exit(davinci_i2c_exit_driver);
> +module_param(i2c_davinci_busfreq, int, 0);

Module parameters are usually defined at the beginning
of the file. Please add a MODULE_PARM_DESC() as well.

You can check drivers/mmc/host/davinci_mmc.c for an example.

Once done, please submit to I2C subsystem list and CC the I2C
maintainers and this list.

Thanks,
Sekhar

_______________________________________________
Davinci-linux-open-source mailing list
[email protected]
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source

Reply via email to