David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Link physical devices with ACPI devices support |
| 3 | * |
| 4 | * Copyright (c) 2005 David Shaohua Li <shaohua.li@intel.com> |
| 5 | * Copyright (c) 2005 Intel Corp. |
| 6 | * |
| 7 | * This file is released under the GPLv2. |
| 8 | */ |
Paul Gortmaker | 214f2c9 | 2011-10-26 16:22:14 -0400 | [diff] [blame] | 9 | #include <linux/export.h> |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 10 | #include <linux/init.h> |
| 11 | #include <linux/list.h> |
| 12 | #include <linux/device.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 13 | #include <linux/slab.h> |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 14 | #include <linux/rwsem.h> |
| 15 | #include <linux/acpi.h> |
| 16 | |
Len Brown | a192a95 | 2009-07-28 16:45:54 -0400 | [diff] [blame] | 17 | #include "internal.h" |
| 18 | |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 19 | #define ACPI_GLUE_DEBUG 0 |
| 20 | #if ACPI_GLUE_DEBUG |
Joe Perches | 23415eb | 2012-12-18 06:31:30 +0000 | [diff] [blame] | 21 | #define DBG(fmt, ...) \ |
| 22 | printk(KERN_DEBUG PREFIX fmt, ##__VA_ARGS__) |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 23 | #else |
Joe Perches | 23415eb | 2012-12-18 06:31:30 +0000 | [diff] [blame] | 24 | #define DBG(fmt, ...) \ |
| 25 | do { \ |
| 26 | if (0) \ |
| 27 | printk(KERN_DEBUG PREFIX fmt, ##__VA_ARGS__); \ |
| 28 | } while (0) |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 29 | #endif |
| 30 | static LIST_HEAD(bus_type_list); |
| 31 | static DECLARE_RWSEM(bus_type_sem); |
| 32 | |
Lan Tianyu | 1033f90 | 2012-08-17 14:44:09 +0800 | [diff] [blame] | 33 | #define PHYSICAL_NODE_STRING "physical_node" |
| 34 | |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 35 | int register_acpi_bus_type(struct acpi_bus_type *type) |
| 36 | { |
| 37 | if (acpi_disabled) |
| 38 | return -ENODEV; |
| 39 | if (type && type->bus && type->find_device) { |
| 40 | down_write(&bus_type_sem); |
| 41 | list_add_tail(&type->list, &bus_type_list); |
| 42 | up_write(&bus_type_sem); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 43 | printk(KERN_INFO PREFIX "bus type %s registered\n", |
| 44 | type->bus->name); |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 45 | return 0; |
| 46 | } |
| 47 | return -ENODEV; |
| 48 | } |
Jeff Garzik | 91e4d5a | 2012-07-25 14:24:13 -0400 | [diff] [blame] | 49 | EXPORT_SYMBOL_GPL(register_acpi_bus_type); |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 50 | |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 51 | int unregister_acpi_bus_type(struct acpi_bus_type *type) |
| 52 | { |
| 53 | if (acpi_disabled) |
| 54 | return 0; |
| 55 | if (type) { |
| 56 | down_write(&bus_type_sem); |
| 57 | list_del_init(&type->list); |
| 58 | up_write(&bus_type_sem); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 59 | printk(KERN_INFO PREFIX "ACPI bus type %s unregistered\n", |
| 60 | type->bus->name); |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 61 | return 0; |
| 62 | } |
| 63 | return -ENODEV; |
| 64 | } |
Jeff Garzik | 91e4d5a | 2012-07-25 14:24:13 -0400 | [diff] [blame] | 65 | EXPORT_SYMBOL_GPL(unregister_acpi_bus_type); |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 66 | |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 67 | static struct acpi_bus_type *acpi_get_bus_type(struct bus_type *type) |
| 68 | { |
| 69 | struct acpi_bus_type *tmp, *ret = NULL; |
| 70 | |
| 71 | down_read(&bus_type_sem); |
| 72 | list_for_each_entry(tmp, &bus_type_list, list) { |
| 73 | if (tmp->bus == type) { |
| 74 | ret = tmp; |
| 75 | break; |
| 76 | } |
| 77 | } |
| 78 | up_read(&bus_type_sem); |
| 79 | return ret; |
| 80 | } |
| 81 | |
| 82 | static int acpi_find_bridge_device(struct device *dev, acpi_handle * handle) |
| 83 | { |
| 84 | struct acpi_bus_type *tmp; |
| 85 | int ret = -ENODEV; |
| 86 | |
| 87 | down_read(&bus_type_sem); |
| 88 | list_for_each_entry(tmp, &bus_type_list, list) { |
| 89 | if (tmp->find_bridge && !tmp->find_bridge(dev, handle)) { |
| 90 | ret = 0; |
| 91 | break; |
| 92 | } |
| 93 | } |
| 94 | up_read(&bus_type_sem); |
| 95 | return ret; |
| 96 | } |
| 97 | |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 98 | /* Get device's handler per its address under its parent */ |
| 99 | struct acpi_find_child { |
| 100 | acpi_handle handle; |
Lin Ming | 439913f | 2010-01-28 10:53:19 +0800 | [diff] [blame] | 101 | u64 address; |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 102 | }; |
| 103 | |
| 104 | static acpi_status |
| 105 | do_acpi_find_child(acpi_handle handle, u32 lvl, void *context, void **rv) |
| 106 | { |
| 107 | acpi_status status; |
| 108 | struct acpi_device_info *info; |
Jan Engelhardt | 50dd096 | 2006-10-01 00:28:50 +0200 | [diff] [blame] | 109 | struct acpi_find_child *find = context; |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 110 | |
Bob Moore | 15b8dd5 | 2009-06-29 13:39:29 +0800 | [diff] [blame] | 111 | status = acpi_get_object_info(handle, &info); |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 112 | if (ACPI_SUCCESS(status)) { |
Zhao Yakui | 108029f | 2010-07-13 03:36:08 +0000 | [diff] [blame] | 113 | if ((info->address == find->address) |
| 114 | && (info->valid & ACPI_VALID_ADR)) |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 115 | find->handle = handle; |
Bob Moore | 15b8dd5 | 2009-06-29 13:39:29 +0800 | [diff] [blame] | 116 | kfree(info); |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 117 | } |
| 118 | return AE_OK; |
| 119 | } |
| 120 | |
Lin Ming | 439913f | 2010-01-28 10:53:19 +0800 | [diff] [blame] | 121 | acpi_handle acpi_get_child(acpi_handle parent, u64 address) |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 122 | { |
| 123 | struct acpi_find_child find = { NULL, address }; |
| 124 | |
| 125 | if (!parent) |
| 126 | return NULL; |
| 127 | acpi_walk_namespace(ACPI_TYPE_DEVICE, parent, |
Lin Ming | 2263576 | 2009-11-13 10:06:08 +0800 | [diff] [blame] | 128 | 1, do_acpi_find_child, NULL, &find, NULL); |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 129 | return find.handle; |
| 130 | } |
| 131 | |
| 132 | EXPORT_SYMBOL(acpi_get_child); |
| 133 | |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 134 | static int acpi_bind_one(struct device *dev, acpi_handle handle) |
| 135 | { |
David Brownell | 1071695 | 2008-02-22 21:54:24 -0800 | [diff] [blame] | 136 | struct acpi_device *acpi_dev; |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 137 | acpi_status status; |
Rafael J. Wysocki | f3fd0c8 | 2012-11-21 00:21:39 +0100 | [diff] [blame] | 138 | struct acpi_device_physical_node *physical_node, *pn; |
Lan Tianyu | 1033f90 | 2012-08-17 14:44:09 +0800 | [diff] [blame] | 139 | char physical_node_name[sizeof(PHYSICAL_NODE_STRING) + 2]; |
| 140 | int retval = -EINVAL; |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 141 | |
Rafael J. Wysocki | 95f8a08 | 2012-11-21 00:21:50 +0100 | [diff] [blame] | 142 | if (ACPI_HANDLE(dev)) { |
Rafael J. Wysocki | f3fd0c8 | 2012-11-21 00:21:39 +0100 | [diff] [blame] | 143 | if (handle) { |
| 144 | dev_warn(dev, "ACPI handle is already set\n"); |
| 145 | return -EINVAL; |
| 146 | } else { |
Rafael J. Wysocki | 95f8a08 | 2012-11-21 00:21:50 +0100 | [diff] [blame] | 147 | handle = ACPI_HANDLE(dev); |
Rafael J. Wysocki | f3fd0c8 | 2012-11-21 00:21:39 +0100 | [diff] [blame] | 148 | } |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 149 | } |
Rafael J. Wysocki | f3fd0c8 | 2012-11-21 00:21:39 +0100 | [diff] [blame] | 150 | if (!handle) |
| 151 | return -EINVAL; |
Lan Tianyu | 1033f90 | 2012-08-17 14:44:09 +0800 | [diff] [blame] | 152 | |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 153 | get_device(dev); |
Lan Tianyu | 1033f90 | 2012-08-17 14:44:09 +0800 | [diff] [blame] | 154 | status = acpi_bus_get_device(handle, &acpi_dev); |
| 155 | if (ACPI_FAILURE(status)) |
| 156 | goto err; |
| 157 | |
Rafael J. Wysocki | f3fd0c8 | 2012-11-21 00:21:39 +0100 | [diff] [blame] | 158 | physical_node = kzalloc(sizeof(*physical_node), GFP_KERNEL); |
Lan Tianyu | 1033f90 | 2012-08-17 14:44:09 +0800 | [diff] [blame] | 159 | if (!physical_node) { |
| 160 | retval = -ENOMEM; |
| 161 | goto err; |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 162 | } |
Lan Tianyu | 1033f90 | 2012-08-17 14:44:09 +0800 | [diff] [blame] | 163 | |
| 164 | mutex_lock(&acpi_dev->physical_node_lock); |
Rafael J. Wysocki | f3fd0c8 | 2012-11-21 00:21:39 +0100 | [diff] [blame] | 165 | |
| 166 | /* Sanity check. */ |
| 167 | list_for_each_entry(pn, &acpi_dev->physical_node_list, node) |
| 168 | if (pn->dev == dev) { |
| 169 | dev_warn(dev, "Already associated with ACPI node\n"); |
| 170 | goto err_free; |
| 171 | } |
| 172 | |
Lan Tianyu | 1033f90 | 2012-08-17 14:44:09 +0800 | [diff] [blame] | 173 | /* allocate physical node id according to physical_node_id_bitmap */ |
| 174 | physical_node->node_id = |
| 175 | find_first_zero_bit(acpi_dev->physical_node_id_bitmap, |
| 176 | ACPI_MAX_PHYSICAL_NODE); |
| 177 | if (physical_node->node_id >= ACPI_MAX_PHYSICAL_NODE) { |
| 178 | retval = -ENOSPC; |
Rafael J. Wysocki | f3fd0c8 | 2012-11-21 00:21:39 +0100 | [diff] [blame] | 179 | goto err_free; |
Lan Tianyu | 1033f90 | 2012-08-17 14:44:09 +0800 | [diff] [blame] | 180 | } |
| 181 | |
| 182 | set_bit(physical_node->node_id, acpi_dev->physical_node_id_bitmap); |
| 183 | physical_node->dev = dev; |
| 184 | list_add_tail(&physical_node->node, &acpi_dev->physical_node_list); |
| 185 | acpi_dev->physical_node_count++; |
Rafael J. Wysocki | f3fd0c8 | 2012-11-21 00:21:39 +0100 | [diff] [blame] | 186 | |
Lan Tianyu | 1033f90 | 2012-08-17 14:44:09 +0800 | [diff] [blame] | 187 | mutex_unlock(&acpi_dev->physical_node_lock); |
| 188 | |
Rafael J. Wysocki | 95f8a08 | 2012-11-21 00:21:50 +0100 | [diff] [blame] | 189 | if (!ACPI_HANDLE(dev)) |
| 190 | ACPI_HANDLE_SET(dev, acpi_dev->handle); |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 191 | |
Lan Tianyu | 1033f90 | 2012-08-17 14:44:09 +0800 | [diff] [blame] | 192 | if (!physical_node->node_id) |
| 193 | strcpy(physical_node_name, PHYSICAL_NODE_STRING); |
| 194 | else |
| 195 | sprintf(physical_node_name, |
| 196 | "physical_node%d", physical_node->node_id); |
| 197 | retval = sysfs_create_link(&acpi_dev->dev.kobj, &dev->kobj, |
| 198 | physical_node_name); |
| 199 | retval = sysfs_create_link(&dev->kobj, &acpi_dev->dev.kobj, |
| 200 | "firmware_node"); |
David Brownell | 1071695 | 2008-02-22 21:54:24 -0800 | [diff] [blame] | 201 | |
Lan Tianyu | 1033f90 | 2012-08-17 14:44:09 +0800 | [diff] [blame] | 202 | if (acpi_dev->wakeup.flags.valid) |
| 203 | device_set_wakeup_capable(dev, true); |
David Brownell | 1071695 | 2008-02-22 21:54:24 -0800 | [diff] [blame] | 204 | |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 205 | return 0; |
Lan Tianyu | 1033f90 | 2012-08-17 14:44:09 +0800 | [diff] [blame] | 206 | |
| 207 | err: |
Rafael J. Wysocki | 95f8a08 | 2012-11-21 00:21:50 +0100 | [diff] [blame] | 208 | ACPI_HANDLE_SET(dev, NULL); |
Lan Tianyu | 1033f90 | 2012-08-17 14:44:09 +0800 | [diff] [blame] | 209 | put_device(dev); |
| 210 | return retval; |
Rafael J. Wysocki | f3fd0c8 | 2012-11-21 00:21:39 +0100 | [diff] [blame] | 211 | |
| 212 | err_free: |
| 213 | mutex_unlock(&acpi_dev->physical_node_lock); |
| 214 | kfree(physical_node); |
| 215 | goto err; |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 216 | } |
| 217 | |
| 218 | static int acpi_unbind_one(struct device *dev) |
| 219 | { |
Lan Tianyu | 1033f90 | 2012-08-17 14:44:09 +0800 | [diff] [blame] | 220 | struct acpi_device_physical_node *entry; |
| 221 | struct acpi_device *acpi_dev; |
| 222 | acpi_status status; |
| 223 | struct list_head *node, *next; |
| 224 | |
Rafael J. Wysocki | 95f8a08 | 2012-11-21 00:21:50 +0100 | [diff] [blame] | 225 | if (!ACPI_HANDLE(dev)) |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 226 | return 0; |
David Brownell | 1071695 | 2008-02-22 21:54:24 -0800 | [diff] [blame] | 227 | |
Rafael J. Wysocki | 95f8a08 | 2012-11-21 00:21:50 +0100 | [diff] [blame] | 228 | status = acpi_bus_get_device(ACPI_HANDLE(dev), &acpi_dev); |
Lan Tianyu | 1033f90 | 2012-08-17 14:44:09 +0800 | [diff] [blame] | 229 | if (ACPI_FAILURE(status)) |
| 230 | goto err; |
David Brownell | 1071695 | 2008-02-22 21:54:24 -0800 | [diff] [blame] | 231 | |
Lan Tianyu | 1033f90 | 2012-08-17 14:44:09 +0800 | [diff] [blame] | 232 | mutex_lock(&acpi_dev->physical_node_lock); |
| 233 | list_for_each_safe(node, next, &acpi_dev->physical_node_list) { |
| 234 | char physical_node_name[sizeof(PHYSICAL_NODE_STRING) + 2]; |
David Brownell | 1071695 | 2008-02-22 21:54:24 -0800 | [diff] [blame] | 235 | |
Lan Tianyu | 1033f90 | 2012-08-17 14:44:09 +0800 | [diff] [blame] | 236 | entry = list_entry(node, struct acpi_device_physical_node, |
| 237 | node); |
| 238 | if (entry->dev != dev) |
| 239 | continue; |
| 240 | |
| 241 | list_del(node); |
| 242 | clear_bit(entry->node_id, acpi_dev->physical_node_id_bitmap); |
| 243 | |
| 244 | acpi_dev->physical_node_count--; |
| 245 | |
| 246 | if (!entry->node_id) |
| 247 | strcpy(physical_node_name, PHYSICAL_NODE_STRING); |
| 248 | else |
| 249 | sprintf(physical_node_name, |
| 250 | "physical_node%d", entry->node_id); |
| 251 | |
| 252 | sysfs_remove_link(&acpi_dev->dev.kobj, physical_node_name); |
| 253 | sysfs_remove_link(&dev->kobj, "firmware_node"); |
Rafael J. Wysocki | 95f8a08 | 2012-11-21 00:21:50 +0100 | [diff] [blame] | 254 | ACPI_HANDLE_SET(dev, NULL); |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 255 | /* acpi_bind_one increase refcnt by one */ |
| 256 | put_device(dev); |
Lan Tianyu | 1033f90 | 2012-08-17 14:44:09 +0800 | [diff] [blame] | 257 | kfree(entry); |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 258 | } |
Lan Tianyu | 1033f90 | 2012-08-17 14:44:09 +0800 | [diff] [blame] | 259 | mutex_unlock(&acpi_dev->physical_node_lock); |
| 260 | |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 261 | return 0; |
Lan Tianyu | 1033f90 | 2012-08-17 14:44:09 +0800 | [diff] [blame] | 262 | |
| 263 | err: |
| 264 | dev_err(dev, "Oops, 'acpi_handle' corrupt\n"); |
| 265 | return -EINVAL; |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 266 | } |
| 267 | |
| 268 | static int acpi_platform_notify(struct device *dev) |
| 269 | { |
| 270 | struct acpi_bus_type *type; |
| 271 | acpi_handle handle; |
| 272 | int ret = -EINVAL; |
| 273 | |
Rafael J. Wysocki | f3fd0c8 | 2012-11-21 00:21:39 +0100 | [diff] [blame] | 274 | ret = acpi_bind_one(dev, NULL); |
| 275 | if (!ret) |
| 276 | goto out; |
| 277 | |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 278 | if (!dev->bus || !dev->parent) { |
| 279 | /* bridge devices genernally haven't bus or parent */ |
| 280 | ret = acpi_find_bridge_device(dev, &handle); |
| 281 | goto end; |
| 282 | } |
| 283 | type = acpi_get_bus_type(dev->bus); |
| 284 | if (!type) { |
Kay Sievers | db1461a | 2009-01-25 23:40:56 +0100 | [diff] [blame] | 285 | DBG("No ACPI bus support for %s\n", dev_name(dev)); |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 286 | ret = -EINVAL; |
| 287 | goto end; |
| 288 | } |
| 289 | if ((ret = type->find_device(dev, &handle)) != 0) |
Kay Sievers | db1461a | 2009-01-25 23:40:56 +0100 | [diff] [blame] | 290 | DBG("Can't get handler for %s\n", dev_name(dev)); |
Rafael J. Wysocki | f3fd0c8 | 2012-11-21 00:21:39 +0100 | [diff] [blame] | 291 | end: |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 292 | if (!ret) |
| 293 | acpi_bind_one(dev, handle); |
| 294 | |
Rafael J. Wysocki | f3fd0c8 | 2012-11-21 00:21:39 +0100 | [diff] [blame] | 295 | out: |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 296 | #if ACPI_GLUE_DEBUG |
| 297 | if (!ret) { |
| 298 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; |
| 299 | |
Mika Westerberg | 06f64c8 | 2012-10-31 22:44:33 +0100 | [diff] [blame] | 300 | acpi_get_name(dev->acpi_handle, ACPI_FULL_PATHNAME, &buffer); |
Kay Sievers | db1461a | 2009-01-25 23:40:56 +0100 | [diff] [blame] | 301 | DBG("Device %s -> %s\n", dev_name(dev), (char *)buffer.pointer); |
Len Brown | 02438d8 | 2006-06-30 03:19:10 -0400 | [diff] [blame] | 302 | kfree(buffer.pointer); |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 303 | } else |
Kay Sievers | db1461a | 2009-01-25 23:40:56 +0100 | [diff] [blame] | 304 | DBG("Device %s -> No ACPI support\n", dev_name(dev)); |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 305 | #endif |
| 306 | |
| 307 | return ret; |
| 308 | } |
| 309 | |
| 310 | static int acpi_platform_notify_remove(struct device *dev) |
| 311 | { |
| 312 | acpi_unbind_one(dev); |
| 313 | return 0; |
| 314 | } |
| 315 | |
Bjorn Helgaas | 0e46517d | 2009-03-24 16:50:09 -0600 | [diff] [blame] | 316 | int __init init_acpi_device_notify(void) |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 317 | { |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 318 | if (platform_notify || platform_notify_remove) { |
| 319 | printk(KERN_ERR PREFIX "Can't use platform_notify\n"); |
| 320 | return 0; |
| 321 | } |
| 322 | platform_notify = acpi_platform_notify; |
| 323 | platform_notify_remove = acpi_platform_notify_remove; |
| 324 | return 0; |
| 325 | } |