23 #include <linux/module.h>
24 #include <linux/slab.h>
70 static int s3c_hwmon_read_ch(
struct device *
dev,
79 dev_dbg(dev,
"reading channel %d\n", channel);
87 #ifdef CONFIG_SENSORS_S3C_RAW
105 ret = s3c_hwmon_read_ch(dev, adc, sa->
index);
110 #define DEF_ADC_ATTR(x) \
111 static SENSOR_DEVICE_ATTR(adc##x##_raw, S_IRUGO, s3c_hwmon_show_raw, NULL, x)
122 static struct attribute *s3c_hwmon_attrs[9] = {
123 &sensor_dev_attr_adc0_raw.dev_attr.attr,
124 &sensor_dev_attr_adc1_raw.dev_attr.attr,
125 &sensor_dev_attr_adc2_raw.dev_attr.attr,
126 &sensor_dev_attr_adc3_raw.dev_attr.attr,
127 &sensor_dev_attr_adc4_raw.dev_attr.attr,
128 &sensor_dev_attr_adc5_raw.dev_attr.attr,
129 &sensor_dev_attr_adc6_raw.dev_attr.attr,
130 &sensor_dev_attr_adc7_raw.dev_attr.attr,
135 .
attrs = s3c_hwmon_attrs,
138 static inline int s3c_hwmon_add_raw(
struct device *dev)
143 static inline void s3c_hwmon_remove_raw(
struct device *dev)
150 static inline int s3c_hwmon_add_raw(
struct device *dev) {
return 0; }
151 static inline void s3c_hwmon_remove_raw(
struct device *dev) { }
175 cfg = pdata->
in[sen_attr->
index];
177 ret = s3c_hwmon_read_ch(dev, hwmon, sen_attr->
index);
203 cfg = pdata->
in[sen_attr->
index];
222 static int s3c_hwmon_create_attr(
struct device *dev,
237 attr->
dev_attr.show = s3c_hwmon_ch_show;
241 dev_err(dev,
"failed to create input attribute\n");
248 "in%d_label", channel);
250 attr = &attrs->
label;
255 attr->
dev_attr.show = s3c_hwmon_label_show;
260 dev_err(dev,
"failed to create label attribute\n");
267 static void s3c_hwmon_remove_attr(
struct device *dev,
286 dev_err(&dev->
dev,
"no platform data supplied\n");
296 platform_set_drvdata(dev, hwmon);
303 if (IS_ERR(hwmon->
client)) {
305 return PTR_ERR(hwmon->
client);
310 ret = s3c_hwmon_add_raw(&dev->
dev);
318 dev_err(&dev->
dev,
"error registering with hwmon\n");
320 goto err_raw_attribute;
329 if (cfg->
mult >= 0x10000)
331 "channel %d multiplier too large\n",
335 dev_err(&dev->
dev,
"channel %d divider zero\n", i);
339 ret = s3c_hwmon_create_attr(&dev->
dev, pdata->
in[i],
340 &hwmon->
attrs[i], i);
343 "error creating channel %d\n", i);
345 for (i--; i >= 0; i--)
346 s3c_hwmon_remove_attr(&dev->
dev,
349 goto err_hwmon_register;
359 s3c_hwmon_remove_raw(&dev->
dev);
369 struct s3c_hwmon *hwmon = platform_get_drvdata(dev);
372 s3c_hwmon_remove_raw(&dev->
dev);
375 s3c_hwmon_remove_attr(&dev->
dev, &hwmon->
attrs[i]);
388 .probe = s3c_hwmon_probe,