dock.c (500050f0d28868af302a3c24d7d1d0191521286e) dock.c (0f39ee8324e75c9d370e84a61323ceb194641a18)
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * dock.c - ACPI dock station driver
4 *
5 * Copyright (C) 2006, 2014, Intel Corp.
6 * Author: Kristen Carlson Accardi <kristen.c.accardi@intel.com>
7 * Rafael J. Wysocki <rafael.j.wysocki@intel.com>
8 */

--- 470 unchanged lines hidden (view full) ---

479 break;
480 }
481 return 0;
482}
483
484/*
485 * show_docked - read method for "docked" file in sysfs
486 */
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * dock.c - ACPI dock station driver
4 *
5 * Copyright (C) 2006, 2014, Intel Corp.
6 * Author: Kristen Carlson Accardi <kristen.c.accardi@intel.com>
7 * Rafael J. Wysocki <rafael.j.wysocki@intel.com>
8 */

--- 470 unchanged lines hidden (view full) ---

479 break;
480 }
481 return 0;
482}
483
484/*
485 * show_docked - read method for "docked" file in sysfs
486 */
487static ssize_t show_docked(struct device *dev,
487static ssize_t docked_show(struct device *dev,
488 struct device_attribute *attr, char *buf)
489{
490 struct dock_station *dock_station = dev->platform_data;
491 struct acpi_device *adev = NULL;
492
493 acpi_bus_get_device(dock_station->handle, &adev);
494 return snprintf(buf, PAGE_SIZE, "%u\n", acpi_device_enumerated(adev));
495}
488 struct device_attribute *attr, char *buf)
489{
490 struct dock_station *dock_station = dev->platform_data;
491 struct acpi_device *adev = NULL;
492
493 acpi_bus_get_device(dock_station->handle, &adev);
494 return snprintf(buf, PAGE_SIZE, "%u\n", acpi_device_enumerated(adev));
495}
496static DEVICE_ATTR(docked, S_IRUGO, show_docked, NULL);
496static DEVICE_ATTR_RO(docked);
497
498/*
499 * show_flags - read method for flags file in sysfs
500 */
497
498/*
499 * show_flags - read method for flags file in sysfs
500 */
501static ssize_t show_flags(struct device *dev,
501static ssize_t flags_show(struct device *dev,
502 struct device_attribute *attr, char *buf)
503{
504 struct dock_station *dock_station = dev->platform_data;
505 return snprintf(buf, PAGE_SIZE, "%d\n", dock_station->flags);
506
507}
502 struct device_attribute *attr, char *buf)
503{
504 struct dock_station *dock_station = dev->platform_data;
505 return snprintf(buf, PAGE_SIZE, "%d\n", dock_station->flags);
506
507}
508static DEVICE_ATTR(flags, S_IRUGO, show_flags, NULL);
508static DEVICE_ATTR_RO(flags);
509
510/*
511 * write_undock - write method for "undock" file in sysfs
512 */
509
510/*
511 * write_undock - write method for "undock" file in sysfs
512 */
513static ssize_t write_undock(struct device *dev, struct device_attribute *attr,
514 const char *buf, size_t count)
513static ssize_t undock_store(struct device *dev, struct device_attribute *attr,
514 const char *buf, size_t count)
515{
516 int ret;
517 struct dock_station *dock_station = dev->platform_data;
518
519 if (!count)
520 return -EINVAL;
521
522 acpi_scan_lock_acquire();
523 begin_undock(dock_station);
524 ret = handle_eject_request(dock_station, ACPI_NOTIFY_EJECT_REQUEST);
525 acpi_scan_lock_release();
526 return ret ? ret: count;
527}
515{
516 int ret;
517 struct dock_station *dock_station = dev->platform_data;
518
519 if (!count)
520 return -EINVAL;
521
522 acpi_scan_lock_acquire();
523 begin_undock(dock_station);
524 ret = handle_eject_request(dock_station, ACPI_NOTIFY_EJECT_REQUEST);
525 acpi_scan_lock_release();
526 return ret ? ret: count;
527}
528static DEVICE_ATTR(undock, S_IWUSR, NULL, write_undock);
528static DEVICE_ATTR_WO(undock);
529
530/*
531 * show_dock_uid - read method for "uid" file in sysfs
532 */
529
530/*
531 * show_dock_uid - read method for "uid" file in sysfs
532 */
533static ssize_t show_dock_uid(struct device *dev,
534 struct device_attribute *attr, char *buf)
533static ssize_t uid_show(struct device *dev,
534 struct device_attribute *attr, char *buf)
535{
536 unsigned long long lbuf;
537 struct dock_station *dock_station = dev->platform_data;
538 acpi_status status = acpi_evaluate_integer(dock_station->handle,
539 "_UID", NULL, &lbuf);
540 if (ACPI_FAILURE(status))
541 return 0;
542
543 return snprintf(buf, PAGE_SIZE, "%llx\n", lbuf);
544}
535{
536 unsigned long long lbuf;
537 struct dock_station *dock_station = dev->platform_data;
538 acpi_status status = acpi_evaluate_integer(dock_station->handle,
539 "_UID", NULL, &lbuf);
540 if (ACPI_FAILURE(status))
541 return 0;
542
543 return snprintf(buf, PAGE_SIZE, "%llx\n", lbuf);
544}
545static DEVICE_ATTR(uid, S_IRUGO, show_dock_uid, NULL);
545static DEVICE_ATTR_RO(uid);
546
546
547static ssize_t show_dock_type(struct device *dev,
548 struct device_attribute *attr, char *buf)
547static ssize_t type_show(struct device *dev,
548 struct device_attribute *attr, char *buf)
549{
550 struct dock_station *dock_station = dev->platform_data;
551 char *type;
552
553 if (dock_station->flags & DOCK_IS_DOCK)
554 type = "dock_station";
555 else if (dock_station->flags & DOCK_IS_ATA)
556 type = "ata_bay";
557 else if (dock_station->flags & DOCK_IS_BAT)
558 type = "battery_bay";
559 else
560 type = "unknown";
561
562 return snprintf(buf, PAGE_SIZE, "%s\n", type);
563}
549{
550 struct dock_station *dock_station = dev->platform_data;
551 char *type;
552
553 if (dock_station->flags & DOCK_IS_DOCK)
554 type = "dock_station";
555 else if (dock_station->flags & DOCK_IS_ATA)
556 type = "ata_bay";
557 else if (dock_station->flags & DOCK_IS_BAT)
558 type = "battery_bay";
559 else
560 type = "unknown";
561
562 return snprintf(buf, PAGE_SIZE, "%s\n", type);
563}
564static DEVICE_ATTR(type, S_IRUGO, show_dock_type, NULL);
564static DEVICE_ATTR_RO(type);
565
566static struct attribute *dock_attributes[] = {
567 &dev_attr_docked.attr,
568 &dev_attr_flags.attr,
569 &dev_attr_undock.attr,
570 &dev_attr_uid.attr,
571 &dev_attr_type.attr,
572 NULL

--- 72 unchanged lines hidden ---
565
566static struct attribute *dock_attributes[] = {
567 &dev_attr_docked.attr,
568 &dev_attr_flags.attr,
569 &dev_attr_undock.attr,
570 &dev_attr_uid.attr,
571 &dev_attr_type.attr,
572 NULL

--- 72 unchanged lines hidden ---