mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Javier Carrasco <javier.carrasco.cruz@gmail.com>
To: Jonathan Cameron <jic23@kernel.org>,
	 Lars-Peter Clausen <lars@metafoo.de>,
	Rob Herring <robh@kernel.org>,
	 Krzysztof Kozlowski <krzk+dt@kernel.org>,
	 Conor Dooley <conor+dt@kernel.org>
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	 devicetree@vger.kernel.org,
	 Javier Carrasco <javier.carrasco.cruz@gmail.com>
Subject: [PATCH 2/4] iio: light: veml6070: use field to set integration time
Date: Thu, 17 Oct 2024 23:39:26 +0200	[thread overview]
Message-ID: <20241017-veml6070-integration-time-v1-2-3507d17d562a@gmail.com> (raw)
In-Reply-To: <20241017-veml6070-integration-time-v1-0-3507d17d562a@gmail.com>

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(-)

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;

-- 
2.43.0


  parent reply	other threads:[~2024-10-17 21:39 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-17 21:39 [PATCH 0/4] iio: light: veml6070: add integration time and minor cleanups Javier Carrasco
2024-10-17 21:39 ` [PATCH 1/4] iio: light: veml6070: use unsigned int instead of unsigned Javier Carrasco
2024-10-19 14:18   ` Jonathan Cameron
2024-10-17 21:39 ` Javier Carrasco [this message]
2024-10-19 14:19   ` [PATCH 2/4] iio: light: veml6070: use field to set integration time Jonathan Cameron
2024-10-17 21:39 ` [PATCH 3/4] dt-bindings: iio: light: veml6075: document rset-kohms Javier Carrasco
2024-10-18 13:29   ` Rob Herring
2024-10-19 14:16   ` Jonathan Cameron
2024-10-17 21:39 ` [PATCH 4/4] iio: light: veml6070: add support for integration time Javier Carrasco
2024-10-18 14:05   ` Javier Carrasco
2024-10-19 14:21   ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241017-veml6070-integration-time-v1-2-3507d17d562a@gmail.com \
    --to=javier.carrasco.cruz@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=jic23@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®