Skip to contentSkip to conversation

leds: pca955x: Fix i2c_smbus_read_i2c_block_data return code check

PATCH In review Eddie James 2 participants 3 messages Sep 29, 2022 LED

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 leds: pca955x: Fix i2c_smbus_read_i2c_block_data return code check

The function returns either a negative errno or the number of bytes successfully read. So, only return for a negative return code.

Fixes c9fb275212da ("leds: pca955x: Add HW blink support")
---
 drivers/leds/leds-pca955x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/leds/leds-pca955x.c +1 -1
index cf0a9fe20086..cba9876b1187 100644
@@ -689,7 +689,7 @@ static int pca955x_probe(struct i2c_client *client)
 	err = i2c_smbus_read_i2c_block_data(client,
 					    0x10 | (pca955x_num_input_regs(chip->bits) + 4), nls,
 					    ls1);
-	if (err)
+	if (err < 0)
 		return err;
 
 	for (i = 0; i < nls; ++i)
Signature · 1 line
2.31.1
#1 lore raw
Quoted 25 lines · Eddie James

The function returns either a negative errno or the number of bytes successfully read. So, only return for a negative return code.

Fixes c9fb275212da ("leds: pca955x: Add HW blink support")
---
 drivers/leds/leds-pca955x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/leds/leds-pca955x.c +1 -1
index cf0a9fe20086..cba9876b1187 100644
@@ -689,7 +689,7 @@ static int pca955x_probe(struct i2c_client *client)
 	err = i2c_smbus_read_i2c_block_data(client,
 					    0x10 | (pca955x_num_input_regs(chip->bits) + 4), nls,
 					    ls1);
-	if (err)
+	if (err < 0)
 		return err;
 
 	for (i = 0; i < nls; ++i)
Signature · 1 line
2.31.1

I think Potin sent this same patch 2 days ago:

    https://lore.kernel.org/openbmc/[email protected]/

Would you mind sending a Reviewed-By / Tested-By for his patch?

Signature · 1 line
Patrick Williams
#2 lore raw
Quoted 22 lines · Patrick Williams
Quoted 21 lines · Eddie James

The function returns either a negative errno or the number of bytes successfully read. So, only return for a negative return code.

Fixes c9fb275212da ("leds: pca955x: Add HW blink support")
---
  drivers/leds/leds-pca955x.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/leds/leds-pca955x.c +1 -1
index cf0a9fe20086..cba9876b1187 100644
@@ -689,7 +689,7 @@ static int pca955x_probe(struct i2c_client *client)
  	err = i2c_smbus_read_i2c_block_data(client,
  					    0x10 | (pca955x_num_input_regs(chip->bits) + 4), nls,
  					    ls1);
-	if (err)
+	if (err < 0)
  		return err;
 
Quoted 8 lines
Quoted 4 lines
drivers/leds/leds-pca955x.c +0 -0
  	for (i = 0; i < nls; ++i)
Signature · 1 line
2.31.1

I think Potin sent this same patch 2 days ago:

     https://lore.kernel.org/openbmc/[email protected]/

Would you mind sending a Reviewed-By / Tested-By for his patch?

Ah, thanks. Missed that. Will do.

Eddie

Quoted 1 line