Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 115536
b: refs/heads/master
c: 2fbbbf1
h: refs/heads/master
v: v3
  • Loading branch information
Jean Delvare authored and Jean Delvare committed Oct 17, 2008
1 parent bf5a8d5 commit 97f5aed
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 38 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6aa693b85257cd41fdb3554016b663519dbf9d14
refs/heads/master: 2fbbbf148840332d614790ea00d9a7ecb38d648d
46 changes: 9 additions & 37 deletions trunk/drivers/hwmon/w83781d.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ FAN_FROM_REG(u8 val, int div)
#define TEMP_FROM_REG(val) ((val) * 1000)

#define BEEP_MASK_FROM_REG(val,type) ((type) == as99127f ? \
(val) ^ 0x7fff : (val))
(~(val)) & 0x7fff : (val) & 0xff7fff)
#define BEEP_MASK_TO_REG(val,type) ((type) == as99127f ? \
(~(val)) & 0x7fff : (val) & 0xffffff)
(~(val)) & 0x7fff : (val) & 0xff7fff)

#define DIV_FROM_REG(val) (1 << (val))

Expand Down Expand Up @@ -240,7 +240,6 @@ struct w83781d_data {
u8 vid; /* Register encoding, combined */
u32 alarms; /* Register encoding, combined */
u32 beep_mask; /* Register encoding, combined */
u8 beep_enable; /* Boolean */
u8 pwm[4]; /* Register value */
u8 pwm2_enable; /* Boolean */
u16 sens[3]; /* 782D/783S only.
Expand Down Expand Up @@ -513,11 +512,6 @@ static ssize_t show_beep_mask (struct device *dev, struct device_attribute *attr
return sprintf(buf, "%ld\n",
(long)BEEP_MASK_FROM_REG(data->beep_mask, data->type));
}
static ssize_t show_beep_enable (struct device *dev, struct device_attribute *attr, char *buf)
{
struct w83781d_data *data = w83781d_update_device(dev);
return sprintf(buf, "%ld\n", (long)data->beep_enable);
}

static ssize_t
store_beep_mask(struct device *dev, struct device_attribute *attr,
Expand All @@ -529,12 +523,12 @@ store_beep_mask(struct device *dev, struct device_attribute *attr,
val = simple_strtoul(buf, NULL, 10);

mutex_lock(&data->update_lock);
data->beep_mask = BEEP_MASK_TO_REG(val, data->type);
data->beep_mask &= 0x8000; /* preserve beep enable */
data->beep_mask |= BEEP_MASK_TO_REG(val, data->type);
w83781d_write_value(data, W83781D_REG_BEEP_INTS1,
data->beep_mask & 0xff);
w83781d_write_value(data, W83781D_REG_BEEP_INTS2,
((data->beep_mask >> 8) & 0x7f)
| data->beep_enable << 7);
(data->beep_mask >> 8) & 0xff);
if (data->type != w83781d && data->type != as99127f) {
w83781d_write_value(data, W83781D_REG_BEEP_INTS3,
((data->beep_mask) >> 16) & 0xff);
Expand All @@ -544,31 +538,8 @@ store_beep_mask(struct device *dev, struct device_attribute *attr,
return count;
}

static ssize_t
store_beep_enable(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
struct w83781d_data *data = dev_get_drvdata(dev);
u32 val;

val = simple_strtoul(buf, NULL, 10);
if (val != 0 && val != 1)
return -EINVAL;

mutex_lock(&data->update_lock);
data->beep_enable = val;
val = w83781d_read_value(data, W83781D_REG_BEEP_INTS2) & 0x7f;
val |= data->beep_enable << 7;
w83781d_write_value(data, W83781D_REG_BEEP_INTS2, val);
mutex_unlock(&data->update_lock);

return count;
}

static DEVICE_ATTR(beep_mask, S_IRUGO | S_IWUSR,
show_beep_mask, store_beep_mask);
static DEVICE_ATTR(beep_enable, S_IRUGO | S_IWUSR,
show_beep_enable, store_beep_enable);

static ssize_t show_beep(struct device *dev, struct device_attribute *attr,
char *buf)
Expand Down Expand Up @@ -663,6 +634,8 @@ static SENSOR_DEVICE_ATTR(temp2_beep, S_IRUGO | S_IWUSR,
show_beep, store_beep, 5);
static SENSOR_DEVICE_ATTR(temp3_beep, S_IRUGO,
show_temp3_beep, store_beep, 13);
static SENSOR_DEVICE_ATTR(beep_enable, S_IRUGO | S_IWUSR,
show_beep, store_beep, 15);

static ssize_t
show_fan_div(struct device *dev, struct device_attribute *da, char *buf)
Expand Down Expand Up @@ -1029,7 +1002,7 @@ static struct attribute* w83781d_attributes[] = {
&dev_attr_vrm.attr,
&dev_attr_alarms.attr,
&dev_attr_beep_mask.attr,
&dev_attr_beep_enable.attr,
&sensor_dev_attr_beep_enable.dev_attr.attr,
NULL
};
static const struct attribute_group w83781d_group = {
Expand Down Expand Up @@ -1775,8 +1748,7 @@ static struct w83781d_data *w83781d_update_device(struct device *dev)
W83781D_REG_ALARM2) << 8);
}
i = w83781d_read_value(data, W83781D_REG_BEEP_INTS2);
data->beep_enable = i >> 7;
data->beep_mask = ((i & 0x7f) << 8) +
data->beep_mask = (i << 8) +
w83781d_read_value(data, W83781D_REG_BEEP_INTS1);
if ((data->type != w83781d) && (data->type != as99127f)) {
data->beep_mask |=
Expand Down

0 comments on commit 97f5aed

Please sign in to comment.