.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * drivers/acpi/device_sysfs.c - ACPI device sysfs attributes and modalias. |
---|
3 | 4 | * |
---|
.. | .. |
---|
6 | 7 | * Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com> |
---|
7 | 8 | * |
---|
8 | 9 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
9 | | - * |
---|
10 | | - * This program is free software; you can redistribute it and/or modify |
---|
11 | | - * it under the terms of the GNU General Public License version 2 as published |
---|
12 | | - * by the Free Software Foundation. |
---|
13 | | - * |
---|
14 | | - * This program is distributed in the hope that it will be useful, but |
---|
15 | | - * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
17 | | - * General Public License for more details. |
---|
18 | 10 | * |
---|
19 | 11 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
20 | 12 | */ |
---|
.. | .. |
---|
333 | 325 | EXPORT_SYMBOL_GPL(acpi_device_modalias); |
---|
334 | 326 | |
---|
335 | 327 | static ssize_t |
---|
336 | | -acpi_device_modalias_show(struct device *dev, struct device_attribute *attr, char *buf) |
---|
| 328 | +modalias_show(struct device *dev, struct device_attribute *attr, char *buf) |
---|
337 | 329 | { |
---|
338 | 330 | return __acpi_device_modalias(to_acpi_device(dev), buf, 1024); |
---|
339 | 331 | } |
---|
340 | | -static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL); |
---|
| 332 | +static DEVICE_ATTR_RO(modalias); |
---|
341 | 333 | |
---|
342 | 334 | static ssize_t real_power_state_show(struct device *dev, |
---|
343 | 335 | struct device_attribute *attr, char *buf) |
---|
.. | .. |
---|
366 | 358 | static DEVICE_ATTR_RO(power_state); |
---|
367 | 359 | |
---|
368 | 360 | static ssize_t |
---|
369 | | -acpi_eject_store(struct device *d, struct device_attribute *attr, |
---|
370 | | - const char *buf, size_t count) |
---|
| 361 | +eject_store(struct device *d, struct device_attribute *attr, |
---|
| 362 | + const char *buf, size_t count) |
---|
371 | 363 | { |
---|
372 | 364 | struct acpi_device *acpi_device = to_acpi_device(d); |
---|
373 | 365 | acpi_object_type not_used; |
---|
.. | .. |
---|
395 | 387 | return status == AE_NO_MEMORY ? -ENOMEM : -EAGAIN; |
---|
396 | 388 | } |
---|
397 | 389 | |
---|
398 | | -static DEVICE_ATTR(eject, 0200, NULL, acpi_eject_store); |
---|
| 390 | +static DEVICE_ATTR_WO(eject); |
---|
399 | 391 | |
---|
400 | 392 | static ssize_t |
---|
401 | | -acpi_device_hid_show(struct device *dev, struct device_attribute *attr, char *buf) |
---|
| 393 | +hid_show(struct device *dev, struct device_attribute *attr, char *buf) |
---|
402 | 394 | { |
---|
403 | 395 | struct acpi_device *acpi_dev = to_acpi_device(dev); |
---|
404 | 396 | |
---|
405 | 397 | return sprintf(buf, "%s\n", acpi_device_hid(acpi_dev)); |
---|
406 | 398 | } |
---|
407 | | -static DEVICE_ATTR(hid, 0444, acpi_device_hid_show, NULL); |
---|
| 399 | +static DEVICE_ATTR_RO(hid); |
---|
408 | 400 | |
---|
409 | | -static ssize_t acpi_device_uid_show(struct device *dev, |
---|
410 | | - struct device_attribute *attr, char *buf) |
---|
| 401 | +static ssize_t uid_show(struct device *dev, |
---|
| 402 | + struct device_attribute *attr, char *buf) |
---|
411 | 403 | { |
---|
412 | 404 | struct acpi_device *acpi_dev = to_acpi_device(dev); |
---|
413 | 405 | |
---|
414 | 406 | return sprintf(buf, "%s\n", acpi_dev->pnp.unique_id); |
---|
415 | 407 | } |
---|
416 | | -static DEVICE_ATTR(uid, 0444, acpi_device_uid_show, NULL); |
---|
| 408 | +static DEVICE_ATTR_RO(uid); |
---|
417 | 409 | |
---|
418 | | -static ssize_t acpi_device_adr_show(struct device *dev, |
---|
419 | | - struct device_attribute *attr, char *buf) |
---|
| 410 | +static ssize_t adr_show(struct device *dev, |
---|
| 411 | + struct device_attribute *attr, char *buf) |
---|
420 | 412 | { |
---|
421 | 413 | struct acpi_device *acpi_dev = to_acpi_device(dev); |
---|
422 | 414 | |
---|
423 | | - return sprintf(buf, "0x%08x\n", |
---|
424 | | - (unsigned int)(acpi_dev->pnp.bus_address)); |
---|
| 415 | + if (acpi_dev->pnp.bus_address > U32_MAX) |
---|
| 416 | + return sprintf(buf, "0x%016llx\n", acpi_dev->pnp.bus_address); |
---|
| 417 | + else |
---|
| 418 | + return sprintf(buf, "0x%08llx\n", acpi_dev->pnp.bus_address); |
---|
425 | 419 | } |
---|
426 | | -static DEVICE_ATTR(adr, 0444, acpi_device_adr_show, NULL); |
---|
| 420 | +static DEVICE_ATTR_RO(adr); |
---|
427 | 421 | |
---|
428 | | -static ssize_t acpi_device_path_show(struct device *dev, |
---|
429 | | - struct device_attribute *attr, char *buf) |
---|
| 422 | +static ssize_t path_show(struct device *dev, |
---|
| 423 | + struct device_attribute *attr, char *buf) |
---|
430 | 424 | { |
---|
431 | 425 | struct acpi_device *acpi_dev = to_acpi_device(dev); |
---|
432 | 426 | |
---|
433 | 427 | return acpi_object_path(acpi_dev->handle, buf); |
---|
434 | 428 | } |
---|
435 | | -static DEVICE_ATTR(path, 0444, acpi_device_path_show, NULL); |
---|
| 429 | +static DEVICE_ATTR_RO(path); |
---|
436 | 430 | |
---|
437 | 431 | /* sysfs file that shows description text from the ACPI _STR method */ |
---|
438 | 432 | static ssize_t description_show(struct device *dev, |
---|
.. | .. |
---|
461 | 455 | static DEVICE_ATTR_RO(description); |
---|
462 | 456 | |
---|
463 | 457 | static ssize_t |
---|
464 | | -acpi_device_sun_show(struct device *dev, struct device_attribute *attr, |
---|
465 | | - char *buf) { |
---|
| 458 | +sun_show(struct device *dev, struct device_attribute *attr, |
---|
| 459 | + char *buf) { |
---|
466 | 460 | struct acpi_device *acpi_dev = to_acpi_device(dev); |
---|
467 | 461 | acpi_status status; |
---|
468 | 462 | unsigned long long sun; |
---|
.. | .. |
---|
473 | 467 | |
---|
474 | 468 | return sprintf(buf, "%llu\n", sun); |
---|
475 | 469 | } |
---|
476 | | -static DEVICE_ATTR(sun, 0444, acpi_device_sun_show, NULL); |
---|
| 470 | +static DEVICE_ATTR_RO(sun); |
---|
477 | 471 | |
---|
478 | 472 | static ssize_t |
---|
479 | | -acpi_device_hrv_show(struct device *dev, struct device_attribute *attr, |
---|
480 | | - char *buf) { |
---|
| 473 | +hrv_show(struct device *dev, struct device_attribute *attr, |
---|
| 474 | + char *buf) { |
---|
481 | 475 | struct acpi_device *acpi_dev = to_acpi_device(dev); |
---|
482 | 476 | acpi_status status; |
---|
483 | 477 | unsigned long long hrv; |
---|
.. | .. |
---|
488 | 482 | |
---|
489 | 483 | return sprintf(buf, "%llu\n", hrv); |
---|
490 | 484 | } |
---|
491 | | -static DEVICE_ATTR(hrv, 0444, acpi_device_hrv_show, NULL); |
---|
| 485 | +static DEVICE_ATTR_RO(hrv); |
---|
492 | 486 | |
---|
493 | 487 | static ssize_t status_show(struct device *dev, struct device_attribute *attr, |
---|
494 | 488 | char *buf) { |
---|