Skip to contentSkip to conversation

hwmon: (oxp-sensors) Minor cleanup of driver code

PATCH Applied Joaquín Ignacio Aramendía 2 participants 5 messages Jun 17, 2023 – Jun 18, 2023 Hardware monitoring

lore
Share & tools
lore
#0 lore raw

cover hwmon: (oxp-sensors) Minor cleanup of driver code

Make some cleanup of the driver removing unnecesary header and some duplicated return on error logic.

Joaquín Ignacio Aramendía (2):
hwmon: (oxp-sensors) Remove unused header
hwmon: (oxp-sensors) Simplify logic of error return

 drivers/hwmon/oxp-sensors.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
Signature · 1 line
2.41.0
#1 lore raw

PATCH 1/2 hwmon: (oxp-sensors) Remove unused header

We are not using <dev_printk.h>, remove that.

---
 drivers/hwmon/oxp-sensors.c | 1 -
 1 file changed, 1 deletion(-)
drivers/hwmon/oxp-sensors.c +0 -1
index be36d38f13d9..584e48d8106e 100644
@@ -16,7 +16,6 @@
  */
 
 #include <linux/acpi.h>
-#include <linux/dev_printk.h>
 #include <linux/dmi.h>
 #include <linux/hwmon.h>
 #include <linux/init.h>
Signature · 1 line
2.41.0
maintainer Applied
#2 lore raw

Re: [PATCH 1/2] hwmon: (oxp-sensors) Remove unused header

Quoted 3 lines · Joaquín Ignacio Aramendía

We are not using <dev_printk.h>, remove that.

Applied.

Thanks,
Guenter

Quoted 16 lines
---
 drivers/hwmon/oxp-sensors.c | 1 -
 1 file changed, 1 deletion(-)
drivers/hwmon/oxp-sensors.c +0 -1
index be36d38f13d9..584e48d8106e 100644
@@ -16,7 +16,6 @@
  */
 
 #include <linux/acpi.h>
-#include <linux/dev_printk.h>
 #include <linux/dmi.h>
 #include <linux/hwmon.h>
 #include <linux/init.h>
#3 lore raw

PATCH 2/2 hwmon: (oxp-sensors) Simplify logic of error return

In reply to Joaquín Ignacio Aramendía

Take return logic on error out of if-else, eliminating duplicated code in tt_togle_store() function.

---
 drivers/hwmon/oxp-sensors.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/hwmon/oxp-sensors.c +3 -4
index 584e48d8106e..1e59d97219c4 100644
@@ -226,13 +226,12 @@ static ssize_t tt_toggle_store(struct device *dev,
 
 	if (value) {
 		rval = tt_toggle_enable();
-		if (rval)
-			return rval;
 	} else {
 		rval = tt_toggle_disable();
-		if (rval)
-			return rval;
 	}
+	if (rval)
+		return rval;
+
 	return count;
 }
 
Signature · 1 line
2.41.0
maintainer Applied
#4 lore raw

Re: [PATCH 2/2] hwmon: (oxp-sensors) Simplify logic of error return

Quoted 4 lines · Joaquín Ignacio Aramendía

Take return logic on error out of if-else, eliminating duplicated code in tt_togle_store() function.

Applied.

Thanks,
Guenter

Quoted 25 lines
---
 drivers/hwmon/oxp-sensors.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/hwmon/oxp-sensors.c +3 -4
index 584e48d8106e..1e59d97219c4 100644
@@ -226,13 +226,12 @@ static ssize_t tt_toggle_store(struct device *dev,
 
 	if (value) {
 		rval = tt_toggle_enable();
-		if (rval)
-			return rval;
 	} else {
 		rval = tt_toggle_disable();
-		if (rval)
-			return rval;
 	}
+	if (rval)
+		return rval;
+
 	return count;
 }