.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * pc87360.c - Part of lm_sensors, Linux kernel modules |
---|
3 | 4 | * for hardware monitoring |
---|
.. | .. |
---|
5 | 6 | * |
---|
6 | 7 | * Copied from smsc47m1.c: |
---|
7 | 8 | * Copyright (C) 2002 Mark D. Studebaker <mdsxyz123@yahoo.com> |
---|
8 | | - * |
---|
9 | | - * This program is free software; you can redistribute it and/or modify |
---|
10 | | - * it under the terms of the GNU General Public License as published by |
---|
11 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
12 | | - * (at your option) any later version. |
---|
13 | | - * |
---|
14 | | - * This program is distributed in the hope that it will be useful, |
---|
15 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | | - * GNU General Public License for more details. |
---|
18 | | - * |
---|
19 | | - * You should have received a copy of the GNU General Public License |
---|
20 | | - * along with this program; if not, write to the Free Software |
---|
21 | | - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
22 | 9 | * |
---|
23 | 10 | * Supports the following chips: |
---|
24 | 11 | * |
---|
.. | .. |
---|
254 | 241 | * Sysfs stuff |
---|
255 | 242 | */ |
---|
256 | 243 | |
---|
257 | | -static ssize_t show_fan_input(struct device *dev, |
---|
| 244 | +static ssize_t fan_input_show(struct device *dev, |
---|
258 | 245 | struct device_attribute *devattr, char *buf) |
---|
259 | 246 | { |
---|
260 | 247 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
.. | .. |
---|
262 | 249 | return sprintf(buf, "%u\n", FAN_FROM_REG(data->fan[attr->index], |
---|
263 | 250 | FAN_DIV_FROM_REG(data->fan_status[attr->index]))); |
---|
264 | 251 | } |
---|
265 | | -static ssize_t show_fan_min(struct device *dev, |
---|
| 252 | +static ssize_t fan_min_show(struct device *dev, |
---|
266 | 253 | struct device_attribute *devattr, char *buf) |
---|
267 | 254 | { |
---|
268 | 255 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
.. | .. |
---|
270 | 257 | return sprintf(buf, "%u\n", FAN_FROM_REG(data->fan_min[attr->index], |
---|
271 | 258 | FAN_DIV_FROM_REG(data->fan_status[attr->index]))); |
---|
272 | 259 | } |
---|
273 | | -static ssize_t show_fan_div(struct device *dev, |
---|
| 260 | +static ssize_t fan_div_show(struct device *dev, |
---|
274 | 261 | struct device_attribute *devattr, char *buf) |
---|
275 | 262 | { |
---|
276 | 263 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
.. | .. |
---|
278 | 265 | return sprintf(buf, "%u\n", |
---|
279 | 266 | FAN_DIV_FROM_REG(data->fan_status[attr->index])); |
---|
280 | 267 | } |
---|
281 | | -static ssize_t show_fan_status(struct device *dev, |
---|
| 268 | +static ssize_t fan_status_show(struct device *dev, |
---|
282 | 269 | struct device_attribute *devattr, char *buf) |
---|
283 | 270 | { |
---|
284 | 271 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
.. | .. |
---|
286 | 273 | return sprintf(buf, "%u\n", |
---|
287 | 274 | FAN_STATUS_FROM_REG(data->fan_status[attr->index])); |
---|
288 | 275 | } |
---|
289 | | -static ssize_t set_fan_min(struct device *dev, |
---|
290 | | - struct device_attribute *devattr, const char *buf, |
---|
291 | | - size_t count) |
---|
| 276 | +static ssize_t fan_min_store(struct device *dev, |
---|
| 277 | + struct device_attribute *devattr, |
---|
| 278 | + const char *buf, size_t count) |
---|
292 | 279 | { |
---|
293 | 280 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
294 | 281 | struct pc87360_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
325 | 312 | } |
---|
326 | 313 | |
---|
327 | 314 | static struct sensor_device_attribute fan_input[] = { |
---|
328 | | - SENSOR_ATTR(fan1_input, S_IRUGO, show_fan_input, NULL, 0), |
---|
329 | | - SENSOR_ATTR(fan2_input, S_IRUGO, show_fan_input, NULL, 1), |
---|
330 | | - SENSOR_ATTR(fan3_input, S_IRUGO, show_fan_input, NULL, 2), |
---|
| 315 | + SENSOR_ATTR_RO(fan1_input, fan_input, 0), |
---|
| 316 | + SENSOR_ATTR_RO(fan2_input, fan_input, 1), |
---|
| 317 | + SENSOR_ATTR_RO(fan3_input, fan_input, 2), |
---|
331 | 318 | }; |
---|
332 | 319 | static struct sensor_device_attribute fan_status[] = { |
---|
333 | | - SENSOR_ATTR(fan1_status, S_IRUGO, show_fan_status, NULL, 0), |
---|
334 | | - SENSOR_ATTR(fan2_status, S_IRUGO, show_fan_status, NULL, 1), |
---|
335 | | - SENSOR_ATTR(fan3_status, S_IRUGO, show_fan_status, NULL, 2), |
---|
| 320 | + SENSOR_ATTR_RO(fan1_status, fan_status, 0), |
---|
| 321 | + SENSOR_ATTR_RO(fan2_status, fan_status, 1), |
---|
| 322 | + SENSOR_ATTR_RO(fan3_status, fan_status, 2), |
---|
336 | 323 | }; |
---|
337 | 324 | static struct sensor_device_attribute fan_div[] = { |
---|
338 | | - SENSOR_ATTR(fan1_div, S_IRUGO, show_fan_div, NULL, 0), |
---|
339 | | - SENSOR_ATTR(fan2_div, S_IRUGO, show_fan_div, NULL, 1), |
---|
340 | | - SENSOR_ATTR(fan3_div, S_IRUGO, show_fan_div, NULL, 2), |
---|
| 325 | + SENSOR_ATTR_RO(fan1_div, fan_div, 0), |
---|
| 326 | + SENSOR_ATTR_RO(fan2_div, fan_div, 1), |
---|
| 327 | + SENSOR_ATTR_RO(fan3_div, fan_div, 2), |
---|
341 | 328 | }; |
---|
342 | 329 | static struct sensor_device_attribute fan_min[] = { |
---|
343 | | - SENSOR_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan_min, set_fan_min, 0), |
---|
344 | | - SENSOR_ATTR(fan2_min, S_IWUSR | S_IRUGO, show_fan_min, set_fan_min, 1), |
---|
345 | | - SENSOR_ATTR(fan3_min, S_IWUSR | S_IRUGO, show_fan_min, set_fan_min, 2), |
---|
| 330 | + SENSOR_ATTR_RW(fan1_min, fan_min, 0), |
---|
| 331 | + SENSOR_ATTR_RW(fan2_min, fan_min, 1), |
---|
| 332 | + SENSOR_ATTR_RW(fan3_min, fan_min, 2), |
---|
346 | 333 | }; |
---|
347 | 334 | |
---|
348 | 335 | #define FAN_UNIT_ATTRS(X) \ |
---|
.. | .. |
---|
353 | 340 | NULL \ |
---|
354 | 341 | } |
---|
355 | 342 | |
---|
356 | | -static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, |
---|
| 343 | +static ssize_t pwm_show(struct device *dev, struct device_attribute *devattr, |
---|
357 | 344 | char *buf) |
---|
358 | 345 | { |
---|
359 | 346 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
.. | .. |
---|
363 | 350 | FAN_CONFIG_INVERT(data->fan_conf, |
---|
364 | 351 | attr->index))); |
---|
365 | 352 | } |
---|
366 | | -static ssize_t set_pwm(struct device *dev, struct device_attribute *devattr, |
---|
367 | | - const char *buf, size_t count) |
---|
| 353 | +static ssize_t pwm_store(struct device *dev, struct device_attribute *devattr, |
---|
| 354 | + const char *buf, size_t count) |
---|
368 | 355 | { |
---|
369 | 356 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
370 | 357 | struct pc87360_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
385 | 372 | } |
---|
386 | 373 | |
---|
387 | 374 | static struct sensor_device_attribute pwm[] = { |
---|
388 | | - SENSOR_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 0), |
---|
389 | | - SENSOR_ATTR(pwm2, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 1), |
---|
390 | | - SENSOR_ATTR(pwm3, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 2), |
---|
| 375 | + SENSOR_ATTR_RW(pwm1, pwm, 0), |
---|
| 376 | + SENSOR_ATTR_RW(pwm2, pwm, 1), |
---|
| 377 | + SENSOR_ATTR_RW(pwm3, pwm, 2), |
---|
391 | 378 | }; |
---|
392 | 379 | |
---|
393 | 380 | static struct attribute *pc8736x_fan_attr[][5] = { |
---|
.. | .. |
---|
402 | 389 | { .attrs = pc8736x_fan_attr[2], }, |
---|
403 | 390 | }; |
---|
404 | 391 | |
---|
405 | | -static ssize_t show_in_input(struct device *dev, |
---|
| 392 | +static ssize_t in_input_show(struct device *dev, |
---|
406 | 393 | struct device_attribute *devattr, char *buf) |
---|
407 | 394 | { |
---|
408 | 395 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
.. | .. |
---|
410 | 397 | return sprintf(buf, "%u\n", IN_FROM_REG(data->in[attr->index], |
---|
411 | 398 | data->in_vref)); |
---|
412 | 399 | } |
---|
413 | | -static ssize_t show_in_min(struct device *dev, |
---|
| 400 | +static ssize_t in_min_show(struct device *dev, |
---|
414 | 401 | struct device_attribute *devattr, char *buf) |
---|
415 | 402 | { |
---|
416 | 403 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
.. | .. |
---|
418 | 405 | return sprintf(buf, "%u\n", IN_FROM_REG(data->in_min[attr->index], |
---|
419 | 406 | data->in_vref)); |
---|
420 | 407 | } |
---|
421 | | -static ssize_t show_in_max(struct device *dev, |
---|
| 408 | +static ssize_t in_max_show(struct device *dev, |
---|
422 | 409 | struct device_attribute *devattr, char *buf) |
---|
423 | 410 | { |
---|
424 | 411 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
.. | .. |
---|
426 | 413 | return sprintf(buf, "%u\n", IN_FROM_REG(data->in_max[attr->index], |
---|
427 | 414 | data->in_vref)); |
---|
428 | 415 | } |
---|
429 | | -static ssize_t show_in_status(struct device *dev, |
---|
| 416 | +static ssize_t in_status_show(struct device *dev, |
---|
430 | 417 | struct device_attribute *devattr, char *buf) |
---|
431 | 418 | { |
---|
432 | 419 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
433 | 420 | struct pc87360_data *data = pc87360_update_device(dev); |
---|
434 | 421 | return sprintf(buf, "%u\n", data->in_status[attr->index]); |
---|
435 | 422 | } |
---|
436 | | -static ssize_t set_in_min(struct device *dev, struct device_attribute *devattr, |
---|
437 | | - const char *buf, size_t count) |
---|
| 423 | +static ssize_t in_min_store(struct device *dev, |
---|
| 424 | + struct device_attribute *devattr, const char *buf, |
---|
| 425 | + size_t count) |
---|
438 | 426 | { |
---|
439 | 427 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
440 | 428 | struct pc87360_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
452 | 440 | mutex_unlock(&data->update_lock); |
---|
453 | 441 | return count; |
---|
454 | 442 | } |
---|
455 | | -static ssize_t set_in_max(struct device *dev, struct device_attribute *devattr, |
---|
456 | | - const char *buf, size_t count) |
---|
| 443 | +static ssize_t in_max_store(struct device *dev, |
---|
| 444 | + struct device_attribute *devattr, const char *buf, |
---|
| 445 | + size_t count) |
---|
457 | 446 | { |
---|
458 | 447 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
459 | 448 | struct pc87360_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
474 | 463 | } |
---|
475 | 464 | |
---|
476 | 465 | static struct sensor_device_attribute in_input[] = { |
---|
477 | | - SENSOR_ATTR(in0_input, S_IRUGO, show_in_input, NULL, 0), |
---|
478 | | - SENSOR_ATTR(in1_input, S_IRUGO, show_in_input, NULL, 1), |
---|
479 | | - SENSOR_ATTR(in2_input, S_IRUGO, show_in_input, NULL, 2), |
---|
480 | | - SENSOR_ATTR(in3_input, S_IRUGO, show_in_input, NULL, 3), |
---|
481 | | - SENSOR_ATTR(in4_input, S_IRUGO, show_in_input, NULL, 4), |
---|
482 | | - SENSOR_ATTR(in5_input, S_IRUGO, show_in_input, NULL, 5), |
---|
483 | | - SENSOR_ATTR(in6_input, S_IRUGO, show_in_input, NULL, 6), |
---|
484 | | - SENSOR_ATTR(in7_input, S_IRUGO, show_in_input, NULL, 7), |
---|
485 | | - SENSOR_ATTR(in8_input, S_IRUGO, show_in_input, NULL, 8), |
---|
486 | | - SENSOR_ATTR(in9_input, S_IRUGO, show_in_input, NULL, 9), |
---|
487 | | - SENSOR_ATTR(in10_input, S_IRUGO, show_in_input, NULL, 10), |
---|
| 466 | + SENSOR_ATTR_RO(in0_input, in_input, 0), |
---|
| 467 | + SENSOR_ATTR_RO(in1_input, in_input, 1), |
---|
| 468 | + SENSOR_ATTR_RO(in2_input, in_input, 2), |
---|
| 469 | + SENSOR_ATTR_RO(in3_input, in_input, 3), |
---|
| 470 | + SENSOR_ATTR_RO(in4_input, in_input, 4), |
---|
| 471 | + SENSOR_ATTR_RO(in5_input, in_input, 5), |
---|
| 472 | + SENSOR_ATTR_RO(in6_input, in_input, 6), |
---|
| 473 | + SENSOR_ATTR_RO(in7_input, in_input, 7), |
---|
| 474 | + SENSOR_ATTR_RO(in8_input, in_input, 8), |
---|
| 475 | + SENSOR_ATTR_RO(in9_input, in_input, 9), |
---|
| 476 | + SENSOR_ATTR_RO(in10_input, in_input, 10), |
---|
488 | 477 | }; |
---|
489 | 478 | static struct sensor_device_attribute in_status[] = { |
---|
490 | | - SENSOR_ATTR(in0_status, S_IRUGO, show_in_status, NULL, 0), |
---|
491 | | - SENSOR_ATTR(in1_status, S_IRUGO, show_in_status, NULL, 1), |
---|
492 | | - SENSOR_ATTR(in2_status, S_IRUGO, show_in_status, NULL, 2), |
---|
493 | | - SENSOR_ATTR(in3_status, S_IRUGO, show_in_status, NULL, 3), |
---|
494 | | - SENSOR_ATTR(in4_status, S_IRUGO, show_in_status, NULL, 4), |
---|
495 | | - SENSOR_ATTR(in5_status, S_IRUGO, show_in_status, NULL, 5), |
---|
496 | | - SENSOR_ATTR(in6_status, S_IRUGO, show_in_status, NULL, 6), |
---|
497 | | - SENSOR_ATTR(in7_status, S_IRUGO, show_in_status, NULL, 7), |
---|
498 | | - SENSOR_ATTR(in8_status, S_IRUGO, show_in_status, NULL, 8), |
---|
499 | | - SENSOR_ATTR(in9_status, S_IRUGO, show_in_status, NULL, 9), |
---|
500 | | - SENSOR_ATTR(in10_status, S_IRUGO, show_in_status, NULL, 10), |
---|
| 479 | + SENSOR_ATTR_RO(in0_status, in_status, 0), |
---|
| 480 | + SENSOR_ATTR_RO(in1_status, in_status, 1), |
---|
| 481 | + SENSOR_ATTR_RO(in2_status, in_status, 2), |
---|
| 482 | + SENSOR_ATTR_RO(in3_status, in_status, 3), |
---|
| 483 | + SENSOR_ATTR_RO(in4_status, in_status, 4), |
---|
| 484 | + SENSOR_ATTR_RO(in5_status, in_status, 5), |
---|
| 485 | + SENSOR_ATTR_RO(in6_status, in_status, 6), |
---|
| 486 | + SENSOR_ATTR_RO(in7_status, in_status, 7), |
---|
| 487 | + SENSOR_ATTR_RO(in8_status, in_status, 8), |
---|
| 488 | + SENSOR_ATTR_RO(in9_status, in_status, 9), |
---|
| 489 | + SENSOR_ATTR_RO(in10_status, in_status, 10), |
---|
501 | 490 | }; |
---|
502 | 491 | static struct sensor_device_attribute in_min[] = { |
---|
503 | | - SENSOR_ATTR(in0_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 0), |
---|
504 | | - SENSOR_ATTR(in1_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 1), |
---|
505 | | - SENSOR_ATTR(in2_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 2), |
---|
506 | | - SENSOR_ATTR(in3_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 3), |
---|
507 | | - SENSOR_ATTR(in4_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 4), |
---|
508 | | - SENSOR_ATTR(in5_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 5), |
---|
509 | | - SENSOR_ATTR(in6_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 6), |
---|
510 | | - SENSOR_ATTR(in7_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 7), |
---|
511 | | - SENSOR_ATTR(in8_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 8), |
---|
512 | | - SENSOR_ATTR(in9_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 9), |
---|
513 | | - SENSOR_ATTR(in10_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 10), |
---|
| 492 | + SENSOR_ATTR_RW(in0_min, in_min, 0), |
---|
| 493 | + SENSOR_ATTR_RW(in1_min, in_min, 1), |
---|
| 494 | + SENSOR_ATTR_RW(in2_min, in_min, 2), |
---|
| 495 | + SENSOR_ATTR_RW(in3_min, in_min, 3), |
---|
| 496 | + SENSOR_ATTR_RW(in4_min, in_min, 4), |
---|
| 497 | + SENSOR_ATTR_RW(in5_min, in_min, 5), |
---|
| 498 | + SENSOR_ATTR_RW(in6_min, in_min, 6), |
---|
| 499 | + SENSOR_ATTR_RW(in7_min, in_min, 7), |
---|
| 500 | + SENSOR_ATTR_RW(in8_min, in_min, 8), |
---|
| 501 | + SENSOR_ATTR_RW(in9_min, in_min, 9), |
---|
| 502 | + SENSOR_ATTR_RW(in10_min, in_min, 10), |
---|
514 | 503 | }; |
---|
515 | 504 | static struct sensor_device_attribute in_max[] = { |
---|
516 | | - SENSOR_ATTR(in0_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 0), |
---|
517 | | - SENSOR_ATTR(in1_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 1), |
---|
518 | | - SENSOR_ATTR(in2_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 2), |
---|
519 | | - SENSOR_ATTR(in3_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 3), |
---|
520 | | - SENSOR_ATTR(in4_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 4), |
---|
521 | | - SENSOR_ATTR(in5_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 5), |
---|
522 | | - SENSOR_ATTR(in6_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 6), |
---|
523 | | - SENSOR_ATTR(in7_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 7), |
---|
524 | | - SENSOR_ATTR(in8_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 8), |
---|
525 | | - SENSOR_ATTR(in9_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 9), |
---|
526 | | - SENSOR_ATTR(in10_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 10), |
---|
| 505 | + SENSOR_ATTR_RW(in0_max, in_max, 0), |
---|
| 506 | + SENSOR_ATTR_RW(in1_max, in_max, 1), |
---|
| 507 | + SENSOR_ATTR_RW(in2_max, in_max, 2), |
---|
| 508 | + SENSOR_ATTR_RW(in3_max, in_max, 3), |
---|
| 509 | + SENSOR_ATTR_RW(in4_max, in_max, 4), |
---|
| 510 | + SENSOR_ATTR_RW(in5_max, in_max, 5), |
---|
| 511 | + SENSOR_ATTR_RW(in6_max, in_max, 6), |
---|
| 512 | + SENSOR_ATTR_RW(in7_max, in_max, 7), |
---|
| 513 | + SENSOR_ATTR_RW(in8_max, in_max, 8), |
---|
| 514 | + SENSOR_ATTR_RW(in9_max, in_max, 9), |
---|
| 515 | + SENSOR_ATTR_RW(in10_max, in_max, 10), |
---|
527 | 516 | }; |
---|
528 | 517 | |
---|
529 | 518 | /* (temp & vin) channel status register alarm bits (pdf sec.11.5.12) */ |
---|
.. | .. |
---|
537 | 526 | * 11.5.2) that (legacy) show_in_alarm() resds (via data->in_alarms) |
---|
538 | 527 | */ |
---|
539 | 528 | |
---|
540 | | -static ssize_t show_in_min_alarm(struct device *dev, |
---|
541 | | - struct device_attribute *devattr, char *buf) |
---|
| 529 | +static ssize_t in_min_alarm_show(struct device *dev, |
---|
| 530 | + struct device_attribute *devattr, char *buf) |
---|
542 | 531 | { |
---|
543 | 532 | struct pc87360_data *data = pc87360_update_device(dev); |
---|
544 | 533 | unsigned nr = to_sensor_dev_attr(devattr)->index; |
---|
545 | 534 | |
---|
546 | 535 | return sprintf(buf, "%u\n", !!(data->in_status[nr] & CHAN_ALM_MIN)); |
---|
547 | 536 | } |
---|
548 | | -static ssize_t show_in_max_alarm(struct device *dev, |
---|
549 | | - struct device_attribute *devattr, char *buf) |
---|
| 537 | +static ssize_t in_max_alarm_show(struct device *dev, |
---|
| 538 | + struct device_attribute *devattr, char *buf) |
---|
550 | 539 | { |
---|
551 | 540 | struct pc87360_data *data = pc87360_update_device(dev); |
---|
552 | 541 | unsigned nr = to_sensor_dev_attr(devattr)->index; |
---|
.. | .. |
---|
555 | 544 | } |
---|
556 | 545 | |
---|
557 | 546 | static struct sensor_device_attribute in_min_alarm[] = { |
---|
558 | | - SENSOR_ATTR(in0_min_alarm, S_IRUGO, show_in_min_alarm, NULL, 0), |
---|
559 | | - SENSOR_ATTR(in1_min_alarm, S_IRUGO, show_in_min_alarm, NULL, 1), |
---|
560 | | - SENSOR_ATTR(in2_min_alarm, S_IRUGO, show_in_min_alarm, NULL, 2), |
---|
561 | | - SENSOR_ATTR(in3_min_alarm, S_IRUGO, show_in_min_alarm, NULL, 3), |
---|
562 | | - SENSOR_ATTR(in4_min_alarm, S_IRUGO, show_in_min_alarm, NULL, 4), |
---|
563 | | - SENSOR_ATTR(in5_min_alarm, S_IRUGO, show_in_min_alarm, NULL, 5), |
---|
564 | | - SENSOR_ATTR(in6_min_alarm, S_IRUGO, show_in_min_alarm, NULL, 6), |
---|
565 | | - SENSOR_ATTR(in7_min_alarm, S_IRUGO, show_in_min_alarm, NULL, 7), |
---|
566 | | - SENSOR_ATTR(in8_min_alarm, S_IRUGO, show_in_min_alarm, NULL, 8), |
---|
567 | | - SENSOR_ATTR(in9_min_alarm, S_IRUGO, show_in_min_alarm, NULL, 9), |
---|
568 | | - SENSOR_ATTR(in10_min_alarm, S_IRUGO, show_in_min_alarm, NULL, 10), |
---|
| 547 | + SENSOR_ATTR_RO(in0_min_alarm, in_min_alarm, 0), |
---|
| 548 | + SENSOR_ATTR_RO(in1_min_alarm, in_min_alarm, 1), |
---|
| 549 | + SENSOR_ATTR_RO(in2_min_alarm, in_min_alarm, 2), |
---|
| 550 | + SENSOR_ATTR_RO(in3_min_alarm, in_min_alarm, 3), |
---|
| 551 | + SENSOR_ATTR_RO(in4_min_alarm, in_min_alarm, 4), |
---|
| 552 | + SENSOR_ATTR_RO(in5_min_alarm, in_min_alarm, 5), |
---|
| 553 | + SENSOR_ATTR_RO(in6_min_alarm, in_min_alarm, 6), |
---|
| 554 | + SENSOR_ATTR_RO(in7_min_alarm, in_min_alarm, 7), |
---|
| 555 | + SENSOR_ATTR_RO(in8_min_alarm, in_min_alarm, 8), |
---|
| 556 | + SENSOR_ATTR_RO(in9_min_alarm, in_min_alarm, 9), |
---|
| 557 | + SENSOR_ATTR_RO(in10_min_alarm, in_min_alarm, 10), |
---|
569 | 558 | }; |
---|
570 | 559 | static struct sensor_device_attribute in_max_alarm[] = { |
---|
571 | | - SENSOR_ATTR(in0_max_alarm, S_IRUGO, show_in_max_alarm, NULL, 0), |
---|
572 | | - SENSOR_ATTR(in1_max_alarm, S_IRUGO, show_in_max_alarm, NULL, 1), |
---|
573 | | - SENSOR_ATTR(in2_max_alarm, S_IRUGO, show_in_max_alarm, NULL, 2), |
---|
574 | | - SENSOR_ATTR(in3_max_alarm, S_IRUGO, show_in_max_alarm, NULL, 3), |
---|
575 | | - SENSOR_ATTR(in4_max_alarm, S_IRUGO, show_in_max_alarm, NULL, 4), |
---|
576 | | - SENSOR_ATTR(in5_max_alarm, S_IRUGO, show_in_max_alarm, NULL, 5), |
---|
577 | | - SENSOR_ATTR(in6_max_alarm, S_IRUGO, show_in_max_alarm, NULL, 6), |
---|
578 | | - SENSOR_ATTR(in7_max_alarm, S_IRUGO, show_in_max_alarm, NULL, 7), |
---|
579 | | - SENSOR_ATTR(in8_max_alarm, S_IRUGO, show_in_max_alarm, NULL, 8), |
---|
580 | | - SENSOR_ATTR(in9_max_alarm, S_IRUGO, show_in_max_alarm, NULL, 9), |
---|
581 | | - SENSOR_ATTR(in10_max_alarm, S_IRUGO, show_in_max_alarm, NULL, 10), |
---|
| 560 | + SENSOR_ATTR_RO(in0_max_alarm, in_max_alarm, 0), |
---|
| 561 | + SENSOR_ATTR_RO(in1_max_alarm, in_max_alarm, 1), |
---|
| 562 | + SENSOR_ATTR_RO(in2_max_alarm, in_max_alarm, 2), |
---|
| 563 | + SENSOR_ATTR_RO(in3_max_alarm, in_max_alarm, 3), |
---|
| 564 | + SENSOR_ATTR_RO(in4_max_alarm, in_max_alarm, 4), |
---|
| 565 | + SENSOR_ATTR_RO(in5_max_alarm, in_max_alarm, 5), |
---|
| 566 | + SENSOR_ATTR_RO(in6_max_alarm, in_max_alarm, 6), |
---|
| 567 | + SENSOR_ATTR_RO(in7_max_alarm, in_max_alarm, 7), |
---|
| 568 | + SENSOR_ATTR_RO(in8_max_alarm, in_max_alarm, 8), |
---|
| 569 | + SENSOR_ATTR_RO(in9_max_alarm, in_max_alarm, 9), |
---|
| 570 | + SENSOR_ATTR_RO(in10_max_alarm, in_max_alarm, 10), |
---|
582 | 571 | }; |
---|
583 | 572 | |
---|
584 | 573 | #define VIN_UNIT_ATTRS(X) \ |
---|
.. | .. |
---|
651 | 640 | .attrs = pc8736x_vin_attr_array, |
---|
652 | 641 | }; |
---|
653 | 642 | |
---|
654 | | -static ssize_t show_therm_input(struct device *dev, |
---|
| 643 | +static ssize_t therm_input_show(struct device *dev, |
---|
655 | 644 | struct device_attribute *devattr, char *buf) |
---|
656 | 645 | { |
---|
657 | 646 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
.. | .. |
---|
659 | 648 | return sprintf(buf, "%u\n", IN_FROM_REG(data->in[attr->index], |
---|
660 | 649 | data->in_vref)); |
---|
661 | 650 | } |
---|
662 | | -static ssize_t show_therm_min(struct device *dev, |
---|
| 651 | +static ssize_t therm_min_show(struct device *dev, |
---|
663 | 652 | struct device_attribute *devattr, char *buf) |
---|
664 | 653 | { |
---|
665 | 654 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
.. | .. |
---|
667 | 656 | return sprintf(buf, "%u\n", IN_FROM_REG(data->in_min[attr->index], |
---|
668 | 657 | data->in_vref)); |
---|
669 | 658 | } |
---|
670 | | -static ssize_t show_therm_max(struct device *dev, |
---|
| 659 | +static ssize_t therm_max_show(struct device *dev, |
---|
671 | 660 | struct device_attribute *devattr, char *buf) |
---|
672 | 661 | { |
---|
673 | 662 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
.. | .. |
---|
675 | 664 | return sprintf(buf, "%u\n", IN_FROM_REG(data->in_max[attr->index], |
---|
676 | 665 | data->in_vref)); |
---|
677 | 666 | } |
---|
678 | | -static ssize_t show_therm_crit(struct device *dev, |
---|
| 667 | +static ssize_t therm_crit_show(struct device *dev, |
---|
679 | 668 | struct device_attribute *devattr, char *buf) |
---|
680 | 669 | { |
---|
681 | 670 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
.. | .. |
---|
683 | 672 | return sprintf(buf, "%u\n", IN_FROM_REG(data->in_crit[attr->index-11], |
---|
684 | 673 | data->in_vref)); |
---|
685 | 674 | } |
---|
686 | | -static ssize_t show_therm_status(struct device *dev, |
---|
| 675 | +static ssize_t therm_status_show(struct device *dev, |
---|
687 | 676 | struct device_attribute *devattr, char *buf) |
---|
688 | 677 | { |
---|
689 | 678 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
.. | .. |
---|
691 | 680 | return sprintf(buf, "%u\n", data->in_status[attr->index]); |
---|
692 | 681 | } |
---|
693 | 682 | |
---|
694 | | -static ssize_t set_therm_min(struct device *dev, |
---|
695 | | - struct device_attribute *devattr, |
---|
696 | | - const char *buf, size_t count) |
---|
| 683 | +static ssize_t therm_min_store(struct device *dev, |
---|
| 684 | + struct device_attribute *devattr, |
---|
| 685 | + const char *buf, size_t count) |
---|
697 | 686 | { |
---|
698 | 687 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
699 | 688 | struct pc87360_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
712 | 701 | return count; |
---|
713 | 702 | } |
---|
714 | 703 | |
---|
715 | | -static ssize_t set_therm_max(struct device *dev, |
---|
716 | | - struct device_attribute *devattr, |
---|
717 | | - const char *buf, size_t count) |
---|
| 704 | +static ssize_t therm_max_store(struct device *dev, |
---|
| 705 | + struct device_attribute *devattr, |
---|
| 706 | + const char *buf, size_t count) |
---|
718 | 707 | { |
---|
719 | 708 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
720 | 709 | struct pc87360_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
732 | 721 | mutex_unlock(&data->update_lock); |
---|
733 | 722 | return count; |
---|
734 | 723 | } |
---|
735 | | -static ssize_t set_therm_crit(struct device *dev, |
---|
736 | | - struct device_attribute *devattr, |
---|
737 | | - const char *buf, size_t count) |
---|
| 724 | +static ssize_t therm_crit_store(struct device *dev, |
---|
| 725 | + struct device_attribute *devattr, |
---|
| 726 | + const char *buf, size_t count) |
---|
738 | 727 | { |
---|
739 | 728 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
740 | 729 | struct pc87360_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
758 | 747 | * used in the chip to measure voltage across the thermistors |
---|
759 | 748 | */ |
---|
760 | 749 | static struct sensor_device_attribute therm_input[] = { |
---|
761 | | - SENSOR_ATTR(temp4_input, S_IRUGO, show_therm_input, NULL, 0 + 11), |
---|
762 | | - SENSOR_ATTR(temp5_input, S_IRUGO, show_therm_input, NULL, 1 + 11), |
---|
763 | | - SENSOR_ATTR(temp6_input, S_IRUGO, show_therm_input, NULL, 2 + 11), |
---|
| 750 | + SENSOR_ATTR_RO(temp4_input, therm_input, 0 + 11), |
---|
| 751 | + SENSOR_ATTR_RO(temp5_input, therm_input, 1 + 11), |
---|
| 752 | + SENSOR_ATTR_RO(temp6_input, therm_input, 2 + 11), |
---|
764 | 753 | }; |
---|
765 | 754 | static struct sensor_device_attribute therm_status[] = { |
---|
766 | | - SENSOR_ATTR(temp4_status, S_IRUGO, show_therm_status, NULL, 0 + 11), |
---|
767 | | - SENSOR_ATTR(temp5_status, S_IRUGO, show_therm_status, NULL, 1 + 11), |
---|
768 | | - SENSOR_ATTR(temp6_status, S_IRUGO, show_therm_status, NULL, 2 + 11), |
---|
| 755 | + SENSOR_ATTR_RO(temp4_status, therm_status, 0 + 11), |
---|
| 756 | + SENSOR_ATTR_RO(temp5_status, therm_status, 1 + 11), |
---|
| 757 | + SENSOR_ATTR_RO(temp6_status, therm_status, 2 + 11), |
---|
769 | 758 | }; |
---|
770 | 759 | static struct sensor_device_attribute therm_min[] = { |
---|
771 | | - SENSOR_ATTR(temp4_min, S_IRUGO | S_IWUSR, |
---|
772 | | - show_therm_min, set_therm_min, 0 + 11), |
---|
773 | | - SENSOR_ATTR(temp5_min, S_IRUGO | S_IWUSR, |
---|
774 | | - show_therm_min, set_therm_min, 1 + 11), |
---|
775 | | - SENSOR_ATTR(temp6_min, S_IRUGO | S_IWUSR, |
---|
776 | | - show_therm_min, set_therm_min, 2 + 11), |
---|
| 760 | + SENSOR_ATTR_RW(temp4_min, therm_min, 0 + 11), |
---|
| 761 | + SENSOR_ATTR_RW(temp5_min, therm_min, 1 + 11), |
---|
| 762 | + SENSOR_ATTR_RW(temp6_min, therm_min, 2 + 11), |
---|
777 | 763 | }; |
---|
778 | 764 | static struct sensor_device_attribute therm_max[] = { |
---|
779 | | - SENSOR_ATTR(temp4_max, S_IRUGO | S_IWUSR, |
---|
780 | | - show_therm_max, set_therm_max, 0 + 11), |
---|
781 | | - SENSOR_ATTR(temp5_max, S_IRUGO | S_IWUSR, |
---|
782 | | - show_therm_max, set_therm_max, 1 + 11), |
---|
783 | | - SENSOR_ATTR(temp6_max, S_IRUGO | S_IWUSR, |
---|
784 | | - show_therm_max, set_therm_max, 2 + 11), |
---|
| 765 | + SENSOR_ATTR_RW(temp4_max, therm_max, 0 + 11), |
---|
| 766 | + SENSOR_ATTR_RW(temp5_max, therm_max, 1 + 11), |
---|
| 767 | + SENSOR_ATTR_RW(temp6_max, therm_max, 2 + 11), |
---|
785 | 768 | }; |
---|
786 | 769 | static struct sensor_device_attribute therm_crit[] = { |
---|
787 | | - SENSOR_ATTR(temp4_crit, S_IRUGO | S_IWUSR, |
---|
788 | | - show_therm_crit, set_therm_crit, 0 + 11), |
---|
789 | | - SENSOR_ATTR(temp5_crit, S_IRUGO | S_IWUSR, |
---|
790 | | - show_therm_crit, set_therm_crit, 1 + 11), |
---|
791 | | - SENSOR_ATTR(temp6_crit, S_IRUGO | S_IWUSR, |
---|
792 | | - show_therm_crit, set_therm_crit, 2 + 11), |
---|
| 770 | + SENSOR_ATTR_RW(temp4_crit, therm_crit, 0 + 11), |
---|
| 771 | + SENSOR_ATTR_RW(temp5_crit, therm_crit, 1 + 11), |
---|
| 772 | + SENSOR_ATTR_RW(temp6_crit, therm_crit, 2 + 11), |
---|
793 | 773 | }; |
---|
794 | 774 | |
---|
795 | 775 | /* |
---|
.. | .. |
---|
797 | 777 | * status register (sec 11.5.12) |
---|
798 | 778 | */ |
---|
799 | 779 | |
---|
800 | | -static ssize_t show_therm_min_alarm(struct device *dev, |
---|
801 | | - struct device_attribute *devattr, char *buf) |
---|
| 780 | +static ssize_t therm_min_alarm_show(struct device *dev, |
---|
| 781 | + struct device_attribute *devattr, |
---|
| 782 | + char *buf) |
---|
802 | 783 | { |
---|
803 | 784 | struct pc87360_data *data = pc87360_update_device(dev); |
---|
804 | 785 | unsigned nr = to_sensor_dev_attr(devattr)->index; |
---|
805 | 786 | |
---|
806 | 787 | return sprintf(buf, "%u\n", !!(data->in_status[nr] & CHAN_ALM_MIN)); |
---|
807 | 788 | } |
---|
808 | | -static ssize_t show_therm_max_alarm(struct device *dev, |
---|
809 | | - struct device_attribute *devattr, char *buf) |
---|
| 789 | +static ssize_t therm_max_alarm_show(struct device *dev, |
---|
| 790 | + struct device_attribute *devattr, |
---|
| 791 | + char *buf) |
---|
810 | 792 | { |
---|
811 | 793 | struct pc87360_data *data = pc87360_update_device(dev); |
---|
812 | 794 | unsigned nr = to_sensor_dev_attr(devattr)->index; |
---|
813 | 795 | |
---|
814 | 796 | return sprintf(buf, "%u\n", !!(data->in_status[nr] & CHAN_ALM_MAX)); |
---|
815 | 797 | } |
---|
816 | | -static ssize_t show_therm_crit_alarm(struct device *dev, |
---|
817 | | - struct device_attribute *devattr, char *buf) |
---|
| 798 | +static ssize_t therm_crit_alarm_show(struct device *dev, |
---|
| 799 | + struct device_attribute *devattr, |
---|
| 800 | + char *buf) |
---|
818 | 801 | { |
---|
819 | 802 | struct pc87360_data *data = pc87360_update_device(dev); |
---|
820 | 803 | unsigned nr = to_sensor_dev_attr(devattr)->index; |
---|
.. | .. |
---|
823 | 806 | } |
---|
824 | 807 | |
---|
825 | 808 | static struct sensor_device_attribute therm_min_alarm[] = { |
---|
826 | | - SENSOR_ATTR(temp4_min_alarm, S_IRUGO, |
---|
827 | | - show_therm_min_alarm, NULL, 0 + 11), |
---|
828 | | - SENSOR_ATTR(temp5_min_alarm, S_IRUGO, |
---|
829 | | - show_therm_min_alarm, NULL, 1 + 11), |
---|
830 | | - SENSOR_ATTR(temp6_min_alarm, S_IRUGO, |
---|
831 | | - show_therm_min_alarm, NULL, 2 + 11), |
---|
| 809 | + SENSOR_ATTR_RO(temp4_min_alarm, therm_min_alarm, 0 + 11), |
---|
| 810 | + SENSOR_ATTR_RO(temp5_min_alarm, therm_min_alarm, 1 + 11), |
---|
| 811 | + SENSOR_ATTR_RO(temp6_min_alarm, therm_min_alarm, 2 + 11), |
---|
832 | 812 | }; |
---|
833 | 813 | static struct sensor_device_attribute therm_max_alarm[] = { |
---|
834 | | - SENSOR_ATTR(temp4_max_alarm, S_IRUGO, |
---|
835 | | - show_therm_max_alarm, NULL, 0 + 11), |
---|
836 | | - SENSOR_ATTR(temp5_max_alarm, S_IRUGO, |
---|
837 | | - show_therm_max_alarm, NULL, 1 + 11), |
---|
838 | | - SENSOR_ATTR(temp6_max_alarm, S_IRUGO, |
---|
839 | | - show_therm_max_alarm, NULL, 2 + 11), |
---|
| 814 | + SENSOR_ATTR_RO(temp4_max_alarm, therm_max_alarm, 0 + 11), |
---|
| 815 | + SENSOR_ATTR_RO(temp5_max_alarm, therm_max_alarm, 1 + 11), |
---|
| 816 | + SENSOR_ATTR_RO(temp6_max_alarm, therm_max_alarm, 2 + 11), |
---|
840 | 817 | }; |
---|
841 | 818 | static struct sensor_device_attribute therm_crit_alarm[] = { |
---|
842 | | - SENSOR_ATTR(temp4_crit_alarm, S_IRUGO, |
---|
843 | | - show_therm_crit_alarm, NULL, 0 + 11), |
---|
844 | | - SENSOR_ATTR(temp5_crit_alarm, S_IRUGO, |
---|
845 | | - show_therm_crit_alarm, NULL, 1 + 11), |
---|
846 | | - SENSOR_ATTR(temp6_crit_alarm, S_IRUGO, |
---|
847 | | - show_therm_crit_alarm, NULL, 2 + 11), |
---|
| 819 | + SENSOR_ATTR_RO(temp4_crit_alarm, therm_crit_alarm, 0 + 11), |
---|
| 820 | + SENSOR_ATTR_RO(temp5_crit_alarm, therm_crit_alarm, 1 + 11), |
---|
| 821 | + SENSOR_ATTR_RO(temp6_crit_alarm, therm_crit_alarm, 2 + 11), |
---|
848 | 822 | }; |
---|
849 | 823 | |
---|
850 | 824 | #define THERM_UNIT_ATTRS(X) \ |
---|
.. | .. |
---|
867 | 841 | .attrs = pc8736x_therm_attr_array, |
---|
868 | 842 | }; |
---|
869 | 843 | |
---|
870 | | -static ssize_t show_temp_input(struct device *dev, |
---|
| 844 | +static ssize_t temp_input_show(struct device *dev, |
---|
871 | 845 | struct device_attribute *devattr, char *buf) |
---|
872 | 846 | { |
---|
873 | 847 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
.. | .. |
---|
875 | 849 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[attr->index])); |
---|
876 | 850 | } |
---|
877 | 851 | |
---|
878 | | -static ssize_t show_temp_min(struct device *dev, |
---|
| 852 | +static ssize_t temp_min_show(struct device *dev, |
---|
879 | 853 | struct device_attribute *devattr, char *buf) |
---|
880 | 854 | { |
---|
881 | 855 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
.. | .. |
---|
883 | 857 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_min[attr->index])); |
---|
884 | 858 | } |
---|
885 | 859 | |
---|
886 | | -static ssize_t show_temp_max(struct device *dev, |
---|
| 860 | +static ssize_t temp_max_show(struct device *dev, |
---|
887 | 861 | struct device_attribute *devattr, char *buf) |
---|
888 | 862 | { |
---|
889 | 863 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
.. | .. |
---|
891 | 865 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_max[attr->index])); |
---|
892 | 866 | } |
---|
893 | 867 | |
---|
894 | | -static ssize_t show_temp_crit(struct device *dev, |
---|
| 868 | +static ssize_t temp_crit_show(struct device *dev, |
---|
895 | 869 | struct device_attribute *devattr, char *buf) |
---|
896 | 870 | { |
---|
897 | 871 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
.. | .. |
---|
900 | 874 | TEMP_FROM_REG(data->temp_crit[attr->index])); |
---|
901 | 875 | } |
---|
902 | 876 | |
---|
903 | | -static ssize_t show_temp_status(struct device *dev, |
---|
| 877 | +static ssize_t temp_status_show(struct device *dev, |
---|
904 | 878 | struct device_attribute *devattr, char *buf) |
---|
905 | 879 | { |
---|
906 | 880 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
.. | .. |
---|
908 | 882 | return sprintf(buf, "%d\n", data->temp_status[attr->index]); |
---|
909 | 883 | } |
---|
910 | 884 | |
---|
911 | | -static ssize_t set_temp_min(struct device *dev, |
---|
912 | | - struct device_attribute *devattr, |
---|
913 | | - const char *buf, size_t count) |
---|
| 885 | +static ssize_t temp_min_store(struct device *dev, |
---|
| 886 | + struct device_attribute *devattr, |
---|
| 887 | + const char *buf, size_t count) |
---|
914 | 888 | { |
---|
915 | 889 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
916 | 890 | struct pc87360_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
929 | 903 | return count; |
---|
930 | 904 | } |
---|
931 | 905 | |
---|
932 | | -static ssize_t set_temp_max(struct device *dev, |
---|
933 | | - struct device_attribute *devattr, |
---|
934 | | - const char *buf, size_t count) |
---|
| 906 | +static ssize_t temp_max_store(struct device *dev, |
---|
| 907 | + struct device_attribute *devattr, |
---|
| 908 | + const char *buf, size_t count) |
---|
935 | 909 | { |
---|
936 | 910 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
937 | 911 | struct pc87360_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
950 | 924 | return count; |
---|
951 | 925 | } |
---|
952 | 926 | |
---|
953 | | -static ssize_t set_temp_crit(struct device *dev, |
---|
954 | | - struct device_attribute *devattr, const char *buf, |
---|
955 | | - size_t count) |
---|
| 927 | +static ssize_t temp_crit_store(struct device *dev, |
---|
| 928 | + struct device_attribute *devattr, |
---|
| 929 | + const char *buf, size_t count) |
---|
956 | 930 | { |
---|
957 | 931 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
958 | 932 | struct pc87360_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
972 | 946 | } |
---|
973 | 947 | |
---|
974 | 948 | static struct sensor_device_attribute temp_input[] = { |
---|
975 | | - SENSOR_ATTR(temp1_input, S_IRUGO, show_temp_input, NULL, 0), |
---|
976 | | - SENSOR_ATTR(temp2_input, S_IRUGO, show_temp_input, NULL, 1), |
---|
977 | | - SENSOR_ATTR(temp3_input, S_IRUGO, show_temp_input, NULL, 2), |
---|
| 949 | + SENSOR_ATTR_RO(temp1_input, temp_input, 0), |
---|
| 950 | + SENSOR_ATTR_RO(temp2_input, temp_input, 1), |
---|
| 951 | + SENSOR_ATTR_RO(temp3_input, temp_input, 2), |
---|
978 | 952 | }; |
---|
979 | 953 | static struct sensor_device_attribute temp_status[] = { |
---|
980 | | - SENSOR_ATTR(temp1_status, S_IRUGO, show_temp_status, NULL, 0), |
---|
981 | | - SENSOR_ATTR(temp2_status, S_IRUGO, show_temp_status, NULL, 1), |
---|
982 | | - SENSOR_ATTR(temp3_status, S_IRUGO, show_temp_status, NULL, 2), |
---|
| 954 | + SENSOR_ATTR_RO(temp1_status, temp_status, 0), |
---|
| 955 | + SENSOR_ATTR_RO(temp2_status, temp_status, 1), |
---|
| 956 | + SENSOR_ATTR_RO(temp3_status, temp_status, 2), |
---|
983 | 957 | }; |
---|
984 | 958 | static struct sensor_device_attribute temp_min[] = { |
---|
985 | | - SENSOR_ATTR(temp1_min, S_IRUGO | S_IWUSR, |
---|
986 | | - show_temp_min, set_temp_min, 0), |
---|
987 | | - SENSOR_ATTR(temp2_min, S_IRUGO | S_IWUSR, |
---|
988 | | - show_temp_min, set_temp_min, 1), |
---|
989 | | - SENSOR_ATTR(temp3_min, S_IRUGO | S_IWUSR, |
---|
990 | | - show_temp_min, set_temp_min, 2), |
---|
| 959 | + SENSOR_ATTR_RW(temp1_min, temp_min, 0), |
---|
| 960 | + SENSOR_ATTR_RW(temp2_min, temp_min, 1), |
---|
| 961 | + SENSOR_ATTR_RW(temp3_min, temp_min, 2), |
---|
991 | 962 | }; |
---|
992 | 963 | static struct sensor_device_attribute temp_max[] = { |
---|
993 | | - SENSOR_ATTR(temp1_max, S_IRUGO | S_IWUSR, |
---|
994 | | - show_temp_max, set_temp_max, 0), |
---|
995 | | - SENSOR_ATTR(temp2_max, S_IRUGO | S_IWUSR, |
---|
996 | | - show_temp_max, set_temp_max, 1), |
---|
997 | | - SENSOR_ATTR(temp3_max, S_IRUGO | S_IWUSR, |
---|
998 | | - show_temp_max, set_temp_max, 2), |
---|
| 964 | + SENSOR_ATTR_RW(temp1_max, temp_max, 0), |
---|
| 965 | + SENSOR_ATTR_RW(temp2_max, temp_max, 1), |
---|
| 966 | + SENSOR_ATTR_RW(temp3_max, temp_max, 2), |
---|
999 | 967 | }; |
---|
1000 | 968 | static struct sensor_device_attribute temp_crit[] = { |
---|
1001 | | - SENSOR_ATTR(temp1_crit, S_IRUGO | S_IWUSR, |
---|
1002 | | - show_temp_crit, set_temp_crit, 0), |
---|
1003 | | - SENSOR_ATTR(temp2_crit, S_IRUGO | S_IWUSR, |
---|
1004 | | - show_temp_crit, set_temp_crit, 1), |
---|
1005 | | - SENSOR_ATTR(temp3_crit, S_IRUGO | S_IWUSR, |
---|
1006 | | - show_temp_crit, set_temp_crit, 2), |
---|
| 969 | + SENSOR_ATTR_RW(temp1_crit, temp_crit, 0), |
---|
| 970 | + SENSOR_ATTR_RW(temp2_crit, temp_crit, 1), |
---|
| 971 | + SENSOR_ATTR_RW(temp3_crit, temp_crit, 2), |
---|
1007 | 972 | }; |
---|
1008 | 973 | |
---|
1009 | 974 | static ssize_t alarms_temp_show(struct device *dev, |
---|
.. | .. |
---|
1021 | 986 | * 12.3.2) that show_temp_alarm() reads (via data->temp_alarms) |
---|
1022 | 987 | */ |
---|
1023 | 988 | |
---|
1024 | | -static ssize_t show_temp_min_alarm(struct device *dev, |
---|
1025 | | - struct device_attribute *devattr, char *buf) |
---|
| 989 | +static ssize_t temp_min_alarm_show(struct device *dev, |
---|
| 990 | + struct device_attribute *devattr, |
---|
| 991 | + char *buf) |
---|
1026 | 992 | { |
---|
1027 | 993 | struct pc87360_data *data = pc87360_update_device(dev); |
---|
1028 | 994 | unsigned nr = to_sensor_dev_attr(devattr)->index; |
---|
.. | .. |
---|
1030 | 996 | return sprintf(buf, "%u\n", !!(data->temp_status[nr] & CHAN_ALM_MIN)); |
---|
1031 | 997 | } |
---|
1032 | 998 | |
---|
1033 | | -static ssize_t show_temp_max_alarm(struct device *dev, |
---|
1034 | | - struct device_attribute *devattr, char *buf) |
---|
| 999 | +static ssize_t temp_max_alarm_show(struct device *dev, |
---|
| 1000 | + struct device_attribute *devattr, |
---|
| 1001 | + char *buf) |
---|
1035 | 1002 | { |
---|
1036 | 1003 | struct pc87360_data *data = pc87360_update_device(dev); |
---|
1037 | 1004 | unsigned nr = to_sensor_dev_attr(devattr)->index; |
---|
.. | .. |
---|
1039 | 1006 | return sprintf(buf, "%u\n", !!(data->temp_status[nr] & CHAN_ALM_MAX)); |
---|
1040 | 1007 | } |
---|
1041 | 1008 | |
---|
1042 | | -static ssize_t show_temp_crit_alarm(struct device *dev, |
---|
1043 | | - struct device_attribute *devattr, char *buf) |
---|
| 1009 | +static ssize_t temp_crit_alarm_show(struct device *dev, |
---|
| 1010 | + struct device_attribute *devattr, |
---|
| 1011 | + char *buf) |
---|
1044 | 1012 | { |
---|
1045 | 1013 | struct pc87360_data *data = pc87360_update_device(dev); |
---|
1046 | 1014 | unsigned nr = to_sensor_dev_attr(devattr)->index; |
---|
.. | .. |
---|
1049 | 1017 | } |
---|
1050 | 1018 | |
---|
1051 | 1019 | static struct sensor_device_attribute temp_min_alarm[] = { |
---|
1052 | | - SENSOR_ATTR(temp1_min_alarm, S_IRUGO, show_temp_min_alarm, NULL, 0), |
---|
1053 | | - SENSOR_ATTR(temp2_min_alarm, S_IRUGO, show_temp_min_alarm, NULL, 1), |
---|
1054 | | - SENSOR_ATTR(temp3_min_alarm, S_IRUGO, show_temp_min_alarm, NULL, 2), |
---|
| 1020 | + SENSOR_ATTR_RO(temp1_min_alarm, temp_min_alarm, 0), |
---|
| 1021 | + SENSOR_ATTR_RO(temp2_min_alarm, temp_min_alarm, 1), |
---|
| 1022 | + SENSOR_ATTR_RO(temp3_min_alarm, temp_min_alarm, 2), |
---|
1055 | 1023 | }; |
---|
1056 | 1024 | |
---|
1057 | 1025 | static struct sensor_device_attribute temp_max_alarm[] = { |
---|
1058 | | - SENSOR_ATTR(temp1_max_alarm, S_IRUGO, show_temp_max_alarm, NULL, 0), |
---|
1059 | | - SENSOR_ATTR(temp2_max_alarm, S_IRUGO, show_temp_max_alarm, NULL, 1), |
---|
1060 | | - SENSOR_ATTR(temp3_max_alarm, S_IRUGO, show_temp_max_alarm, NULL, 2), |
---|
| 1026 | + SENSOR_ATTR_RO(temp1_max_alarm, temp_max_alarm, 0), |
---|
| 1027 | + SENSOR_ATTR_RO(temp2_max_alarm, temp_max_alarm, 1), |
---|
| 1028 | + SENSOR_ATTR_RO(temp3_max_alarm, temp_max_alarm, 2), |
---|
1061 | 1029 | }; |
---|
1062 | 1030 | |
---|
1063 | 1031 | static struct sensor_device_attribute temp_crit_alarm[] = { |
---|
1064 | | - SENSOR_ATTR(temp1_crit_alarm, S_IRUGO, show_temp_crit_alarm, NULL, 0), |
---|
1065 | | - SENSOR_ATTR(temp2_crit_alarm, S_IRUGO, show_temp_crit_alarm, NULL, 1), |
---|
1066 | | - SENSOR_ATTR(temp3_crit_alarm, S_IRUGO, show_temp_crit_alarm, NULL, 2), |
---|
| 1032 | + SENSOR_ATTR_RO(temp1_crit_alarm, temp_crit_alarm, 0), |
---|
| 1033 | + SENSOR_ATTR_RO(temp2_crit_alarm, temp_crit_alarm, 1), |
---|
| 1034 | + SENSOR_ATTR_RO(temp3_crit_alarm, temp_crit_alarm, 2), |
---|
1067 | 1035 | }; |
---|
1068 | 1036 | |
---|
1069 | 1037 | #define TEMP_FAULT 0x40 /* open diode */ |
---|
1070 | | -static ssize_t show_temp_fault(struct device *dev, |
---|
1071 | | - struct device_attribute *devattr, char *buf) |
---|
| 1038 | +static ssize_t temp_fault_show(struct device *dev, |
---|
| 1039 | + struct device_attribute *devattr, char *buf) |
---|
1072 | 1040 | { |
---|
1073 | 1041 | struct pc87360_data *data = pc87360_update_device(dev); |
---|
1074 | 1042 | unsigned nr = to_sensor_dev_attr(devattr)->index; |
---|
.. | .. |
---|
1076 | 1044 | return sprintf(buf, "%u\n", !!(data->temp_status[nr] & TEMP_FAULT)); |
---|
1077 | 1045 | } |
---|
1078 | 1046 | static struct sensor_device_attribute temp_fault[] = { |
---|
1079 | | - SENSOR_ATTR(temp1_fault, S_IRUGO, show_temp_fault, NULL, 0), |
---|
1080 | | - SENSOR_ATTR(temp2_fault, S_IRUGO, show_temp_fault, NULL, 1), |
---|
1081 | | - SENSOR_ATTR(temp3_fault, S_IRUGO, show_temp_fault, NULL, 2), |
---|
| 1047 | + SENSOR_ATTR_RO(temp1_fault, temp_fault, 0), |
---|
| 1048 | + SENSOR_ATTR_RO(temp2_fault, temp_fault, 1), |
---|
| 1049 | + SENSOR_ATTR_RO(temp3_fault, temp_fault, 2), |
---|
1082 | 1050 | }; |
---|
1083 | 1051 | |
---|
1084 | 1052 | #define TEMP_UNIT_ATTRS(X) \ |
---|