Source
170
170
result = data->adc_values[ch_num];
171
171
}
172
172
173
173
exit:
174
174
mutex_unlock(&data->update_lock);
175
175
176
176
return result;
177
177
}
178
178
179
179
/* Shows the voltage associated with the specified ADC channel */
180
-
static ssize_t powr1220_show_voltage(struct device *dev,
181
-
struct device_attribute *dev_attr, char *buf)
180
+
static ssize_t powr1220_voltage_show(struct device *dev,
181
+
struct device_attribute *dev_attr,
182
+
char *buf)
182
183
{
183
184
struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr);
184
185
int adc_val = powr1220_read_adc(dev, attr->index);
185
186
186
187
if (adc_val < 0)
187
188
return adc_val;
188
189
189
190
return sprintf(buf, "%d\n", adc_val);
190
191
}
191
192
192
193
/* Shows the maximum setting associated with the specified ADC channel */
193
-
static ssize_t powr1220_show_max(struct device *dev,
194
-
struct device_attribute *dev_attr, char *buf)
194
+
static ssize_t powr1220_max_show(struct device *dev,
195
+
struct device_attribute *dev_attr, char *buf)
195
196
{
196
197
struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr);
197
198
struct powr1220_data *data = dev_get_drvdata(dev);
198
199
199
200
return sprintf(buf, "%d\n", data->adc_maxes[attr->index]);
200
201
}
201
202
202
203
/* Shows the label associated with the specified ADC channel */
203
-
static ssize_t powr1220_show_label(struct device *dev,
204
-
struct device_attribute *dev_attr, char *buf)
204
+
static ssize_t powr1220_label_show(struct device *dev,
205
+
struct device_attribute *dev_attr,
206
+
char *buf)
205
207
{
206
208
struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr);
207
209
208
210
return sprintf(buf, "%s\n", input_names[attr->index]);
209
211
}
210
212
211
-
static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, powr1220_show_voltage, NULL,
212
-
VMON1);
213
-
static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, powr1220_show_voltage, NULL,
214
-
VMON2);
215
-
static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, powr1220_show_voltage, NULL,
216
-
VMON3);
217
-
static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, powr1220_show_voltage, NULL,
218
-
VMON4);
219
-
static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, powr1220_show_voltage, NULL,
220
-
VMON5);
221
-
static SENSOR_DEVICE_ATTR(in5_input, S_IRUGO, powr1220_show_voltage, NULL,
222
-
VMON6);
223
-
static SENSOR_DEVICE_ATTR(in6_input, S_IRUGO, powr1220_show_voltage, NULL,
224
-
VMON7);
225
-
static SENSOR_DEVICE_ATTR(in7_input, S_IRUGO, powr1220_show_voltage, NULL,
226
-
VMON8);
227
-
static SENSOR_DEVICE_ATTR(in8_input, S_IRUGO, powr1220_show_voltage, NULL,
228
-
VMON9);
229
-
static SENSOR_DEVICE_ATTR(in9_input, S_IRUGO, powr1220_show_voltage, NULL,
230
-
VMON10);
231
-
static SENSOR_DEVICE_ATTR(in10_input, S_IRUGO, powr1220_show_voltage, NULL,
232
-
VMON11);
233
-
static SENSOR_DEVICE_ATTR(in11_input, S_IRUGO, powr1220_show_voltage, NULL,
234
-
VMON12);
235
-
static SENSOR_DEVICE_ATTR(in12_input, S_IRUGO, powr1220_show_voltage, NULL,
236
-
VCCA);
237
-
static SENSOR_DEVICE_ATTR(in13_input, S_IRUGO, powr1220_show_voltage, NULL,
238
-
VCCINP);
239
-
240
-
static SENSOR_DEVICE_ATTR(in0_highest, S_IRUGO, powr1220_show_max, NULL,
241
-
VMON1);
242
-
static SENSOR_DEVICE_ATTR(in1_highest, S_IRUGO, powr1220_show_max, NULL,
243
-
VMON2);
244
-
static SENSOR_DEVICE_ATTR(in2_highest, S_IRUGO, powr1220_show_max, NULL,
245
-
VMON3);
246
-
static SENSOR_DEVICE_ATTR(in3_highest, S_IRUGO, powr1220_show_max, NULL,
247
-
VMON4);
248
-
static SENSOR_DEVICE_ATTR(in4_highest, S_IRUGO, powr1220_show_max, NULL,
249
-
VMON5);
250
-
static SENSOR_DEVICE_ATTR(in5_highest, S_IRUGO, powr1220_show_max, NULL,
251
-
VMON6);
252
-
static SENSOR_DEVICE_ATTR(in6_highest, S_IRUGO, powr1220_show_max, NULL,
253
-
VMON7);
254
-
static SENSOR_DEVICE_ATTR(in7_highest, S_IRUGO, powr1220_show_max, NULL,
255
-
VMON8);
256
-
static SENSOR_DEVICE_ATTR(in8_highest, S_IRUGO, powr1220_show_max, NULL,
257
-
VMON9);
258
-
static SENSOR_DEVICE_ATTR(in9_highest, S_IRUGO, powr1220_show_max, NULL,
259
-
VMON10);
260
-
static SENSOR_DEVICE_ATTR(in10_highest, S_IRUGO, powr1220_show_max, NULL,
261
-
VMON11);
262
-
static SENSOR_DEVICE_ATTR(in11_highest, S_IRUGO, powr1220_show_max, NULL,
263
-
VMON12);
264
-
static SENSOR_DEVICE_ATTR(in12_highest, S_IRUGO, powr1220_show_max, NULL,
265
-
VCCA);
266
-
static SENSOR_DEVICE_ATTR(in13_highest, S_IRUGO, powr1220_show_max, NULL,
267
-
VCCINP);
268
-
269
-
static SENSOR_DEVICE_ATTR(in0_label, S_IRUGO, powr1220_show_label, NULL,
270
-
VMON1);
271
-
static SENSOR_DEVICE_ATTR(in1_label, S_IRUGO, powr1220_show_label, NULL,
272
-
VMON2);
273
-
static SENSOR_DEVICE_ATTR(in2_label, S_IRUGO, powr1220_show_label, NULL,
274
-
VMON3);
275
-
static SENSOR_DEVICE_ATTR(in3_label, S_IRUGO, powr1220_show_label, NULL,
276
-
VMON4);
277
-
static SENSOR_DEVICE_ATTR(in4_label, S_IRUGO, powr1220_show_label, NULL,
278
-
VMON5);
279
-
static SENSOR_DEVICE_ATTR(in5_label, S_IRUGO, powr1220_show_label, NULL,
280
-
VMON6);
281
-
static SENSOR_DEVICE_ATTR(in6_label, S_IRUGO, powr1220_show_label, NULL,
282
-
VMON7);
283
-
static SENSOR_DEVICE_ATTR(in7_label, S_IRUGO, powr1220_show_label, NULL,
284
-
VMON8);
285
-
static SENSOR_DEVICE_ATTR(in8_label, S_IRUGO, powr1220_show_label, NULL,
286
-
VMON9);
287
-
static SENSOR_DEVICE_ATTR(in9_label, S_IRUGO, powr1220_show_label, NULL,
288
-
VMON10);
289
-
static SENSOR_DEVICE_ATTR(in10_label, S_IRUGO, powr1220_show_label, NULL,
290
-
VMON11);
291
-
static SENSOR_DEVICE_ATTR(in11_label, S_IRUGO, powr1220_show_label, NULL,
292
-
VMON12);
293
-
static SENSOR_DEVICE_ATTR(in12_label, S_IRUGO, powr1220_show_label, NULL,
294
-
VCCA);
295
-
static SENSOR_DEVICE_ATTR(in13_label, S_IRUGO, powr1220_show_label, NULL,
296
-
VCCINP);
213
+
static SENSOR_DEVICE_ATTR_RO(in0_input, powr1220_voltage, VMON1);
214
+
static SENSOR_DEVICE_ATTR_RO(in1_input, powr1220_voltage, VMON2);
215
+
static SENSOR_DEVICE_ATTR_RO(in2_input, powr1220_voltage, VMON3);
216
+
static SENSOR_DEVICE_ATTR_RO(in3_input, powr1220_voltage, VMON4);
217
+
static SENSOR_DEVICE_ATTR_RO(in4_input, powr1220_voltage, VMON5);
218
+
static SENSOR_DEVICE_ATTR_RO(in5_input, powr1220_voltage, VMON6);
219
+
static SENSOR_DEVICE_ATTR_RO(in6_input, powr1220_voltage, VMON7);
220
+
static SENSOR_DEVICE_ATTR_RO(in7_input, powr1220_voltage, VMON8);
221
+
static SENSOR_DEVICE_ATTR_RO(in8_input, powr1220_voltage, VMON9);
222
+
static SENSOR_DEVICE_ATTR_RO(in9_input, powr1220_voltage, VMON10);
223
+
static SENSOR_DEVICE_ATTR_RO(in10_input, powr1220_voltage, VMON11);
224
+
static SENSOR_DEVICE_ATTR_RO(in11_input, powr1220_voltage, VMON12);
225
+
static SENSOR_DEVICE_ATTR_RO(in12_input, powr1220_voltage, VCCA);
226
+
static SENSOR_DEVICE_ATTR_RO(in13_input, powr1220_voltage, VCCINP);
227
+
228
+
static SENSOR_DEVICE_ATTR_RO(in0_highest, powr1220_max, VMON1);
229
+
static SENSOR_DEVICE_ATTR_RO(in1_highest, powr1220_max, VMON2);
230
+
static SENSOR_DEVICE_ATTR_RO(in2_highest, powr1220_max, VMON3);
231
+
static SENSOR_DEVICE_ATTR_RO(in3_highest, powr1220_max, VMON4);
232
+
static SENSOR_DEVICE_ATTR_RO(in4_highest, powr1220_max, VMON5);
233
+
static SENSOR_DEVICE_ATTR_RO(in5_highest, powr1220_max, VMON6);
234
+
static SENSOR_DEVICE_ATTR_RO(in6_highest, powr1220_max, VMON7);
235
+
static SENSOR_DEVICE_ATTR_RO(in7_highest, powr1220_max, VMON8);
236
+
static SENSOR_DEVICE_ATTR_RO(in8_highest, powr1220_max, VMON9);
237
+
static SENSOR_DEVICE_ATTR_RO(in9_highest, powr1220_max, VMON10);
238
+
static SENSOR_DEVICE_ATTR_RO(in10_highest, powr1220_max, VMON11);
239
+
static SENSOR_DEVICE_ATTR_RO(in11_highest, powr1220_max, VMON12);
240
+
static SENSOR_DEVICE_ATTR_RO(in12_highest, powr1220_max, VCCA);
241
+
static SENSOR_DEVICE_ATTR_RO(in13_highest, powr1220_max, VCCINP);
242
+
243
+
static SENSOR_DEVICE_ATTR_RO(in0_label, powr1220_label, VMON1);
244
+
static SENSOR_DEVICE_ATTR_RO(in1_label, powr1220_label, VMON2);
245
+
static SENSOR_DEVICE_ATTR_RO(in2_label, powr1220_label, VMON3);
246
+
static SENSOR_DEVICE_ATTR_RO(in3_label, powr1220_label, VMON4);
247
+
static SENSOR_DEVICE_ATTR_RO(in4_label, powr1220_label, VMON5);
248
+
static SENSOR_DEVICE_ATTR_RO(in5_label, powr1220_label, VMON6);
249
+
static SENSOR_DEVICE_ATTR_RO(in6_label, powr1220_label, VMON7);
250
+
static SENSOR_DEVICE_ATTR_RO(in7_label, powr1220_label, VMON8);
251
+
static SENSOR_DEVICE_ATTR_RO(in8_label, powr1220_label, VMON9);
252
+
static SENSOR_DEVICE_ATTR_RO(in9_label, powr1220_label, VMON10);
253
+
static SENSOR_DEVICE_ATTR_RO(in10_label, powr1220_label, VMON11);
254
+
static SENSOR_DEVICE_ATTR_RO(in11_label, powr1220_label, VMON12);
255
+
static SENSOR_DEVICE_ATTR_RO(in12_label, powr1220_label, VCCA);
256
+
static SENSOR_DEVICE_ATTR_RO(in13_label, powr1220_label, VCCINP);
297
257
298
258
static struct attribute *powr1220_attrs[] = {
299
259
&sensor_dev_attr_in0_input.dev_attr.attr,
300
260
&sensor_dev_attr_in1_input.dev_attr.attr,
301
261
&sensor_dev_attr_in2_input.dev_attr.attr,
302
262
&sensor_dev_attr_in3_input.dev_attr.attr,
303
263
&sensor_dev_attr_in4_input.dev_attr.attr,
304
264
&sensor_dev_attr_in5_input.dev_attr.attr,
305
265
&sensor_dev_attr_in6_input.dev_attr.attr,
306
266
&sensor_dev_attr_in7_input.dev_attr.attr,