Blame view
drivers/acpi/container.c
3.3 KB
1da177e4c Linux-2.6.12-rc2 |
1 |
/* |
68a67f6c7 ACPI / container:... |
2 |
* container.c - ACPI Generic Container Driver |
1da177e4c Linux-2.6.12-rc2 |
3 4 5 6 |
* * Copyright (C) 2004 Anil S Keshavamurthy (anil.s.keshavamurthy@intel.com) * Copyright (C) 2004 Keiichiro Tokunaga (tokunaga.keiich@jp.fujitsu.com) * Copyright (C) 2004 Motoyuki Ito (motoyuki@soft.fujitsu.com) |
1da177e4c Linux-2.6.12-rc2 |
7 |
* Copyright (C) 2004 FUJITSU LIMITED |
68a67f6c7 ACPI / container:... |
8 9 |
* Copyright (C) 2004, 2013 Intel Corp. * Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com> |
1da177e4c Linux-2.6.12-rc2 |
10 11 12 13 14 15 16 17 18 19 20 21 22 |
* * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or (at * your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * |
1da177e4c Linux-2.6.12-rc2 |
23 24 |
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ |
1da177e4c Linux-2.6.12-rc2 |
25 |
#include <linux/acpi.h> |
caa73ea15 ACPI / hotplug / ... |
26 |
#include <linux/container.h> |
1da177e4c Linux-2.6.12-rc2 |
27 |
|
2f9b06fc9 ACPI: suppress co... |
28 |
#include "internal.h" |
1da177e4c Linux-2.6.12-rc2 |
29 |
#define _COMPONENT ACPI_CONTAINER_COMPONENT |
f52fd66d2 ACPI: clean up AC... |
30 |
ACPI_MODULE_NAME("container"); |
1da177e4c Linux-2.6.12-rc2 |
31 |
|
1ba90e3a8 ACPI: autoload mo... |
32 33 34 35 36 37 |
static const struct acpi_device_id container_device_ids[] = { {"ACPI0004", 0}, {"PNP0A05", 0}, {"PNP0A06", 0}, {"", 0}, }; |
1ba90e3a8 ACPI: autoload mo... |
38 |
|
a1ec65721 ACPI / scan: alwa... |
39 |
#ifdef CONFIG_ACPI_CONTAINER |
caa73ea15 ACPI / hotplug / ... |
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
static int acpi_container_offline(struct container_dev *cdev) { struct acpi_device *adev = ACPI_COMPANION(&cdev->dev); struct acpi_device *child; /* Check all of the dependent devices' physical companions. */ list_for_each_entry(child, &adev->children, node) if (!acpi_scan_is_offline(child, false)) return -EBUSY; return 0; } static void acpi_container_release(struct device *dev) { kfree(to_container_dev(dev)); } |
46394fd01 ACPI / hotplug: M... |
57 |
static int container_device_attach(struct acpi_device *adev, |
737f1a9f8 ACPI / scan: Make... |
58 59 |
const struct acpi_device_id *not_used) { |
caa73ea15 ACPI / hotplug / ... |
60 61 62 |
struct container_dev *cdev; struct device *dev; int ret; |
1e2380cd1 ACPI / dock: Disp... |
63 64 |
if (adev->flags.is_dock_station) return 0; |
caa73ea15 ACPI / hotplug / ... |
65 66 67 68 69 70 71 72 73 74 75 |
cdev = kzalloc(sizeof(*cdev), GFP_KERNEL); if (!cdev) return -ENOMEM; cdev->offline = acpi_container_offline; dev = &cdev->dev; dev->bus = &container_subsys; dev_set_name(dev, "%s", dev_name(&adev->dev)); ACPI_COMPANION_SET(dev, adev); dev->release = acpi_container_release; ret = device_register(dev); |
0f6aa09e4 ACPI / container:... |
76 77 |
if (ret) { put_device(dev); |
caa73ea15 ACPI / hotplug / ... |
78 |
return ret; |
0f6aa09e4 ACPI / container:... |
79 |
} |
caa73ea15 ACPI / hotplug / ... |
80 |
adev->driver_data = dev; |
737f1a9f8 ACPI / scan: Make... |
81 82 |
return 1; } |
46394fd01 ACPI / hotplug: M... |
83 84 |
static void container_device_detach(struct acpi_device *adev) { |
caa73ea15 ACPI / hotplug / ... |
85 86 87 88 89 |
struct device *dev = acpi_driver_data(adev); adev->driver_data = NULL; if (dev) device_unregister(dev); |
46394fd01 ACPI / hotplug: M... |
90 |
} |
8ab17fc92 ACPI / hotplug: G... |
91 92 93 94 95 96 |
static void container_device_online(struct acpi_device *adev) { struct device *dev = acpi_driver_data(adev); kobject_uevent(&dev->kobj, KOBJ_ONLINE); } |
79917f34a ACPI / container:... |
97 |
static struct acpi_scan_handler container_handler = { |
1ba90e3a8 ACPI: autoload mo... |
98 |
.ids = container_device_ids, |
737f1a9f8 ACPI / scan: Make... |
99 |
.attach = container_device_attach, |
46394fd01 ACPI / hotplug: M... |
100 |
.detach = container_device_detach, |
68a67f6c7 ACPI / container:... |
101 102 |
.hotplug = { .enabled = true, |
caa73ea15 ACPI / hotplug / ... |
103 |
.demand_offline = true, |
8ab17fc92 ACPI / hotplug: G... |
104 |
.notify_online = container_device_online, |
68a67f6c7 ACPI / container:... |
105 |
}, |
1da177e4c Linux-2.6.12-rc2 |
106 |
}; |
737f1a9f8 ACPI / scan: Make... |
107 |
void __init acpi_container_init(void) |
1da177e4c Linux-2.6.12-rc2 |
108 |
{ |
a1ec65721 ACPI / scan: alwa... |
109 110 111 112 113 114 115 116 117 118 119 |
acpi_scan_add_handler(&container_handler); } #else static struct acpi_scan_handler container_handler = { .ids = container_device_ids, }; void __init acpi_container_init(void) { |
79917f34a ACPI / container:... |
120 |
acpi_scan_add_handler_with_hotplug(&container_handler, "container"); |
1da177e4c Linux-2.6.12-rc2 |
121 |
} |
a1ec65721 ACPI / scan: alwa... |
122 123 |
#endif /* CONFIG_ACPI_CONTAINER */ |