.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * A hwmon driver for the Intel 5000 series chipset FB-DIMM AMB |
---|
3 | 4 | * temperature sensors |
---|
4 | 5 | * Copyright (C) 2007 IBM |
---|
5 | 6 | * |
---|
6 | 7 | * 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 |
---|
21 | 8 | */ |
---|
22 | 9 | |
---|
23 | 10 | #include <linux/module.h> |
---|
.. | .. |
---|
296 | 283 | snprintf(iattr->name, AMB_SYSFS_NAME_LEN, |
---|
297 | 284 | "temp%d_label", d); |
---|
298 | 285 | 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; |
---|
300 | 287 | iattr->s_attr.dev_attr.show = show_label; |
---|
301 | 288 | iattr->s_attr.index = k; |
---|
302 | 289 | sysfs_attr_init(&iattr->s_attr.dev_attr.attr); |
---|
.. | .. |
---|
311 | 298 | snprintf(iattr->name, AMB_SYSFS_NAME_LEN, |
---|
312 | 299 | "temp%d_input", d); |
---|
313 | 300 | 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; |
---|
315 | 302 | iattr->s_attr.dev_attr.show = show_amb_temp; |
---|
316 | 303 | iattr->s_attr.index = k; |
---|
317 | 304 | sysfs_attr_init(&iattr->s_attr.dev_attr.attr); |
---|
.. | .. |
---|
326 | 313 | snprintf(iattr->name, AMB_SYSFS_NAME_LEN, |
---|
327 | 314 | "temp%d_min", d); |
---|
328 | 315 | 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; |
---|
330 | 317 | iattr->s_attr.dev_attr.show = show_amb_min; |
---|
331 | 318 | iattr->s_attr.dev_attr.store = store_amb_min; |
---|
332 | 319 | iattr->s_attr.index = k; |
---|
.. | .. |
---|
342 | 329 | snprintf(iattr->name, AMB_SYSFS_NAME_LEN, |
---|
343 | 330 | "temp%d_mid", d); |
---|
344 | 331 | 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; |
---|
346 | 333 | iattr->s_attr.dev_attr.show = show_amb_mid; |
---|
347 | 334 | iattr->s_attr.dev_attr.store = store_amb_mid; |
---|
348 | 335 | iattr->s_attr.index = k; |
---|
.. | .. |
---|
358 | 345 | snprintf(iattr->name, AMB_SYSFS_NAME_LEN, |
---|
359 | 346 | "temp%d_max", d); |
---|
360 | 347 | 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; |
---|
362 | 349 | iattr->s_attr.dev_attr.show = show_amb_max; |
---|
363 | 350 | iattr->s_attr.dev_attr.store = store_amb_max; |
---|
364 | 351 | iattr->s_attr.index = k; |
---|
.. | .. |
---|
374 | 361 | snprintf(iattr->name, AMB_SYSFS_NAME_LEN, |
---|
375 | 362 | "temp%d_alarm", d); |
---|
376 | 363 | 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; |
---|
378 | 365 | iattr->s_attr.dev_attr.show = show_amb_alarm; |
---|
379 | 366 | iattr->s_attr.index = k; |
---|
380 | 367 | sysfs_attr_init(&iattr->s_attr.dev_attr.attr); |
---|
.. | .. |
---|
409 | 396 | |
---|
410 | 397 | static int i5k_amb_add(void) |
---|
411 | 398 | { |
---|
412 | | - int res = -ENODEV; |
---|
| 399 | + int res; |
---|
413 | 400 | |
---|
414 | 401 | /* only ever going to be one of these */ |
---|
415 | 402 | amb_pdev = platform_device_alloc(DRVNAME, 0); |
---|
.. | .. |
---|
440 | 427 | if (!pcidev) |
---|
441 | 428 | return -ENODEV; |
---|
442 | 429 | |
---|
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) |
---|
444 | 432 | goto out; |
---|
445 | 433 | data->amb_base = val32; |
---|
446 | 434 | |
---|
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) |
---|
448 | 437 | goto out; |
---|
449 | 438 | data->amb_len = val32; |
---|
450 | 439 | |
---|
.. | .. |
---|
471 | 460 | if (!pcidev) |
---|
472 | 461 | return -ENODEV; |
---|
473 | 462 | |
---|
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) |
---|
475 | 465 | goto out; |
---|
476 | 466 | amb_present[0] = val16; |
---|
477 | 467 | |
---|
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) |
---|
479 | 470 | goto out; |
---|
480 | 471 | amb_present[1] = val16; |
---|
481 | 472 | |
---|
.. | .. |
---|
541 | 532 | goto err; |
---|
542 | 533 | } |
---|
543 | 534 | |
---|
544 | | - data->amb_mmio = ioremap_nocache(data->amb_base, data->amb_len); |
---|
| 535 | + data->amb_mmio = ioremap(data->amb_base, data->amb_len); |
---|
545 | 536 | if (!data->amb_mmio) { |
---|
546 | 537 | res = -EBUSY; |
---|
547 | 538 | goto err_map_failed; |
---|