Re: [PATCH v6 5/6] i2c: Add support for Intel LJCA USB I2C driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Ye,

looks good, just a few questions:

On Fri, Mar 24, 2023 at 01:21:12AM +0800, Ye Xiang wrote:
> This patch implements the I2C function of Intel USB-I2C/GPIO/SPI adapter

also here, please keep using the imperative form.

> device named "La Jolla Cove Adapter" (LJCA). It communicate with LJCA
> I2c module with specific protocol through interfaces exported by LJCA USB
> driver.
> 
> Signed-off-by: Ye Xiang <xiang.ye@xxxxxxxxx>

[...]

> +enum ljca_xfer_type {
> +	LJCA_I2C_READ_XFER_TYPE,
> +	LJCA_I2C_WRITE_XFER_TYPE,
> +};
> +
> +/* I2C r/w Flags */
> +#define LJCA_I2C_SLAVE_TRANSFER_WRITE	(0)
> +#define LJCA_I2C_SLAVE_TRANSFER_READ	(1)

the enum above and the bits here look a bit redundant to me as
they are the same thing.

What's the point for writing something like:

 if (type == LJCA_I2C_READ_XFER_TYPE)
	addr |= LJCA_I2C_SLAVE_TRANSFER_WRITE

when the two are the same. You are just adding confusion.

As this is a bit field, you can just keep the defines.

[...]

> +static u8 ljca_i2c_format_slave_addr(u8 slave_addr, u8 type)
> +{
> +	return (slave_addr << 1) | (type == LJCA_I2C_READ_XFER_TYPE) ?
> +		       LJCA_I2C_SLAVE_TRANSFER_READ :
> +		       LJCA_I2C_SLAVE_TRANSFER_WRITE;
> +}

How about:

	return (slave_addr << 1) | !!type;

BTW, am I reading correctly that the address here is composed as:

   7     6     5     5     3     2     1    0
 ADDR7 ADDR6 ADDR5 ADDR4 ADDR3 ADDR2 ADDR1 R/W

[...]

> +static u32 ljca_i2c_func(struct i2c_adapter *adap)
> +{
> +	return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;

how is the smbus supported here?

Andi



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux