14 #include <linux/kernel.h>
15 #include <linux/module.h>
18 #include <linux/slab.h>
20 #include <linux/device.h>
27 #define MAX199_LIMIT 4000
28 #define MAX197_LIMIT 10000
30 #define MAX197_NUM_CH 8
33 #define MAX197_BIP (1 << 3)
34 #define MAX197_RNG (1 << 4)
36 #define MAX197_SCALE 12207
96 bool is_min = attr->
nr;
102 range = max197_is_full_range(data, channel) ?
105 if (max197_is_bipolar(data, channel))
113 return sprintf(buf,
"%d\n", range);
119 const char *buf,
size_t count)
123 int channel = attr->
index;
124 bool is_min = attr->
nr;
129 if (kstrtol(buf, 10, &value))
151 max197_set_unipolarity(data, channel);
152 }
else if (value == -half) {
153 max197_set_bipolarity(data, channel);
154 max197_set_half_range(data, channel);
155 }
else if (value == -full) {
156 max197_set_bipolarity(data, channel);
157 max197_set_full_range(data, channel);
158 }
else if (value == half) {
160 max197_set_half_range(data, channel);
161 }
else if (value == full) {
163 max197_set_full_range(data, channel);
178 int channel = attr->
index;
187 dev_err(dev,
"conversion failed\n");
198 if (max197_is_full_range(data, channel))
203 ret =
sprintf(buf,
"%d\n", value);
217 #define MAX197_SENSOR_DEVICE_ATTR_CH(chan) \
218 static SENSOR_DEVICE_ATTR(in##chan##_input, S_IRUGO, \
219 max197_show_input, NULL, chan); \
220 static SENSOR_DEVICE_ATTR_2(in##chan##_min, S_IRUGO | S_IWUSR, \
222 max197_store_range, \
224 static SENSOR_DEVICE_ATTR_2(in##chan##_max, S_IRUGO | S_IWUSR, \
226 max197_store_range, \
229 #define MAX197_SENSOR_DEV_ATTR_IN(chan) \
230 &sensor_dev_attr_in##chan##_input.dev_attr.attr, \
231 &sensor_dev_attr_in##chan##_max.dev_attr.attr, \
232 &sensor_dev_attr_in##chan##_min.dev_attr.attr
268 dev_err(&pdev->
dev,
"no platform data supplied\n");
273 dev_err(&pdev->
dev,
"no convert function supplied\n");
297 platform_set_drvdata(pdev, data);
301 dev_err(&pdev->
dev,
"sysfs create group failed\n");
308 dev_err(&pdev->
dev,
"hwmon device register failed\n");
321 struct max197_data *data = platform_get_drvdata(pdev);
341 .probe = max197_probe,
343 .id_table = max197_device_ids,