14 #include <linux/kernel.h>
15 #include <linux/module.h>
18 #include <linux/slab.h>
19 #include <linux/i2c.h>
58 dev_dbg(&client->
dev,
"Starting ltc4215 update\n");
88 voltage = regval * 151 / 1000;
92 voltage = regval * 605 / 10;
99 voltage = regval * 482 * 125 / 1000;
111 static unsigned int ltc4215_get_current(
struct device *dev)
134 const unsigned int curr = voltage / 4;
144 const int voltage = ltc4215_get_voltage(dev, attr->
index);
153 const unsigned int curr = ltc4215_get_current(dev);
162 const unsigned int curr = ltc4215_get_current(dev);
163 const int output_voltage = ltc4215_get_voltage(dev,
LTC4215_ADIN);
166 const unsigned int power =
abs(output_voltage * curr);
189 #define LTC4215_VOLTAGE(name, ltc4215_cmd_idx) \
190 static SENSOR_DEVICE_ATTR(name, S_IRUGO, \
191 ltc4215_show_voltage, NULL, ltc4215_cmd_idx)
193 #define LTC4215_CURRENT(name) \
194 static SENSOR_DEVICE_ATTR(name, S_IRUGO, \
195 ltc4215_show_current, NULL, 0);
197 #define LTC4215_POWER(name) \
198 static SENSOR_DEVICE_ATTR(name, S_IRUGO, \
199 ltc4215_show_power, NULL, 0);
201 #define LTC4215_ALARM(name, mask, reg) \
202 static SENSOR_DEVICE_ATTR_2(name, S_IRUGO, \
203 ltc4215_show_alarm, NULL, (mask), reg)
227 static struct attribute *ltc4215_attributes[] = {
228 &sensor_dev_attr_curr1_input.dev_attr.attr,
229 &sensor_dev_attr_curr1_max_alarm.dev_attr.attr,
231 &sensor_dev_attr_power1_input.dev_attr.attr,
233 &sensor_dev_attr_in1_input.dev_attr.attr,
234 &sensor_dev_attr_in1_max_alarm.dev_attr.attr,
235 &sensor_dev_attr_in1_min_alarm.dev_attr.attr,
237 &sensor_dev_attr_in2_input.dev_attr.attr,
238 &sensor_dev_attr_in2_min_alarm.dev_attr.attr,
244 .attrs = ltc4215_attributes,
261 i2c_set_clientdata(client, data);
275 goto out_hwmon_device_register;
280 out_hwmon_device_register:
285 static int ltc4215_remove(
struct i2c_client *client)
306 .probe = ltc4215_probe,
307 .remove = ltc4215_remove,
308 .id_table = ltc4215_id,