.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * dock.c - ACPI dock station driver |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2006, 2014, Intel Corp. |
---|
5 | 6 | * Author: Kristen Carlson Accardi <kristen.c.accardi@intel.com> |
---|
6 | 7 | * 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 | | - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
21 | 8 | */ |
---|
22 | 9 | |
---|
23 | 10 | #include <linux/kernel.h> |
---|
.. | .. |
---|
32 | 19 | #include <linux/acpi.h> |
---|
33 | 20 | |
---|
34 | 21 | #include "internal.h" |
---|
35 | | - |
---|
36 | | -ACPI_MODULE_NAME("dock"); |
---|
37 | 22 | |
---|
38 | 23 | static bool immediate_undock = 1; |
---|
39 | 24 | module_param(immediate_undock, bool, 0644); |
---|
.. | .. |
---|
246 | 231 | * between them). |
---|
247 | 232 | */ |
---|
248 | 233 | 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); |
---|
250 | 236 | |
---|
251 | 237 | list_for_each_entry_reverse(dd, &ds->dependent_devices, list) |
---|
252 | 238 | acpi_bus_trim(dd->adev); |
---|
.. | .. |
---|
482 | 468 | surprise_removal = 1; |
---|
483 | 469 | event = ACPI_NOTIFY_EJECT_REQUEST; |
---|
484 | 470 | /* Fall back */ |
---|
485 | | - /* fall through */ |
---|
| 471 | + fallthrough; |
---|
486 | 472 | case ACPI_NOTIFY_EJECT_REQUEST: |
---|
487 | 473 | begin_undock(ds); |
---|
488 | 474 | if ((immediate_undock && !(ds->flags & DOCK_IS_ATA)) |
---|
.. | .. |
---|
498 | 484 | /* |
---|
499 | 485 | * show_docked - read method for "docked" file in sysfs |
---|
500 | 486 | */ |
---|
501 | | -static ssize_t show_docked(struct device *dev, |
---|
| 487 | +static ssize_t docked_show(struct device *dev, |
---|
502 | 488 | struct device_attribute *attr, char *buf) |
---|
503 | 489 | { |
---|
504 | 490 | struct dock_station *dock_station = dev->platform_data; |
---|
.. | .. |
---|
507 | 493 | acpi_bus_get_device(dock_station->handle, &adev); |
---|
508 | 494 | return snprintf(buf, PAGE_SIZE, "%u\n", acpi_device_enumerated(adev)); |
---|
509 | 495 | } |
---|
510 | | -static DEVICE_ATTR(docked, S_IRUGO, show_docked, NULL); |
---|
| 496 | +static DEVICE_ATTR_RO(docked); |
---|
511 | 497 | |
---|
512 | 498 | /* |
---|
513 | 499 | * show_flags - read method for flags file in sysfs |
---|
514 | 500 | */ |
---|
515 | | -static ssize_t show_flags(struct device *dev, |
---|
| 501 | +static ssize_t flags_show(struct device *dev, |
---|
516 | 502 | struct device_attribute *attr, char *buf) |
---|
517 | 503 | { |
---|
518 | 504 | struct dock_station *dock_station = dev->platform_data; |
---|
519 | 505 | return snprintf(buf, PAGE_SIZE, "%d\n", dock_station->flags); |
---|
520 | 506 | |
---|
521 | 507 | } |
---|
522 | | -static DEVICE_ATTR(flags, S_IRUGO, show_flags, NULL); |
---|
| 508 | +static DEVICE_ATTR_RO(flags); |
---|
523 | 509 | |
---|
524 | 510 | /* |
---|
525 | 511 | * write_undock - write method for "undock" file in sysfs |
---|
526 | 512 | */ |
---|
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) |
---|
529 | 515 | { |
---|
530 | 516 | int ret; |
---|
531 | 517 | struct dock_station *dock_station = dev->platform_data; |
---|
.. | .. |
---|
539 | 525 | acpi_scan_lock_release(); |
---|
540 | 526 | return ret ? ret: count; |
---|
541 | 527 | } |
---|
542 | | -static DEVICE_ATTR(undock, S_IWUSR, NULL, write_undock); |
---|
| 528 | +static DEVICE_ATTR_WO(undock); |
---|
543 | 529 | |
---|
544 | 530 | /* |
---|
545 | 531 | * show_dock_uid - read method for "uid" file in sysfs |
---|
546 | 532 | */ |
---|
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) |
---|
549 | 535 | { |
---|
550 | 536 | unsigned long long lbuf; |
---|
551 | 537 | struct dock_station *dock_station = dev->platform_data; |
---|
.. | .. |
---|
556 | 542 | |
---|
557 | 543 | return snprintf(buf, PAGE_SIZE, "%llx\n", lbuf); |
---|
558 | 544 | } |
---|
559 | | -static DEVICE_ATTR(uid, S_IRUGO, show_dock_uid, NULL); |
---|
| 545 | +static DEVICE_ATTR_RO(uid); |
---|
560 | 546 | |
---|
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) |
---|
563 | 549 | { |
---|
564 | 550 | struct dock_station *dock_station = dev->platform_data; |
---|
565 | 551 | char *type; |
---|
.. | .. |
---|
575 | 561 | |
---|
576 | 562 | return snprintf(buf, PAGE_SIZE, "%s\n", type); |
---|
577 | 563 | } |
---|
578 | | -static DEVICE_ATTR(type, S_IRUGO, show_dock_type, NULL); |
---|
| 564 | +static DEVICE_ATTR_RO(type); |
---|
579 | 565 | |
---|
580 | 566 | static struct attribute *dock_attributes[] = { |
---|
581 | 567 | &dev_attr_docked.attr, |
---|