hc
2024-05-10 23fa18eaa71266feff7ba8d83022d9e1cc83c65a
kernel/drivers/hwmon/stts751.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * STTS751 sensor driver
34 *
....@@ -8,16 +9,6 @@
89 * Written by Andrea Merello <andrea.merello@gmail.com>
910 *
1011 * 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.
2112 */
2213
2314 #include <linux/bitops.h>
....@@ -85,7 +76,7 @@
8576 { }
8677 };
8778
88
-static const struct of_device_id stts751_of_match[] = {
79
+static const struct of_device_id __maybe_unused stts751_of_match[] = {
8980 { .compatible = "stts751" },
9081 { },
9182 };
....@@ -382,8 +373,8 @@
382373 return 0;
383374 }
384375
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)
387378 {
388379 int ret;
389380 struct stts751_priv *priv = dev_get_drvdata(dev);
....@@ -399,8 +390,8 @@
399390 return snprintf(buf, PAGE_SIZE, "%d\n", priv->max_alert);
400391 }
401392
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)
404395 {
405396 int ret;
406397 struct stts751_priv *priv = dev_get_drvdata(dev);
....@@ -416,7 +407,7 @@
416407 return snprintf(buf, PAGE_SIZE, "%d\n", priv->min_alert);
417408 }
418409
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,
420411 char *buf)
421412 {
422413 int ret;
....@@ -431,7 +422,7 @@
431422 return snprintf(buf, PAGE_SIZE, "%d\n", priv->temp);
432423 }
433424
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,
435426 char *buf)
436427 {
437428 struct stts751_priv *priv = dev_get_drvdata(dev);
....@@ -439,8 +430,8 @@
439430 return snprintf(buf, PAGE_SIZE, "%d\n", priv->therm);
440431 }
441432
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)
444435 {
445436 int ret;
446437 long temp;
....@@ -473,7 +464,7 @@
473464 return count;
474465 }
475466
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,
477468 char *buf)
478469 {
479470 struct stts751_priv *priv = dev_get_drvdata(dev);
....@@ -481,8 +472,8 @@
481472 return snprintf(buf, PAGE_SIZE, "%d\n", priv->hyst);
482473 }
483474
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)
486477 {
487478 int ret;
488479 long temp;
....@@ -506,7 +497,7 @@
506497 return count;
507498 }
508499
509
-static ssize_t show_therm_trip(struct device *dev,
500
+static ssize_t therm_trip_show(struct device *dev,
510501 struct device_attribute *attr, char *buf)
511502 {
512503 int ret;
....@@ -521,7 +512,7 @@
521512 return snprintf(buf, PAGE_SIZE, "%d\n", priv->therm_trip);
522513 }
523514
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,
525516 char *buf)
526517 {
527518 struct stts751_priv *priv = dev_get_drvdata(dev);
....@@ -529,8 +520,8 @@
529520 return snprintf(buf, PAGE_SIZE, "%d\n", priv->event_max);
530521 }
531522
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)
534525 {
535526 int ret;
536527 long temp;
....@@ -555,7 +546,7 @@
555546 return ret;
556547 }
557548
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,
559550 char *buf)
560551 {
561552 struct stts751_priv *priv = dev_get_drvdata(dev);
....@@ -563,8 +554,8 @@
563554 return snprintf(buf, PAGE_SIZE, "%d\n", priv->event_min);
564555 }
565556
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)
568559 {
569560 int ret;
570561 long temp;
....@@ -589,8 +580,8 @@
589580 return ret;
590581 }
591582
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)
594585 {
595586 struct stts751_priv *priv = dev_get_drvdata(dev);
596587
....@@ -598,8 +589,9 @@
598589 stts751_intervals[priv->interval]);
599590 }
600591
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)
603595 {
604596 unsigned long val;
605597 int idx;
....@@ -746,16 +738,15 @@
746738 return 0;
747739 }
748740
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);
759750
760751 static struct attribute *stts751_attrs[] = {
761752 &sensor_dev_attr_temp1_input.dev_attr.attr,
....@@ -771,8 +762,7 @@
771762 };
772763 ATTRIBUTE_GROUPS(stts751);
773764
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)
776766 {
777767 struct stts751_priv *priv;
778768 int ret;
....@@ -831,7 +821,7 @@
831821 .name = DEVNAME,
832822 .of_match_table = of_match_ptr(stts751_of_match),
833823 },
834
- .probe = stts751_probe,
824
+ .probe_new = stts751_probe,
835825 .id_table = stts751_id,
836826 .detect = stts751_detect,
837827 .alert = stts751_alert,