Lines Matching +full:multi +full:- +full:attr
1 // SPDX-License-Identifier: GPL-2.0-only
6 * sht4x.c - Linux hwmon driver for SHT4x Temperature and Humidity sensor
41 #define SHT4X_MIN_TEMPERATURE -45000
49 * struct sht4x_data - All the data required to operate an SHT4X chip
61 long update_interval; /* in milli-seconds */
68 * sht4x_read_values() - read and parse the raw data from the SHT4X
70 * Return: 0 if successful, -ERRNO if not
77 struct i2c_client *client = data->client; in sht4x_read_values()
82 mutex_lock(&data->lock); in sht4x_read_values()
83 next_update = data->last_updated + in sht4x_read_values()
84 msecs_to_jiffies(data->update_interval); in sht4x_read_values()
86 if (data->valid && time_before_eq(jiffies, next_update)) in sht4x_read_values()
98 ret = -ENODATA; in sht4x_read_values()
107 dev_err(&client->dev, "data integrity check failed\n"); in sht4x_read_values()
108 ret = -EIO; in sht4x_read_values()
114 dev_err(&client->dev, "data integrity check failed\n"); in sht4x_read_values()
115 ret = -EIO; in sht4x_read_values()
119 data->temperature = ((21875 * (int32_t)t_ticks) >> 13) - 45000; in sht4x_read_values()
120 data->humidity = ((15625 * (int32_t)rh_ticks) >> 13) - 6000; in sht4x_read_values()
121 data->last_updated = jiffies; in sht4x_read_values()
122 data->valid = true; in sht4x_read_values()
126 mutex_unlock(&data->lock); in sht4x_read_values()
132 data->update_interval = clamp_val(val, SHT4X_MIN_POLL_INTERVAL, INT_MAX); in sht4x_interval_write()
137 /* sht4x_interval_read() - read the minimum poll interval in milliseconds */
140 *val = data->update_interval; in sht4x_interval_read()
144 /* sht4x_temperature1_read() - read the temperature in millidegrees */
153 *val = data->temperature; in sht4x_temperature1_read()
158 /* sht4x_humidity1_read() - read a relative humidity in millipercent */
167 *val = data->humidity; in sht4x_humidity1_read()
174 u32 attr, int channel) in sht4x_hwmon_visible() argument
188 u32 attr, int channel, long *val) in sht4x_hwmon_read() argument
200 return -EOPNOTSUPP; in sht4x_hwmon_read()
205 u32 attr, int channel, long val) in sht4x_hwmon_write() argument
213 return -EOPNOTSUPP; in sht4x_hwmon_write()
237 struct device *device = &client->dev; in sht4x_probe()
244 * we require full i2c support since the sht4x uses multi-byte read and in sht4x_probe()
245 * writes as well as multi-byte commands which are not supported by in sht4x_probe()
248 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) in sht4x_probe()
249 return -EOPNOTSUPP; in sht4x_probe()
253 return -ENOMEM; in sht4x_probe()
255 data->update_interval = SHT4X_MIN_POLL_INTERVAL; in sht4x_probe()
256 data->client = client; in sht4x_probe()
258 mutex_init(&data->lock); in sht4x_probe()
266 return -EIO; in sht4x_probe()
269 client->name, in sht4x_probe()