aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/gl518sm.c
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2007-10-22 11:47:16 -0400
committerMark M. Hoffman <mhoffman@lightlink.com>2008-02-07 20:39:41 -0500
commitda6848da293b88e5ac46f5ecc6ae41122d5f680b (patch)
tree401d6b3bc8ece09443cf47457b226eee9b7ac114 /drivers/hwmon/gl518sm.c
parent28292e79dcecac3688530a7f78d1930b78fac96b (diff)
hwmon: (gl518sm) Add individual alarm and beep files
The new libsensors needs these. Signed-off-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>
Diffstat (limited to 'drivers/hwmon/gl518sm.c')
-rw-r--r--drivers/hwmon/gl518sm.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/drivers/hwmon/gl518sm.c b/drivers/hwmon/gl518sm.c
index ed901f96a04f..535ad8776a68 100644
--- a/drivers/hwmon/gl518sm.c
+++ b/drivers/hwmon/gl518sm.c
@@ -345,6 +345,61 @@ static DEVICE_ATTR(beep_enable, S_IWUSR|S_IRUGO,
345static DEVICE_ATTR(beep_mask, S_IWUSR|S_IRUGO, 345static DEVICE_ATTR(beep_mask, S_IWUSR|S_IRUGO,
346 show_beep_mask, set_beep_mask); 346 show_beep_mask, set_beep_mask);
347 347
348static ssize_t show_alarm(struct device *dev, struct device_attribute *attr,
349 char *buf)
350{
351 int bitnr = to_sensor_dev_attr(attr)->index;
352 struct gl518_data *data = gl518_update_device(dev);
353 return sprintf(buf, "%u\n", (data->alarms >> bitnr) & 1);
354}
355
356static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 0);
357static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 1);
358static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 2);
359static SENSOR_DEVICE_ATTR(in3_alarm, S_IRUGO, show_alarm, NULL, 3);
360static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 4);
361static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL, 5);
362static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, 6);
363
364static ssize_t show_beep(struct device *dev, struct device_attribute *attr,
365 char *buf)
366{
367 int bitnr = to_sensor_dev_attr(attr)->index;
368 struct gl518_data *data = gl518_update_device(dev);
369 return sprintf(buf, "%u\n", (data->beep_mask >> bitnr) & 1);
370}
371
372static ssize_t set_beep(struct device *dev, struct device_attribute *attr,
373 const char *buf, size_t count)
374{
375 struct i2c_client *client = to_i2c_client(dev);
376 struct gl518_data *data = i2c_get_clientdata(client);
377 int bitnr = to_sensor_dev_attr(attr)->index;
378 unsigned long bit;
379
380 bit = simple_strtoul(buf, NULL, 10);
381 if (bit & ~1)
382 return -EINVAL;
383
384 mutex_lock(&data->update_lock);
385 data->beep_mask = gl518_read_value(client, GL518_REG_ALARM);
386 if (bit)
387 data->beep_mask |= (1 << bitnr);
388 else
389 data->beep_mask &= ~(1 << bitnr);
390 gl518_write_value(client, GL518_REG_ALARM, data->beep_mask);
391 mutex_unlock(&data->update_lock);
392 return count;
393}
394
395static SENSOR_DEVICE_ATTR(in0_beep, S_IRUGO|S_IWUSR, show_beep, set_beep, 0);
396static SENSOR_DEVICE_ATTR(in1_beep, S_IRUGO|S_IWUSR, show_beep, set_beep, 1);
397static SENSOR_DEVICE_ATTR(in2_beep, S_IRUGO|S_IWUSR, show_beep, set_beep, 2);
398static SENSOR_DEVICE_ATTR(in3_beep, S_IRUGO|S_IWUSR, show_beep, set_beep, 3);
399static SENSOR_DEVICE_ATTR(temp1_beep, S_IRUGO|S_IWUSR, show_beep, set_beep, 4);
400static SENSOR_DEVICE_ATTR(fan1_beep, S_IRUGO|S_IWUSR, show_beep, set_beep, 5);
401static SENSOR_DEVICE_ATTR(fan2_beep, S_IRUGO|S_IWUSR, show_beep, set_beep, 6);
402
348static struct attribute *gl518_attributes[] = { 403static struct attribute *gl518_attributes[] = {
349 &dev_attr_in3_input.attr, 404 &dev_attr_in3_input.attr,
350 &dev_attr_in0_min.attr, 405 &dev_attr_in0_min.attr,
@@ -355,6 +410,14 @@ static struct attribute *gl518_attributes[] = {
355 &dev_attr_in1_max.attr, 410 &dev_attr_in1_max.attr,
356 &dev_attr_in2_max.attr, 411 &dev_attr_in2_max.attr,
357 &dev_attr_in3_max.attr, 412 &dev_attr_in3_max.attr,
413 &sensor_dev_attr_in0_alarm.dev_attr.attr,
414 &sensor_dev_attr_in1_alarm.dev_attr.attr,
415 &sensor_dev_attr_in2_alarm.dev_attr.attr,
416 &sensor_dev_attr_in3_alarm.dev_attr.attr,
417 &sensor_dev_attr_in0_beep.dev_attr.attr,
418 &sensor_dev_attr_in1_beep.dev_attr.attr,
419 &sensor_dev_attr_in2_beep.dev_attr.attr,
420 &sensor_dev_attr_in3_beep.dev_attr.attr,
358 421
359 &dev_attr_fan1_auto.attr, 422 &dev_attr_fan1_auto.attr,
360 &sensor_dev_attr_fan1_input.dev_attr.attr, 423 &sensor_dev_attr_fan1_input.dev_attr.attr,
@@ -363,10 +426,16 @@ static struct attribute *gl518_attributes[] = {
363 &sensor_dev_attr_fan2_min.dev_attr.attr, 426 &sensor_dev_attr_fan2_min.dev_attr.attr,
364 &sensor_dev_attr_fan1_div.dev_attr.attr, 427 &sensor_dev_attr_fan1_div.dev_attr.attr,
365 &sensor_dev_attr_fan2_div.dev_attr.attr, 428 &sensor_dev_attr_fan2_div.dev_attr.attr,
429 &sensor_dev_attr_fan1_alarm.dev_attr.attr,
430 &sensor_dev_attr_fan2_alarm.dev_attr.attr,
431 &sensor_dev_attr_fan1_beep.dev_attr.attr,
432 &sensor_dev_attr_fan2_beep.dev_attr.attr,
366 433
367 &dev_attr_temp1_input.attr, 434 &dev_attr_temp1_input.attr,
368 &dev_attr_temp1_max.attr, 435 &dev_attr_temp1_max.attr,
369 &dev_attr_temp1_max_hyst.attr, 436 &dev_attr_temp1_max_hyst.attr,
437 &sensor_dev_attr_temp1_alarm.dev_attr.attr,
438 &sensor_dev_attr_temp1_beep.dev_attr.attr,
370 439
371 &dev_attr_alarms.attr, 440 &dev_attr_alarms.attr,
372 &dev_attr_beep_enable.attr, 441 &dev_attr_beep_enable.attr,