hc
2023-12-06 08f87f769b595151be1afeff53e144f543faa614
kernel/drivers/hwmon/tc654.c
....@@ -1,17 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * tc654.c - Linux kernel modules for fan speed controller
34 *
45 * Copyright (C) 2016 Allied Telesis Labs NZ
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation; either version 2 of the License, or
9
- * (at your option) any later version.
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU General Public License for more details.
156 */
167
178 #include <linux/bitops.h>
....@@ -200,7 +191,7 @@
200191 * sysfs attributes
201192 */
202193
203
-static ssize_t show_fan(struct device *dev, struct device_attribute *da,
194
+static ssize_t fan_show(struct device *dev, struct device_attribute *da,
204195 char *buf)
205196 {
206197 int nr = to_sensor_dev_attr(da)->index;
....@@ -218,7 +209,7 @@
218209 return sprintf(buf, "%d\n", val);
219210 }
220211
221
-static ssize_t show_fan_min(struct device *dev, struct device_attribute *da,
212
+static ssize_t fan_min_show(struct device *dev, struct device_attribute *da,
222213 char *buf)
223214 {
224215 int nr = to_sensor_dev_attr(da)->index;
....@@ -231,8 +222,8 @@
231222 TC654_FAN_FAULT_FROM_REG(data->fan_fault[nr]));
232223 }
233224
234
-static ssize_t set_fan_min(struct device *dev, struct device_attribute *da,
235
- const char *buf, size_t count)
225
+static ssize_t fan_min_store(struct device *dev, struct device_attribute *da,
226
+ const char *buf, size_t count)
236227 {
237228 int nr = to_sensor_dev_attr(da)->index;
238229 struct tc654_data *data = dev_get_drvdata(dev);
....@@ -255,7 +246,7 @@
255246 return ret < 0 ? ret : count;
256247 }
257248
258
-static ssize_t show_fan_alarm(struct device *dev, struct device_attribute *da,
249
+static ssize_t fan_alarm_show(struct device *dev, struct device_attribute *da,
259250 char *buf)
260251 {
261252 int nr = to_sensor_dev_attr(da)->index;
....@@ -275,8 +266,8 @@
275266
276267 static const u8 TC654_FAN_PULSE_SHIFT[] = { 1, 3 };
277268
278
-static ssize_t show_fan_pulses(struct device *dev, struct device_attribute *da,
279
- char *buf)
269
+static ssize_t fan_pulses_show(struct device *dev,
270
+ struct device_attribute *da, char *buf)
280271 {
281272 int nr = to_sensor_dev_attr(da)->index;
282273 struct tc654_data *data = tc654_update_client(dev);
....@@ -289,8 +280,9 @@
289280 return sprintf(buf, "%d\n", val);
290281 }
291282
292
-static ssize_t set_fan_pulses(struct device *dev, struct device_attribute *da,
293
- const char *buf, size_t count)
283
+static ssize_t fan_pulses_store(struct device *dev,
284
+ struct device_attribute *da, const char *buf,
285
+ size_t count)
294286 {
295287 int nr = to_sensor_dev_attr(da)->index;
296288 struct tc654_data *data = dev_get_drvdata(dev);
....@@ -329,8 +321,8 @@
329321 return ret < 0 ? ret : count;
330322 }
331323
332
-static ssize_t show_pwm_mode(struct device *dev,
333
- struct device_attribute *da, char *buf)
324
+static ssize_t pwm_mode_show(struct device *dev, struct device_attribute *da,
325
+ char *buf)
334326 {
335327 struct tc654_data *data = tc654_update_client(dev);
336328
....@@ -340,9 +332,8 @@
340332 return sprintf(buf, "%d\n", !!(data->config & TC654_REG_CONFIG_DUTYC));
341333 }
342334
343
-static ssize_t set_pwm_mode(struct device *dev,
344
- struct device_attribute *da,
345
- const char *buf, size_t count)
335
+static ssize_t pwm_mode_store(struct device *dev, struct device_attribute *da,
336
+ const char *buf, size_t count)
346337 {
347338 struct tc654_data *data = dev_get_drvdata(dev);
348339 struct i2c_client *client = data->client;
....@@ -371,7 +362,7 @@
371362 static const int tc654_pwm_map[16] = { 77, 88, 102, 112, 124, 136, 148, 160,
372363 172, 184, 196, 207, 219, 231, 243, 255};
373364
374
-static ssize_t show_pwm(struct device *dev, struct device_attribute *da,
365
+static ssize_t pwm_show(struct device *dev, struct device_attribute *da,
375366 char *buf)
376367 {
377368 struct tc654_data *data = tc654_update_client(dev);
....@@ -388,8 +379,8 @@
388379 return sprintf(buf, "%d\n", pwm);
389380 }
390381
391
-static ssize_t set_pwm(struct device *dev, struct device_attribute *da,
392
- const char *buf, size_t count)
382
+static ssize_t pwm_store(struct device *dev, struct device_attribute *da,
383
+ const char *buf, size_t count)
393384 {
394385 struct tc654_data *data = dev_get_drvdata(dev);
395386 struct i2c_client *client = data->client;
....@@ -423,22 +414,16 @@
423414 return ret < 0 ? ret : count;
424415 }
425416
426
-static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0);
427
-static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 1);
428
-static SENSOR_DEVICE_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan_min,
429
- set_fan_min, 0);
430
-static SENSOR_DEVICE_ATTR(fan2_min, S_IWUSR | S_IRUGO, show_fan_min,
431
- set_fan_min, 1);
432
-static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_fan_alarm, NULL, 0);
433
-static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_fan_alarm, NULL, 1);
434
-static SENSOR_DEVICE_ATTR(fan1_pulses, S_IWUSR | S_IRUGO, show_fan_pulses,
435
- set_fan_pulses, 0);
436
-static SENSOR_DEVICE_ATTR(fan2_pulses, S_IWUSR | S_IRUGO, show_fan_pulses,
437
- set_fan_pulses, 1);
438
-static SENSOR_DEVICE_ATTR(pwm1_mode, S_IWUSR | S_IRUGO,
439
- show_pwm_mode, set_pwm_mode, 0);
440
-static SENSOR_DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm,
441
- set_pwm, 0);
417
+static SENSOR_DEVICE_ATTR_RO(fan1_input, fan, 0);
418
+static SENSOR_DEVICE_ATTR_RO(fan2_input, fan, 1);
419
+static SENSOR_DEVICE_ATTR_RW(fan1_min, fan_min, 0);
420
+static SENSOR_DEVICE_ATTR_RW(fan2_min, fan_min, 1);
421
+static SENSOR_DEVICE_ATTR_RO(fan1_alarm, fan_alarm, 0);
422
+static SENSOR_DEVICE_ATTR_RO(fan2_alarm, fan_alarm, 1);
423
+static SENSOR_DEVICE_ATTR_RW(fan1_pulses, fan_pulses, 0);
424
+static SENSOR_DEVICE_ATTR_RW(fan2_pulses, fan_pulses, 1);
425
+static SENSOR_DEVICE_ATTR_RW(pwm1_mode, pwm_mode, 0);
426
+static SENSOR_DEVICE_ATTR_RW(pwm1, pwm, 0);
442427
443428 /* Driver data */
444429 static struct attribute *tc654_attrs[] = {
....@@ -461,8 +446,7 @@
461446 * device probe and removal
462447 */
463448
464
-static int tc654_probe(struct i2c_client *client,
465
- const struct i2c_device_id *id)
449
+static int tc654_probe(struct i2c_client *client)
466450 {
467451 struct device *dev = &client->dev;
468452 struct tc654_data *data;
....@@ -503,7 +487,7 @@
503487 .driver = {
504488 .name = "tc654",
505489 },
506
- .probe = tc654_probe,
490
+ .probe_new = tc654_probe,
507491 .id_table = tc654_id,
508492 };
509493