Skip to content

Commit 5bca68a

Browse files
Hunterteaegggroeck
authored andcommitted
hwmon: (sht3x) remove blocking_io property
Due to no support on clock-strench, blocking mode was removed and now single-shot mode only uses non-blocking mode. Signed-off-by: JuenKit Yip <JuenKit_Yip@hotmail.com> Link: https://lore.kernel.org/r/DB4PR10MB6261DA9202AF37B4F6ECDD6C9258A@DB4PR10MB6261.EURPRD10.PROD.OUTLOOK.COM Signed-off-by: Guenter Roeck <linux@roeck-us.net>
1 parent fc669e9 commit 5bca68a

2 files changed

Lines changed: 17 additions & 30 deletions

File tree

Documentation/hwmon/sht3x.rst

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,14 @@ The device communicates with the I2C protocol. Sensors can have the I2C
2828
addresses 0x44 or 0x45, depending on the wiring. See
2929
Documentation/i2c/instantiating-devices.rst for methods to instantiate the device.
3030

31-
There are two options configurable by means of sht3x_data:
32-
33-
1. blocking (pull the I2C clock line down while performing the measurement) or
34-
non-blocking mode. Blocking mode will guarantee the fastest result but
35-
the I2C bus will be busy during that time. By default, non-blocking mode
36-
is used. Make sure clock-stretching works properly on your device if you
37-
want to use blocking mode.
38-
2. high or low accuracy. High accuracy is used by default and using it is
31+
There is only one option configurable by means of sht3x_data:
32+
33+
high or low accuracy. High accuracy is used by default and using it is
3934
strongly recommended.
4035

36+
Even if sht3x sensor supports clock-strech(blocking mode) and non-strench
37+
(non-blocking mode) in single-shot mode, this driver only supports the latter.
38+
4139
The sht3x sensor supports a single shot mode as well as 5 periodic measure
4240
modes, which can be controlled with the update_interval sysfs interface.
4341
The allowed update_interval in milliseconds are as follows:

drivers/hwmon/sht3x.c

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,10 @@
2222
#include <linux/jiffies.h>
2323

2424
/* commands (high precision mode) */
25-
static const unsigned char sht3x_cmd_measure_blocking_hpm[] = { 0x2c, 0x06 };
26-
static const unsigned char sht3x_cmd_measure_nonblocking_hpm[] = { 0x24, 0x00 };
25+
static const unsigned char sht3x_cmd_measure_single_hpm[] = { 0x24, 0x00 };
2726

2827
/* commands (low power mode) */
29-
static const unsigned char sht3x_cmd_measure_blocking_lpm[] = { 0x2c, 0x10 };
30-
static const unsigned char sht3x_cmd_measure_nonblocking_lpm[] = { 0x24, 0x16 };
28+
static const unsigned char sht3x_cmd_measure_single_lpm[] = { 0x24, 0x16 };
3129

3230
/* commands for periodic mode */
3331
static const unsigned char sht3x_cmd_measure_periodic_mode[] = { 0xe0, 0x00 };
@@ -41,9 +39,9 @@ static const unsigned char sht3x_cmd_heater_off[] = { 0x30, 0x66 };
4139
static const unsigned char sht3x_cmd_read_status_reg[] = { 0xf3, 0x2d };
4240
static const unsigned char sht3x_cmd_clear_status_reg[] = { 0x30, 0x41 };
4341

44-
/* delays for non-blocking i2c commands, both in us */
45-
#define SHT3X_NONBLOCKING_WAIT_TIME_HPM 15000
46-
#define SHT3X_NONBLOCKING_WAIT_TIME_LPM 4000
42+
/* delays for single-shot mode i2c commands, both in us */
43+
#define SHT3X_SINGLE_WAIT_TIME_HPM 15000
44+
#define SHT3X_SINGLE_WAIT_TIME_LPM 4000
4745

4846
#define SHT3X_WORD_LEN 2
4947
#define SHT3X_CMD_LENGTH 2
@@ -134,7 +132,6 @@ struct sht3x_data {
134132
const unsigned char *command;
135133
u32 wait_time; /* in us*/
136134
unsigned long last_update; /* last update in periodic mode*/
137-
bool blocking_io;
138135
bool high_precision;
139136

140137
/*
@@ -432,26 +429,19 @@ static ssize_t humidity1_limit_store(struct device *dev,
432429
static void sht3x_select_command(struct sht3x_data *data)
433430
{
434431
/*
435-
* In blocking mode (clock stretching mode) the I2C bus
436-
* is blocked for other traffic, thus the call to i2c_master_recv()
437-
* will wait until the data is ready. For non blocking mode, we
438-
* have to wait ourselves.
432+
* For single-shot mode, only non blocking mode is support,
433+
* we have to wait ourselves for result.
439434
*/
440435
if (data->mode > 0) {
441436
data->command = sht3x_cmd_measure_periodic_mode;
442437
data->wait_time = 0;
443-
} else if (data->blocking_io) {
444-
data->command = data->high_precision ?
445-
sht3x_cmd_measure_blocking_hpm :
446-
sht3x_cmd_measure_blocking_lpm;
447-
data->wait_time = 0;
448438
} else {
449439
if (data->high_precision) {
450-
data->command = sht3x_cmd_measure_nonblocking_hpm;
451-
data->wait_time = SHT3X_NONBLOCKING_WAIT_TIME_HPM;
440+
data->command = sht3x_cmd_measure_single_hpm;
441+
data->wait_time = SHT3X_SINGLE_WAIT_TIME_HPM;
452442
} else {
453-
data->command = sht3x_cmd_measure_nonblocking_lpm;
454-
data->wait_time = SHT3X_NONBLOCKING_WAIT_TIME_LPM;
443+
data->command = sht3x_cmd_measure_single_lpm;
444+
data->wait_time = SHT3X_SINGLE_WAIT_TIME_LPM;
455445
}
456446
}
457447
}
@@ -689,7 +679,6 @@ static int sht3x_probe(struct i2c_client *client)
689679
if (!data)
690680
return -ENOMEM;
691681

692-
data->blocking_io = false;
693682
data->high_precision = true;
694683
data->mode = 0;
695684
data->last_update = jiffies - msecs_to_jiffies(3000);

0 commit comments

Comments
 (0)