w1_therm: adding bulk read support to trigger multiple conversion on bus
authorAkira Shimahara <akira215corp@gmail.com>
Mon, 11 May 2020 20:38:20 +0000 (22:38 +0200)
committerpopcornmix <popcornmix@gmail.com>
Wed, 1 Jul 2020 15:34:10 +0000 (16:34 +0100)
commit4310a6219c4e9cec517937294590142f4caf8989
treeea28dd7884e8d469b6b4eacc4a30cdc7d72b5655
parente00c3d6867f1f3580f3516bdc4a88d8679858fe8
w1_therm: adding bulk read support to trigger multiple conversion on bus

commit 57c76221d5af648c8355a55c09b050c5d8d38189 upstream.

Adding bulk read support:
Sending a 'trigger' command in the dedicated sysfs entry of bus master
device send a conversion command for all the slaves on the bus. The sysfs
entry is added as soon as at least one device supporting this feature
is detected on the bus.

The behavior of the sysfs reading temperature on the device is as follow:
 * If no bulk read pending, trigger a conversion on the device, wait for
 the conversion to be done, read the temperature in device RAM
 * If a bulk read has been trigger, access directly the device RAM
This behavior is the same on the 2 sysfs entries ('temperature' and
'w1_slave').

Reading the therm_bulk_read sysfs give the status of bulk operations:
 * '-1': conversion in progress on at least 1 sensor
 * '1': conversion complete but at least one sensor has not been read yet
 * '0': no bulk operation. Reading temperature on ecah device will trigger
a conversion

As not all devices support bulk read feature, it has been added in device
family structure.

The attribute is set at master level as soon as a supporting device is
discover. It is removed when the last supported device leave the bus.
The count of supported device is kept with the static counter
bulk_read_device_counter.

A strong pull up is apply on the line if at least one device required it.
The duration of the pull up is the max time required by a device on the
line, which depends on the resolution settings of each device. The strong
pull up could be adjust with the a module parameter.

Updating documentation in Documentation/ABI/testing/sysfs-driver-w1_therm
and Documentation/w1/slaves/w1_therm.rst accordingly.

Signed-off-by: Akira Shimahara <akira215corp@gmail.com>
Link: https://lore.kernel.org/r/20200511203820.411483-1-akira215corp@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Documentation/ABI/testing/sysfs-driver-w1_therm
Documentation/w1/slaves/w1_therm.rst
drivers/w1/slaves/w1_therm.c