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; |
Rafael J. Wysocki | 5354009 | 2013-03-03 22:35:20 +0100 | [diff] [blame] | 39 | if (type && type->match && type->find_device) { |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 40 | down_write(&bus_type_sem); |
| 41 | list_add_tail(&type->list, &bus_type_list); |
| 42 | up_write(&bus_type_sem); |
Rafael J. Wysocki | 5354009 | 2013-03-03 22:35:20 +0100 | [diff] [blame] | 43 | printk(KERN_INFO PREFIX "bus type %s registered\n", type->name); |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 44 | return 0; |
| 45 | } |
| 46 | return -ENODEV; |
| 47 | } |
Jeff Garzik | 91e4d5a | 2012-07-25 14:24:13 -0400 | [diff] [blame] | 48 | EXPORT_SYMBOL_GPL(register_acpi_bus_type); |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 49 | |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 50 | int unregister_acpi_bus_type(struct acpi_bus_type *type) |
| 51 | { |
| 52 | if (acpi_disabled) |
| 53 | return 0; |
| 54 | if (type) { |
| 55 | down_write(&bus_type_sem); |
| 56 | list_del_init(&type->list); |
| 57 | up_write(&bus_type_sem); |
Rafael J. Wysocki | 5354009 | 2013-03-03 22:35:20 +0100 | [diff] [blame] | 58 | printk(KERN_INFO PREFIX "bus type %s unregistered\n", |
| 59 | type->name); |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 60 | return 0; |
| 61 | } |
| 62 | return -ENODEV; |
| 63 | } |
Jeff Garzik | 91e4d5a | 2012-07-25 14:24:13 -0400 | [diff] [blame] | 64 | EXPORT_SYMBOL_GPL(unregister_acpi_bus_type); |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 65 | |
Rafael J. Wysocki | 5354009 | 2013-03-03 22:35:20 +0100 | [diff] [blame] | 66 | static struct acpi_bus_type *acpi_get_bus_type(struct device *dev) |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 67 | { |
| 68 | struct acpi_bus_type *tmp, *ret = NULL; |
| 69 | |
| 70 | down_read(&bus_type_sem); |
| 71 | list_for_each_entry(tmp, &bus_type_list, list) { |
Rafael J. Wysocki | 5354009 | 2013-03-03 22:35:20 +0100 | [diff] [blame] | 72 | if (tmp->match(dev)) { |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 73 | ret = tmp; |
| 74 | break; |
| 75 | } |
| 76 | } |
| 77 | up_read(&bus_type_sem); |
| 78 | return ret; |
| 79 | } |
| 80 | |
Rafael J. Wysocki | 33f767d | 2013-01-10 13:13:49 +0100 | [diff] [blame] | 81 | static acpi_status do_acpi_find_child(acpi_handle handle, u32 lvl_not_used, |
| 82 | void *addr_p, void **ret_p) |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 83 | { |
Jeff Wu | c7d9ca9 | 2013-05-29 06:31:30 +0000 | [diff] [blame] | 84 | unsigned long long addr, sta; |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 85 | acpi_status status; |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 86 | |
Rafael J. Wysocki | 33f767d | 2013-01-10 13:13:49 +0100 | [diff] [blame] | 87 | status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, &addr); |
| 88 | if (ACPI_SUCCESS(status) && addr == *((u64 *)addr_p)) { |
| 89 | *ret_p = handle; |
Jeff Wu | c7d9ca9 | 2013-05-29 06:31:30 +0000 | [diff] [blame] | 90 | status = acpi_bus_get_status_handle(handle, &sta); |
| 91 | if (ACPI_SUCCESS(status) && (sta & ACPI_STA_DEVICE_ENABLED)) |
| 92 | return AE_CTRL_TERMINATE; |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 93 | } |
| 94 | return AE_OK; |
| 95 | } |
| 96 | |
Lin Ming | 439913f | 2010-01-28 10:53:19 +0800 | [diff] [blame] | 97 | acpi_handle acpi_get_child(acpi_handle parent, u64 address) |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 98 | { |
Rafael J. Wysocki | 33f767d | 2013-01-10 13:13:49 +0100 | [diff] [blame] | 99 | void *ret = NULL; |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 100 | |
| 101 | if (!parent) |
| 102 | return NULL; |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 103 | |
Rafael J. Wysocki | 33f767d | 2013-01-10 13:13:49 +0100 | [diff] [blame] | 104 | acpi_walk_namespace(ACPI_TYPE_DEVICE, parent, 1, NULL, |
| 105 | do_acpi_find_child, &address, &ret); |
| 106 | return (acpi_handle)ret; |
| 107 | } |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 108 | EXPORT_SYMBOL(acpi_get_child); |
| 109 | |
Rafael J. Wysocki | ac212b6 | 2013-05-03 00:26:22 +0200 | [diff] [blame] | 110 | int acpi_bind_one(struct device *dev, acpi_handle handle) |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 111 | { |
David Brownell | 1071695 | 2008-02-22 21:54:24 -0800 | [diff] [blame] | 112 | struct acpi_device *acpi_dev; |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 113 | acpi_status status; |
Rafael J. Wysocki | f3fd0c8 | 2012-11-21 00:21:39 +0100 | [diff] [blame] | 114 | struct acpi_device_physical_node *physical_node, *pn; |
Lan Tianyu | 1033f90 | 2012-08-17 14:44:09 +0800 | [diff] [blame] | 115 | char physical_node_name[sizeof(PHYSICAL_NODE_STRING) + 2]; |
| 116 | int retval = -EINVAL; |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 117 | |
Rafael J. Wysocki | 95f8a08 | 2012-11-21 00:21:50 +0100 | [diff] [blame] | 118 | if (ACPI_HANDLE(dev)) { |
Rafael J. Wysocki | f3fd0c8 | 2012-11-21 00:21:39 +0100 | [diff] [blame] | 119 | if (handle) { |
| 120 | dev_warn(dev, "ACPI handle is already set\n"); |
| 121 | return -EINVAL; |
| 122 | } else { |
Rafael J. Wysocki | 95f8a08 | 2012-11-21 00:21:50 +0100 | [diff] [blame] | 123 | handle = ACPI_HANDLE(dev); |
Rafael J. Wysocki | f3fd0c8 | 2012-11-21 00:21:39 +0100 | [diff] [blame] | 124 | } |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 125 | } |
Rafael J. Wysocki | f3fd0c8 | 2012-11-21 00:21:39 +0100 | [diff] [blame] | 126 | if (!handle) |
| 127 | return -EINVAL; |
Lan Tianyu | 1033f90 | 2012-08-17 14:44:09 +0800 | [diff] [blame] | 128 | |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 129 | get_device(dev); |
Lan Tianyu | 1033f90 | 2012-08-17 14:44:09 +0800 | [diff] [blame] | 130 | status = acpi_bus_get_device(handle, &acpi_dev); |
| 131 | if (ACPI_FAILURE(status)) |
| 132 | goto err; |
| 133 | |
Rafael J. Wysocki | f3fd0c8 | 2012-11-21 00:21:39 +0100 | [diff] [blame] | 134 | physical_node = kzalloc(sizeof(*physical_node), GFP_KERNEL); |
Lan Tianyu | 1033f90 | 2012-08-17 14:44:09 +0800 | [diff] [blame] | 135 | if (!physical_node) { |
| 136 | retval = -ENOMEM; |
| 137 | goto err; |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 138 | } |
Lan Tianyu | 1033f90 | 2012-08-17 14:44:09 +0800 | [diff] [blame] | 139 | |
| 140 | mutex_lock(&acpi_dev->physical_node_lock); |
Rafael J. Wysocki | f3fd0c8 | 2012-11-21 00:21:39 +0100 | [diff] [blame] | 141 | |
| 142 | /* Sanity check. */ |
| 143 | list_for_each_entry(pn, &acpi_dev->physical_node_list, node) |
| 144 | if (pn->dev == dev) { |
| 145 | dev_warn(dev, "Already associated with ACPI node\n"); |
| 146 | goto err_free; |
| 147 | } |
| 148 | |
Lan Tianyu | 1033f90 | 2012-08-17 14:44:09 +0800 | [diff] [blame] | 149 | /* allocate physical node id according to physical_node_id_bitmap */ |
| 150 | physical_node->node_id = |
| 151 | find_first_zero_bit(acpi_dev->physical_node_id_bitmap, |
| 152 | ACPI_MAX_PHYSICAL_NODE); |
| 153 | if (physical_node->node_id >= ACPI_MAX_PHYSICAL_NODE) { |
| 154 | retval = -ENOSPC; |
Rafael J. Wysocki | f3fd0c8 | 2012-11-21 00:21:39 +0100 | [diff] [blame] | 155 | goto err_free; |
Lan Tianyu | 1033f90 | 2012-08-17 14:44:09 +0800 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | set_bit(physical_node->node_id, acpi_dev->physical_node_id_bitmap); |
| 159 | physical_node->dev = dev; |
| 160 | list_add_tail(&physical_node->node, &acpi_dev->physical_node_list); |
| 161 | acpi_dev->physical_node_count++; |
Rafael J. Wysocki | f3fd0c8 | 2012-11-21 00:21:39 +0100 | [diff] [blame] | 162 | |
Lan Tianyu | 1033f90 | 2012-08-17 14:44:09 +0800 | [diff] [blame] | 163 | mutex_unlock(&acpi_dev->physical_node_lock); |
| 164 | |
Rafael J. Wysocki | 95f8a08 | 2012-11-21 00:21:50 +0100 | [diff] [blame] | 165 | if (!ACPI_HANDLE(dev)) |
| 166 | ACPI_HANDLE_SET(dev, acpi_dev->handle); |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 167 | |
Lan Tianyu | 1033f90 | 2012-08-17 14:44:09 +0800 | [diff] [blame] | 168 | if (!physical_node->node_id) |
| 169 | strcpy(physical_node_name, PHYSICAL_NODE_STRING); |
| 170 | else |
| 171 | sprintf(physical_node_name, |
| 172 | "physical_node%d", physical_node->node_id); |
| 173 | retval = sysfs_create_link(&acpi_dev->dev.kobj, &dev->kobj, |
| 174 | physical_node_name); |
| 175 | retval = sysfs_create_link(&dev->kobj, &acpi_dev->dev.kobj, |
| 176 | "firmware_node"); |
David Brownell | 1071695 | 2008-02-22 21:54:24 -0800 | [diff] [blame] | 177 | |
Lan Tianyu | 1033f90 | 2012-08-17 14:44:09 +0800 | [diff] [blame] | 178 | if (acpi_dev->wakeup.flags.valid) |
| 179 | device_set_wakeup_capable(dev, true); |
David Brownell | 1071695 | 2008-02-22 21:54:24 -0800 | [diff] [blame] | 180 | |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 181 | return 0; |
Lan Tianyu | 1033f90 | 2012-08-17 14:44:09 +0800 | [diff] [blame] | 182 | |
| 183 | err: |
Rafael J. Wysocki | 95f8a08 | 2012-11-21 00:21:50 +0100 | [diff] [blame] | 184 | ACPI_HANDLE_SET(dev, NULL); |
Lan Tianyu | 1033f90 | 2012-08-17 14:44:09 +0800 | [diff] [blame] | 185 | put_device(dev); |
| 186 | return retval; |
Rafael J. Wysocki | f3fd0c8 | 2012-11-21 00:21:39 +0100 | [diff] [blame] | 187 | |
| 188 | err_free: |
| 189 | mutex_unlock(&acpi_dev->physical_node_lock); |
| 190 | kfree(physical_node); |
| 191 | goto err; |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 192 | } |
Rafael J. Wysocki | ac212b6 | 2013-05-03 00:26:22 +0200 | [diff] [blame] | 193 | EXPORT_SYMBOL_GPL(acpi_bind_one); |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 194 | |
Rafael J. Wysocki | ac212b6 | 2013-05-03 00:26:22 +0200 | [diff] [blame] | 195 | int acpi_unbind_one(struct device *dev) |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 196 | { |
Lan Tianyu | 1033f90 | 2012-08-17 14:44:09 +0800 | [diff] [blame] | 197 | struct acpi_device_physical_node *entry; |
| 198 | struct acpi_device *acpi_dev; |
| 199 | acpi_status status; |
| 200 | struct list_head *node, *next; |
| 201 | |
Rafael J. Wysocki | 95f8a08 | 2012-11-21 00:21:50 +0100 | [diff] [blame] | 202 | if (!ACPI_HANDLE(dev)) |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 203 | return 0; |
David Brownell | 1071695 | 2008-02-22 21:54:24 -0800 | [diff] [blame] | 204 | |
Rafael J. Wysocki | 95f8a08 | 2012-11-21 00:21:50 +0100 | [diff] [blame] | 205 | status = acpi_bus_get_device(ACPI_HANDLE(dev), &acpi_dev); |
Lan Tianyu | 1033f90 | 2012-08-17 14:44:09 +0800 | [diff] [blame] | 206 | if (ACPI_FAILURE(status)) |
| 207 | goto err; |
David Brownell | 1071695 | 2008-02-22 21:54:24 -0800 | [diff] [blame] | 208 | |
Lan Tianyu | 1033f90 | 2012-08-17 14:44:09 +0800 | [diff] [blame] | 209 | mutex_lock(&acpi_dev->physical_node_lock); |
| 210 | list_for_each_safe(node, next, &acpi_dev->physical_node_list) { |
| 211 | char physical_node_name[sizeof(PHYSICAL_NODE_STRING) + 2]; |
David Brownell | 1071695 | 2008-02-22 21:54:24 -0800 | [diff] [blame] | 212 | |
Lan Tianyu | 1033f90 | 2012-08-17 14:44:09 +0800 | [diff] [blame] | 213 | entry = list_entry(node, struct acpi_device_physical_node, |
| 214 | node); |
| 215 | if (entry->dev != dev) |
| 216 | continue; |
| 217 | |
| 218 | list_del(node); |
| 219 | clear_bit(entry->node_id, acpi_dev->physical_node_id_bitmap); |
| 220 | |
| 221 | acpi_dev->physical_node_count--; |
| 222 | |
| 223 | if (!entry->node_id) |
| 224 | strcpy(physical_node_name, PHYSICAL_NODE_STRING); |
| 225 | else |
| 226 | sprintf(physical_node_name, |
| 227 | "physical_node%d", entry->node_id); |
| 228 | |
| 229 | sysfs_remove_link(&acpi_dev->dev.kobj, physical_node_name); |
| 230 | sysfs_remove_link(&dev->kobj, "firmware_node"); |
Rafael J. Wysocki | 95f8a08 | 2012-11-21 00:21:50 +0100 | [diff] [blame] | 231 | ACPI_HANDLE_SET(dev, NULL); |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 232 | /* acpi_bind_one increase refcnt by one */ |
| 233 | put_device(dev); |
Lan Tianyu | 1033f90 | 2012-08-17 14:44:09 +0800 | [diff] [blame] | 234 | kfree(entry); |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 235 | } |
Lan Tianyu | 1033f90 | 2012-08-17 14:44:09 +0800 | [diff] [blame] | 236 | mutex_unlock(&acpi_dev->physical_node_lock); |
| 237 | |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 238 | return 0; |
Lan Tianyu | 1033f90 | 2012-08-17 14:44:09 +0800 | [diff] [blame] | 239 | |
| 240 | err: |
| 241 | dev_err(dev, "Oops, 'acpi_handle' corrupt\n"); |
| 242 | return -EINVAL; |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 243 | } |
Rafael J. Wysocki | ac212b6 | 2013-05-03 00:26:22 +0200 | [diff] [blame] | 244 | EXPORT_SYMBOL_GPL(acpi_unbind_one); |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 245 | |
| 246 | static int acpi_platform_notify(struct device *dev) |
| 247 | { |
Rafael J. Wysocki | 5354009 | 2013-03-03 22:35:20 +0100 | [diff] [blame] | 248 | struct acpi_bus_type *type = acpi_get_bus_type(dev); |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 249 | acpi_handle handle; |
Rafael J. Wysocki | 11909ca | 2012-12-23 00:02:13 +0100 | [diff] [blame] | 250 | int ret; |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 251 | |
Rafael J. Wysocki | f3fd0c8 | 2012-11-21 00:21:39 +0100 | [diff] [blame] | 252 | ret = acpi_bind_one(dev, NULL); |
Rafael J. Wysocki | 9241448 | 2013-03-03 22:35:44 +0100 | [diff] [blame] | 253 | if (ret && type) { |
Rafael J. Wysocki | 11909ca | 2012-12-23 00:02:13 +0100 | [diff] [blame] | 254 | ret = type->find_device(dev, &handle); |
| 255 | if (ret) { |
| 256 | DBG("Unable to get handle for %s\n", dev_name(dev)); |
| 257 | goto out; |
| 258 | } |
| 259 | ret = acpi_bind_one(dev, handle); |
| 260 | if (ret) |
| 261 | goto out; |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 262 | } |
Rafael J. Wysocki | 11909ca | 2012-12-23 00:02:13 +0100 | [diff] [blame] | 263 | |
| 264 | if (type && type->setup) |
| 265 | type->setup(dev); |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 266 | |
Rafael J. Wysocki | f3fd0c8 | 2012-11-21 00:21:39 +0100 | [diff] [blame] | 267 | out: |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 268 | #if ACPI_GLUE_DEBUG |
| 269 | if (!ret) { |
| 270 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; |
| 271 | |
Yinghai Lu | a412a11 | 2013-01-12 14:00:06 +0100 | [diff] [blame] | 272 | acpi_get_name(ACPI_HANDLE(dev), ACPI_FULL_PATHNAME, &buffer); |
Kay Sievers | db1461a | 2009-01-25 23:40:56 +0100 | [diff] [blame] | 273 | DBG("Device %s -> %s\n", dev_name(dev), (char *)buffer.pointer); |
Len Brown | 02438d8 | 2006-06-30 03:19:10 -0400 | [diff] [blame] | 274 | kfree(buffer.pointer); |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 275 | } else |
Kay Sievers | db1461a | 2009-01-25 23:40:56 +0100 | [diff] [blame] | 276 | DBG("Device %s -> No ACPI support\n", dev_name(dev)); |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 277 | #endif |
| 278 | |
| 279 | return ret; |
| 280 | } |
| 281 | |
| 282 | static int acpi_platform_notify_remove(struct device *dev) |
| 283 | { |
Rafael J. Wysocki | 11909ca | 2012-12-23 00:02:13 +0100 | [diff] [blame] | 284 | struct acpi_bus_type *type; |
| 285 | |
Rafael J. Wysocki | 5354009 | 2013-03-03 22:35:20 +0100 | [diff] [blame] | 286 | type = acpi_get_bus_type(dev); |
Rafael J. Wysocki | 11909ca | 2012-12-23 00:02:13 +0100 | [diff] [blame] | 287 | if (type && type->cleanup) |
| 288 | type->cleanup(dev); |
| 289 | |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 290 | acpi_unbind_one(dev); |
| 291 | return 0; |
| 292 | } |
| 293 | |
Bjorn Helgaas | 0e46517 | 2009-03-24 16:50:09 -0600 | [diff] [blame] | 294 | int __init init_acpi_device_notify(void) |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 295 | { |
David Shaohua Li | 4e10d12 | 2005-03-18 18:45:35 -0500 | [diff] [blame] | 296 | if (platform_notify || platform_notify_remove) { |
| 297 | printk(KERN_ERR PREFIX "Can't use platform_notify\n"); |
| 298 | return 0; |
| 299 | } |
| 300 | platform_notify = acpi_platform_notify; |
| 301 | platform_notify_remove = acpi_platform_notify_remove; |
| 302 | return 0; |
| 303 | } |