Message ID | 20200325151211.19949-1-i.mikhaylov@yadro.com |
---|---|
Headers | show |
Series | iio: proximity: driver for vcnl3020 | expand |
On Wed, Mar 25, 2020 at 5:14 PM Ivan Mikhaylov <i.mikhaylov@yadro.com> wrote: > > Add proximity sensor driver for Vishay vcnl3020. Only on-demand > measurement is supported for now. > You missed chagelog here. (For the future, please, don't miss, but now send a followup message what you have done in v2) > Ivan Mikhaylov (2): > iio: proximity: provide device tree binding document > iio: proximity: Add driver support for vcnl3020 proximity sensor > > .../bindings/iio/proximity/vcnl3020.yaml | 47 ++++ > drivers/iio/proximity/Kconfig | 10 + > drivers/iio/proximity/Makefile | 1 + > drivers/iio/proximity/vcnl3020.c | 242 ++++++++++++++++++ > 4 files changed, 300 insertions(+) > create mode 100644 Documentation/devicetree/bindings/iio/proximity/vcnl3020.yaml > create mode 100644 drivers/iio/proximity/vcnl3020.c > > -- > 2.21.1 >
On Wed, Mar 25, 2020 at 5:14 PM Ivan Mikhaylov <i.mikhaylov@yadro.com> wrote: > > Proximity sensor driver based on light/vcnl4000.c code. > For now supports only the single on-demand measurement. > > The VCNL3020 is a fully integrated proximity sensor. Fully > integrated means that the infrared emitter is included in the > package. It has 16-bit resolution. It includes a signal > processing IC and features standard I2C communication > interface. It features an interrupt function. Thank you for an update, my comments below. ... > +config VCNL3020 > + tristate "VCNL3020 proximity sensor" > + depends on I2C REGMAP_I2C ... > +struct vcnl3020_data { > + struct regmap *regmap; > + struct i2c_client *client; Since you have switched to regmap I2C API, do you really need client here, perhaps struct device *dev would be enough? > + u8 rev; > + struct mutex lock; > +}; ... > + rc = regmap_read(data->regmap, VCNL_PROD_REV, ®); > + if (rc < 0) { I think you may drop all these ' < 0' checks for regmap, otherwise can you elaborate what positive return code, if any, means? > + dev_err(&data->client->dev, > + "Error (%d) reading product revision", rc); > + return rc; > + } ... > + rc = regmap_write(data->regmap, VCNL_LED_CURRENT, led_current); > + if (rc < 0) { ...after above change... > + dev_err(&data->client->dev, "Error (%d) setting LED current", > + rc); > + return rc; > + } > + > + return 0; ...simple return rc; here. ... > + /* wait for data to become ready */ > + do { > + rc = regmap_read(data->regmap, VCNL_COMMAND, ®); > + if (rc < 0) > + goto err_unlock; > + if (reg & VCNL_PS_RDY) > + break; > + msleep(20); /* measurement takes up to 100 ms */ > + } while (--tries); regmap_read_poll_timeput() ... > +static const struct iio_chan_spec vcnl3020_channels[] = { > + { > + .type = IIO_PROXIMITY, > + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), > + } Leave comma here. > +};
On Wed, 2020-03-25 at 18:12 +0300, Ivan Mikhaylov wrote: > Add proximity sensor driver for Vishay vcnl3020. Only on-demand > measurement is supported for now. > > Ivan Mikhaylov (2): > iio: proximity: provide device tree binding document > iio: proximity: Add driver support for vcnl3020 proximity sensor > > .../bindings/iio/proximity/vcnl3020.yaml | 47 ++++ > drivers/iio/proximity/Kconfig | 10 + > drivers/iio/proximity/Makefile | 1 + > drivers/iio/proximity/vcnl3020.c | 242 ++++++++++++++++++ > 4 files changed, 300 insertions(+) > create mode 100644 > Documentation/devicetree/bindings/iio/proximity/vcnl3020.yaml > create mode 100644 drivers/iio/proximity/vcnl3020.c > Changes from v1: 1. using regmap interface instead of i2c_smbus_* calls. 2. switch from probe to probe_new. 3. s32/int32_t -> int