diff options
Diffstat (limited to 'drivers/hwmon/adm1021.c')
-rw-r--r-- | drivers/hwmon/adm1021.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/drivers/hwmon/adm1021.c b/drivers/hwmon/adm1021.c index de84398775b6..afc594318125 100644 --- a/drivers/hwmon/adm1021.c +++ b/drivers/hwmon/adm1021.c | |||
@@ -83,6 +83,7 @@ struct adm1021_data { | |||
83 | 83 | ||
84 | struct mutex update_lock; | 84 | struct mutex update_lock; |
85 | char valid; /* !=0 if following fields are valid */ | 85 | char valid; /* !=0 if following fields are valid */ |
86 | char low_power; /* !=0 if device in low power mode */ | ||
86 | unsigned long last_updated; /* In jiffies */ | 87 | unsigned long last_updated; /* In jiffies */ |
87 | 88 | ||
88 | int temp_max[2]; /* Register values */ | 89 | int temp_max[2]; /* Register values */ |
@@ -213,6 +214,35 @@ static ssize_t set_temp_min(struct device *dev, | |||
213 | return count; | 214 | return count; |
214 | } | 215 | } |
215 | 216 | ||
217 | static ssize_t show_low_power(struct device *dev, | ||
218 | struct device_attribute *devattr, char *buf) | ||
219 | { | ||
220 | struct adm1021_data *data = adm1021_update_device(dev); | ||
221 | return sprintf(buf, "%d\n", data->low_power); | ||
222 | } | ||
223 | |||
224 | static ssize_t set_low_power(struct device *dev, | ||
225 | struct device_attribute *devattr, | ||
226 | const char *buf, size_t count) | ||
227 | { | ||
228 | struct i2c_client *client = to_i2c_client(dev); | ||
229 | struct adm1021_data *data = i2c_get_clientdata(client); | ||
230 | int low_power = simple_strtol(buf, NULL, 10) != 0; | ||
231 | |||
232 | mutex_lock(&data->update_lock); | ||
233 | if (low_power != data->low_power) { | ||
234 | int config = i2c_smbus_read_byte_data( | ||
235 | client, ADM1021_REG_CONFIG_R); | ||
236 | data->low_power = low_power; | ||
237 | i2c_smbus_write_byte_data(client, ADM1021_REG_CONFIG_W, | ||
238 | (config & 0xBF) | (low_power << 6)); | ||
239 | } | ||
240 | mutex_unlock(&data->update_lock); | ||
241 | |||
242 | return count; | ||
243 | } | ||
244 | |||
245 | |||
216 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); | 246 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); |
217 | static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_max, | 247 | static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_max, |
218 | set_temp_max, 0); | 248 | set_temp_max, 0); |
@@ -230,6 +260,7 @@ static SENSOR_DEVICE_ATTR(temp2_min_alarm, S_IRUGO, show_alarm, NULL, 3); | |||
230 | static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_alarm, NULL, 2); | 260 | static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_alarm, NULL, 2); |
231 | 261 | ||
232 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); | 262 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); |
263 | static DEVICE_ATTR(low_power, S_IWUSR | S_IRUGO, show_low_power, set_low_power); | ||
233 | 264 | ||
234 | static struct attribute *adm1021_attributes[] = { | 265 | static struct attribute *adm1021_attributes[] = { |
235 | &sensor_dev_attr_temp1_max.dev_attr.attr, | 266 | &sensor_dev_attr_temp1_max.dev_attr.attr, |
@@ -244,6 +275,7 @@ static struct attribute *adm1021_attributes[] = { | |||
244 | &sensor_dev_attr_temp2_min_alarm.dev_attr.attr, | 275 | &sensor_dev_attr_temp2_min_alarm.dev_attr.attr, |
245 | &sensor_dev_attr_temp2_fault.dev_attr.attr, | 276 | &sensor_dev_attr_temp2_fault.dev_attr.attr, |
246 | &dev_attr_alarms.attr, | 277 | &dev_attr_alarms.attr, |
278 | &dev_attr_low_power.attr, | ||
247 | NULL | 279 | NULL |
248 | }; | 280 | }; |
249 | 281 | ||