hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/hwmon/ad7414.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * An hwmon driver for the Analog Devices AD7414
34 *
....@@ -12,11 +13,6 @@
1213 *
1314 * Based on ad7418.c
1415 * Copyright 2006 Tower Technologies, Alessandro Zummo <a.zummo at towertech.it>
15
- *
16
- * This program is free software; you can redistribute it and/or modify
17
- * it under the terms of the GNU General Public License as published by
18
- * the Free Software Foundation; either version 2 of the License, or
19
- * (at your option) any later version.
2016 */
2117
2218 #include <linux/module.h>
....@@ -107,25 +103,25 @@
107103 return data;
108104 }
109105
110
-static ssize_t show_temp_input(struct device *dev,
106
+static ssize_t temp_input_show(struct device *dev,
111107 struct device_attribute *attr, char *buf)
112108 {
113109 struct ad7414_data *data = ad7414_update_device(dev);
114110 return sprintf(buf, "%d\n", ad7414_temp_from_reg(data->temp_input));
115111 }
116
-static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp_input, NULL, 0);
112
+static SENSOR_DEVICE_ATTR_RO(temp1_input, temp_input, 0);
117113
118
-static ssize_t show_max_min(struct device *dev, struct device_attribute *attr,
119
- char *buf)
114
+static ssize_t max_min_show(struct device *dev, struct device_attribute *attr,
115
+ char *buf)
120116 {
121117 int index = to_sensor_dev_attr(attr)->index;
122118 struct ad7414_data *data = ad7414_update_device(dev);
123119 return sprintf(buf, "%d\n", data->temps[index] * 1000);
124120 }
125121
126
-static ssize_t set_max_min(struct device *dev,
127
- struct device_attribute *attr,
128
- const char *buf, size_t count)
122
+static ssize_t max_min_store(struct device *dev,
123
+ struct device_attribute *attr, const char *buf,
124
+ size_t count)
129125 {
130126 struct ad7414_data *data = dev_get_drvdata(dev);
131127 struct i2c_client *client = data->client;
....@@ -147,12 +143,10 @@
147143 return count;
148144 }
149145
150
-static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO,
151
- show_max_min, set_max_min, 0);
152
-static SENSOR_DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO,
153
- show_max_min, set_max_min, 1);
146
+static SENSOR_DEVICE_ATTR_RW(temp1_max, max_min, 0);
147
+static SENSOR_DEVICE_ATTR_RW(temp1_min, max_min, 1);
154148
155
-static ssize_t show_alarm(struct device *dev, struct device_attribute *attr,
149
+static ssize_t alarm_show(struct device *dev, struct device_attribute *attr,
156150 char *buf)
157151 {
158152 int bitnr = to_sensor_dev_attr(attr)->index;
....@@ -161,8 +155,8 @@
161155 return sprintf(buf, "%d\n", value);
162156 }
163157
164
-static SENSOR_DEVICE_ATTR(temp1_min_alarm, S_IRUGO, show_alarm, NULL, 3);
165
-static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 4);
158
+static SENSOR_DEVICE_ATTR_RO(temp1_min_alarm, alarm, 3);
159
+static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, alarm, 4);
166160
167161 static struct attribute *ad7414_attrs[] = {
168162 &sensor_dev_attr_temp1_input.dev_attr.attr,
....@@ -175,8 +169,7 @@
175169
176170 ATTRIBUTE_GROUPS(ad7414);
177171
178
-static int ad7414_probe(struct i2c_client *client,
179
- const struct i2c_device_id *dev_id)
172
+static int ad7414_probe(struct i2c_client *client)
180173 {
181174 struct device *dev = &client->dev;
182175 struct ad7414_data *data;
....@@ -217,7 +210,7 @@
217210 };
218211 MODULE_DEVICE_TABLE(i2c, ad7414_id);
219212
220
-static const struct of_device_id ad7414_of_match[] = {
213
+static const struct of_device_id __maybe_unused ad7414_of_match[] = {
221214 { .compatible = "ad,ad7414" },
222215 { },
223216 };
....@@ -228,7 +221,7 @@
228221 .name = "ad7414",
229222 .of_match_table = of_match_ptr(ad7414_of_match),
230223 },
231
- .probe = ad7414_probe,
224
+ .probe_new = ad7414_probe,
232225 .id_table = ad7414_id,
233226 };
234227