[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aW57j-zfhKGp1VTm@smile.fi.intel.com>
Date: Mon, 19 Jan 2026 20:44:31 +0200
From: Andy Shevchenko <andriy.shevchenko@...el.com>
To: petr.hodina@...tonmail.com
Cc: Song Qiang <songqiang1304521@...il.com>,
Jonathan Cameron <jic23@...nel.org>,
David Lechner <dlechner@...libre.com>,
Nuno Sá <nuno.sa@...log.com>,
Andy Shevchenko <andy@...nel.org>, Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>,
Liam Girdwood <lgirdwood@...il.com>,
Mark Brown <broonie@...nel.org>, David Heidelberg <david@...t.cz>,
linux-iio@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 4/4] iio: proximity: vl53l0x-i2c: Use raw I2C access and
read full device ID
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, ®, 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
Powered by blists - more mailing lists