diff options
author | Guenter Roeck <linux@roeck-us.net> | 2019-06-07 10:23:20 -0700 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2019-06-23 18:33:01 -0700 |
commit | f5b20b11bbc230f64c099b12c37121aacf6f0b65 (patch) | |
tree | 7552bf9f1b55b5daf221535b05437de6c77b4a59 | |
parent | bf8c9edaa5c61999ed06c001d87c9a0c86cd0bf8 (diff) |
hwmon: (max6650) Cache alarm_en register
The alarm_en register is read each time the is_visible function is called.
Since it is a configuration register, this is completely unnecessary.
Read it once and cache its value.
Cc: Jean-Francois Dagenais <jeff.dagenais@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
-rw-r--r-- | drivers/hwmon/max6650.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/drivers/hwmon/max6650.c b/drivers/hwmon/max6650.c index 90565318aafb..2edee4ca5cae 100644 --- a/drivers/hwmon/max6650.c +++ b/drivers/hwmon/max6650.c @@ -114,6 +114,7 @@ struct max6650_data { u8 count; u8 dac; u8 alarm; + u8 alarm_en; unsigned long cooling_dev_state; }; @@ -545,8 +546,6 @@ static umode_t max6650_attrs_visible(struct kobject *kobj, struct attribute *a, { struct device *dev = container_of(kobj, struct device, kobj); struct max6650_data *data = dev_get_drvdata(dev); - struct i2c_client *client = data->client; - u8 alarm_en = i2c_smbus_read_byte_data(client, MAX6650_REG_ALARM_EN); struct device_attribute *devattr; /* @@ -559,7 +558,7 @@ static umode_t max6650_attrs_visible(struct kobject *kobj, struct attribute *a, || devattr == &sensor_dev_attr_fan1_fault.dev_attr || devattr == &sensor_dev_attr_gpio1_alarm.dev_attr || devattr == &sensor_dev_attr_gpio2_alarm.dev_attr) { - if (!(alarm_en & to_sensor_dev_attr(devattr)->index)) + if (!(data->alarm_en & to_sensor_dev_attr(devattr)->index)) return 0; } @@ -682,6 +681,13 @@ static int max6650_init_client(struct max6650_data *data, } data->count = reg; + reg = i2c_smbus_read_byte_data(client, MAX6650_REG_ALARM_EN); + if (reg < 0) { + dev_err(dev, "Failed to read alarm configuration, aborting.\n"); + return reg; + } + data->alarm_en = reg; + if (!of_property_read_u32(client->dev.of_node, "maxim,fan-target-rpm", &target_rpm)) { max6650_set_target(data, target_rpm); |