Skip to contentSkip to conversation

i2c: cpm: Remove linux,i2c-index conversion from be32

PATCH Applied Christophe Leroy 4 participants 4 messages Dec 6, 2023 – Dec 19, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 i2c: cpm: Remove linux,i2c-index conversion from be32

sparse reports an error on some data that gets converted from be32.

That's because that data is typed u32 instead of __be32.

The type is correct, the be32_to_cpu() conversion is not.

Remove the conversion.

---
v2: Use u32 directly, remove be32_to_cpu().

---
 drivers/i2c/busses/i2c-cpm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-cpm.c +1 -1
index 9a664abf734d..771d60bc8d71 100644
@@ -658,7 +658,7 @@ static int cpm_i2c_probe(struct platform_device *ofdev)
 	/* register new adapter to i2c module... */
 
 	data = of_get_property(ofdev->dev.of_node, "linux,i2c-index", &len);
-	cpm->adap.nr = (data && len == 4) ? be32_to_cpup(data) : -1;
+	cpm->adap.nr = (data && len == 4) ? *data : -1;
 	result = i2c_add_numbered_adapter(&cpm->adap);
 
 	if (result < 0)
Signature · 1 line
2.41.0
maintainer Acked-by on v2 1/1
#1 lore raw

Am 06.12.2023 um 23:24 schrieb Christophe Leroy:

Quoted 30 lines

sparse reports an error on some data that gets converted from be32.

That's because that data is typed u32 instead of __be32.

The type is correct, the be32_to_cpu() conversion is not.

Remove the conversion.

---
v2: Use u32 directly, remove be32_to_cpu().

---
  drivers/i2c/busses/i2c-cpm.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-cpm.c +1 -1
index 9a664abf734d..771d60bc8d71 100644
@@ -658,7 +658,7 @@ static int cpm_i2c_probe(struct platform_device *ofdev)
  	/* register new adapter to i2c module... */
 
  	data = of_get_property(ofdev->dev.of_node, "linux,i2c-index", &len);
-	cpm->adap.nr = (data && len == 4) ? be32_to_cpup(data) : -1;
+	cpm->adap.nr = (data && len == 4) ? *data : -1;
  	result = i2c_add_numbered_adapter(&cpm->adap);
 
  	if (result < 0)
maintainer Reviewed-by on v2 1/1
#2 lore raw
In reply to Christophe Leroy

Hi Christophe,

Quoted 22 lines · Christophe Leroy

sparse reports an error on some data that gets converted from be32.

That's because that data is typed u32 instead of __be32.

The type is correct, the be32_to_cpu() conversion is not.

Remove the conversion.

---
v2: Use u32 directly, remove be32_to_cpu().

---
 drivers/i2c/busses/i2c-cpm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-cpm.c +0 -0
index 9a664abf734d..771d60bc8d71 100644

drivers/i2c/busses/i2c-cpm.c static int cpm_i2c_probe(struct platform_device *ofdev) · line 661

Quoted 5 lines
drivers/i2c/busses/i2c-cpm.c +1 -1
@@ -658,7 +658,7 @@ static int cpm_i2c_probe(struct platform_device *ofdev)
 	/* register new adapter to i2c module... */
 
 	data = of_get_property(ofdev->dev.of_node, "linux,i2c-index", &len);
-	cpm->adap.nr = (data && len == 4) ? be32_to_cpup(data) : -1;
+	cpm->adap.nr = (data && len == 4) ? *data : -1;

thanks!

Andi

Applied
#3 lore raw
In reply to Christophe Leroy
Quoted 11 lines · Christophe Leroy

sparse reports an error on some data that gets converted from be32.

That's because that data is typed u32 instead of __be32.

The type is correct, the be32_to_cpu() conversion is not.

Remove the conversion.

Applied to for-next, thanks!