Source
227
227
228
228
data->last_updated = jiffies;
229
229
data->valid = 1;
230
230
}
231
231
232
232
mutex_unlock(&data->update_lock);
233
233
234
234
return data;
235
235
}
236
236
237
-
static ssize_t show_temp(struct device *dev, struct device_attribute *da,
237
+
static ssize_t temp_show(struct device *dev, struct device_attribute *da,
238
238
char *buf)
239
239
{
240
240
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
241
241
struct ds1621_data *data = ds1621_update_client(dev);
242
242
return sprintf(buf, "%d\n",
243
243
DS1621_TEMP_FROM_REG(data->temp[attr->index]));
244
244
}
245
245
246
-
static ssize_t set_temp(struct device *dev, struct device_attribute *da,
247
-
const char *buf, size_t count)
246
+
static ssize_t temp_store(struct device *dev, struct device_attribute *da,
247
+
const char *buf, size_t count)
248
248
{
249
249
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
250
250
struct ds1621_data *data = dev_get_drvdata(dev);
251
251
long val;
252
252
int err;
253
253
254
254
err = kstrtol(buf, 10, &val);
255
255
if (err)
256
256
return err;
257
257
263
263
return count;
264
264
}
265
265
266
266
static ssize_t alarms_show(struct device *dev, struct device_attribute *da,
267
267
char *buf)
268
268
{
269
269
struct ds1621_data *data = ds1621_update_client(dev);
270
270
return sprintf(buf, "%d\n", ALARMS_FROM_REG(data->conf));
271
271
}
272
272
273
-
static ssize_t show_alarm(struct device *dev, struct device_attribute *da,
273
+
static ssize_t alarm_show(struct device *dev, struct device_attribute *da,
274
274
char *buf)
275
275
{
276
276
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
277
277
struct ds1621_data *data = ds1621_update_client(dev);
278
278
return sprintf(buf, "%d\n", !!(data->conf & attr->index));
279
279
}
280
280
281
281
static ssize_t update_interval_show(struct device *dev,
282
282
struct device_attribute *da, char *buf)
283
283
{
312
312
data->update_interval = ds1721_convrates[resol];
313
313
data->zbits = 7 - resol;
314
314
mutex_unlock(&data->update_lock);
315
315
316
316
return count;
317
317
}
318
318
319
319
static DEVICE_ATTR_RO(alarms);
320
320
static DEVICE_ATTR_RW(update_interval);
321
321
322
-
static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0);
323
-
static SENSOR_DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO, show_temp, set_temp, 1);
324
-
static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp, set_temp, 2);
325
-
static SENSOR_DEVICE_ATTR(temp1_min_alarm, S_IRUGO, show_alarm, NULL,
326
-
DS1621_ALARM_TEMP_LOW);
327
-
static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL,
328
-
DS1621_ALARM_TEMP_HIGH);
322
+
static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, 0);
323
+
static SENSOR_DEVICE_ATTR_RW(temp1_min, temp, 1);
324
+
static SENSOR_DEVICE_ATTR_RW(temp1_max, temp, 2);
325
+
static SENSOR_DEVICE_ATTR_RO(temp1_min_alarm, alarm, DS1621_ALARM_TEMP_LOW);
326
+
static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, alarm, DS1621_ALARM_TEMP_HIGH);
329
327
330
328
static struct attribute *ds1621_attributes[] = {
331
329
&sensor_dev_attr_temp1_input.dev_attr.attr,
332
330
&sensor_dev_attr_temp1_min.dev_attr.attr,
333
331
&sensor_dev_attr_temp1_max.dev_attr.attr,
334
332
&sensor_dev_attr_temp1_min_alarm.dev_attr.attr,
335
333
&sensor_dev_attr_temp1_max_alarm.dev_attr.attr,
336
334
&dev_attr_alarms.attr,
337
335
&dev_attr_update_interval.attr,
338
336
NULL