diff options
author | Jean Delvare <khali@linux-fr.org> | 2010-10-28 14:31:47 -0400 |
---|---|---|
committer | Jean Delvare <khali@endymion.delvare> | 2010-10-28 14:31:47 -0400 |
commit | 02728ffef9c2cf067e654e832b8c282a8a4d0b16 (patch) | |
tree | 00da2e02471413e8698cd5de3258329b5f03e1db /drivers/hwmon/w83795.c | |
parent | 54891a3c135b30ca0718dbf81f78260795a5b2fe (diff) |
hwmon: (w83795) Rework beep_enable implementation
Handle beep_enable just like all other beep bits. It doesn't need
anything special, so let's avoid redundant code. This also saves a
duplicate register read at initialization time.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/hwmon/w83795.c')
-rw-r--r-- | drivers/hwmon/w83795.c | 40 |
1 files changed, 2 insertions, 38 deletions
diff --git a/drivers/hwmon/w83795.c b/drivers/hwmon/w83795.c index b360696f241d..fd70a7b46295 100644 --- a/drivers/hwmon/w83795.c +++ b/drivers/hwmon/w83795.c | |||
@@ -398,7 +398,6 @@ struct w83795_data { | |||
398 | 398 | ||
399 | u8 alarms[6]; /* Register value */ | 399 | u8 alarms[6]; /* Register value */ |
400 | u8 beeps[6]; /* Register value */ | 400 | u8 beeps[6]; /* Register value */ |
401 | u8 beep_enable; | ||
402 | 401 | ||
403 | char valid; | 402 | char valid; |
404 | }; | 403 | }; |
@@ -616,39 +615,6 @@ store_beep(struct device *dev, struct device_attribute *attr, | |||
616 | return count; | 615 | return count; |
617 | } | 616 | } |
618 | 617 | ||
619 | static ssize_t | ||
620 | show_beep_enable(struct device *dev, struct device_attribute *attr, char *buf) | ||
621 | { | ||
622 | struct i2c_client *client = to_i2c_client(dev); | ||
623 | struct w83795_data *data = i2c_get_clientdata(client); | ||
624 | return sprintf(buf, "%u\n", data->beep_enable); | ||
625 | } | ||
626 | |||
627 | static ssize_t | ||
628 | store_beep_enable(struct device *dev, struct device_attribute *attr, | ||
629 | const char *buf, size_t count) | ||
630 | { | ||
631 | struct i2c_client *client = to_i2c_client(dev); | ||
632 | struct w83795_data *data = i2c_get_clientdata(client); | ||
633 | unsigned long val; | ||
634 | u8 tmp; | ||
635 | |||
636 | if (strict_strtoul(buf, 10, &val) < 0) | ||
637 | return -EINVAL; | ||
638 | if (val != 0 && val != 1) | ||
639 | return -EINVAL; | ||
640 | |||
641 | mutex_lock(&data->update_lock); | ||
642 | data->beep_enable = val; | ||
643 | tmp = w83795_read(client, W83795_REG_BEEP(5)); | ||
644 | tmp &= 0x7f; | ||
645 | tmp |= val << 7; | ||
646 | w83795_write(client, W83795_REG_BEEP(5), tmp); | ||
647 | mutex_unlock(&data->update_lock); | ||
648 | |||
649 | return count; | ||
650 | } | ||
651 | |||
652 | /* Write any value to clear chassis alarm */ | 618 | /* Write any value to clear chassis alarm */ |
653 | static ssize_t | 619 | static ssize_t |
654 | store_chassis_clear(struct device *dev, | 620 | store_chassis_clear(struct device *dev, |
@@ -1689,8 +1655,8 @@ static const struct sensor_device_attribute_2 w83795_pwm[][7] = { | |||
1689 | static const struct sensor_device_attribute_2 sda_single_files[] = { | 1655 | static const struct sensor_device_attribute_2 sda_single_files[] = { |
1690 | SENSOR_ATTR_2(chassis, S_IWUSR | S_IRUGO, show_alarm_beep, | 1656 | SENSOR_ATTR_2(chassis, S_IWUSR | S_IRUGO, show_alarm_beep, |
1691 | store_chassis_clear, ALARM_STATUS, 46), | 1657 | store_chassis_clear, ALARM_STATUS, 46), |
1692 | SENSOR_ATTR_2(beep_enable, S_IWUSR | S_IRUGO, show_beep_enable, | 1658 | SENSOR_ATTR_2(beep_enable, S_IWUSR | S_IRUGO, show_alarm_beep, |
1693 | store_beep_enable, NOT_USED, NOT_USED), | 1659 | store_beep, BEEP_ENABLE, 47), |
1694 | SENSOR_ATTR_2(speed_cruise_tolerance, S_IWUSR | S_IRUGO, show_fanin, | 1660 | SENSOR_ATTR_2(speed_cruise_tolerance, S_IWUSR | S_IRUGO, show_fanin, |
1695 | store_fanin, FANIN_TOL, NOT_USED), | 1661 | store_fanin, FANIN_TOL, NOT_USED), |
1696 | SENSOR_ATTR_2(pwm_default, S_IWUSR | S_IRUGO, show_sf_setup, | 1662 | SENSOR_ATTR_2(pwm_default, S_IWUSR | S_IRUGO, show_sf_setup, |
@@ -2136,8 +2102,6 @@ static int w83795_probe(struct i2c_client *client, | |||
2136 | data->alarms[i] = w83795_read(client, W83795_REG_ALARM(i)); | 2102 | data->alarms[i] = w83795_read(client, W83795_REG_ALARM(i)); |
2137 | data->beeps[i] = w83795_read(client, W83795_REG_BEEP(i)); | 2103 | data->beeps[i] = w83795_read(client, W83795_REG_BEEP(i)); |
2138 | } | 2104 | } |
2139 | data->beep_enable = | ||
2140 | (w83795_read(client, W83795_REG_BEEP(5)) >> 7) & 0x01; | ||
2141 | 2105 | ||
2142 | err = w83795_handle_files(dev, device_create_file); | 2106 | err = w83795_handle_files(dev, device_create_file); |
2143 | if (err) | 2107 | if (err) |