Re: [PATCH v4 2/2] iio: proximity: Add driver support for vcnl3020 proximity sensor

From: Andy Shevchenko
Date: Sat Mar 28 2020 - 14:56:55 EST


On Sat, Mar 28, 2020 at 5:11 PM Jonathan Cameron <jic23@xxxxxxxxxx> wrote:
> On Fri, 27 Mar 2020 13:49:54 +0300
> Ivan Mikhaylov <i.mikhaylov@xxxxxxxxx> wrote:

...

> > Datasheet: http://www.vishay.com/docs/84150/vcnl3020.pdf
> > Signed-off-by: Ivan Mikhaylov <i.mikhaylov@xxxxxxxxx>
> A few things inline.
>
> I note Andy suggested a Datasheet tag, but has it actually been
> standardised?

I don't think so, but I bet it's a good idea to have it.

...

> > + rc = device_property_read_u32(data->dev, "led-current", &led_current);
>
> The presence of a firmware read (dt / acpi etc) means that the i2c id table
> isn't actually useful for probing.

...in case if there are no defaults hard coded in the driver.

> > + if (rc) {
> > + dev_err(data->dev, "Couldn't get led current (%d)", rc);
> > + return rc;
> > + }

...

> > + rc = regmap_read(data->regmap, VCNL_PS_RESULT_HI, &hi);
> > + if (rc)
> > + goto err_unlock;
> > + dev_dbg(data->dev, "result high byte 0x%x", hi);
> > +
> > + rc = regmap_read(data->regmap, VCNL_PS_RESULT_LO, &lo);
> > + if (rc)
> > + goto err_unlock;
>
> These are neigbouring registers. Can you not get away with a bulk read?
> The datasheet suggests the device does auto address incrementing.
>
> If you do that, you can read directly into an __be16/__le16 (I haven't
> checked which) and do an endian conversion to whatever the cpu is
> using.

Oh, indeed. How I missed this during my review? :-)

--
With Best Regards,
Andy Shevchenko