Skip to contentSkip to conversation

hwmon: Add sht4x Temperature and Humidity Sensor Driver

PATCH Superseded Navin Sankar Velliangiri 1 participant 1 message May 8, 2021

Subsystems (2)

v4 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 hwmon: Add sht4x Temperature and Humidity Sensor Driver

This patch adds a hwmon driver for the SHT4x Temperature and Humidity sensor.

---

Changes in v2:

* Removed unused macro SHT4X_MIN_POLL_INTERVAL
* Replaced time_after instead of ktime_after
* Used goto statements for error handling
* Hardcorded the interval_time instead of clamp_val().

Changes in v3:

* Accept the poll interval if it is greater than SHT4X_MIN_POLL_INTERVAL and return -EINVAL for negative values & less than SHT4X_MIN_POLL_INTERVAL.
* Changed the data type of update_interval and last_upadated to long.

Changes in v4:

* "update interval" is long but msecs_to_jiffies() accepts only unsigned int. clamp_val() api is used to assign the update_interval stays within UINT_MAX.

 Documentation/hwmon/index.rst |   1 +
 Documentation/hwmon/sht4x.rst |  45 +++++
 drivers/hwmon/Kconfig         |  13 +-
 drivers/hwmon/Makefile        |   1 +
 drivers/hwmon/sht4x.c         | 305 ++++++++++++++++++++++++++++++++++
 5 files changed, 364 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/hwmon/sht4x.rst
 create mode 100644 drivers/hwmon/sht4x.c
Documentation/hwmon/index.rst +1 -0
index 8d5a2df1ecb6..2a20c6616e21 100644
@@ -160,6 +160,7 @@ Hardware Monitoring Kernel Drivers
    sht15
    sht21
    sht3x
+   sht4x
    shtc1
    sis5595
    sl28cpld
Documentation/hwmon/sht4x.rst new file +45 -0

45 lines not on this page · raw message

drivers/hwmon/Kconfig +12 -1
index 54f04e61fb83..ad10469d7b13 100644
@@ -1583,6 +1583,17 @@ config SENSORS_SHT3x
 	  This driver can also be built as a module. If so, the module
 	  will be called sht3x.
 
+config SENSORS_SHT4x
+	tristate "Sensiron humidity and temperature sensors. SHT4x and compat."
+	depends on I2C
+	select CRC8
+	help
+	  If you say yes here you get support for thr Sensiron SHT40, SHT41 and
+	  SHT45 humidity and temperature sensors.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called sht4x.
+
 config SENSORS_SHTC1
 	tristate "Sensiron humidity and temperature sensors. SHTC1 and compat."
 	depends on I2C
@@ -1798,7 +1809,7 @@ config SENSORS_ADS7871
 
 config SENSORS_AMC6821
 	tristate "Texas Instruments AMC6821"
-	depends on I2C
+	depends on I2C
 	help
 	  If you say yes here you get support for the Texas Instruments
 	  AMC6821 hardware monitoring chips.
drivers/hwmon/Makefile +1 -0
index fe38e8a5c979..62cee3e03c7f 100644
@@ -170,6 +170,7 @@ obj-$(CONFIG_SENSORS_SL28CPLD)	+= sl28cpld-hwmon.o
 obj-$(CONFIG_SENSORS_SHT15)	+= sht15.o
 obj-$(CONFIG_SENSORS_SHT21)	+= sht21.o
 obj-$(CONFIG_SENSORS_SHT3x)	+= sht3x.o
+obj-$(CONFIG_SENSORS_SHT4x)	+= sht4x.o
 obj-$(CONFIG_SENSORS_SHTC1)	+= shtc1.o
 obj-$(CONFIG_SENSORS_SIS5595)	+= sis5595.o
 obj-$(CONFIG_SENSORS_SMM665)	+= smm665.o
drivers/hwmon/sht4x.c new file +305 -0

305 lines not on this page · raw message

--
2.31.1