hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/acpi/dock.c
....@@ -1,23 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * dock.c - ACPI dock station driver
34 *
45 * Copyright (C) 2006, 2014, Intel Corp.
56 * Author: Kristen Carlson Accardi <kristen.c.accardi@intel.com>
67 * Rafael J. Wysocki <rafael.j.wysocki@intel.com>
7
- *
8
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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 as published by
12
- * the Free Software Foundation; either version 2 of the License, or (at
13
- * your option) any later version.
14
- *
15
- * This program is distributed in the hope that it will be useful, but
16
- * WITHOUT ANY WARRANTY; without even the implied warranty of
17
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18
- * General Public License for more details.
19
- *
20
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
218 */
229
2310 #include <linux/kernel.h>
....@@ -32,8 +19,6 @@
3219 #include <linux/acpi.h>
3320
3421 #include "internal.h"
35
-
36
-ACPI_MODULE_NAME("dock");
3722
3823 static bool immediate_undock = 1;
3924 module_param(immediate_undock, bool, 0644);
....@@ -246,7 +231,8 @@
246231 * between them).
247232 */
248233 list_for_each_entry_reverse(dd, &ds->dependent_devices, list)
249
- dock_hotplug_event(dd, ACPI_NOTIFY_EJECT_REQUEST, false);
234
+ dock_hotplug_event(dd, ACPI_NOTIFY_EJECT_REQUEST,
235
+ DOCK_CALL_HANDLER);
250236
251237 list_for_each_entry_reverse(dd, &ds->dependent_devices, list)
252238 acpi_bus_trim(dd->adev);
....@@ -482,7 +468,7 @@
482468 surprise_removal = 1;
483469 event = ACPI_NOTIFY_EJECT_REQUEST;
484470 /* Fall back */
485
- /* fall through */
471
+ fallthrough;
486472 case ACPI_NOTIFY_EJECT_REQUEST:
487473 begin_undock(ds);
488474 if ((immediate_undock && !(ds->flags & DOCK_IS_ATA))
....@@ -498,7 +484,7 @@
498484 /*
499485 * show_docked - read method for "docked" file in sysfs
500486 */
501
-static ssize_t show_docked(struct device *dev,
487
+static ssize_t docked_show(struct device *dev,
502488 struct device_attribute *attr, char *buf)
503489 {
504490 struct dock_station *dock_station = dev->platform_data;
....@@ -507,25 +493,25 @@
507493 acpi_bus_get_device(dock_station->handle, &adev);
508494 return snprintf(buf, PAGE_SIZE, "%u\n", acpi_device_enumerated(adev));
509495 }
510
-static DEVICE_ATTR(docked, S_IRUGO, show_docked, NULL);
496
+static DEVICE_ATTR_RO(docked);
511497
512498 /*
513499 * show_flags - read method for flags file in sysfs
514500 */
515
-static ssize_t show_flags(struct device *dev,
501
+static ssize_t flags_show(struct device *dev,
516502 struct device_attribute *attr, char *buf)
517503 {
518504 struct dock_station *dock_station = dev->platform_data;
519505 return snprintf(buf, PAGE_SIZE, "%d\n", dock_station->flags);
520506
521507 }
522
-static DEVICE_ATTR(flags, S_IRUGO, show_flags, NULL);
508
+static DEVICE_ATTR_RO(flags);
523509
524510 /*
525511 * write_undock - write method for "undock" file in sysfs
526512 */
527
-static ssize_t write_undock(struct device *dev, struct device_attribute *attr,
528
- const char *buf, size_t count)
513
+static ssize_t undock_store(struct device *dev, struct device_attribute *attr,
514
+ const char *buf, size_t count)
529515 {
530516 int ret;
531517 struct dock_station *dock_station = dev->platform_data;
....@@ -539,13 +525,13 @@
539525 acpi_scan_lock_release();
540526 return ret ? ret: count;
541527 }
542
-static DEVICE_ATTR(undock, S_IWUSR, NULL, write_undock);
528
+static DEVICE_ATTR_WO(undock);
543529
544530 /*
545531 * show_dock_uid - read method for "uid" file in sysfs
546532 */
547
-static ssize_t show_dock_uid(struct device *dev,
548
- struct device_attribute *attr, char *buf)
533
+static ssize_t uid_show(struct device *dev,
534
+ struct device_attribute *attr, char *buf)
549535 {
550536 unsigned long long lbuf;
551537 struct dock_station *dock_station = dev->platform_data;
....@@ -556,10 +542,10 @@
556542
557543 return snprintf(buf, PAGE_SIZE, "%llx\n", lbuf);
558544 }
559
-static DEVICE_ATTR(uid, S_IRUGO, show_dock_uid, NULL);
545
+static DEVICE_ATTR_RO(uid);
560546
561
-static ssize_t show_dock_type(struct device *dev,
562
- struct device_attribute *attr, char *buf)
547
+static ssize_t type_show(struct device *dev,
548
+ struct device_attribute *attr, char *buf)
563549 {
564550 struct dock_station *dock_station = dev->platform_data;
565551 char *type;
....@@ -575,7 +561,7 @@
575561
576562 return snprintf(buf, PAGE_SIZE, "%s\n", type);
577563 }
578
-static DEVICE_ATTR(type, S_IRUGO, show_dock_type, NULL);
564
+static DEVICE_ATTR_RO(type);
579565
580566 static struct attribute *dock_attributes[] = {
581567 &dev_attr_docked.attr,