diff options
author | Guenter Roeck <linux@roeck-us.net> | 2019-06-07 19:23:21 +0200 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2019-06-24 03:33:01 +0200 |
commit | 0d5cc9383eea0835621cd458c34f1209d483e2ef (patch) | |
tree | 34f3cde18942663221e7619079f3a18d6deb09f3 /drivers/hwmon/max6650.c | |
parent | hwmon: (max6650) Cache alarm_en register (diff) | |
download | linux-0d5cc9383eea0835621cd458c34f1209d483e2ef.tar.xz linux-0d5cc9383eea0835621cd458c34f1209d483e2ef.zip |
hwmon: (max6650) Simplify alarm handling
Instead of re-reading the alarm register after reporting an alarm,
mark cached values as invalid. While this results in always reading all
data on subsequent reads, it is quite unlikely that such reads will
actually happen before the cache times out. The upside is avoiding
unnecessary unconditional i2c read operations.
Cc: Jean-Francois Dagenais <jeff.dagenais@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/max6650.c')
-rw-r--r-- | drivers/hwmon/max6650.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/drivers/hwmon/max6650.c b/drivers/hwmon/max6650.c index 2edee4ca5cae..045e67f73846 100644 --- a/drivers/hwmon/max6650.c +++ b/drivers/hwmon/max6650.c @@ -512,15 +512,12 @@ static ssize_t alarm_show(struct device *dev, { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct max6650_data *data = max6650_update_device(dev); - struct i2c_client *client = data->client; - int alarm = 0; + bool alarm = data->alarm & attr->index; - if (data->alarm & attr->index) { + if (alarm) { mutex_lock(&data->update_lock); - alarm = 1; data->alarm &= ~attr->index; - data->alarm |= i2c_smbus_read_byte_data(client, - MAX6650_REG_ALARM); + data->valid = false; mutex_unlock(&data->update_lock); } |