.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * STTS751 sensor driver |
---|
3 | 4 | * |
---|
.. | .. |
---|
8 | 9 | * Written by Andrea Merello <andrea.merello@gmail.com> |
---|
9 | 10 | * |
---|
10 | 11 | * Based on LM95241 driver and LM90 driver |
---|
11 | | - * |
---|
12 | | - * This program is free software; you can redistribute it and/or modify |
---|
13 | | - * it under the terms of the GNU General Public License as published by |
---|
14 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
15 | | - * (at your option) any later version. |
---|
16 | | - * |
---|
17 | | - * This program is distributed in the hope that it will be useful, |
---|
18 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
19 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
20 | | - * GNU General Public License for more details. |
---|
21 | 12 | */ |
---|
22 | 13 | |
---|
23 | 14 | #include <linux/bitops.h> |
---|
.. | .. |
---|
85 | 76 | { } |
---|
86 | 77 | }; |
---|
87 | 78 | |
---|
88 | | -static const struct of_device_id stts751_of_match[] = { |
---|
| 79 | +static const struct of_device_id __maybe_unused stts751_of_match[] = { |
---|
89 | 80 | { .compatible = "stts751" }, |
---|
90 | 81 | { }, |
---|
91 | 82 | }; |
---|
.. | .. |
---|
382 | 373 | return 0; |
---|
383 | 374 | } |
---|
384 | 375 | |
---|
385 | | -static ssize_t show_max_alarm(struct device *dev, struct device_attribute *attr, |
---|
386 | | - char *buf) |
---|
| 376 | +static ssize_t max_alarm_show(struct device *dev, |
---|
| 377 | + struct device_attribute *attr, char *buf) |
---|
387 | 378 | { |
---|
388 | 379 | int ret; |
---|
389 | 380 | struct stts751_priv *priv = dev_get_drvdata(dev); |
---|
.. | .. |
---|
399 | 390 | return snprintf(buf, PAGE_SIZE, "%d\n", priv->max_alert); |
---|
400 | 391 | } |
---|
401 | 392 | |
---|
402 | | -static ssize_t show_min_alarm(struct device *dev, struct device_attribute *attr, |
---|
403 | | - char *buf) |
---|
| 393 | +static ssize_t min_alarm_show(struct device *dev, |
---|
| 394 | + struct device_attribute *attr, char *buf) |
---|
404 | 395 | { |
---|
405 | 396 | int ret; |
---|
406 | 397 | struct stts751_priv *priv = dev_get_drvdata(dev); |
---|
.. | .. |
---|
416 | 407 | return snprintf(buf, PAGE_SIZE, "%d\n", priv->min_alert); |
---|
417 | 408 | } |
---|
418 | 409 | |
---|
419 | | -static ssize_t show_input(struct device *dev, struct device_attribute *attr, |
---|
| 410 | +static ssize_t input_show(struct device *dev, struct device_attribute *attr, |
---|
420 | 411 | char *buf) |
---|
421 | 412 | { |
---|
422 | 413 | int ret; |
---|
.. | .. |
---|
431 | 422 | return snprintf(buf, PAGE_SIZE, "%d\n", priv->temp); |
---|
432 | 423 | } |
---|
433 | 424 | |
---|
434 | | -static ssize_t show_therm(struct device *dev, struct device_attribute *attr, |
---|
| 425 | +static ssize_t therm_show(struct device *dev, struct device_attribute *attr, |
---|
435 | 426 | char *buf) |
---|
436 | 427 | { |
---|
437 | 428 | struct stts751_priv *priv = dev_get_drvdata(dev); |
---|
.. | .. |
---|
439 | 430 | return snprintf(buf, PAGE_SIZE, "%d\n", priv->therm); |
---|
440 | 431 | } |
---|
441 | 432 | |
---|
442 | | -static ssize_t set_therm(struct device *dev, struct device_attribute *attr, |
---|
443 | | - const char *buf, size_t count) |
---|
| 433 | +static ssize_t therm_store(struct device *dev, struct device_attribute *attr, |
---|
| 434 | + const char *buf, size_t count) |
---|
444 | 435 | { |
---|
445 | 436 | int ret; |
---|
446 | 437 | long temp; |
---|
.. | .. |
---|
473 | 464 | return count; |
---|
474 | 465 | } |
---|
475 | 466 | |
---|
476 | | -static ssize_t show_hyst(struct device *dev, struct device_attribute *attr, |
---|
| 467 | +static ssize_t hyst_show(struct device *dev, struct device_attribute *attr, |
---|
477 | 468 | char *buf) |
---|
478 | 469 | { |
---|
479 | 470 | struct stts751_priv *priv = dev_get_drvdata(dev); |
---|
.. | .. |
---|
481 | 472 | return snprintf(buf, PAGE_SIZE, "%d\n", priv->hyst); |
---|
482 | 473 | } |
---|
483 | 474 | |
---|
484 | | -static ssize_t set_hyst(struct device *dev, struct device_attribute *attr, |
---|
485 | | - const char *buf, size_t count) |
---|
| 475 | +static ssize_t hyst_store(struct device *dev, struct device_attribute *attr, |
---|
| 476 | + const char *buf, size_t count) |
---|
486 | 477 | { |
---|
487 | 478 | int ret; |
---|
488 | 479 | long temp; |
---|
.. | .. |
---|
506 | 497 | return count; |
---|
507 | 498 | } |
---|
508 | 499 | |
---|
509 | | -static ssize_t show_therm_trip(struct device *dev, |
---|
| 500 | +static ssize_t therm_trip_show(struct device *dev, |
---|
510 | 501 | struct device_attribute *attr, char *buf) |
---|
511 | 502 | { |
---|
512 | 503 | int ret; |
---|
.. | .. |
---|
521 | 512 | return snprintf(buf, PAGE_SIZE, "%d\n", priv->therm_trip); |
---|
522 | 513 | } |
---|
523 | 514 | |
---|
524 | | -static ssize_t show_max(struct device *dev, struct device_attribute *attr, |
---|
| 515 | +static ssize_t max_show(struct device *dev, struct device_attribute *attr, |
---|
525 | 516 | char *buf) |
---|
526 | 517 | { |
---|
527 | 518 | struct stts751_priv *priv = dev_get_drvdata(dev); |
---|
.. | .. |
---|
529 | 520 | return snprintf(buf, PAGE_SIZE, "%d\n", priv->event_max); |
---|
530 | 521 | } |
---|
531 | 522 | |
---|
532 | | -static ssize_t set_max(struct device *dev, struct device_attribute *attr, |
---|
533 | | - const char *buf, size_t count) |
---|
| 523 | +static ssize_t max_store(struct device *dev, struct device_attribute *attr, |
---|
| 524 | + const char *buf, size_t count) |
---|
534 | 525 | { |
---|
535 | 526 | int ret; |
---|
536 | 527 | long temp; |
---|
.. | .. |
---|
555 | 546 | return ret; |
---|
556 | 547 | } |
---|
557 | 548 | |
---|
558 | | -static ssize_t show_min(struct device *dev, struct device_attribute *attr, |
---|
| 549 | +static ssize_t min_show(struct device *dev, struct device_attribute *attr, |
---|
559 | 550 | char *buf) |
---|
560 | 551 | { |
---|
561 | 552 | struct stts751_priv *priv = dev_get_drvdata(dev); |
---|
.. | .. |
---|
563 | 554 | return snprintf(buf, PAGE_SIZE, "%d\n", priv->event_min); |
---|
564 | 555 | } |
---|
565 | 556 | |
---|
566 | | -static ssize_t set_min(struct device *dev, struct device_attribute *attr, |
---|
567 | | - const char *buf, size_t count) |
---|
| 557 | +static ssize_t min_store(struct device *dev, struct device_attribute *attr, |
---|
| 558 | + const char *buf, size_t count) |
---|
568 | 559 | { |
---|
569 | 560 | int ret; |
---|
570 | 561 | long temp; |
---|
.. | .. |
---|
589 | 580 | return ret; |
---|
590 | 581 | } |
---|
591 | 582 | |
---|
592 | | -static ssize_t show_interval(struct device *dev, struct device_attribute *attr, |
---|
593 | | - char *buf) |
---|
| 583 | +static ssize_t interval_show(struct device *dev, |
---|
| 584 | + struct device_attribute *attr, char *buf) |
---|
594 | 585 | { |
---|
595 | 586 | struct stts751_priv *priv = dev_get_drvdata(dev); |
---|
596 | 587 | |
---|
.. | .. |
---|
598 | 589 | stts751_intervals[priv->interval]); |
---|
599 | 590 | } |
---|
600 | 591 | |
---|
601 | | -static ssize_t set_interval(struct device *dev, struct device_attribute *attr, |
---|
602 | | - const char *buf, size_t count) |
---|
| 592 | +static ssize_t interval_store(struct device *dev, |
---|
| 593 | + struct device_attribute *attr, const char *buf, |
---|
| 594 | + size_t count) |
---|
603 | 595 | { |
---|
604 | 596 | unsigned long val; |
---|
605 | 597 | int idx; |
---|
.. | .. |
---|
746 | 738 | return 0; |
---|
747 | 739 | } |
---|
748 | 740 | |
---|
749 | | -static SENSOR_DEVICE_ATTR(temp1_input, 0444, show_input, NULL, 0); |
---|
750 | | -static SENSOR_DEVICE_ATTR(temp1_min, 0644, show_min, set_min, 0); |
---|
751 | | -static SENSOR_DEVICE_ATTR(temp1_max, 0644, show_max, set_max, 0); |
---|
752 | | -static SENSOR_DEVICE_ATTR(temp1_min_alarm, 0444, show_min_alarm, NULL, 0); |
---|
753 | | -static SENSOR_DEVICE_ATTR(temp1_max_alarm, 0444, show_max_alarm, NULL, 0); |
---|
754 | | -static SENSOR_DEVICE_ATTR(temp1_crit, 0644, show_therm, set_therm, 0); |
---|
755 | | -static SENSOR_DEVICE_ATTR(temp1_crit_hyst, 0644, show_hyst, set_hyst, 0); |
---|
756 | | -static SENSOR_DEVICE_ATTR(temp1_crit_alarm, 0444, show_therm_trip, NULL, 0); |
---|
757 | | -static SENSOR_DEVICE_ATTR(update_interval, 0644, |
---|
758 | | - show_interval, set_interval, 0); |
---|
| 741 | +static SENSOR_DEVICE_ATTR_RO(temp1_input, input, 0); |
---|
| 742 | +static SENSOR_DEVICE_ATTR_RW(temp1_min, min, 0); |
---|
| 743 | +static SENSOR_DEVICE_ATTR_RW(temp1_max, max, 0); |
---|
| 744 | +static SENSOR_DEVICE_ATTR_RO(temp1_min_alarm, min_alarm, 0); |
---|
| 745 | +static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, max_alarm, 0); |
---|
| 746 | +static SENSOR_DEVICE_ATTR_RW(temp1_crit, therm, 0); |
---|
| 747 | +static SENSOR_DEVICE_ATTR_RW(temp1_crit_hyst, hyst, 0); |
---|
| 748 | +static SENSOR_DEVICE_ATTR_RO(temp1_crit_alarm, therm_trip, 0); |
---|
| 749 | +static SENSOR_DEVICE_ATTR_RW(update_interval, interval, 0); |
---|
759 | 750 | |
---|
760 | 751 | static struct attribute *stts751_attrs[] = { |
---|
761 | 752 | &sensor_dev_attr_temp1_input.dev_attr.attr, |
---|
.. | .. |
---|
771 | 762 | }; |
---|
772 | 763 | ATTRIBUTE_GROUPS(stts751); |
---|
773 | 764 | |
---|
774 | | -static int stts751_probe(struct i2c_client *client, |
---|
775 | | - const struct i2c_device_id *id) |
---|
| 765 | +static int stts751_probe(struct i2c_client *client) |
---|
776 | 766 | { |
---|
777 | 767 | struct stts751_priv *priv; |
---|
778 | 768 | int ret; |
---|
.. | .. |
---|
831 | 821 | .name = DEVNAME, |
---|
832 | 822 | .of_match_table = of_match_ptr(stts751_of_match), |
---|
833 | 823 | }, |
---|
834 | | - .probe = stts751_probe, |
---|
| 824 | + .probe_new = stts751_probe, |
---|
835 | 825 | .id_table = stts751_id, |
---|
836 | 826 | .detect = stts751_detect, |
---|
837 | 827 | .alert = stts751_alert, |
---|