Linux IIO development
 help / color / mirror / Atom feed
* [PATCH 0/3] Add support for more stk3311 variant
@ 2024-05-21 15:34 Barnabás Czémán
  2024-05-21 15:34 ` [PATCH 1/3] iio: light: stk3310: relax failure to match id Barnabás Czémán
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Barnabás Czémán @ 2024-05-21 15:34 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen
  Cc: linux-iio, linux-kernel, Barnabás Czémán

This patch series remove probe failing when a compatible variant's chip id is not
defined in the driver like stk3311-a and make chip id additions easier.
It adds stk3311-a and stk3311-s34 chip ids.

I have tested stk3311-a in Xiaomi Redmi S2 (ysl) and Xiaom Redmi 5
(rosy),
it has 0x15 as chip id.

stk3311-s34 chip id comes from this thread it should be compatible with
this driver:
https://lore.kernel.org/linux-iio/20200703194406.110855-1-megous@megous.com/

Signed-off-by: Barnabás Czémán <trabarni@gmail.com>
---
Barnabás Czémán (3):
      iio: light: stk3310: relax failure to match id
      iio: light: stk3310: make chip id check expandable
      iio: light: stk3310: support more stk3311 variants

 drivers/iio/light/stk3310.c | 31 ++++++++++++++++++++++++-------
 1 file changed, 24 insertions(+), 7 deletions(-)
---
base-commit: 124cfbcd6d185d4f50be02d5f5afe61578916773
change-id: 20240521-stk3311-2ee6ddafb970

Best regards,
-- 
Barnabás Czémán <trabarni@gmail.com>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] iio: light: stk3310: relax failure to match id
  2024-05-21 15:34 [PATCH 0/3] Add support for more stk3311 variant Barnabás Czémán
@ 2024-05-21 15:34 ` Barnabás Czémán
  2024-05-21 15:34 ` [PATCH 2/3] iio: light: stk3310: make chip id check expandable Barnabás Czémán
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Barnabás Czémán @ 2024-05-21 15:34 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen
  Cc: linux-iio, linux-kernel, Barnabás Czémán

Relax failure to match ID to a warning rather than probe fail.
This add abilty to use other compatible variants when chip id
is not defined in the driver.

Signed-off-by: Barnabás Czémán <trabarni@gmail.com>
---
 drivers/iio/light/stk3310.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/iio/light/stk3310.c b/drivers/iio/light/stk3310.c
index 08d471438175..7cae261541c6 100644
--- a/drivers/iio/light/stk3310.c
+++ b/drivers/iio/light/stk3310.c
@@ -477,8 +477,7 @@ static int stk3310_init(struct iio_dev *indio_dev)
 	    chipid != STK3311_CHIP_ID_VAL &&
 	    chipid != STK3311X_CHIP_ID_VAL &&
 	    chipid != STK3335_CHIP_ID_VAL) {
-		dev_err(&client->dev, "invalid chip id: 0x%x\n", chipid);
-		return -ENODEV;
+		dev_warn(&client->dev, "unknown chip id: 0x%x\n", chipid);
 	}
 
 	state = STK3310_STATE_EN_ALS | STK3310_STATE_EN_PS;

-- 
2.45.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] iio: light: stk3310: make chip id check expandable
  2024-05-21 15:34 [PATCH 0/3] Add support for more stk3311 variant Barnabás Czémán
  2024-05-21 15:34 ` [PATCH 1/3] iio: light: stk3310: relax failure to match id Barnabás Czémán
@ 2024-05-21 15:34 ` Barnabás Czémán
  2024-05-21 15:34 ` [PATCH 3/3] iio: light: stk3310: support more stk3311 variants Barnabás Czémán
  2024-05-25 16:50 ` [PATCH 0/3] Add support for more stk3311 variant Jonathan Cameron
  3 siblings, 0 replies; 5+ messages in thread
From: Barnabás Czémán @ 2024-05-21 15:34 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen
  Cc: linux-iio, linux-kernel, Barnabás Czémán

Modify chip id check for support easier additions
for compatible variants.

Signed-off-by: Barnabás Czémán <trabarni@gmail.com>
---
 drivers/iio/light/stk3310.c | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/light/stk3310.c b/drivers/iio/light/stk3310.c
index 7cae261541c6..5b3fe98af9c9 100644
--- a/drivers/iio/light/stk3310.c
+++ b/drivers/iio/light/stk3310.c
@@ -81,6 +81,13 @@ static const struct reg_field stk3310_reg_field_flag_psint =
 static const struct reg_field stk3310_reg_field_flag_nf =
 				REG_FIELD(STK3310_REG_FLAG, 0, 0);
 
+static const u8 stk3310_chip_ids[] = {
+	STK3310_CHIP_ID_VAL,
+	STK3311X_CHIP_ID_VAL,
+	STK3311_CHIP_ID_VAL,
+	STK3335_CHIP_ID_VAL,
+};
+
 /* Estimate maximum proximity values with regard to measurement scale. */
 static const int stk3310_ps_max[4] = {
 	STK3310_PS_MAX_VAL / 640,
@@ -197,6 +204,16 @@ static const struct attribute_group stk3310_attribute_group = {
 	.attrs = stk3310_attributes
 };
 
+static int stk3310_check_chip_id(const u8 chip_id)
+{
+	for (int i = 0; i < ARRAY_SIZE(stk3310_chip_ids); i++) {
+		if (chip_id == stk3310_chip_ids[i])
+			return 0;
+	}
+
+	return -ENODEV;
+}
+
 static int stk3310_get_index(const int table[][2], int table_size,
 			     int val, int val2)
 {
@@ -473,12 +490,9 @@ static int stk3310_init(struct iio_dev *indio_dev)
 	if (ret < 0)
 		return ret;
 
-	if (chipid != STK3310_CHIP_ID_VAL &&
-	    chipid != STK3311_CHIP_ID_VAL &&
-	    chipid != STK3311X_CHIP_ID_VAL &&
-	    chipid != STK3335_CHIP_ID_VAL) {
+	ret = stk3310_check_chip_id(chipid);
+	if (ret < 0)
 		dev_warn(&client->dev, "unknown chip id: 0x%x\n", chipid);
-	}
 
 	state = STK3310_STATE_EN_ALS | STK3310_STATE_EN_PS;
 	ret = stk3310_set_state(data, state);

-- 
2.45.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] iio: light: stk3310: support more stk3311 variants
  2024-05-21 15:34 [PATCH 0/3] Add support for more stk3311 variant Barnabás Czémán
  2024-05-21 15:34 ` [PATCH 1/3] iio: light: stk3310: relax failure to match id Barnabás Czémán
  2024-05-21 15:34 ` [PATCH 2/3] iio: light: stk3310: make chip id check expandable Barnabás Czémán
@ 2024-05-21 15:34 ` Barnabás Czémán
  2024-05-25 16:50 ` [PATCH 0/3] Add support for more stk3311 variant Jonathan Cameron
  3 siblings, 0 replies; 5+ messages in thread
From: Barnabás Czémán @ 2024-05-21 15:34 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen
  Cc: linux-iio, linux-kernel, Barnabás Czémán

Add support for more stk3311 variants like stk3311-a
and stk3311-s34, they are register compatible but they
have different chip ids.

Signed-off-by: Barnabás Czémán <trabarni@gmail.com>
---
 drivers/iio/light/stk3310.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/iio/light/stk3310.c b/drivers/iio/light/stk3310.c
index 5b3fe98af9c9..2905c9feff1a 100644
--- a/drivers/iio/light/stk3310.c
+++ b/drivers/iio/light/stk3310.c
@@ -37,6 +37,8 @@
 
 #define STK3310_CHIP_ID_VAL			0x13
 #define STK3311_CHIP_ID_VAL			0x1D
+#define STK3311A_CHIP_ID_VAL			0x15
+#define STK3311S34_CHIP_ID_VAL			0x1E
 #define STK3311X_CHIP_ID_VAL			0x12
 #define STK3335_CHIP_ID_VAL			0x51
 #define STK3310_PSINT_EN			0x01
@@ -83,6 +85,8 @@ static const struct reg_field stk3310_reg_field_flag_nf =
 
 static const u8 stk3310_chip_ids[] = {
 	STK3310_CHIP_ID_VAL,
+	STK3311A_CHIP_ID_VAL,
+	STK3311S34_CHIP_ID_VAL,
 	STK3311X_CHIP_ID_VAL,
 	STK3311_CHIP_ID_VAL,
 	STK3335_CHIP_ID_VAL,

-- 
2.45.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/3] Add support for more stk3311 variant
  2024-05-21 15:34 [PATCH 0/3] Add support for more stk3311 variant Barnabás Czémán
                   ` (2 preceding siblings ...)
  2024-05-21 15:34 ` [PATCH 3/3] iio: light: stk3310: support more stk3311 variants Barnabás Czémán
@ 2024-05-25 16:50 ` Jonathan Cameron
  3 siblings, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2024-05-25 16:50 UTC (permalink / raw)
  To: Barnabás Czémán
  Cc: Lars-Peter Clausen, linux-iio, linux-kernel

On Tue, 21 May 2024 17:34:50 +0200
Barnabás Czémán <trabarni@gmail.com> wrote:

> This patch series remove probe failing when a compatible variant's chip id is not
> defined in the driver like stk3311-a and make chip id additions easier.
> It adds stk3311-a and stk3311-s34 chip ids.
> 
> I have tested stk3311-a in Xiaomi Redmi S2 (ysl) and Xiaom Redmi 5
> (rosy),
> it has 0x15 as chip id.
> 
> stk3311-s34 chip id comes from this thread it should be compatible with
> this driver:
> https://lore.kernel.org/linux-iio/20200703194406.110855-1-megous@megous.com/
> 
> Signed-off-by: Barnabás Czémán <trabarni@gmail.com>
Nice small and well presented series.  Thanks!

Applied to the togreg branch of iio.git.  Note I'll rebase that on rc1 in a day
or two and it will initially just be pushed out a testing for 0-day to
see if it can find anythign we missed.

Thanks,

Jonathan

> ---
> Barnabás Czémán (3):
>       iio: light: stk3310: relax failure to match id
>       iio: light: stk3310: make chip id check expandable
>       iio: light: stk3310: support more stk3311 variants
> 
>  drivers/iio/light/stk3310.c | 31 ++++++++++++++++++++++++-------
>  1 file changed, 24 insertions(+), 7 deletions(-)
> ---
> base-commit: 124cfbcd6d185d4f50be02d5f5afe61578916773
> change-id: 20240521-stk3311-2ee6ddafb970
> 
> Best regards,


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-05-25 16:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-21 15:34 [PATCH 0/3] Add support for more stk3311 variant Barnabás Czémán
2024-05-21 15:34 ` [PATCH 1/3] iio: light: stk3310: relax failure to match id Barnabás Czémán
2024-05-21 15:34 ` [PATCH 2/3] iio: light: stk3310: make chip id check expandable Barnabás Czémán
2024-05-21 15:34 ` [PATCH 3/3] iio: light: stk3310: support more stk3311 variants Barnabás Czémán
2024-05-25 16:50 ` [PATCH 0/3] Add support for more stk3311 variant Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox