Re: [PATCH 4/4] iio: proximity: vl53l0x-i2c: Use raw I2C access and read full device ID

From: Andy Shevchenko

Date: Mon Jan 19 2026 - 13:44:37 EST


On Mon, Jan 19, 2026 at 06:19:58PM +0100, Petr Hodina via B4 Relay wrote:

> Replace SMBus byte reads with raw I2C transfers when reading the device
> identification registers.
>
> The VL53L0X exposes its model and revision as 16-bit registers, which are
> more accurately accessed using standard I2C send/receive operations.
> This also avoids depending on SMBus byte data support, which is not
> guaranteed on all I2C adapters.
>
> Read and log both model and revision IDs, and validate the model ID
> during probe to ensure the expected device is present.

...

> };
>
> +

Stray blank line addition.

> +static int vl53l0x_read_word(struct i2c_client *client, u8 reg, u16 *val)
> +{
> + int ret;
> + u8 buf[2];

Here and everywhere else, please, keep the reversed xmas tree ordering.

> + ret = i2c_master_send(client, &reg, 1);
> + if (ret < 0)
> + return ret;
> + if (ret != 1)
> + return -EIO;
> +
> + ret = i2c_master_recv(client, buf, 2);

sizeof(buf)

> + if (ret < 0)
> + return ret;
> + if (ret != 2)

Ditto.

> + return -EIO;
> +
> + *val = (buf[0] << 8) | buf[1];

Actually define

__be16 buf;

and use

*val = be16_to_cpu(buf);

> + return 0;
> +}

...

> static int vl53l0x_probe(struct i2c_client *client)
> {
> struct vl53l0x_data *data;
> struct iio_dev *indio_dev;
> int ret;
> + u16 model, rev;
>

Use reversed xmas tree ordering.

--
With Best Regards,
Andy Shevchenko