dt-bindings: hwmon: Add description for new hwmon driver hs3001
Subsystems (4)
PATCH v2 1/2 dt-bindings: hwmon: Add description for new hwmon driver hs3001
This is the initial description.
v1: Using separate dt-binding hs300x.yaml
v2: Reviewer recommends documentation of driver dt-binding in trivial-devices.yaml because the driver has no special properties to describe.
--- Documentation/devicetree/bindings/trivial-devices.yaml | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/trivial-devices.yaml +2 -0
@@ -315,6 +315,8 @@ properties: - plx,pex8648 # Pulsedlight LIDAR range-finding sensor - pulsedlight,lidar-lite-v2 + # Renesas HS300[1,2,3,4] Temperature and Relative Humidity Sensors + - renesas,hs3001 # Renesas ISL29501 time-of-flight sensor - renesas,isl29501 # Rohm DH2228FV
Signature · 1 line
2.41.0
PATCH v2 2/2 hwmon: (hs3001) Add driver for Renesas HS3001
Add base support for Renesas HS3001 temperature
and humidity sensors and its compatibles HS3002,
HS3003 and HS3004.
The sensor has a fix I2C address 0x44. The resolution is fixed to 14bit (ref. Missing feature).
Missing feature:
- Accessing non-volatile memory: Custom board has no possibility to control voltage supply of sensor. Thus, we cannot send the necessary control commands within the first 10ms after power-on.
Changelog:
v1: Initial version
v2: Extensive refactoring following recommendations of reviewers:
- Delete unused defines and device properties. These are added in the initial version because the device supports a programming mode, but I was not able to implement it, because the custom board was not able to control the power supply of the device and so I cannot enter the programming mode of the device.
- Correct missunderstanding comments for defines.
- Delete mutexes for data and I2C bus accesses.
- Replace attributes with recommented chip-info structure. In the initial version I followed the sth3x.c implementation that uses files and attributes in sysfs. The show functions are replaced by is_visible and read callbacks from the HWMON ABI. I also delete pointless function argument checks.
- Correct Yoda programming.
- Refactor probe function and delete sleep and measurement of humidity and temperature in probe function. I kept an initial I2C communication to ensure that the device is accessible during probe.
- Reduce the number of atteributes to humidity and temperature input.
--- Documentation/hwmon/hs3001.rst | 37 +++++ MAINTAINERS | 6 + drivers/hwmon/Kconfig | 10 ++ drivers/hwmon/Makefile | 1 + drivers/hwmon/hs3001.c | 261 +++++++++++++++++++++++++++++++++ 5 files changed, 315 insertions(+) create mode 100644 Documentation/hwmon/hs3001.rst create mode 100644 drivers/hwmon/hs3001.c
Documentation/hwmon/hs3001.rst new file +37 -0
@@ -0,0 +1,37 @@ +.. SPDX-License-Identifier: GPL-2.0-or-later + +Kernel driver HS3001 +=================== + +Supported chips: + + * Renesas HS3001, HS3002, HS3003, HS3004 + + Prefix: 'hs3001' + + Addresses scanned: - + + Datasheet: https://www.renesas.com/us/en/document/dst/hs300x-datasheet?r=417401 + +Author: + + - Andre Werner <[email protected]> + +Description +----------- + +This driver implements support for the Renesas HS3001 chips, a humidity +and temperature family. Temperature is measured in degrees celsius, relative +humidity is expressed as a percentage. In the sysfs interface, all values are +scaled by 1000, i.e. the value for 31.5 degrees celsius is 31500. + +The device communicates with the I2C protocol. Sensors have the I2C +address 0x44 by default. + +sysfs-Interface +--------------- + +=============================================================================== +temp1_input: temperature input +humidity1_input: humidity input +===============================================================================
MAINTAINERS +6 -0
@@ -9494,6 +9494,12 @@ S: Maintained W: http://artax.karlin.mff.cuni.cz/~mikulas/vyplody/hpfs/index-e.cgi F: fs/hpfs/ +HS3001 Hardware Temperature and Humidity Sensor +M: Andre Werner <[email protected]> +L: [email protected] +S: Maintained +F: drivers/hwmon/hs3001.c + HSI SUBSYSTEM M: Sebastian Reichel <[email protected]> S: Maintained
drivers/hwmon/Kconfig +10 -0
@@ -734,6 +734,16 @@ config SENSORS_HIH6130 This driver can also be built as a module. If so, the module will be called hih6130. +config SENSORS_HS3001 + tristate "Renesas HS3001 humidity and temperature sensors" + depends on I2C + help + If you say yes here you get support for the Renesas HS3001, + to HS3004 humidity and temperature sensors. + + This driver can also be built as a module. If so, the module + will be called hs3001. + config SENSORS_IBMAEM tristate "IBM Active Energy Manager temperature/power sensors and control" select IPMI_SI
drivers/hwmon/Makefile +1 -0
@@ -86,6 +86,7 @@ obj-$(CONFIG_SENSORS_GSC) += gsc-hwmon.o obj-$(CONFIG_SENSORS_GPIO_FAN) += gpio-fan.o obj-$(CONFIG_SENSORS_GXP_FAN_CTRL) += gxp-fan-ctrl.o obj-$(CONFIG_SENSORS_HIH6130) += hih6130.o +obj-$(CONFIG_SENSORS_HS3001) += hs3001.o obj-$(CONFIG_SENSORS_ULTRA45) += ultra45_env.o obj-$(CONFIG_SENSORS_I5500) += i5500_temp.o obj-$(CONFIG_SENSORS_I5K_AMB) += i5k_amb.o
drivers/hwmon/hs3001.c new file +261 -0
261 lines not on this page · raw message
Signature · 1 line
2.41.0
Re: [PATCH v2 2/2] hwmon: (hs3001) Add driver for Renesas HS3001
Quoted 28 lines · Andre Werner
Add base support for Renesas HS3001 temperature
and humidity sensors and its compatibles HS3002,
HS3003 and HS3004.The sensor has a fix I2C address
0x44. The resolution is fixed to 14bit (ref. Missing feature).Missing feature:
- Accessing non-volatile memory: Custom board has no possibility to control voltage supply of sensor. Thus, we cannot send the necessary control commands within the first 10ms after power-on.Signed-off-by Andre Werner <[email protected]>Changelog:
v1: Initial version
v2: Extensive refactoring following recommendations of reviewers:
- Delete unused defines and device properties. These are added in the initial version because the device supports a programming mode, but I was not able to implement it, because the custom board was not able to control the power supply of the device and so I cannot enter the programming mode of the device.
- Correct missunderstanding comments for defines.
- Delete mutexes for data and I2C bus accesses.
- Replace attributes with recommented chip-info structure. In the initial version I followed thesth3x.cimplementation that uses
Quoted 8 lines
files and attributes in sysfs. The show functions are replaced by
is_visibleand read callbacks from the HWMON ABI. I also delete pointless function argument checks.
- Correct Yoda programming.
- Refactor probe function and delete sleep and measurement of humidity and temperature in probe function. I kept an initial I2C communication to ensure that the device is accessible during probe.
- Reduce the number of atteributes to humidity and temperature input.
Also wrong placement of SoB and changelog.
Quoted 9 lines
--- Documentation/hwmon/hs3001.rst | 37 +++++ MAINTAINERS | 6 + drivers/hwmon/Kconfig | 10 ++ drivers/hwmon/Makefile | 1 + drivers/hwmon/hs3001.c | 261 +++++++++++++++++++++++++++++++++ 5 files changed, 315 insertions(+) create mode 100644 Documentation/hwmon/hs3001.rst create mode 100644 drivers/hwmon/hs3001.c
...
drivers/hwmon/hs3001.c line 52
Quoted 9 lines
drivers/hwmon/hs3001.c new file +9
-0+/* Definitions for Status Bits of A/D Data */ +#define HS3001_DATA_VALID 0x00/* Valid Data */ +#define HS3001_DATA_STALE 0x01/* Stale Data */ + +#define LIMIT_MAX 0 +#define LIMIT_MIN 1 + +enum hs3001_chips { + hs3001,
Drop, not effectively used.
Quoted 1 line
+};
...
drivers/hwmon/hs3001.c line 189
Quoted 4 lines
drivers/hwmon/hs3001.c new file +4
-0+ +/* device ID table */ +static const struct i2c_device_id hs3001_ids[] = { + {"hs3001" , hs3001 },
Drop match data
drivers/hwmon/hs3001.c line 197
Quoted 8 lines
drivers/hwmon/hs3001.c new file +8
-0+ { }, +}; + +MODULE_DEVICE_TABLE (i2c, hs3001_ids); + +static const struct of_device_id hs3001_of_match[] = { + {.compatible ="renesas,hs3001" , + .data = (void *)hs3001
Drop
Quoted 16 lines
drivers/hwmon/hs3001.c new file +16
-0+ }, + { }, +}; + +MODULE_DEVICE_TABLE (of, hs3001_of_match); + +static int hs3001_probe (struct i2c_client *client) +{ +struct hs3001_data *data; +struct device *hwmon_dev; +struct device *dev = &client->dev; +int ret; + +if (!i2c_check_functionality (client->adapter,I2C_FUNC_I2C )) +return -EOPNOTSUPP ; +
drivers/hwmon/hs3001.c line 223
Quoted 10 lines
drivers/hwmon/hs3001.c new file +10
-0+ data =devm_kzalloc (dev,sizeof (*data),GFP_KERNEL ); +if (!data) +return -ENOMEM ; + + data->client = client; + +if (client->dev.of_node) + data->type = (enum hs3001_chips )of_device_get_match_data (&client->dev); +else + data->type =i2c_match_id (hs3001_ids, client)->driver_data;
This is useless and dead code. You have only one type of device. Don't over-complicate simple things.
Best regards,
Krzysztof
Quoted 8 lines · Andre Werner
This is the initial description.
Signed-off-by Andre Werner <[email protected]>v1: Using separate dt-binding
hs300x.yaml
v2: Reviewer recommends documentation of driver dt-binding intrivial-devices.yamlbecause the driver has no special properties to describe.
Changelog goes after ---. Even if you intended to keep it in commit msg, definitely not after SoB. Does this even pass checkpatch?
Quoted 9 lines
--- Documentation/devicetree/bindings/trivial-devices.yaml | 2 ++ 1 file changed, 2 insertions(+)Documentation/devicetree/bindings/trivial-devices.yaml +0
-0
Documentation/devicetree/bindings/trivial-devices.yaml properties: · line 319
Quoted 5 lines
Documentation/devicetree/bindings/trivial-devices.yaml +2
-0@@ -315,6 +315,8 @@ properties: - plx,pex8648 # Pulsedlight LIDAR range-finding sensor - pulsedlight,lidar-lite-v2 + # Renesas HS300[1,2,3,4] Temperature and Relative Humidity Sensors + - renesas,hs3001
What about the rest of the devices - hs300[234]? Usually we ask for specific compatibles, that's why separate binding made some sense.
Best regards,
Krzysztof
Quoted 8 lines · Andre Werner
This is the initial description.
Signed-off-by Andre Werner <[email protected]>v1: Using separate dt-binding
hs300x.yaml
v2: Reviewer recommends documentation of driver dt-binding intrivial-devices.yamlbecause the driver has no special properties to describe.
BTW, you already sent v2, so this is v3. Please version your patches correctly.
Best regards,
Krzysztof