aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/hwmon/emc1403.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/drivers/hwmon/emc1403.c b/drivers/hwmon/emc1403.c
index 0e4b5642638d..5b58b20dead1 100644
--- a/drivers/hwmon/emc1403.c
+++ b/drivers/hwmon/emc1403.c
@@ -89,6 +89,35 @@ static ssize_t store_temp(struct device *dev,
89 return count; 89 return count;
90} 90}
91 91
92static ssize_t store_bit(struct device *dev,
93 struct device_attribute *attr, const char *buf, size_t count)
94{
95 struct i2c_client *client = to_i2c_client(dev);
96 struct thermal_data *data = i2c_get_clientdata(client);
97 struct sensor_device_attribute_2 *sda = to_sensor_dev_attr_2(attr);
98 unsigned long val;
99 int retval;
100
101 if (strict_strtoul(buf, 10, &val))
102 return -EINVAL;
103
104 mutex_lock(&data->mutex);
105 retval = i2c_smbus_read_byte_data(client, sda->nr);
106 if (retval < 0)
107 goto fail;
108
109 retval &= ~sda->index;
110 if (val)
111 retval |= sda->index;
112
113 retval = i2c_smbus_write_byte_data(client, sda->index, retval);
114 if (retval == 0)
115 retval = count;
116fail:
117 mutex_unlock(&data->mutex);
118 return retval;
119}
120
92static ssize_t show_hyst(struct device *dev, 121static ssize_t show_hyst(struct device *dev,
93 struct device_attribute *attr, char *buf) 122 struct device_attribute *attr, char *buf)
94{ 123{
@@ -200,6 +229,9 @@ static SENSOR_DEVICE_ATTR_2(temp3_crit_alarm, S_IRUGO,
200static SENSOR_DEVICE_ATTR(temp3_crit_hyst, S_IRUGO | S_IWUSR, 229static SENSOR_DEVICE_ATTR(temp3_crit_hyst, S_IRUGO | S_IWUSR,
201 show_hyst, store_hyst, 0x1A); 230 show_hyst, store_hyst, 0x1A);
202 231
232static SENSOR_DEVICE_ATTR_2(power_state, S_IRUGO | S_IWUSR,
233 show_bit, store_bit, 0x03, 0x40);
234
203static struct attribute *mid_att_thermal[] = { 235static struct attribute *mid_att_thermal[] = {
204 &sensor_dev_attr_temp1_min.dev_attr.attr, 236 &sensor_dev_attr_temp1_min.dev_attr.attr,
205 &sensor_dev_attr_temp1_max.dev_attr.attr, 237 &sensor_dev_attr_temp1_max.dev_attr.attr,
@@ -225,6 +257,7 @@ static struct attribute *mid_att_thermal[] = {
225 &sensor_dev_attr_temp3_max_alarm.dev_attr.attr, 257 &sensor_dev_attr_temp3_max_alarm.dev_attr.attr,
226 &sensor_dev_attr_temp3_crit_alarm.dev_attr.attr, 258 &sensor_dev_attr_temp3_crit_alarm.dev_attr.attr,
227 &sensor_dev_attr_temp3_crit_hyst.dev_attr.attr, 259 &sensor_dev_attr_temp3_crit_hyst.dev_attr.attr,
260 &sensor_dev_attr_power_state.dev_attr.attr,
228 NULL 261 NULL
229}; 262};
230 263