Add driver for HTU31
Subsystems (4)
Andrei Lalaev
maintainerv2 cover Add driver for HTU31
This patch series adds support for HTU31 humidity and temperature sensor.
Changes in v2:
- replace DIV_ROUND_CLOSEST with DIV_ROUND_CLOSEST_ULL to prevent possible overflow
- drop mutex locking from htu31_read_serial_number, as the function is only called from probe
- add description of the private data structure
- fix the issues pointed by Christophe
- add an entry to MAINTAINERS file
- add Krzysztof's ACK to dt-bindings patch
v1: https://lore.kernel.org/all/[email protected]/#t
Andrei Lalaev (2):
hwmon: add driver for HTU31
dt-bindings: hwmon: Add description for sensor HTU31
.../devicetree/bindings/trivial-devices.yaml | 2 + Documentation/hwmon/htu31.rst | 38 ++ Documentation/hwmon/index.rst | 1 + MAINTAINERS | 6 + drivers/hwmon/Kconfig | 11 + drivers/hwmon/Makefile | 1 + drivers/hwmon/htu31.c | 345 ++++++++++++++++++ 7 files changed, 404 insertions(+) create mode 100644 Documentation/hwmon/htu31.rst create mode 100644 drivers/hwmon/htu31.c
Signature · 1 line
2.48.1
Andrei Lalaev
maintainerPATCH v2 1/2 hwmon: add driver for HTU31
Add base support for HTU31 temperature and humidity sensor.
Besides temperature and humidity values, the driver also exports a 24-bit serial number and heater control to sysfs.
--- Documentation/hwmon/htu31.rst | 38 ++++ Documentation/hwmon/index.rst | 1 + MAINTAINERS | 6 + drivers/hwmon/Kconfig | 11 ++ drivers/hwmon/Makefile | 1 + drivers/hwmon/htu31.c | 345 ++++++++++++++++++++++++++++++++++ 6 files changed, 402 insertions(+) create mode 100644 Documentation/hwmon/htu31.rst create mode 100644 drivers/hwmon/htu31.c
Documentation/hwmon/htu31.rst new file +38 -0
@@ -0,0 +1,38 @@ +.. SPDX-License-Identifier: GPL-2.0-or-later + +Kernel driver HTU31 +==================== + +Supported chips: + + * Measurement Specialties HTU31 + + Prefix: 'htu31' + + Addresses scanned: - + + Datasheet: Publicly available from https://www.te.com/en/product-CAT-HSC0007.html + +Author: + + - Andrei Lalaev <[email protected]> + +Description +----------- + +HTU31 is a humidity and temperature sensor. + +Supported temperature range is from -40 to 125 degrees Celsius. + +Communication with the device is performed via I2C protocol. Sensor's default address +is 0x40. + +sysfs-Interface +--------------- + +=================== ================= +temp1_input: temperature input +humidity1_input: humidity input +serial_number: serial number +heater_enable: heater control +=================== =================
Documentation/hwmon/index.rst +1 -0
@@ -85,6 +85,7 @@ Hardware Monitoring Kernel Drivers hih6130 hp-wmi-sensors hs3001 + htu31 ibmaem ibm-cffps ibmpowernv
MAINTAINERS +6 -0
@@ -10643,6 +10643,12 @@ W: http://www.st.com/ F: Documentation/devicetree/bindings/iio/humidity/st,hts221.yaml F: drivers/iio/humidity/hts221* +HTU31 Hardware Temperature and Humidity Sensor +M: Andrei Lalaev <[email protected]> +L: [email protected] +S: Maintained +F: drivers/hwmon/htu31.c + HUAWEI ETHERNET DRIVER M: Cai Huoqing <[email protected]> L: [email protected]
drivers/hwmon/Kconfig +11 -0
@@ -789,6 +789,17 @@ config SENSORS_HS3001 This driver can also be built as a module. If so, the module will be called hs3001. +config SENSORS_HTU31 + tristate "Measurement Specialties HTU31 humidity and temperature sensor" + depends on I2C + select CRC8 + help + If you say yes here you get support for the HTU31 humidity + and temperature sensors. + + This driver can also be built as a module. If so, the module + will be called htu31. + config SENSORS_IBMAEM tristate "IBM Active Energy Manager temperature/power sensors and control" select IPMI_SI
drivers/hwmon/Makefile +1 -0
@@ -199,6 +199,7 @@ obj-$(CONFIG_SENSORS_SCH5636) += sch5636.o obj-$(CONFIG_SENSORS_SFCTEMP) += sfctemp.o obj-$(CONFIG_SENSORS_SG2042_MCU) += sg2042-mcu.o obj-$(CONFIG_SENSORS_SL28CPLD) += sl28cpld-hwmon.o +obj-$(CONFIG_SENSORS_HTU31) += htu31.o obj-$(CONFIG_SENSORS_SHT15) += sht15.o obj-$(CONFIG_SENSORS_SHT21) += sht21.o obj-$(CONFIG_SENSORS_SHT3x) += sht3x.o
drivers/hwmon/htu31.c new file +345 -0
345 lines not on this page · raw message
Signature · 1 line
2.48.1
Guenter Roeck
maintainerRe: [PATCH 1/2] hwmon: add driver for HTU31
Quoted 7 lines · Andrei Lalaev
Add base support for HTU31 temperature and humidity sensor.
Besides temperature and humidity values, the driver also exports a 24-bit serial number and heater control to sysfs.
Signed-off-by Andrei Lalaev <[email protected]>---
...
drivers/hwmon/htu31.c line 262
Quoted 4 lines
drivers/hwmon/htu31.c new file +4
-0+ +static struct attribute *htu31_attrs[] = { + &dev_attr_heater_enable.attr, + &dev_attr_serial_number.attr,
I'll accept the heater enable attribute as sysfs attribute, but the serial number is most definitely not a hardware monitoring attribute. Please expose is through debugfs.
Thanks,
Guenter
Andrei Lalaev
maintainerRe: [PATCH 1/2] hwmon: add driver for HTU31
Quoted 9 lines · Guenter Roeck
Quoted 7 lines · Andrei Lalaev
Add base support for HTU31 temperature and humidity sensor.
Besides temperature and humidity values, the driver also exports a 24-bit serial number and heater control to sysfs.
Signed-off-by Andrei Lalaev <[email protected]>---
...
Quoted 8 lines
drivers/hwmon/htu31.c line 262
Quoted 4 lines
drivers/hwmon/htu31.c new file +4
-0+ +static struct attribute *htu31_attrs[] = { + &dev_attr_heater_enable.attr, + &dev_attr_serial_number.attr,I'll accept the heater enable attribute as sysfs attribute, but the serial number is most definitely not a hardware monitoring attribute. Please expose is through debugfs.
It makes sense. Will be moved to debugfs in v3.
Thank you!
Best regards,
Andrei Lalaev
Guenter Roeck
maintainerRe: [PATCH 1/2] hwmon: add driver for HTU31
Quoted 19 lines · Andrei Lalaev
Quoted 9 lines · Guenter Roeck
Quoted 7 lines · Andrei Lalaev
Add base support for HTU31 temperature and humidity sensor.
Besides temperature and humidity values, the driver also exports a 24-bit serial number and heater control to sysfs.
Signed-off-by Andrei Lalaev <[email protected]>---
...
Quoted 8 lines
drivers/hwmon/htu31.c line 262
Quoted 4 lines
drivers/hwmon/htu31.c new file +4
-0+ +static struct attribute *htu31_attrs[] = { + &dev_attr_heater_enable.attr, + &dev_attr_serial_number.attr,I'll accept the heater enable attribute as sysfs attribute, but the serial number is most definitely not a hardware monitoring attribute. Please expose is through debugfs.
Quoted 2 lines
It makes sense. Will be moved to debugfs in v3.
Note that there is now a ->debugfs pointer in struct i2c_client. You can use that pointer to attach debugfs files, and there is no need to remove the files in the remove function.
Guenter
Andrei Lalaev
maintainerPATCH v2 2/2 dt-bindings: hwmon: Add description for sensor HTU31
In reply to Andrei LalaevAdd trivial binding for HTU31 Temperature and Humidity sensor.
--- Documentation/devicetree/bindings/trivial-devices.yaml | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/trivial-devices.yaml +2 -0
@@ -189,6 +189,8 @@ properties: - mcube,mc3230 # Measurement Specialities I2C temperature and humidity sensor - meas,htu21 + # Measurement Specialities I2C temperature and humidity sensor + - meas,htu31 # Measurement Specialities I2C pressure and temperature sensor - meas,ms5637 # Measurement Specialities I2C pressure and temperature sensor
Signature · 1 line
2.48.1
Re: [PATCH 2/2] dt-bindings: hwmon: Add description for sensor HTU31
Quoted 8 lines · Andrei Lalaev
Add trivial binding for HTU31 Temperature and Humidity sensor.
Signed-off-by Andrei Lalaev <[email protected]>--- Documentation/devicetree/bindings/trivial-devices.yaml | 2 ++ 1 file changed, 2 insertions(+)
Please version your patchsets correctly. git format-patch -v2 or b4.
This is not v1 and you could not get my ack on v1.
Best regards,
Krzysztof
Andrei Lalaev
maintainerRe: [PATCH 2/2] dt-bindings: hwmon: Add description for sensor HTU31
Quoted 10 lines · Krzysztof Kozlowski
Quoted 8 lines · Andrei Lalaev
Add trivial binding for HTU31 Temperature and Humidity sensor.
Signed-off-by Andrei Lalaev <[email protected]>--- Documentation/devicetree/bindings/trivial-devices.yaml | 2 ++ 1 file changed, 2 insertions(+)
Quoted 4 lines
Please version your patchsets correctly.
git format-patch -v2or b4.This is not v1 and you could not get my ack on v1.
Oh, my bad, sorry, I manually edited the cover letter and forgot about patches' subjects :/
Should I resend v2 with normal versioning, or would you prefer me to go straight to v3?
Best regards,
Andrei Lalaev
Re: [PATCH 2/2] dt-bindings: hwmon: Add description for sensor HTU31
Quoted 11 lines · Andrei Lalaev
Quoted 10 lines · Krzysztof Kozlowski
Quoted 8 lines · Andrei Lalaev
Add trivial binding for HTU31 Temperature and Humidity sensor.
Signed-off-by Andrei Lalaev <[email protected]>--- Documentation/devicetree/bindings/trivial-devices.yaml | 2 ++ 1 file changed, 2 insertions(+)
Quoted 8 lines
Quoted 4 lines
Please version your patchsets correctly.
git format-patch -v2or b4.This is not v1 and you could not get my ack on v1.
Oh, my bad, sorry, I manually edited the cover letter and forgot about patches' subjects :/
Should I resend v2 with normal versioning, or would you prefer me to go straight to v3?
Tools might work fine with it, so no need to resend, unless Guenter asks. But if you send v3 for any reason, be sure to mark all of the patches.
Best regards,
Krzysztof
Guenter Roeck
maintainerRe: [PATCH 2/2] dt-bindings: hwmon: Add description for sensor HTU31
Quoted 17 lines · Krzysztof Kozlowski
Quoted 16 lines · Andrei Lalaev
Quoted 14 lines · Krzysztof Kozlowski
Quoted 8 lines · Andrei Lalaev
Add trivial binding for HTU31 Temperature and Humidity sensor.
Signed-off-by Andrei Lalaev <[email protected]>--- Documentation/devicetree/bindings/trivial-devices.yaml | 2 ++ 1 file changed, 2 insertions(+)Please version your patchsets correctly.
git format-patch -v2or b4.This is not v1 and you could not get my ack on v1.
Quoted 7 lines
Quoted 3 lines
Oh, my bad, sorry, I manually edited the cover letter and forgot about patches' subjects :/
Should I resend v2 with normal versioning, or would you prefer me to go straight to v3?
Tools might work fine with it, so no need to resend, unless Guenter asks. But if you send v3 for any reason, be sure to mark all of the patches.
Please no resend just to add version numbers to the patches.
Guenter