mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 12:43:29 +02:00
hwmon: (sht3x) Add new non-stardard sysfs attribute
Add "repeatability" attribute to sysfs, it could be read or written to control the sensor. Signed-off-by: JuenKit Yip <JuenKit_Yip@hotmail.com> Link: https://lore.kernel.org/r/DB4PR10MB6261B507C7656E3568DA33E39258A@DB4PR10MB6261.EURPRD10.PROD.OUTLOOK.COM [groeck: Fixed multi-line alignment; dropped check of unsigned against < 0] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
committed by
Guenter Roeck
parent
3d2c211c0d
commit
af5ab55012
@@ -28,11 +28,6 @@ The device communicates with the I2C protocol. Sensors can have the I2C
|
||||
addresses 0x44 or 0x45, depending on the wiring. See
|
||||
Documentation/i2c/instantiating-devices.rst for methods to instantiate the device.
|
||||
|
||||
There is only one option configurable by means of sht3x_data:
|
||||
|
||||
repeatability: high repeatability is used by default and using it is
|
||||
strongly recommended.
|
||||
|
||||
Even if sht3x sensor supports clock-strech(blocking mode) and non-strench
|
||||
(non-blocking mode) in single-shot mode, this driver only supports the latter.
|
||||
|
||||
@@ -83,4 +78,11 @@ heater_enable: heater enable, heating element removes excess humidity from
|
||||
update_interval: update interval, 0 for single shot, interval in msec
|
||||
for periodic measurement. If the interval is not supported
|
||||
by the sensor, the next faster interval is chosen
|
||||
repeatability: write or read repeatability, higher repeatability means
|
||||
longer measurement duration, lower noise level and
|
||||
larger energy consumption:
|
||||
|
||||
- 0: low repeatability
|
||||
- 1: medium repeatability
|
||||
- 2: high repeatability
|
||||
=================== ============================================================
|
||||
|
@@ -637,6 +637,37 @@ out:
|
||||
return count;
|
||||
}
|
||||
|
||||
static ssize_t repeatability_show(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct sht3x_data *data = dev_get_drvdata(dev);
|
||||
|
||||
return sysfs_emit(buf, "%d\n", data->repeatability);
|
||||
}
|
||||
|
||||
static ssize_t repeatability_store(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf,
|
||||
size_t count)
|
||||
{
|
||||
int ret;
|
||||
u8 val;
|
||||
|
||||
struct sht3x_data *data = dev_get_drvdata(dev);
|
||||
|
||||
ret = kstrtou8(buf, 0, &val);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (val > 2)
|
||||
return -EINVAL;
|
||||
|
||||
data->repeatability = val;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static SENSOR_DEVICE_ATTR_RO(temp1_input, temp1_input, 0);
|
||||
static SENSOR_DEVICE_ATTR_RO(humidity1_input, humidity1_input, 0);
|
||||
static SENSOR_DEVICE_ATTR_RW(temp1_max, temp1_limit, limit_max);
|
||||
@@ -653,6 +684,7 @@ static SENSOR_DEVICE_ATTR_RO(temp1_alarm, temp1_alarm, 0);
|
||||
static SENSOR_DEVICE_ATTR_RO(humidity1_alarm, humidity1_alarm, 0);
|
||||
static SENSOR_DEVICE_ATTR_RW(heater_enable, heater_enable, 0);
|
||||
static SENSOR_DEVICE_ATTR_RW(update_interval, update_interval, 0);
|
||||
static SENSOR_DEVICE_ATTR_RW(repeatability, repeatability, 0);
|
||||
|
||||
static struct attribute *sht3x_attrs[] = {
|
||||
&sensor_dev_attr_temp1_input.dev_attr.attr,
|
||||
@@ -669,6 +701,7 @@ static struct attribute *sht3x_attrs[] = {
|
||||
&sensor_dev_attr_humidity1_alarm.dev_attr.attr,
|
||||
&sensor_dev_attr_heater_enable.dev_attr.attr,
|
||||
&sensor_dev_attr_update_interval.dev_attr.attr,
|
||||
&sensor_dev_attr_repeatability.dev_attr.attr,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user