w1_therm: adding resolution sysfs entry
PATCH v4 5/9 w1_therm: adding resolution sysfs entry
Adding resolution sysfs entry (RW) to get or set the device resolution Write values are managed as follow:
* 9..12: resolution to set in bit
* Anything else: do nothing
Read values are :
* 9..12: device resolution in bit
* -xx: xx is kernel error when reading the resolution
Only supported devices will show the sysfs entry. A new family has been created for DS18S20 devices as they do not implement resolution feature.
The resolution of each device is check when the device is discover by the bus master, in w1_therm_add_slave(struct w1_slave *). The status is stored in the device structure w1_therm_family_data so that the driver always knows the resolution of each device, which could be used later to determine the required conversion duration (resolution dependent).
The resolution is re evaluate each time a user read or write the sysfs entry.
--- .../ABI/testing/sysfs-driver-w1_therm | 17 + drivers/w1/slaves/w1_therm.c | 404 ++++++++++++++---- drivers/w1/slaves/w1_therm.h | 91 +++- 3 files changed, 408 insertions(+), 104 deletions(-)
Documentation/ABI/testing/sysfs-driver-w1_therm +17 -0
@@ -10,6 +10,23 @@ Users: any user space application which wants to communicate with w1_term device +What: /sys/bus/w1/devices/.../resolution +Date: Apr 2020 +Contact: Akira Shimahara <[email protected]> +Description: + (RW) get or set the device resolution (on supported devices, + if not, this entry is not present). Note that the resolution + will be changed only in device RAM, so it will be cleared when + power is lost. Trigger a `save` to EEPROM command to keep + values after power-on. Read or write are : + * `9..12`: device resolution in bit + or resolution to set in bit + * `-xx`: xx is kernel error when reading the resolution + * Anything else: do nothing +Users: any user space application which wants to communicate with + w1_term device + + What: /sys/bus/w1/devices/.../w1_slave Date: Apr 2020 Contact: Akira Shimahara <[email protected]>
drivers/w1/slaves/w1_therm.c +309 -95
514 lines not on this page · raw message
drivers/w1/slaves/w1_therm.h +82 -9
160 lines not on this page · raw message
Signature · 1 line
2.26.2