[PATCH V1 2/2] i2c: iproc: add slave pec support

Andy Shevchenko andy.shevchenko at gmail.com
Thu Jul 16 06:14:13 EDT 2020


On Thu, Jul 16, 2020 at 11:14 AM Rayagonda Kokatanur
<rayagonda.kokatanur at broadcom.com> wrote:
>
> Iproc supports PEC computation and checking in both Master
> and Slave mode.
>
> This patch adds support for PEC in slave mode.

...

> -#define S_RX_PEC_ERR_SHIFT           29
> +#define S_RX_PEC_ERR_SHIFT           28
> +#define S_RX_PEC_ERR_MASK            0x3
> +#define S_RX_PEC_ERR                 0x1

This needs to be explained in the commit message, in particular why
this change makes no regression.

...

> +static int bcm_iproc_smbus_check_slave_pec(struct bcm_iproc_i2c_dev *iproc_i2c,
> +                                          u32 val)
> +{
> +       u8 err_status;

> +       int ret = 0;

Completely redundant variable.

> +       if (!iproc_i2c->en_s_pec)
> +               return ret;

return 0;

> +       err_status = (u8)((val >> S_RX_PEC_ERR_SHIFT) & S_RX_PEC_ERR_MASK);

Why casting?

> +       if (err_status == S_RX_PEC_ERR) {
> +               dev_err(iproc_i2c->device, "Slave PEC error\n");

> +               ret = -EBADMSG;

return ...

> +       }
> +
> +       return ret;

return 0;

> +}

...

> +                       if (rx_status == I2C_SLAVE_RX_END) {
> +                               int ret;
> +
> +                               ret = bcm_iproc_smbus_check_slave_pec(iproc_i2c,
> +                                                                     val);

One line looks better.

> +                               if (!ret)

Why not positive conditional?

> +                                       i2c_slave_event(iproc_i2c->slave,
> +                                                       I2C_SLAVE_STOP, &value);
> +                               else
> +                                       i2c_slave_event(iproc_i2c->slave,
> +                                                       I2C_SLAVE_PEC_ERR,
> +                                                       &value);
> +                       }

-- 
With Best Regards,
Andy Shevchenko



More information about the linux-arm-kernel mailing list