* [PATCH] iio: light: cm3232: Reset before reading HW ID
@ 2024-11-14 9:13 Cibil Pankiras
2024-11-24 12:58 ` Jonathan Cameron
0 siblings, 1 reply; 4+ messages in thread
From: Cibil Pankiras @ 2024-11-14 9:13 UTC (permalink / raw)
To: linux-iio; +Cc: Cibil Pankiras, Kevin Tsai
[-- Attachment #1: Type: text/plain, Size: 1641 bytes --]
According to the datasheet, the chip requires a reset before any data
can be read. This commit moves the device identification logic to
occur after the reset to ensure proper initialization.
Cc: Kevin Tsai <ktsai@capellamicro.com>
Signed-off-by: Cibil Pankiras <cibil.pankiras@aerq.com>
---
drivers/iio/light/cm3232.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/iio/light/cm3232.c b/drivers/iio/light/cm3232.c
index b6288dd25bbf..5b00ad2a014e 100644
--- a/drivers/iio/light/cm3232.c
+++ b/drivers/iio/light/cm3232.c
@@ -89,6 +89,15 @@ static int cm3232_reg_init(struct cm3232_chip *chip)
chip->als_info = &cm3232_als_info_default;
+ /* Disable and reset device */
+ chip->regs_cmd = CM3232_CMD_ALS_DISABLE | CM3232_CMD_ALS_RESET;
+ ret = i2c_smbus_write_byte_data(client, CM3232_REG_ADDR_CMD,
+ chip->regs_cmd);
+ if (ret < 0) {
+ dev_err(&chip->client->dev, "Error writing reg_cmd\n");
+ return ret;
+ }
+
/* Identify device */
ret = i2c_smbus_read_word_data(client, CM3232_REG_ADDR_ID);
if (ret < 0) {
@@ -99,15 +108,6 @@ static int cm3232_reg_init(struct cm3232_chip *chip)
if ((ret & 0xFF) != chip->als_info->hw_id)
return -ENODEV;
- /* Disable and reset device */
- chip->regs_cmd = CM3232_CMD_ALS_DISABLE | CM3232_CMD_ALS_RESET;
- ret = i2c_smbus_write_byte_data(client, CM3232_REG_ADDR_CMD,
- chip->regs_cmd);
- if (ret < 0) {
- dev_err(&chip->client->dev, "Error writing reg_cmd\n");
- return ret;
- }
-
/* Register default value */
chip->regs_cmd = chip->als_info->regs_cmd_default;
--
2.34.1
[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 4147 bytes --]
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] iio: light: cm3232: Reset before reading HW ID
2024-11-14 9:13 [PATCH] iio: light: cm3232: Reset before reading HW ID Cibil Pankiras
@ 2024-11-24 12:58 ` Jonathan Cameron
0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2024-11-24 12:58 UTC (permalink / raw)
To: Cibil Pankiras; +Cc: linux-iio, Kevin Tsai
On Thu, 14 Nov 2024 10:13:23 +0100
Cibil Pankiras <cibil.pankiras@aerq.com> wrote:
> According to the datasheet, the chip requires a reset before any data
> can be read. This commit moves the device identification logic to
> occur after the reset to ensure proper initialization.
>
> Cc: Kevin Tsai <ktsai@capellamicro.com>
> Signed-off-by: Cibil Pankiras <cibil.pankiras@aerq.com>
Hi Cibil,
This is an interesting corner, because if the ID register isn't going
to match, chances are that write just wrote wrong data to something else.
Ah well, the firmware should be correct so I'm not sure I care about
that change.
Applied but to the togreg branch of iio.git, not as a fix because
it does make me a little nervous and I'd like to not rush it in!
Thanks,
Jonathan
> ---
> drivers/iio/light/cm3232.c | 18 +++++++++---------
> 1 file changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/iio/light/cm3232.c b/drivers/iio/light/cm3232.c
> index b6288dd25bbf..5b00ad2a014e 100644
> --- a/drivers/iio/light/cm3232.c
> +++ b/drivers/iio/light/cm3232.c
> @@ -89,6 +89,15 @@ static int cm3232_reg_init(struct cm3232_chip *chip)
>
> chip->als_info = &cm3232_als_info_default;
>
> + /* Disable and reset device */
> + chip->regs_cmd = CM3232_CMD_ALS_DISABLE | CM3232_CMD_ALS_RESET;
> + ret = i2c_smbus_write_byte_data(client, CM3232_REG_ADDR_CMD,
> + chip->regs_cmd);
> + if (ret < 0) {
> + dev_err(&chip->client->dev, "Error writing reg_cmd\n");
> + return ret;
> + }
> +
> /* Identify device */
> ret = i2c_smbus_read_word_data(client, CM3232_REG_ADDR_ID);
> if (ret < 0) {
> @@ -99,15 +108,6 @@ static int cm3232_reg_init(struct cm3232_chip *chip)
> if ((ret & 0xFF) != chip->als_info->hw_id)
> return -ENODEV;
>
> - /* Disable and reset device */
> - chip->regs_cmd = CM3232_CMD_ALS_DISABLE | CM3232_CMD_ALS_RESET;
> - ret = i2c_smbus_write_byte_data(client, CM3232_REG_ADDR_CMD,
> - chip->regs_cmd);
> - if (ret < 0) {
> - dev_err(&chip->client->dev, "Error writing reg_cmd\n");
> - return ret;
> - }
> -
> /* Register default value */
> chip->regs_cmd = chip->als_info->regs_cmd_default;
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] iio: light: cm3232: Reset before reading HW ID
@ 2024-11-14 13:16 Cibil
2024-11-24 12:59 ` Jonathan Cameron
0 siblings, 1 reply; 4+ messages in thread
From: Cibil @ 2024-11-14 13:16 UTC (permalink / raw)
To: jic23, ktsai, lars; +Cc: linux-iio, linux-kernel, Cibil Pankiras
[-- Attachment #1: Type: text/plain, Size: 1691 bytes --]
From: Cibil Pankiras <cibil.pankiras@aerq.com>
According to the datasheet, the chip requires a reset before any data
can be read. This commit moves the device identification logic to
occur after the reset to ensure proper initialization.
Cc: Kevin Tsai <ktsai@capellamicro.com>
Signed-off-by: Cibil Pankiras <cibil.pankiras@aerq.com>
---
drivers/iio/light/cm3232.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/iio/light/cm3232.c b/drivers/iio/light/cm3232.c
index 2c80a0535d2c..db33671c448c 100644
--- a/drivers/iio/light/cm3232.c
+++ b/drivers/iio/light/cm3232.c
@@ -89,6 +89,15 @@ static int cm3232_reg_init(struct cm3232_chip *chip)
chip->als_info = &cm3232_als_info_default;
+ /* Disable and reset device */
+ chip->regs_cmd = CM3232_CMD_ALS_DISABLE | CM3232_CMD_ALS_RESET;
+ ret = i2c_smbus_write_byte_data(client, CM3232_REG_ADDR_CMD,
+ chip->regs_cmd);
+ if (ret < 0) {
+ dev_err(&chip->client->dev, "Error writing reg_cmd\n");
+ return ret;
+ }
+
/* Identify device */
ret = i2c_smbus_read_word_data(client, CM3232_REG_ADDR_ID);
if (ret < 0) {
@@ -99,15 +108,6 @@ static int cm3232_reg_init(struct cm3232_chip *chip)
if ((ret & 0xFF) != chip->als_info->hw_id)
return -ENODEV;
- /* Disable and reset device */
- chip->regs_cmd = CM3232_CMD_ALS_DISABLE | CM3232_CMD_ALS_RESET;
- ret = i2c_smbus_write_byte_data(client, CM3232_REG_ADDR_CMD,
- chip->regs_cmd);
- if (ret < 0) {
- dev_err(&chip->client->dev, "Error writing reg_cmd\n");
- return ret;
- }
-
/* Register default value */
chip->regs_cmd = chip->als_info->regs_cmd_default;
--
2.34.1
[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 4147 bytes --]
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] iio: light: cm3232: Reset before reading HW ID
2024-11-14 13:16 Cibil
@ 2024-11-24 12:59 ` Jonathan Cameron
0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2024-11-24 12:59 UTC (permalink / raw)
To: Cibil; +Cc: ktsai, lars, linux-iio, linux-kernel
On Thu, 14 Nov 2024 14:16:56 +0100
Cibil <cibil.pankiras@aerq.com> wrote:
> From: Cibil Pankiras <cibil.pankiras@aerq.com>
>
> According to the datasheet, the chip requires a reset before any data
> can be read. This commit moves the device identification logic to
> occur after the reset to ensure proper initialization.
>
> Cc: Kevin Tsai <ktsai@capellamicro.com>
> Signed-off-by: Cibil Pankiras <cibil.pankiras@aerq.com>
Hi Cibil,
If you are resending for any reason make sure you add
[RESEND to the patch title and say why under the ---
That let's people know it is the same code if they have multiple
copies.
Thanks,
Jonathan
> ---
> drivers/iio/light/cm3232.c | 18 +++++++++---------
> 1 file changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/iio/light/cm3232.c b/drivers/iio/light/cm3232.c
> index 2c80a0535d2c..db33671c448c 100644
> --- a/drivers/iio/light/cm3232.c
> +++ b/drivers/iio/light/cm3232.c
> @@ -89,6 +89,15 @@ static int cm3232_reg_init(struct cm3232_chip *chip)
>
> chip->als_info = &cm3232_als_info_default;
>
> + /* Disable and reset device */
> + chip->regs_cmd = CM3232_CMD_ALS_DISABLE | CM3232_CMD_ALS_RESET;
> + ret = i2c_smbus_write_byte_data(client, CM3232_REG_ADDR_CMD,
> + chip->regs_cmd);
> + if (ret < 0) {
> + dev_err(&chip->client->dev, "Error writing reg_cmd\n");
> + return ret;
> + }
> +
> /* Identify device */
> ret = i2c_smbus_read_word_data(client, CM3232_REG_ADDR_ID);
> if (ret < 0) {
> @@ -99,15 +108,6 @@ static int cm3232_reg_init(struct cm3232_chip *chip)
> if ((ret & 0xFF) != chip->als_info->hw_id)
> return -ENODEV;
>
> - /* Disable and reset device */
> - chip->regs_cmd = CM3232_CMD_ALS_DISABLE | CM3232_CMD_ALS_RESET;
> - ret = i2c_smbus_write_byte_data(client, CM3232_REG_ADDR_CMD,
> - chip->regs_cmd);
> - if (ret < 0) {
> - dev_err(&chip->client->dev, "Error writing reg_cmd\n");
> - return ret;
> - }
> -
> /* Register default value */
> chip->regs_cmd = chip->als_info->regs_cmd_default;
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-11-24 13:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-14 9:13 [PATCH] iio: light: cm3232: Reset before reading HW ID Cibil Pankiras
2024-11-24 12:58 ` Jonathan Cameron
-- strict thread matches above, loose matches on Subject: below --
2024-11-14 13:16 Cibil
2024-11-24 12:59 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox