Message ID | 20240923-veml6035-v2-2-58c72a0df31c@gmail.com (mailing list archive) |
---|---|
State | Changes Requested |
Headers | show |
Series | iio: light: veml6030: fix issues and add support for veml6035 | expand |
On Mon, 23 Sep 2024 00:17:50 +0200 Javier Carrasco <javier.carrasco.cruz@gmail.com> wrote: > The veml6030 requires a delay of 4 ms after activating the sensor. That > is done correctly during the hw initialization, but it's missing after > resuming. > > Move the delay to the power on function to make sure that it is always > observerd. When at it, use fsleep() instead of usleep_range() as such a > narrow range is not required. > > Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> > --- > drivers/iio/light/veml6030.c | 14 ++++++++++---- > 1 file changed, 10 insertions(+), 4 deletions(-) > > diff --git a/drivers/iio/light/veml6030.c b/drivers/iio/light/veml6030.c > index a3dfe56b7eec..e412a22474e0 100644 > --- a/drivers/iio/light/veml6030.c > +++ b/drivers/iio/light/veml6030.c > @@ -144,8 +144,17 @@ static const struct attribute_group veml6030_event_attr_group = { > > static int veml6030_als_pwr_on(struct veml6030_data *data) > { > - return regmap_clear_bits(data->regmap, VEML6030_REG_ALS_CONF, > + int ret; > + > + ret = regmap_clear_bits(data->regmap, VEML6030_REG_ALS_CONF, sneaky double space on the line above. Should just be 1. > VEML6030_ALS_SD); Which will require this be indented by 1 less as well and hence an extra line of apparent change. > + if (ret) > + return ret; > + > + /* Wait 4 ms to let processor & oscillator start correctly */ > + fsleep(4000); > + > + return 0; > } > > static int veml6030_als_shut_down(struct veml6030_data *data) > @@ -767,9 +776,6 @@ static int veml6030_hw_init(struct iio_dev *indio_dev) > return ret; > } > > - /* Wait 4 ms to let processor & oscillator start correctly */ > - usleep_range(4000, 4002); > - > /* Clear stale interrupt status bits if any during start */ > ret = regmap_read(data->regmap, VEML6030_REG_ALS_INT, &val); > if (ret < 0) { >
diff --git a/drivers/iio/light/veml6030.c b/drivers/iio/light/veml6030.c index a3dfe56b7eec..e412a22474e0 100644 --- a/drivers/iio/light/veml6030.c +++ b/drivers/iio/light/veml6030.c @@ -144,8 +144,17 @@ static const struct attribute_group veml6030_event_attr_group = { static int veml6030_als_pwr_on(struct veml6030_data *data) { - return regmap_clear_bits(data->regmap, VEML6030_REG_ALS_CONF, + int ret; + + ret = regmap_clear_bits(data->regmap, VEML6030_REG_ALS_CONF, VEML6030_ALS_SD); + if (ret) + return ret; + + /* Wait 4 ms to let processor & oscillator start correctly */ + fsleep(4000); + + return 0; } static int veml6030_als_shut_down(struct veml6030_data *data) @@ -767,9 +776,6 @@ static int veml6030_hw_init(struct iio_dev *indio_dev) return ret; } - /* Wait 4 ms to let processor & oscillator start correctly */ - usleep_range(4000, 4002); - /* Clear stale interrupt status bits if any during start */ ret = regmap_read(data->regmap, VEML6030_REG_ALS_INT, &val); if (ret < 0) {
The veml6030 requires a delay of 4 ms after activating the sensor. That is done correctly during the hw initialization, but it's missing after resuming. Move the delay to the power on function to make sure that it is always observerd. When at it, use fsleep() instead of usleep_range() as such a narrow range is not required. Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> --- drivers/iio/light/veml6030.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)