hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/hwmon/i5k_amb.c
....@@ -1,23 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * A hwmon driver for the Intel 5000 series chipset FB-DIMM AMB
34 * temperature sensors
45 * Copyright (C) 2007 IBM
56 *
67 * Author: Darrick J. Wong <darrick.wong@oracle.com>
7
- *
8
- * This program is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation; either version 2 of the License, or
11
- * (at your option) any later version.
12
- *
13
- * This program is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
- * GNU General Public License for more details.
17
- *
18
- * You should have received a copy of the GNU General Public License
19
- * along with this program; if not, write to the Free Software
20
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
218 */
229
2310 #include <linux/module.h>
....@@ -296,7 +283,7 @@
296283 snprintf(iattr->name, AMB_SYSFS_NAME_LEN,
297284 "temp%d_label", d);
298285 iattr->s_attr.dev_attr.attr.name = iattr->name;
299
- iattr->s_attr.dev_attr.attr.mode = S_IRUGO;
286
+ iattr->s_attr.dev_attr.attr.mode = 0444;
300287 iattr->s_attr.dev_attr.show = show_label;
301288 iattr->s_attr.index = k;
302289 sysfs_attr_init(&iattr->s_attr.dev_attr.attr);
....@@ -311,7 +298,7 @@
311298 snprintf(iattr->name, AMB_SYSFS_NAME_LEN,
312299 "temp%d_input", d);
313300 iattr->s_attr.dev_attr.attr.name = iattr->name;
314
- iattr->s_attr.dev_attr.attr.mode = S_IRUGO;
301
+ iattr->s_attr.dev_attr.attr.mode = 0444;
315302 iattr->s_attr.dev_attr.show = show_amb_temp;
316303 iattr->s_attr.index = k;
317304 sysfs_attr_init(&iattr->s_attr.dev_attr.attr);
....@@ -326,7 +313,7 @@
326313 snprintf(iattr->name, AMB_SYSFS_NAME_LEN,
327314 "temp%d_min", d);
328315 iattr->s_attr.dev_attr.attr.name = iattr->name;
329
- iattr->s_attr.dev_attr.attr.mode = S_IWUSR | S_IRUGO;
316
+ iattr->s_attr.dev_attr.attr.mode = 0644;
330317 iattr->s_attr.dev_attr.show = show_amb_min;
331318 iattr->s_attr.dev_attr.store = store_amb_min;
332319 iattr->s_attr.index = k;
....@@ -342,7 +329,7 @@
342329 snprintf(iattr->name, AMB_SYSFS_NAME_LEN,
343330 "temp%d_mid", d);
344331 iattr->s_attr.dev_attr.attr.name = iattr->name;
345
- iattr->s_attr.dev_attr.attr.mode = S_IWUSR | S_IRUGO;
332
+ iattr->s_attr.dev_attr.attr.mode = 0644;
346333 iattr->s_attr.dev_attr.show = show_amb_mid;
347334 iattr->s_attr.dev_attr.store = store_amb_mid;
348335 iattr->s_attr.index = k;
....@@ -358,7 +345,7 @@
358345 snprintf(iattr->name, AMB_SYSFS_NAME_LEN,
359346 "temp%d_max", d);
360347 iattr->s_attr.dev_attr.attr.name = iattr->name;
361
- iattr->s_attr.dev_attr.attr.mode = S_IWUSR | S_IRUGO;
348
+ iattr->s_attr.dev_attr.attr.mode = 0644;
362349 iattr->s_attr.dev_attr.show = show_amb_max;
363350 iattr->s_attr.dev_attr.store = store_amb_max;
364351 iattr->s_attr.index = k;
....@@ -374,7 +361,7 @@
374361 snprintf(iattr->name, AMB_SYSFS_NAME_LEN,
375362 "temp%d_alarm", d);
376363 iattr->s_attr.dev_attr.attr.name = iattr->name;
377
- iattr->s_attr.dev_attr.attr.mode = S_IRUGO;
364
+ iattr->s_attr.dev_attr.attr.mode = 0444;
378365 iattr->s_attr.dev_attr.show = show_amb_alarm;
379366 iattr->s_attr.index = k;
380367 sysfs_attr_init(&iattr->s_attr.dev_attr.attr);
....@@ -409,7 +396,7 @@
409396
410397 static int i5k_amb_add(void)
411398 {
412
- int res = -ENODEV;
399
+ int res;
413400
414401 /* only ever going to be one of these */
415402 amb_pdev = platform_device_alloc(DRVNAME, 0);
....@@ -440,11 +427,13 @@
440427 if (!pcidev)
441428 return -ENODEV;
442429
443
- if (pci_read_config_dword(pcidev, I5K_REG_AMB_BASE_ADDR, &val32))
430
+ pci_read_config_dword(pcidev, I5K_REG_AMB_BASE_ADDR, &val32);
431
+ if (val32 == (u32)~0)
444432 goto out;
445433 data->amb_base = val32;
446434
447
- if (pci_read_config_dword(pcidev, I5K_REG_AMB_LEN_ADDR, &val32))
435
+ pci_read_config_dword(pcidev, I5K_REG_AMB_LEN_ADDR, &val32);
436
+ if (val32 == (u32)~0)
448437 goto out;
449438 data->amb_len = val32;
450439
....@@ -471,11 +460,13 @@
471460 if (!pcidev)
472461 return -ENODEV;
473462
474
- if (pci_read_config_word(pcidev, I5K_REG_CHAN0_PRESENCE_ADDR, &val16))
463
+ pci_read_config_word(pcidev, I5K_REG_CHAN0_PRESENCE_ADDR, &val16);
464
+ if (val16 == (u16)~0)
475465 goto out;
476466 amb_present[0] = val16;
477467
478
- if (pci_read_config_word(pcidev, I5K_REG_CHAN1_PRESENCE_ADDR, &val16))
468
+ pci_read_config_word(pcidev, I5K_REG_CHAN1_PRESENCE_ADDR, &val16);
469
+ if (val16 == (u16)~0)
479470 goto out;
480471 amb_present[1] = val16;
481472
....@@ -541,7 +532,7 @@
541532 goto err;
542533 }
543534
544
- data->amb_mmio = ioremap_nocache(data->amb_base, data->amb_len);
535
+ data->amb_mmio = ioremap(data->amb_base, data->amb_len);
545536 if (!data->amb_mmio) {
546537 res = -EBUSY;
547538 goto err_map_failed;