Source
199
199
200
200
mutex_unlock(&data->update_lock);
201
201
202
202
return data;
203
203
}
204
204
205
205
/*
206
206
* Sysfs stuff
207
207
*/
208
208
209
-
static ssize_t show_temp_max10(struct device *dev,
209
+
static ssize_t temp_max10_show(struct device *dev,
210
210
struct device_attribute *dev_attr, char *buf)
211
211
{
212
212
struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr);
213
213
struct max6642_data *data = max6642_update_device(dev);
214
214
215
215
return sprintf(buf, "%d\n",
216
216
temp_from_reg10(data->temp_input[attr->index]));
217
217
}
218
218
219
-
static ssize_t show_temp_max(struct device *dev, struct device_attribute *attr,
220
-
char *buf)
219
+
static ssize_t temp_max_show(struct device *dev,
220
+
struct device_attribute *attr, char *buf)
221
221
{
222
222
struct sensor_device_attribute_2 *attr2 = to_sensor_dev_attr_2(attr);
223
223
struct max6642_data *data = max6642_update_device(dev);
224
224
225
225
return sprintf(buf, "%d\n", temp_from_reg(data->temp_high[attr2->nr]));
226
226
}
227
227
228
-
static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr,
229
-
const char *buf, size_t count)
228
+
static ssize_t temp_max_store(struct device *dev,
229
+
struct device_attribute *attr, const char *buf,
230
+
size_t count)
230
231
{
231
232
struct sensor_device_attribute_2 *attr2 = to_sensor_dev_attr_2(attr);
232
233
struct max6642_data *data = dev_get_drvdata(dev);
233
234
unsigned long val;
234
235
int err;
235
236
236
237
err = kstrtoul(buf, 10, &val);
237
238
if (err < 0)
238
239
return err;
239
240
240
241
mutex_lock(&data->update_lock);
241
242
data->temp_high[attr2->nr] = clamp_val(temp_to_reg(val), 0, 255);
242
243
i2c_smbus_write_byte_data(data->client, attr2->index,
243
244
data->temp_high[attr2->nr]);
244
245
mutex_unlock(&data->update_lock);
245
246
return count;
246
247
}
247
248
248
-
static ssize_t show_alarm(struct device *dev, struct device_attribute *attr,
249
+
static ssize_t alarm_show(struct device *dev, struct device_attribute *attr,
249
250
char *buf)
250
251
{
251
252
int bitnr = to_sensor_dev_attr(attr)->index;
252
253
struct max6642_data *data = max6642_update_device(dev);
253
254
return sprintf(buf, "%d\n", (data->alarms >> bitnr) & 1);
254
255
}
255
256
256
-
static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp_max10, NULL, 0);
257
-
static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp_max10, NULL, 1);
258
-
static SENSOR_DEVICE_ATTR_2(temp1_max, S_IWUSR | S_IRUGO, show_temp_max,
259
-
set_temp_max, 0, MAX6642_REG_W_LOCAL_HIGH);
260
-
static SENSOR_DEVICE_ATTR_2(temp2_max, S_IWUSR | S_IRUGO, show_temp_max,
261
-
set_temp_max, 1, MAX6642_REG_W_REMOTE_HIGH);
262
-
static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_alarm, NULL, 2);
263
-
static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 6);
264
-
static SENSOR_DEVICE_ATTR(temp2_max_alarm, S_IRUGO, show_alarm, NULL, 4);
257
+
static SENSOR_DEVICE_ATTR_RO(temp1_input, temp_max10, 0);
258
+
static SENSOR_DEVICE_ATTR_RO(temp2_input, temp_max10, 1);
259
+
static SENSOR_DEVICE_ATTR_2_RW(temp1_max, temp_max, 0,
260
+
MAX6642_REG_W_LOCAL_HIGH);
261
+
static SENSOR_DEVICE_ATTR_2_RW(temp2_max, temp_max, 1,
262
+
MAX6642_REG_W_REMOTE_HIGH);
263
+
static SENSOR_DEVICE_ATTR_RO(temp2_fault, alarm, 2);
264
+
static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, alarm, 6);
265
+
static SENSOR_DEVICE_ATTR_RO(temp2_max_alarm, alarm, 4);
265
266
266
267
static struct attribute *max6642_attrs[] = {
267
268
&sensor_dev_attr_temp1_input.dev_attr.attr,
268
269
&sensor_dev_attr_temp2_input.dev_attr.attr,
269
270
&sensor_dev_attr_temp1_max.dev_attr.attr,
270
271
&sensor_dev_attr_temp2_max.dev_attr.attr,
271
272
272
273
&sensor_dev_attr_temp2_fault.dev_attr.attr,
273
274
&sensor_dev_attr_temp1_max_alarm.dev_attr.attr,
274
275
&sensor_dev_attr_temp2_max_alarm.dev_attr.attr,