hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/acpi/device_sysfs.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * drivers/acpi/device_sysfs.c - ACPI device sysfs attributes and modalias.
34 *
....@@ -6,15 +7,6 @@
67 * Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
78 *
89 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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.
1810 *
1911 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2012 */
....@@ -333,11 +325,11 @@
333325 EXPORT_SYMBOL_GPL(acpi_device_modalias);
334326
335327 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)
337329 {
338330 return __acpi_device_modalias(to_acpi_device(dev), buf, 1024);
339331 }
340
-static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL);
332
+static DEVICE_ATTR_RO(modalias);
341333
342334 static ssize_t real_power_state_show(struct device *dev,
343335 struct device_attribute *attr, char *buf)
....@@ -366,8 +358,8 @@
366358 static DEVICE_ATTR_RO(power_state);
367359
368360 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)
371363 {
372364 struct acpi_device *acpi_device = to_acpi_device(d);
373365 acpi_object_type not_used;
....@@ -395,44 +387,46 @@
395387 return status == AE_NO_MEMORY ? -ENOMEM : -EAGAIN;
396388 }
397389
398
-static DEVICE_ATTR(eject, 0200, NULL, acpi_eject_store);
390
+static DEVICE_ATTR_WO(eject);
399391
400392 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)
402394 {
403395 struct acpi_device *acpi_dev = to_acpi_device(dev);
404396
405397 return sprintf(buf, "%s\n", acpi_device_hid(acpi_dev));
406398 }
407
-static DEVICE_ATTR(hid, 0444, acpi_device_hid_show, NULL);
399
+static DEVICE_ATTR_RO(hid);
408400
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)
411403 {
412404 struct acpi_device *acpi_dev = to_acpi_device(dev);
413405
414406 return sprintf(buf, "%s\n", acpi_dev->pnp.unique_id);
415407 }
416
-static DEVICE_ATTR(uid, 0444, acpi_device_uid_show, NULL);
408
+static DEVICE_ATTR_RO(uid);
417409
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)
420412 {
421413 struct acpi_device *acpi_dev = to_acpi_device(dev);
422414
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);
425419 }
426
-static DEVICE_ATTR(adr, 0444, acpi_device_adr_show, NULL);
420
+static DEVICE_ATTR_RO(adr);
427421
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)
430424 {
431425 struct acpi_device *acpi_dev = to_acpi_device(dev);
432426
433427 return acpi_object_path(acpi_dev->handle, buf);
434428 }
435
-static DEVICE_ATTR(path, 0444, acpi_device_path_show, NULL);
429
+static DEVICE_ATTR_RO(path);
436430
437431 /* sysfs file that shows description text from the ACPI _STR method */
438432 static ssize_t description_show(struct device *dev,
....@@ -461,8 +455,8 @@
461455 static DEVICE_ATTR_RO(description);
462456
463457 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) {
466460 struct acpi_device *acpi_dev = to_acpi_device(dev);
467461 acpi_status status;
468462 unsigned long long sun;
....@@ -473,11 +467,11 @@
473467
474468 return sprintf(buf, "%llu\n", sun);
475469 }
476
-static DEVICE_ATTR(sun, 0444, acpi_device_sun_show, NULL);
470
+static DEVICE_ATTR_RO(sun);
477471
478472 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) {
481475 struct acpi_device *acpi_dev = to_acpi_device(dev);
482476 acpi_status status;
483477 unsigned long long hrv;
....@@ -488,7 +482,7 @@
488482
489483 return sprintf(buf, "%llu\n", hrv);
490484 }
491
-static DEVICE_ATTR(hrv, 0444, acpi_device_hrv_show, NULL);
485
+static DEVICE_ATTR_RO(hrv);
492486
493487 static ssize_t status_show(struct device *dev, struct device_attribute *attr,
494488 char *buf) {