Skip to contentSkip to conversation

drivers:adp8870_bl: check the return value of adp8870_write

PATCH In review Li Zhong 2 participants 2 messages Sep 21, 2022 – Sep 22, 2022

Subsystems (2)
lore
Share & tools
lore

Li Zhong

author
#0 lore raw

PATCH 1/1 drivers:adp8870_bl: check the return value of adp8870_write

Check and propagate the return value of adp8870_write() when it fails, which is possible when SMBus writing byte fails.

---
 drivers/video/backlight/adp8870_bl.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/video/backlight/adp8870_bl.c +5 -1
index 8b5213a39527..0eb4ae2ff592 100644
@@ -567,9 +567,13 @@ static ssize_t adp8870_store(struct device *dev, const char *buf,
 		return ret;
 
 	mutex_lock(&data->lock);
-	adp8870_write(data->client, reg, val);
+	ret = adp8870_write(data->client, reg, val);
 	mutex_unlock(&data->lock);
 
+	if (ret) {
+		return ret;
+	}
+
 	return count;
 }
 
Signature · 1 line
2.25.1
#1 lore raw
Quoted 2 lines · Li Zhong

Subject: [PATCH v1] drivers:adp8870_bl: check the return value of adp8870_write

                     ^^^^^^^^^^^^^^^^^^^^

Should be backlight: adp8870_bl.

Quoted 2 lines

Check and propagate the return value of adp8870_write() when it fails, which is possible when SMBus writing byte fails.

This looks like a sensible change, however...

When writing patches like this please review the whole file for similar concerns and fix all instances of the same issue. In this case there is another unchecked call to adp8870_write() in adp8870_bl_ambient_light_zone_store() (this function also contains other unchecked calls).

Note that the unchecked use in adp8870_led_work() because there is no way to propogate the error from this function (and adp8870_write() already logged the error).

It would also be good to review and fix adp8860_bl.c at the same time since these drivers are very similar (ideally the identical code in these drivers should be factored out).

Quoted 10 lines
---
 drivers/video/backlight/adp8870_bl.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/video/backlight/adp8870_bl.c +0 -0
index 8b5213a39527..0eb4ae2ff592 100644

drivers/video/backlight/adp8870_bl.c static ssize_t adp8870_store(struct device *dev, const char *buf, · line 575

Quoted 10 lines
drivers/video/backlight/adp8870_bl.c +4 -1
@@ -567,9 +567,13 @@ static ssize_t adp8870_store(struct device *dev, const char *buf,
 		return ret;
 
 	mutex_lock(&data->lock);
-	adp8870_write(data->client, reg, val);
+	ret = adp8870_write(data->client, reg, val);
 	mutex_unlock(&data->lock);
 
+	if (ret) {
+		return ret;
+	}

No need for braces here.

drivers/video/backlight/adp8870_bl.c static ssize_t adp8870_store(struct device *dev, const char *buf, · line 579

Quoted 4 lines
drivers/video/backlight/adp8870_bl.c +1 -0
+
 	return count;
 }
 

Thanks

Daniel.