Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 363050
b: refs/heads/master
c: b5f0f1e
h: refs/heads/master
v: v3
  • Loading branch information
Guenter Roeck committed Apr 8, 2013
1 parent b6742da commit 0f4916f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 29 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: bc0c591ec1d1f5dd0549c0f0d003647d197a025b
refs/heads/master: b5f0f1eadf14d7afad8c8c7aadee7527082efaac
46 changes: 18 additions & 28 deletions trunk/drivers/hwmon/ltc4215.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,12 @@ static ssize_t ltc4215_show_alarm(struct device *dev,
struct device_attribute *da,
char *buf)
{
struct sensor_device_attribute_2 *attr = to_sensor_dev_attr_2(da);
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct ltc4215_data *data = ltc4215_update_device(dev);
const u8 reg = data->regs[attr->index];
const u32 mask = attr->nr;
const u8 reg = data->regs[LTC4215_STATUS];
const u32 mask = attr->index;

return snprintf(buf, PAGE_SIZE, "%u\n", (reg & mask) ? 1 : 0);
return snprintf(buf, PAGE_SIZE, "%u\n", !!(reg & mask));
}

/*
Expand All @@ -186,39 +186,29 @@ static ssize_t ltc4215_show_alarm(struct device *dev,
* for each register.
*/

#define LTC4215_VOLTAGE(name, ltc4215_cmd_idx) \
static SENSOR_DEVICE_ATTR(name, S_IRUGO, \
ltc4215_show_voltage, NULL, ltc4215_cmd_idx)

#define LTC4215_CURRENT(name) \
static SENSOR_DEVICE_ATTR(name, S_IRUGO, \
ltc4215_show_current, NULL, 0);

#define LTC4215_POWER(name) \
static SENSOR_DEVICE_ATTR(name, S_IRUGO, \
ltc4215_show_power, NULL, 0);

#define LTC4215_ALARM(name, mask, reg) \
static SENSOR_DEVICE_ATTR_2(name, S_IRUGO, \
ltc4215_show_alarm, NULL, (mask), reg)

/* Construct a sensor_device_attribute structure for each register */

/* Current */
LTC4215_CURRENT(curr1_input);
LTC4215_ALARM(curr1_max_alarm, (1 << 2), LTC4215_STATUS);
static SENSOR_DEVICE_ATTR(curr1_input, S_IRUGO, ltc4215_show_current, NULL, 0);
static SENSOR_DEVICE_ATTR(curr1_max_alarm, S_IRUGO, ltc4215_show_alarm, NULL,
1 << 2);

/* Power (virtual) */
LTC4215_POWER(power1_input);
static SENSOR_DEVICE_ATTR(power1_input, S_IRUGO, ltc4215_show_power, NULL, 0);

/* Input Voltage */
LTC4215_VOLTAGE(in1_input, LTC4215_ADIN);
LTC4215_ALARM(in1_max_alarm, (1 << 0), LTC4215_STATUS);
LTC4215_ALARM(in1_min_alarm, (1 << 1), LTC4215_STATUS);
static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, ltc4215_show_voltage, NULL,
LTC4215_ADIN);
static SENSOR_DEVICE_ATTR(in1_max_alarm, S_IRUGO, ltc4215_show_alarm, NULL,
1 << 0);
static SENSOR_DEVICE_ATTR(in1_min_alarm, S_IRUGO, ltc4215_show_alarm, NULL,
1 << 1);

/* Output Voltage */
LTC4215_VOLTAGE(in2_input, LTC4215_SOURCE);
LTC4215_ALARM(in2_min_alarm, (1 << 3), LTC4215_STATUS);
static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, ltc4215_show_voltage, NULL,
LTC4215_SOURCE);
static SENSOR_DEVICE_ATTR(in2_min_alarm, S_IRUGO, ltc4215_show_alarm, NULL,
1 << 3);

/*
* Finally, construct an array of pointers to members of the above objects,
Expand Down

0 comments on commit 0f4916f

Please sign in to comment.