Skip to contentSkip to conversation

iio: light: tsl2591: fix some signedness bugs

PATCH In review Dan Carpenter 2 participants 3 messages May 14, 2021 – May 16, 2021

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

PATCH 1/2 iio: light: tsl2591: fix some signedness bugs

These variables need to be int for the error handling to work.

Fixes f053d4e748ce ("iio: light: Added AMS tsl2591 driver implementation")
---
 drivers/iio/light/tsl2591.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/iio/light/tsl2591.c +3 -3
index 2bdae388ff01..26e3cb6c4ff8 100644
@@ -213,7 +213,7 @@ static int tsl2591_gain_to_multiplier(const u8 als_gain)
 	}
 }
 
-static u8 tsl2591_multiplier_to_gain(const u32 multiplier)
+static int tsl2591_multiplier_to_gain(const u32 multiplier)
 {
 	switch (multiplier) {
 	case TSL2591_CTRL_ALS_LOW_GAIN_MULTIPLIER:
@@ -783,8 +783,8 @@ static int tsl2591_write_raw(struct iio_dev *indio_dev,
 			     int val, int val2, long mask)
 {
 	struct tsl2591_chip *chip = iio_priv(indio_dev);
-	u32 int_time;
-	u8 gain;
+	int int_time;
+	int gain;
 	int ret;
 
 	mutex_lock(&chip->als_mutex);
Signature · 1 line
2.30.2
#1 lore raw

PATCH 2/2 iio: light: tsl2591: delete a stray tab

This return statement is indented one more tab than it should be.

---
 drivers/iio/light/tsl2591.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/light/tsl2591.c +1 -1
index 26e3cb6c4ff8..39e68d0c9d6a 100644
@@ -451,7 +451,7 @@ static int tsl2591_read_channel_data(struct iio_dev *indio_dev,
 					    sizeof(als_data), als_data);
 	if (ret < 0) {
 		dev_err(&client->dev, "Failed to read data bytes");
-			return ret;
+		return ret;
 	}
 
 	als_ch0 = get_unaligned_le16(&als_data[0]);
Signature · 1 line
2.30.2
maintainer
#2 lore raw
In reply to Dan Carpenter
Quoted 4 lines · On Fri, 14 May 2021 16:10:07 +0300 Dan Carpenter <[email protected]>…

These variables need to be int for the error handling to work.

Fixes f053d4e748ce ("iio: light: Added AMS tsl2591 driver implementation")

Both applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to poke at it.

As such, there is still a bit of time if anyone else wants to review these / give tags etc, before I push it out as a non rebasing branch.

thanks,

Jonathan

Quoted 28 lines
---
 drivers/iio/light/tsl2591.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/iio/light/tsl2591.c +3 -3
index 2bdae388ff01..26e3cb6c4ff8 100644
@@ -213,7 +213,7 @@ static int tsl2591_gain_to_multiplier(const u8 als_gain)
 	}
 }
 
-static u8 tsl2591_multiplier_to_gain(const u32 multiplier)
+static int tsl2591_multiplier_to_gain(const u32 multiplier)
 {
 	switch (multiplier) {
 	case TSL2591_CTRL_ALS_LOW_GAIN_MULTIPLIER:
@@ -783,8 +783,8 @@ static int tsl2591_write_raw(struct iio_dev *indio_dev,
 			     int val, int val2, long mask)
 {
 	struct tsl2591_chip *chip = iio_priv(indio_dev);
-	u32 int_time;
-	u8 gain;
+	int int_time;
+	int gain;
 	int ret;
 
 	mutex_lock(&chip->als_mutex);