28 #include <linux/kernel.h>
29 #include <linux/module.h>
32 #include <linux/slab.h>
33 #include <linux/i2c.h>
39 #define LTC4261_STATUS 0x00
40 #define LTC4261_FAULT 0x01
41 #define LTC4261_ALERT 0x02
42 #define LTC4261_CONTROL 0x03
43 #define LTC4261_SENSE_H 0x04
44 #define LTC4261_SENSE_L 0x05
45 #define LTC4261_ADIN2_H 0x06
46 #define LTC4261_ADIN2_L 0x07
47 #define LTC4261_ADIN_H 0x08
48 #define LTC4261_ADIN_L 0x09
53 #define FAULT_OV (1<<0)
54 #define FAULT_UV (1<<1)
55 #define FAULT_OC (1<<2)
86 "Failed to read ADC value: error %d\n",
107 val = (data->
regs[
reg] << 2) + (data->
regs[reg + 1] >> 6);
123 val = val * 625 / 10;
143 return PTR_ERR(data);
145 value = ltc4261_get_value(data, attr->
index);
158 return PTR_ERR(data);
173 #define LTC4261_VALUE(name, ltc4261_cmd_idx) \
174 static SENSOR_DEVICE_ATTR(name, S_IRUGO, \
175 ltc4261_show_value, NULL, ltc4261_cmd_idx)
177 #define LTC4261_BOOL(name, mask) \
178 static SENSOR_DEVICE_ATTR(name, S_IRUGO, \
179 ltc4261_show_bool, NULL, (mask))
206 static struct attribute *ltc4261_attributes[] = {
207 &sensor_dev_attr_in1_input.dev_attr.attr,
208 &sensor_dev_attr_in1_min_alarm.dev_attr.attr,
209 &sensor_dev_attr_in1_max_alarm.dev_attr.attr,
210 &sensor_dev_attr_in2_input.dev_attr.attr,
211 &sensor_dev_attr_in2_min_alarm.dev_attr.attr,
212 &sensor_dev_attr_in2_max_alarm.dev_attr.attr,
214 &sensor_dev_attr_curr1_input.dev_attr.attr,
215 &sensor_dev_attr_curr1_max_alarm.dev_attr.attr,
221 .attrs = ltc4261_attributes,
224 static int ltc4261_probe(
struct i2c_client *client,
235 dev_err(&client->
dev,
"Failed to read status register\n");
243 i2c_set_clientdata(client, data);
257 goto out_hwmon_device_register;
262 out_hwmon_device_register:
267 static int ltc4261_remove(
struct i2c_client *client)
289 .probe = ltc4261_probe,
290 .remove = ltc4261_remove,
291 .id_table = ltc4261_id,