Skip to contentSkip to conversation

hwmon: Add W83773G driver

PATCH New Lei YU 1 participant 3 messages Jan 17, 2018

Subsystems (2)
lore
Share & tools
lore

Lei YU

author
#0 lore raw

PATCH 1/3 hwmon: Add W83773G driver

Nuvoton W83773G is a hardware monitor IC providing one local temperature and two remote temperature sensors.

---
 drivers/hwmon/Kconfig   |  10 ++
 drivers/hwmon/Makefile  |   1 +
 drivers/hwmon/w83773g.c | 329 ++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 340 insertions(+)
 create mode 100644 drivers/hwmon/w83773g.c
drivers/hwmon/Kconfig +10 -0
index 9256dd0..fb0fa33 100644
@@ -1703,6 +1703,16 @@ config SENSORS_VT8231
 	  This driver can also be built as a module.  If so, the module
 	  will be called vt8231.
 
+config SENSORS_W83773G
+	tristate "Nuvoton W83773G"
+	depends on I2C
+	help
+	  If you say yes here you get support for the Nuvoton W83773G hardware
+	  monitoring chip.
+
+	  This driver can also be built as a module.  If so, the module
+	  will be called w83773g.
+
 config SENSORS_W83781D
 	tristate "Winbond W83781D, W83782D, W83783S, Asus AS99127F"
 	depends on I2C
drivers/hwmon/Makefile +1 -0
index 98000fc..fc26696 100644
@@ -13,6 +13,7 @@ obj-$(CONFIG_SENSORS_ATK0110)	+= asus_atk0110.o
 # asb100, then w83781d go first, as they can override other drivers' addresses.
 obj-$(CONFIG_SENSORS_ASB100)	+= asb100.o
 obj-$(CONFIG_SENSORS_W83627HF)	+= w83627hf.o
+obj-$(CONFIG_SENSORS_W83773G)	+= w83773g.o
 obj-$(CONFIG_SENSORS_W83792D)	+= w83792d.o
 obj-$(CONFIG_SENSORS_W83793)	+= w83793.o
 obj-$(CONFIG_SENSORS_W83795)	+= w83795.o
drivers/hwmon/w83773g.c new file +329 -0

329 lines not on this page · raw message

Signature · 1 line
1.9.1
author
#1 lore raw

PATCH 2/3 hwmon: (w83773g) Add documentation

Add documentation for the w83773g driver.

---
 Documentation/hwmon/w83773g | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
 create mode 100644 Documentation/hwmon/w83773g
Documentation/hwmon/w83773g new file +33 -0
new file mode 100644
index 0000000..4cc6c0b
@@ -0,0 +1,33 @@
+Kernel driver w83773g
+====================
+
+Supported chips:
+  * Nuvoton W83773G
+    Prefix: 'w83773g'
+    Addresses scanned: I2C 0x4c and 0x4d
+    Datasheet: https://www.nuvoton.com/resource-files/W83773G_SG_DatasheetV1_2.pdf
+
+Authors:
+	Lei YU <[email protected]>
+
+Description
+-----------
+
+This driver implements support for Nuvoton W83773G temperature sensor
+chip. This chip implements one local and two remote sensors.
+The chip also features offsets for the two remote sensors which get added to
+the input readings. The chip does all the scaling by itself and the driver
+therefore reports true temperatures that don't need any user-space adjustments.
+Temperature is measured in degrees Celsius.
+The chip is wired over I2C/SMBus and specified over a temperature
+range of -40 to +125 degrees Celsius (for local sensor) and -40 to +127
+degrees Celsius (for remote sensors).
+Resolution for both the local and remote channels is 0.125 degree C.
+
+The chip supports only temperature measurement. The driver exports
+the temperature values via the following sysfs files:
+
+temp[1-3]_input
+temp[2-3]_fault
+temp[2-3]_offset
+update_interval
Signature · 1 line
1.9.1
author
#2 lore raw

PATCH 3/3 hwmon: (w83773g) Fix fault detection and reporting

In reply to Lei YU

From: Guenter Roeck <[email protected]>

Smatch reports:

drivers/hwmon/w83773g.c:105
get_fault() warn: shift has higher precedence than mask

Code analysis shows that the code is indeed wrong. Fix it, and while we are at it, drop unnecessary typecast.

Fixes 86a10c802362 ("hwmon: Add W83773G driver")
Cc Lei YU <[email protected]>
---
 drivers/hwmon/w83773g.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/w83773g.c +1 -1
index 0b97c28..e858093 100644
@@ -102,7 +102,7 @@ static int get_fault(struct regmap *regmap, int index, long *val)
 	if (ret < 0)
 		return ret;
 
-	*val = (u8)regval & 0x04 >> 2;
+	*val = (regval & 0x04) >> 2;
 	return 0;
 }
 
Signature · 1 line
1.9.1