[U-Boot] [PATCH 28/51] i2c: ihs_i2c: Prepare DM conversion

Simon Glass sjg at chromium.org
Wed Jul 19 09:05:39 UTC 2017


On 14 July 2017 at 05:55, Mario Six <mario.six at gdsys.cc> wrote:
> Prepare the function interface of the ihs_i2c driver for DM conversion
> in a future patch.
>
> While we're at it, fix some style violations, and make the code more readable.
>
> Signed-off-by: Mario Six <mario.six at gdsys.cc>
> ---
>
>  drivers/i2c/ihs_i2c.c | 74 +++++++++++++++++++++++++++++++--------------------
>  1 file changed, 45 insertions(+), 29 deletions(-)

Reviewed-by: Simon Glass <sjg at chromium.org>

Please see below

>
> diff --git a/drivers/i2c/ihs_i2c.c b/drivers/i2c/ihs_i2c.c
> index 29612e69fe..e066ad53db 100644
> --- a/drivers/i2c/ihs_i2c.c
> +++ b/drivers/i2c/ihs_i2c.c

> @@ -182,13 +182,29 @@ static int ihs_i2c_probe(struct i2c_adapter *adap, uchar chip)
>  static int ihs_i2c_read(struct i2c_adapter *adap, uchar chip, uint addr,
>                         int alen, uchar *buffer, int len)
>  {
> -       return ihs_i2c_access(adap, chip, addr, alen, buffer, len, true);
> +       u8 addr_bytes[4];
> +
> +       addr_bytes[0] = (addr >> 0) & 0xFF;
> +       addr_bytes[1] = (addr >> 8) & 0xFF;
> +       addr_bytes[2] = (addr >> 16) & 0xFF;
> +       addr_bytes[3] = (addr >> 24) & 0xFF;

Can you use put_unaligned_le32() or similar?

> +
> +       return ihs_i2c_access(adap, chip, addr_bytes, alen, buffer, len,
> +                             I2COP_READ);
>  }
>
>  static int ihs_i2c_write(struct i2c_adapter *adap, uchar chip, uint addr,
>                          int alen, uchar *buffer, int len)
>  {
> -       return ihs_i2c_access(adap, chip, addr, alen, buffer, len, false);
> +       u8 addr_bytes[4];
> +
> +       addr_bytes[0] = (addr >> 0) & 0xFF;
> +       addr_bytes[1] = (addr >> 8) & 0xFF;
> +       addr_bytes[2] = (addr >> 16) & 0xFF;
> +       addr_bytes[3] = (addr >> 24) & 0xFF;
> +
> +       return ihs_i2c_access(adap, chip, addr_bytes, alen, buffer, len,
> +                             I2COP_WRITE);
>  }
>
>  static unsigned int ihs_i2c_set_bus_speed(struct i2c_adapter *adap,
> --
> 2.11.0
>

Regards,
Simon


More information about the U-Boot mailing list