diff mbox series

[2/4] iio: light: veml6070: use field to set integration time

Message ID 20241017-veml6070-integration-time-v1-2-3507d17d562a@gmail.com (mailing list archive)
State Accepted
Headers show
Series iio: light: veml6070: add integration time and minor cleanups. | expand

Commit Message

Javier Carrasco Oct. 17, 2024, 9:39 p.m. UTC
Define the integration time within the configuration register as a field
to easy its handling as an index, preparing the driver to support
configurable integration times.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
---
 drivers/iio/light/veml6070.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Jonathan Cameron Oct. 19, 2024, 2:19 p.m. UTC | #1
On Thu, 17 Oct 2024 23:39:26 +0200
Javier Carrasco <javier.carrasco.cruz@gmail.com> wrote:

> Define the integration time within the configuration register as a field
> to easy its handling as an index, preparing the driver to support
> configurable integration times.
> 
> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Applied this patch.

Thanks,

Jonathan
diff mbox series

Patch

diff --git a/drivers/iio/light/veml6070.c b/drivers/iio/light/veml6070.c
index 484b767df481..d11ae00f61f8 100644
--- a/drivers/iio/light/veml6070.c
+++ b/drivers/iio/light/veml6070.c
@@ -9,6 +9,7 @@ 
  * TODO: integration time, ACK signal
  */
 
+#include <linux/bitfield.h>
 #include <linux/module.h>
 #include <linux/i2c.h>
 #include <linux/mutex.h>
@@ -28,7 +29,7 @@ 
 #define VEML6070_COMMAND_RSRVD	BIT(1) /* reserved, set to 1 */
 #define VEML6070_COMMAND_SD	BIT(0) /* shutdown mode when set */
 
-#define VEML6070_IT_10	0x04 /* integration time 1x */
+#define VEML6070_IT_10	0x01 /* integration time 1x */
 
 struct veml6070_data {
 	struct i2c_client *client1;
@@ -172,8 +173,8 @@  static int veml6070_probe(struct i2c_client *client)
 		return dev_err_probe(&client->dev, PTR_ERR(data->client2),
 				     "i2c device for second chip address failed\n");
 
-	data->config = VEML6070_IT_10 | VEML6070_COMMAND_RSRVD |
-		VEML6070_COMMAND_SD;
+	data->config = FIELD_PREP(VEML6070_COMMAND_IT, VEML6070_IT_10) |
+		VEML6070_COMMAND_RSRVD | VEML6070_COMMAND_SD;
 	ret = i2c_smbus_write_byte(data->client1, data->config);
 	if (ret < 0)
 		return ret;