aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2009-09-26 01:08:43 -0400
committerLen Brown <len.brown@intel.com>2009-09-26 01:08:43 -0400
commitea2610515755614da76677185349c66880c1e84d (patch)
tree277e0547ed3435906d19df13a8821c3c1bcc2d0c
parent6d7f18f6ea3a13af95bdf507fc54d42b165e1712 (diff)
parent57f3674f5e9c7b1102ae62fc2920d2fa09fce1ea (diff)
Merge branch 'bjorn-HID' into release
-rw-r--r--drivers/acpi/bus.c49
-rw-r--r--drivers/acpi/scan.c705
-rw-r--r--drivers/pci/hotplug/acpiphp_ibm.c1
-rw-r--r--drivers/pnp/pnpacpi/core.c21
-rw-r--r--include/acpi/acpi_bus.h22
5 files changed, 315 insertions, 483 deletions
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 135fbfe1825c..741191524353 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -94,36 +94,33 @@ int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device)
94 94
95EXPORT_SYMBOL(acpi_bus_get_device); 95EXPORT_SYMBOL(acpi_bus_get_device);
96 96
97int acpi_bus_get_status(struct acpi_device *device) 97acpi_status acpi_bus_get_status_handle(acpi_handle handle,
98 unsigned long long *sta)
98{ 99{
99 acpi_status status = AE_OK; 100 acpi_status status;
100 unsigned long long sta = 0;
101
102 101
103 if (!device) 102 status = acpi_evaluate_integer(handle, "_STA", NULL, sta);
104 return -EINVAL; 103 if (ACPI_SUCCESS(status))
104 return AE_OK;
105 105
106 /* 106 if (status == AE_NOT_FOUND) {
107 * Evaluate _STA if present. 107 *sta = ACPI_STA_DEVICE_PRESENT | ACPI_STA_DEVICE_ENABLED |
108 */ 108 ACPI_STA_DEVICE_UI | ACPI_STA_DEVICE_FUNCTIONING;
109 if (device->flags.dynamic_status) { 109 return AE_OK;
110 status =
111 acpi_evaluate_integer(device->handle, "_STA", NULL, &sta);
112 if (ACPI_FAILURE(status))
113 return -ENODEV;
114 STRUCT_TO_INT(device->status) = (int)sta;
115 } 110 }
111 return status;
112}
116 113
117 /* 114int acpi_bus_get_status(struct acpi_device *device)
118 * According to ACPI spec some device can be present and functional 115{
119 * even if the parent is not present but functional. 116 acpi_status status;
120 * In such conditions the child device should not inherit the status 117 unsigned long long sta;
121 * from the parent. 118
122 */ 119 status = acpi_bus_get_status_handle(device->handle, &sta);
123 else 120 if (ACPI_FAILURE(status))
124 STRUCT_TO_INT(device->status) = 121 return -ENODEV;
125 ACPI_STA_DEVICE_PRESENT | ACPI_STA_DEVICE_ENABLED | 122
126 ACPI_STA_DEVICE_UI | ACPI_STA_DEVICE_FUNCTIONING; 123 STRUCT_TO_INT(device->status) = (int) sta;
127 124
128 if (device->status.functional && !device->status.present) { 125 if (device->status.functional && !device->status.present) {
129 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]: " 126 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]: "
@@ -135,10 +132,8 @@ int acpi_bus_get_status(struct acpi_device *device)
135 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]\n", 132 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]\n",
136 device->pnp.bus_id, 133 device->pnp.bus_id,
137 (u32) STRUCT_TO_INT(device->status))); 134 (u32) STRUCT_TO_INT(device->status)));
138
139 return 0; 135 return 0;
140} 136}
141
142EXPORT_SYMBOL(acpi_bus_get_status); 137EXPORT_SYMBOL(acpi_bus_get_status);
143 138
144void acpi_bus_private_data_handler(acpi_handle handle, 139void acpi_bus_private_data_handler(acpi_handle handle,
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 408ebde18986..468921bed22f 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -22,6 +22,8 @@ extern struct acpi_device *acpi_root;
22#define ACPI_BUS_HID "LNXSYBUS" 22#define ACPI_BUS_HID "LNXSYBUS"
23#define ACPI_BUS_DEVICE_NAME "System Bus" 23#define ACPI_BUS_DEVICE_NAME "System Bus"
24 24
25#define ACPI_IS_ROOT_DEVICE(device) (!(device)->parent)
26
25static LIST_HEAD(acpi_device_list); 27static LIST_HEAD(acpi_device_list);
26static LIST_HEAD(acpi_bus_id_list); 28static LIST_HEAD(acpi_bus_id_list);
27DEFINE_MUTEX(acpi_device_lock); 29DEFINE_MUTEX(acpi_device_lock);
@@ -43,40 +45,19 @@ static int create_modalias(struct acpi_device *acpi_dev, char *modalias,
43{ 45{
44 int len; 46 int len;
45 int count; 47 int count;
46 48 struct acpi_hardware_id *id;
47 if (!acpi_dev->flags.hardware_id && !acpi_dev->flags.compatible_ids)
48 return -ENODEV;
49 49
50 len = snprintf(modalias, size, "acpi:"); 50 len = snprintf(modalias, size, "acpi:");
51 size -= len; 51 size -= len;
52 52
53 if (acpi_dev->flags.hardware_id) { 53 list_for_each_entry(id, &acpi_dev->pnp.ids, list) {
54 count = snprintf(&modalias[len], size, "%s:", 54 count = snprintf(&modalias[len], size, "%s:", id->id);
55 acpi_dev->pnp.hardware_id);
56 if (count < 0 || count >= size) 55 if (count < 0 || count >= size)
57 return -EINVAL; 56 return -EINVAL;
58 len += count; 57 len += count;
59 size -= count; 58 size -= count;
60 } 59 }
61 60
62 if (acpi_dev->flags.compatible_ids) {
63 struct acpica_device_id_list *cid_list;
64 int i;
65
66 cid_list = acpi_dev->pnp.cid_list;
67 for (i = 0; i < cid_list->count; i++) {
68 count = snprintf(&modalias[len], size, "%s:",
69 cid_list->ids[i].string);
70 if (count < 0 || count >= size) {
71 printk(KERN_ERR PREFIX "%s cid[%i] exceeds event buffer size",
72 acpi_dev->pnp.device_name, i);
73 break;
74 }
75 len += count;
76 size -= count;
77 }
78 }
79
80 modalias[len] = '\0'; 61 modalias[len] = '\0';
81 return len; 62 return len;
82} 63}
@@ -183,7 +164,7 @@ static ssize_t
183acpi_device_hid_show(struct device *dev, struct device_attribute *attr, char *buf) { 164acpi_device_hid_show(struct device *dev, struct device_attribute *attr, char *buf) {
184 struct acpi_device *acpi_dev = to_acpi_device(dev); 165 struct acpi_device *acpi_dev = to_acpi_device(dev);
185 166
186 return sprintf(buf, "%s\n", acpi_dev->pnp.hardware_id); 167 return sprintf(buf, "%s\n", acpi_device_hid(acpi_dev));
187} 168}
188static DEVICE_ATTR(hid, 0444, acpi_device_hid_show, NULL); 169static DEVICE_ATTR(hid, 0444, acpi_device_hid_show, NULL);
189 170
@@ -219,17 +200,13 @@ static int acpi_device_setup_files(struct acpi_device *dev)
219 goto end; 200 goto end;
220 } 201 }
221 202
222 if (dev->flags.hardware_id) { 203 result = device_create_file(&dev->dev, &dev_attr_hid);
223 result = device_create_file(&dev->dev, &dev_attr_hid); 204 if (result)
224 if (result) 205 goto end;
225 goto end;
226 }
227 206
228 if (dev->flags.hardware_id || dev->flags.compatible_ids) { 207 result = device_create_file(&dev->dev, &dev_attr_modalias);
229 result = device_create_file(&dev->dev, &dev_attr_modalias); 208 if (result)
230 if (result) 209 goto end;
231 goto end;
232 }
233 210
234 /* 211 /*
235 * If device has _EJ0, 'eject' file is created that is used to trigger 212 * If device has _EJ0, 'eject' file is created that is used to trigger
@@ -255,11 +232,8 @@ static void acpi_device_remove_files(struct acpi_device *dev)
255 if (ACPI_SUCCESS(status)) 232 if (ACPI_SUCCESS(status))
256 device_remove_file(&dev->dev, &dev_attr_eject); 233 device_remove_file(&dev->dev, &dev_attr_eject);
257 234
258 if (dev->flags.hardware_id || dev->flags.compatible_ids) 235 device_remove_file(&dev->dev, &dev_attr_modalias);
259 device_remove_file(&dev->dev, &dev_attr_modalias); 236 device_remove_file(&dev->dev, &dev_attr_hid);
260
261 if (dev->flags.hardware_id)
262 device_remove_file(&dev->dev, &dev_attr_hid);
263 if (dev->handle) 237 if (dev->handle)
264 device_remove_file(&dev->dev, &dev_attr_path); 238 device_remove_file(&dev->dev, &dev_attr_path);
265} 239}
@@ -271,6 +245,7 @@ int acpi_match_device_ids(struct acpi_device *device,
271 const struct acpi_device_id *ids) 245 const struct acpi_device_id *ids)
272{ 246{
273 const struct acpi_device_id *id; 247 const struct acpi_device_id *id;
248 struct acpi_hardware_id *hwid;
274 249
275 /* 250 /*
276 * If the device is not present, it is unnecessary to load device 251 * If the device is not present, it is unnecessary to load device
@@ -279,40 +254,30 @@ int acpi_match_device_ids(struct acpi_device *device,
279 if (!device->status.present) 254 if (!device->status.present)
280 return -ENODEV; 255 return -ENODEV;
281 256
282 if (device->flags.hardware_id) { 257 for (id = ids; id->id[0]; id++)
283 for (id = ids; id->id[0]; id++) { 258 list_for_each_entry(hwid, &device->pnp.ids, list)
284 if (!strcmp((char*)id->id, device->pnp.hardware_id)) 259 if (!strcmp((char *) id->id, hwid->id))
285 return 0; 260 return 0;
286 }
287 }
288
289 if (device->flags.compatible_ids) {
290 struct acpica_device_id_list *cid_list = device->pnp.cid_list;
291 int i;
292
293 for (id = ids; id->id[0]; id++) {
294 /* compare multiple _CID entries against driver ids */
295 for (i = 0; i < cid_list->count; i++) {
296 if (!strcmp((char*)id->id,
297 cid_list->ids[i].string))
298 return 0;
299 }
300 }
301 }
302 261
303 return -ENOENT; 262 return -ENOENT;
304} 263}
305EXPORT_SYMBOL(acpi_match_device_ids); 264EXPORT_SYMBOL(acpi_match_device_ids);
306 265
266static void acpi_free_ids(struct acpi_device *device)
267{
268 struct acpi_hardware_id *id, *tmp;
269
270 list_for_each_entry_safe(id, tmp, &device->pnp.ids, list) {
271 kfree(id->id);
272 kfree(id);
273 }
274}
275
307static void acpi_device_release(struct device *dev) 276static void acpi_device_release(struct device *dev)
308{ 277{
309 struct acpi_device *acpi_dev = to_acpi_device(dev); 278 struct acpi_device *acpi_dev = to_acpi_device(dev);
310 279
311 kfree(acpi_dev->pnp.cid_list); 280 acpi_free_ids(acpi_dev);
312 if (acpi_dev->flags.hardware_id)
313 kfree(acpi_dev->pnp.hardware_id);
314 if (acpi_dev->flags.unique_id)
315 kfree(acpi_dev->pnp.unique_id);
316 kfree(acpi_dev); 281 kfree(acpi_dev);
317} 282}
318 283
@@ -378,15 +343,13 @@ static acpi_status acpi_device_notify_fixed(void *data)
378static int acpi_device_install_notify_handler(struct acpi_device *device) 343static int acpi_device_install_notify_handler(struct acpi_device *device)
379{ 344{
380 acpi_status status; 345 acpi_status status;
381 char *hid;
382 346
383 hid = acpi_device_hid(device); 347 if (device->device_type == ACPI_BUS_TYPE_POWER_BUTTON)
384 if (!strcmp(hid, ACPI_BUTTON_HID_POWERF))
385 status = 348 status =
386 acpi_install_fixed_event_handler(ACPI_EVENT_POWER_BUTTON, 349 acpi_install_fixed_event_handler(ACPI_EVENT_POWER_BUTTON,
387 acpi_device_notify_fixed, 350 acpi_device_notify_fixed,
388 device); 351 device);
389 else if (!strcmp(hid, ACPI_BUTTON_HID_SLEEPF)) 352 else if (device->device_type == ACPI_BUS_TYPE_SLEEP_BUTTON)
390 status = 353 status =
391 acpi_install_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON, 354 acpi_install_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON,
392 acpi_device_notify_fixed, 355 acpi_device_notify_fixed,
@@ -404,10 +367,10 @@ static int acpi_device_install_notify_handler(struct acpi_device *device)
404 367
405static void acpi_device_remove_notify_handler(struct acpi_device *device) 368static void acpi_device_remove_notify_handler(struct acpi_device *device)
406{ 369{
407 if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_POWERF)) 370 if (device->device_type == ACPI_BUS_TYPE_POWER_BUTTON)
408 acpi_remove_fixed_event_handler(ACPI_EVENT_POWER_BUTTON, 371 acpi_remove_fixed_event_handler(ACPI_EVENT_POWER_BUTTON,
409 acpi_device_notify_fixed); 372 acpi_device_notify_fixed);
410 else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_SLEEPF)) 373 else if (device->device_type == ACPI_BUS_TYPE_SLEEP_BUTTON)
411 acpi_remove_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON, 374 acpi_remove_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON,
412 acpi_device_notify_fixed); 375 acpi_device_notify_fixed);
413 else 376 else
@@ -474,12 +437,12 @@ struct bus_type acpi_bus_type = {
474 .uevent = acpi_device_uevent, 437 .uevent = acpi_device_uevent,
475}; 438};
476 439
477static int acpi_device_register(struct acpi_device *device, 440static int acpi_device_register(struct acpi_device *device)
478 struct acpi_device *parent)
479{ 441{
480 int result; 442 int result;
481 struct acpi_device_bus_id *acpi_device_bus_id, *new_bus_id; 443 struct acpi_device_bus_id *acpi_device_bus_id, *new_bus_id;
482 int found = 0; 444 int found = 0;
445
483 /* 446 /*
484 * Linkage 447 * Linkage
485 * ------- 448 * -------
@@ -501,8 +464,9 @@ static int acpi_device_register(struct acpi_device *device,
501 * If failed, create one and link it into acpi_bus_id_list 464 * If failed, create one and link it into acpi_bus_id_list
502 */ 465 */
503 list_for_each_entry(acpi_device_bus_id, &acpi_bus_id_list, node) { 466 list_for_each_entry(acpi_device_bus_id, &acpi_bus_id_list, node) {
504 if(!strcmp(acpi_device_bus_id->bus_id, device->flags.hardware_id? device->pnp.hardware_id : "device")) { 467 if (!strcmp(acpi_device_bus_id->bus_id,
505 acpi_device_bus_id->instance_no ++; 468 acpi_device_hid(device))) {
469 acpi_device_bus_id->instance_no++;
506 found = 1; 470 found = 1;
507 kfree(new_bus_id); 471 kfree(new_bus_id);
508 break; 472 break;
@@ -510,7 +474,7 @@ static int acpi_device_register(struct acpi_device *device,
510 } 474 }
511 if (!found) { 475 if (!found) {
512 acpi_device_bus_id = new_bus_id; 476 acpi_device_bus_id = new_bus_id;
513 strcpy(acpi_device_bus_id->bus_id, device->flags.hardware_id ? device->pnp.hardware_id : "device"); 477 strcpy(acpi_device_bus_id->bus_id, acpi_device_hid(device));
514 acpi_device_bus_id->instance_no = 0; 478 acpi_device_bus_id->instance_no = 0;
515 list_add_tail(&acpi_device_bus_id->node, &acpi_bus_id_list); 479 list_add_tail(&acpi_device_bus_id->node, &acpi_bus_id_list);
516 } 480 }
@@ -524,7 +488,7 @@ static int acpi_device_register(struct acpi_device *device,
524 mutex_unlock(&acpi_device_lock); 488 mutex_unlock(&acpi_device_lock);
525 489
526 if (device->parent) 490 if (device->parent)
527 device->dev.parent = &parent->dev; 491 device->dev.parent = &device->parent->dev;
528 device->dev.bus = &acpi_bus_type; 492 device->dev.bus = &acpi_bus_type;
529 device->dev.release = &acpi_device_release; 493 device->dev.release = &acpi_device_release;
530 result = device_register(&device->dev); 494 result = device_register(&device->dev);
@@ -664,6 +628,33 @@ EXPORT_SYMBOL(acpi_bus_unregister_driver);
664/* -------------------------------------------------------------------------- 628/* --------------------------------------------------------------------------
665 Device Enumeration 629 Device Enumeration
666 -------------------------------------------------------------------------- */ 630 -------------------------------------------------------------------------- */
631static struct acpi_device *acpi_bus_get_parent(acpi_handle handle)
632{
633 acpi_status status;
634 int ret;
635 struct acpi_device *device;
636
637 /*
638 * Fixed hardware devices do not appear in the namespace and do not
639 * have handles, but we fabricate acpi_devices for them, so we have
640 * to deal with them specially.
641 */
642 if (handle == NULL)
643 return acpi_root;
644
645 do {
646 status = acpi_get_parent(handle, &handle);
647 if (status == AE_NULL_ENTRY)
648 return NULL;
649 if (ACPI_FAILURE(status))
650 return acpi_root;
651
652 ret = acpi_bus_get_device(handle, &device);
653 if (ret == 0)
654 return device;
655 } while (1);
656}
657
667acpi_status 658acpi_status
668acpi_bus_get_ejd(acpi_handle handle, acpi_handle *ejd) 659acpi_bus_get_ejd(acpi_handle handle, acpi_handle *ejd)
669{ 660{
@@ -876,11 +867,6 @@ static int acpi_bus_get_flags(struct acpi_device *device)
876 if (ACPI_SUCCESS(status)) 867 if (ACPI_SUCCESS(status))
877 device->flags.dynamic_status = 1; 868 device->flags.dynamic_status = 1;
878 869
879 /* Presence of _CID indicates 'compatible_ids' */
880 status = acpi_get_handle(device->handle, "_CID", &temp);
881 if (ACPI_SUCCESS(status))
882 device->flags.compatible_ids = 1;
883
884 /* Presence of _RMV indicates 'removable' */ 870 /* Presence of _RMV indicates 'removable' */
885 status = acpi_get_handle(device->handle, "_RMV", &temp); 871 status = acpi_get_handle(device->handle, "_RMV", &temp);
886 if (ACPI_SUCCESS(status)) 872 if (ACPI_SUCCESS(status))
@@ -918,8 +904,7 @@ static int acpi_bus_get_flags(struct acpi_device *device)
918 return 0; 904 return 0;
919} 905}
920 906
921static void acpi_device_get_busid(struct acpi_device *device, 907static void acpi_device_get_busid(struct acpi_device *device)
922 acpi_handle handle, int type)
923{ 908{
924 char bus_id[5] = { '?', 0 }; 909 char bus_id[5] = { '?', 0 };
925 struct acpi_buffer buffer = { sizeof(bus_id), bus_id }; 910 struct acpi_buffer buffer = { sizeof(bus_id), bus_id };
@@ -931,10 +916,12 @@ static void acpi_device_get_busid(struct acpi_device *device,
931 * The device's Bus ID is simply the object name. 916 * The device's Bus ID is simply the object name.
932 * TBD: Shouldn't this value be unique (within the ACPI namespace)? 917 * TBD: Shouldn't this value be unique (within the ACPI namespace)?
933 */ 918 */
934 switch (type) { 919 if (ACPI_IS_ROOT_DEVICE(device)) {
935 case ACPI_BUS_TYPE_SYSTEM:
936 strcpy(device->pnp.bus_id, "ACPI"); 920 strcpy(device->pnp.bus_id, "ACPI");
937 break; 921 return;
922 }
923
924 switch (device->device_type) {
938 case ACPI_BUS_TYPE_POWER_BUTTON: 925 case ACPI_BUS_TYPE_POWER_BUTTON:
939 strcpy(device->pnp.bus_id, "PWRF"); 926 strcpy(device->pnp.bus_id, "PWRF");
940 break; 927 break;
@@ -942,7 +929,7 @@ static void acpi_device_get_busid(struct acpi_device *device,
942 strcpy(device->pnp.bus_id, "SLPF"); 929 strcpy(device->pnp.bus_id, "SLPF");
943 break; 930 break;
944 default: 931 default:
945 acpi_get_name(handle, ACPI_SINGLE_NAME, &buffer); 932 acpi_get_name(device->handle, ACPI_SINGLE_NAME, &buffer);
946 /* Clean up trailing underscores (if any) */ 933 /* Clean up trailing underscores (if any) */
947 for (i = 3; i > 1; i--) { 934 for (i = 3; i > 1; i--) {
948 if (bus_id[i] == '_') 935 if (bus_id[i] == '_')
@@ -1000,204 +987,132 @@ static int acpi_dock_match(struct acpi_device *device)
1000 return acpi_get_handle(device->handle, "_DCK", &tmp); 987 return acpi_get_handle(device->handle, "_DCK", &tmp);
1001} 988}
1002 989
1003static struct acpica_device_id_list* 990char *acpi_device_hid(struct acpi_device *device)
1004acpi_add_cid(
1005 struct acpi_device_info *info,
1006 struct acpica_device_id *new_cid)
1007{ 991{
1008 struct acpica_device_id_list *cid; 992 struct acpi_hardware_id *hid;
1009 char *next_id_string;
1010 acpi_size cid_length;
1011 acpi_size new_cid_length;
1012 u32 i;
1013
1014
1015 /* Allocate new CID list with room for the new CID */
1016
1017 if (!new_cid)
1018 new_cid_length = info->compatible_id_list.list_size;
1019 else if (info->compatible_id_list.list_size)
1020 new_cid_length = info->compatible_id_list.list_size +
1021 new_cid->length + sizeof(struct acpica_device_id);
1022 else
1023 new_cid_length = sizeof(struct acpica_device_id_list) + new_cid->length;
1024
1025 cid = ACPI_ALLOCATE_ZEROED(new_cid_length);
1026 if (!cid) {
1027 return NULL;
1028 }
1029
1030 cid->list_size = new_cid_length;
1031 cid->count = info->compatible_id_list.count;
1032 if (new_cid)
1033 cid->count++;
1034 next_id_string = (char *) cid->ids + (cid->count * sizeof(struct acpica_device_id));
1035
1036 /* Copy all existing CIDs */
1037
1038 for (i = 0; i < info->compatible_id_list.count; i++) {
1039 cid_length = info->compatible_id_list.ids[i].length;
1040 cid->ids[i].string = next_id_string;
1041 cid->ids[i].length = cid_length;
1042 993
1043 ACPI_MEMCPY(next_id_string, info->compatible_id_list.ids[i].string, 994 hid = list_first_entry(&device->pnp.ids, struct acpi_hardware_id, list);
1044 cid_length); 995 return hid->id;
1045 996}
1046 next_id_string += cid_length; 997EXPORT_SYMBOL(acpi_device_hid);
1047 }
1048 998
1049 /* Append the new CID */ 999static void acpi_add_id(struct acpi_device *device, const char *dev_id)
1000{
1001 struct acpi_hardware_id *id;
1050 1002
1051 if (new_cid) { 1003 id = kmalloc(sizeof(*id), GFP_KERNEL);
1052 cid->ids[i].string = next_id_string; 1004 if (!id)
1053 cid->ids[i].length = new_cid->length; 1005 return;
1054 1006
1055 ACPI_MEMCPY(next_id_string, new_cid->string, new_cid->length); 1007 id->id = kmalloc(strlen(dev_id) + 1, GFP_KERNEL);
1008 if (!id->id) {
1009 kfree(id);
1010 return;
1056 } 1011 }
1057 1012
1058 return cid; 1013 strcpy(id->id, dev_id);
1014 list_add_tail(&id->list, &device->pnp.ids);
1059} 1015}
1060 1016
1061static void acpi_device_set_id(struct acpi_device *device, 1017static void acpi_device_set_id(struct acpi_device *device)
1062 struct acpi_device *parent, acpi_handle handle,
1063 int type)
1064{ 1018{
1065 struct acpi_device_info *info = NULL;
1066 char *hid = NULL;
1067 char *uid = NULL;
1068 struct acpica_device_id_list *cid_list = NULL;
1069 char *cid_add = NULL;
1070 acpi_status status; 1019 acpi_status status;
1020 struct acpi_device_info *info;
1021 struct acpica_device_id_list *cid_list;
1022 int i;
1071 1023
1072 switch (type) { 1024 switch (device->device_type) {
1073 case ACPI_BUS_TYPE_DEVICE: 1025 case ACPI_BUS_TYPE_DEVICE:
1074 status = acpi_get_object_info(handle, &info); 1026 if (ACPI_IS_ROOT_DEVICE(device)) {
1027 acpi_add_id(device, ACPI_SYSTEM_HID);
1028 break;
1029 } else if (ACPI_IS_ROOT_DEVICE(device->parent)) {
1030 /* \_SB_, the only root-level namespace device */
1031 acpi_add_id(device, ACPI_BUS_HID);
1032 strcpy(device->pnp.device_name, ACPI_BUS_DEVICE_NAME);
1033 strcpy(device->pnp.device_class, ACPI_BUS_CLASS);
1034 break;
1035 }
1036
1037 status = acpi_get_object_info(device->handle, &info);
1075 if (ACPI_FAILURE(status)) { 1038 if (ACPI_FAILURE(status)) {
1076 printk(KERN_ERR PREFIX "%s: Error reading device info\n", __func__); 1039 printk(KERN_ERR PREFIX "%s: Error reading device info\n", __func__);
1077 return; 1040 return;
1078 } 1041 }
1079 1042
1080 if (info->valid & ACPI_VALID_HID) 1043 if (info->valid & ACPI_VALID_HID)
1081 hid = info->hardware_id.string; 1044 acpi_add_id(device, info->hardware_id.string);
1082 if (info->valid & ACPI_VALID_UID) 1045 if (info->valid & ACPI_VALID_CID) {
1083 uid = info->unique_id.string;
1084 if (info->valid & ACPI_VALID_CID)
1085 cid_list = &info->compatible_id_list; 1046 cid_list = &info->compatible_id_list;
1047 for (i = 0; i < cid_list->count; i++)
1048 acpi_add_id(device, cid_list->ids[i].string);
1049 }
1086 if (info->valid & ACPI_VALID_ADR) { 1050 if (info->valid & ACPI_VALID_ADR) {
1087 device->pnp.bus_address = info->address; 1051 device->pnp.bus_address = info->address;
1088 device->flags.bus_address = 1; 1052 device->flags.bus_address = 1;
1089 } 1053 }
1090 1054
1091 /* If we have a video/bay/dock device, add our selfdefined 1055 /*
1092 HID to the CID list. Like that the video/bay/dock drivers 1056 * Some devices don't reliably have _HIDs & _CIDs, so add
1093 will get autoloaded and the device might still match 1057 * synthetic HIDs to make sure drivers can find them.
1094 against another driver. 1058 */
1095 */
1096 if (acpi_is_video_device(device)) 1059 if (acpi_is_video_device(device))
1097 cid_add = ACPI_VIDEO_HID; 1060 acpi_add_id(device, ACPI_VIDEO_HID);
1098 else if (ACPI_SUCCESS(acpi_bay_match(device))) 1061 else if (ACPI_SUCCESS(acpi_bay_match(device)))
1099 cid_add = ACPI_BAY_HID; 1062 acpi_add_id(device, ACPI_BAY_HID);
1100 else if (ACPI_SUCCESS(acpi_dock_match(device))) 1063 else if (ACPI_SUCCESS(acpi_dock_match(device)))
1101 cid_add = ACPI_DOCK_HID; 1064 acpi_add_id(device, ACPI_DOCK_HID);
1102 1065
1103 break; 1066 break;
1104 case ACPI_BUS_TYPE_POWER: 1067 case ACPI_BUS_TYPE_POWER:
1105 hid = ACPI_POWER_HID; 1068 acpi_add_id(device, ACPI_POWER_HID);
1106 break; 1069 break;
1107 case ACPI_BUS_TYPE_PROCESSOR: 1070 case ACPI_BUS_TYPE_PROCESSOR:
1108 hid = ACPI_PROCESSOR_OBJECT_HID; 1071 acpi_add_id(device, ACPI_PROCESSOR_OBJECT_HID);
1109 break;
1110 case ACPI_BUS_TYPE_SYSTEM:
1111 hid = ACPI_SYSTEM_HID;
1112 break; 1072 break;
1113 case ACPI_BUS_TYPE_THERMAL: 1073 case ACPI_BUS_TYPE_THERMAL:
1114 hid = ACPI_THERMAL_HID; 1074 acpi_add_id(device, ACPI_THERMAL_HID);
1115 break; 1075 break;
1116 case ACPI_BUS_TYPE_POWER_BUTTON: 1076 case ACPI_BUS_TYPE_POWER_BUTTON:
1117 hid = ACPI_BUTTON_HID_POWERF; 1077 acpi_add_id(device, ACPI_BUTTON_HID_POWERF);
1118 break; 1078 break;
1119 case ACPI_BUS_TYPE_SLEEP_BUTTON: 1079 case ACPI_BUS_TYPE_SLEEP_BUTTON:
1120 hid = ACPI_BUTTON_HID_SLEEPF; 1080 acpi_add_id(device, ACPI_BUTTON_HID_SLEEPF);
1121 break; 1081 break;
1122 } 1082 }
1123 1083
1124 /* 1084 /*
1125 * \_SB 1085 * We build acpi_devices for some objects that don't have _HID or _CID,
1126 * ---- 1086 * e.g., PCI bridges and slots. Drivers can't bind to these objects,
1127 * Fix for the system root bus device -- the only root-level device. 1087 * but we do use them indirectly by traversing the acpi_device tree.
1088 * This generic ID isn't useful for driver binding, but it provides
1089 * the useful property that "every acpi_device has an ID."
1128 */ 1090 */
1129 if (((acpi_handle)parent == ACPI_ROOT_OBJECT) && (type == ACPI_BUS_TYPE_DEVICE)) { 1091 if (list_empty(&device->pnp.ids))
1130 hid = ACPI_BUS_HID; 1092 acpi_add_id(device, "device");
1131 strcpy(device->pnp.device_name, ACPI_BUS_DEVICE_NAME);
1132 strcpy(device->pnp.device_class, ACPI_BUS_CLASS);
1133 }
1134
1135 if (hid) {
1136 device->pnp.hardware_id = ACPI_ALLOCATE_ZEROED(strlen (hid) + 1);
1137 if (device->pnp.hardware_id) {
1138 strcpy(device->pnp.hardware_id, hid);
1139 device->flags.hardware_id = 1;
1140 }
1141 }
1142 if (!device->flags.hardware_id)
1143 device->pnp.hardware_id = "";
1144
1145 if (uid) {
1146 device->pnp.unique_id = ACPI_ALLOCATE_ZEROED(strlen (uid) + 1);
1147 if (device->pnp.unique_id) {
1148 strcpy(device->pnp.unique_id, uid);
1149 device->flags.unique_id = 1;
1150 }
1151 }
1152 if (!device->flags.unique_id)
1153 device->pnp.unique_id = "";
1154
1155 if (cid_list || cid_add) {
1156 struct acpica_device_id_list *list;
1157
1158 if (cid_add) {
1159 struct acpica_device_id cid;
1160 cid.length = strlen (cid_add) + 1;
1161 cid.string = cid_add;
1162
1163 list = acpi_add_cid(info, &cid);
1164 } else {
1165 list = acpi_add_cid(info, NULL);
1166 }
1167
1168 if (list) {
1169 device->pnp.cid_list = list;
1170 if (cid_add)
1171 device->flags.compatible_ids = 1;
1172 }
1173 }
1174
1175 kfree(info);
1176} 1093}
1177 1094
1178static int acpi_device_set_context(struct acpi_device *device, int type) 1095static int acpi_device_set_context(struct acpi_device *device)
1179{ 1096{
1180 acpi_status status = AE_OK; 1097 acpi_status status;
1181 int result = 0; 1098
1182 /* 1099 /*
1183 * Context 1100 * Context
1184 * ------- 1101 * -------
1185 * Attach this 'struct acpi_device' to the ACPI object. This makes 1102 * Attach this 'struct acpi_device' to the ACPI object. This makes
1186 * resolutions from handle->device very efficient. Note that we need 1103 * resolutions from handle->device very efficient. Fixed hardware
1187 * to be careful with fixed-feature devices as they all attach to the 1104 * devices have no handles, so we skip them.
1188 * root object.
1189 */ 1105 */
1190 if (type != ACPI_BUS_TYPE_POWER_BUTTON && 1106 if (!device->handle)
1191 type != ACPI_BUS_TYPE_SLEEP_BUTTON) { 1107 return 0;
1192 status = acpi_attach_data(device->handle,
1193 acpi_bus_data_handler, device);
1194 1108
1195 if (ACPI_FAILURE(status)) { 1109 status = acpi_attach_data(device->handle,
1196 printk(KERN_ERR PREFIX "Error attaching device data\n"); 1110 acpi_bus_data_handler, device);
1197 result = -ENODEV; 1111 if (ACPI_SUCCESS(status))
1198 } 1112 return 0;
1199 } 1113
1200 return result; 1114 printk(KERN_ERR PREFIX "Error attaching device data\n");
1115 return -ENODEV;
1201} 1116}
1202 1117
1203static int acpi_bus_remove(struct acpi_device *dev, int rmdevice) 1118static int acpi_bus_remove(struct acpi_device *dev, int rmdevice)
@@ -1223,17 +1138,14 @@ static int acpi_bus_remove(struct acpi_device *dev, int rmdevice)
1223 return 0; 1138 return 0;
1224} 1139}
1225 1140
1226static int 1141static int acpi_add_single_object(struct acpi_device **child,
1227acpi_add_single_object(struct acpi_device **child, 1142 acpi_handle handle, int type,
1228 struct acpi_device *parent, acpi_handle handle, int type, 1143 unsigned long long sta,
1229 struct acpi_bus_ops *ops) 1144 struct acpi_bus_ops *ops)
1230{ 1145{
1231 int result = 0; 1146 int result;
1232 struct acpi_device *device = NULL; 1147 struct acpi_device *device;
1233 1148 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
1234
1235 if (!child)
1236 return -EINVAL;
1237 1149
1238 device = kzalloc(sizeof(struct acpi_device), GFP_KERNEL); 1150 device = kzalloc(sizeof(struct acpi_device), GFP_KERNEL);
1239 if (!device) { 1151 if (!device) {
@@ -1241,75 +1153,31 @@ acpi_add_single_object(struct acpi_device **child,
1241 return -ENOMEM; 1153 return -ENOMEM;
1242 } 1154 }
1243 1155
1156 INIT_LIST_HEAD(&device->pnp.ids);
1157 device->device_type = type;
1244 device->handle = handle; 1158 device->handle = handle;
1245 device->parent = parent; 1159 device->parent = acpi_bus_get_parent(handle);
1246 device->bus_ops = *ops; /* workround for not call .start */ 1160 device->bus_ops = *ops; /* workround for not call .start */
1161 STRUCT_TO_INT(device->status) = sta;
1247 1162
1248 1163 acpi_device_get_busid(device);
1249 acpi_device_get_busid(device, handle, type);
1250 1164
1251 /* 1165 /*
1252 * Flags 1166 * Flags
1253 * ----- 1167 * -----
1254 * Get prior to calling acpi_bus_get_status() so we know whether 1168 * Note that we only look for object handles -- cannot evaluate objects
1255 * or not _STA is present. Note that we only look for object 1169 * until we know the device is present and properly initialized.
1256 * handles -- cannot evaluate objects until we know the device is
1257 * present and properly initialized.
1258 */ 1170 */
1259 result = acpi_bus_get_flags(device); 1171 result = acpi_bus_get_flags(device);
1260 if (result) 1172 if (result)
1261 goto end; 1173 goto end;
1262 1174
1263 /* 1175 /*
1264 * Status
1265 * ------
1266 * See if the device is present. We always assume that non-Device
1267 * and non-Processor objects (e.g. thermal zones, power resources,
1268 * etc.) are present, functioning, etc. (at least when parent object
1269 * is present). Note that _STA has a different meaning for some
1270 * objects (e.g. power resources) so we need to be careful how we use
1271 * it.
1272 */
1273 switch (type) {
1274 case ACPI_BUS_TYPE_PROCESSOR:
1275 case ACPI_BUS_TYPE_DEVICE:
1276 result = acpi_bus_get_status(device);
1277 if (ACPI_FAILURE(result)) {
1278 result = -ENODEV;
1279 goto end;
1280 }
1281 /*
1282 * When the device is neither present nor functional, the
1283 * device should not be added to Linux ACPI device tree.
1284 * When the status of the device is not present but functinal,
1285 * it should be added to Linux ACPI tree. For example : bay
1286 * device , dock device.
1287 * In such conditions it is unncessary to check whether it is
1288 * bay device or dock device.
1289 */
1290 if (!device->status.present && !device->status.functional) {
1291 result = -ENODEV;
1292 goto end;
1293 }
1294 break;
1295 default:
1296 STRUCT_TO_INT(device->status) =
1297 ACPI_STA_DEVICE_PRESENT | ACPI_STA_DEVICE_ENABLED |
1298 ACPI_STA_DEVICE_UI | ACPI_STA_DEVICE_FUNCTIONING;
1299 break;
1300 }
1301
1302 /*
1303 * Initialize Device 1176 * Initialize Device
1304 * ----------------- 1177 * -----------------
1305 * TBD: Synch with Core's enumeration/initialization process. 1178 * TBD: Synch with Core's enumeration/initialization process.
1306 */ 1179 */
1307 1180 acpi_device_set_id(device);
1308 /*
1309 * Hardware ID, Unique ID, & Bus Address
1310 * -------------------------------------
1311 */
1312 acpi_device_set_id(device, parent, handle, type);
1313 1181
1314 /* 1182 /*
1315 * Power Management 1183 * Power Management
@@ -1341,10 +1209,10 @@ acpi_add_single_object(struct acpi_device **child,
1341 goto end; 1209 goto end;
1342 } 1210 }
1343 1211
1344 if ((result = acpi_device_set_context(device, type))) 1212 if ((result = acpi_device_set_context(device)))
1345 goto end; 1213 goto end;
1346 1214
1347 result = acpi_device_register(device, parent); 1215 result = acpi_device_register(device);
1348 1216
1349 /* 1217 /*
1350 * Bind _ADR-Based Devices when hot add 1218 * Bind _ADR-Based Devices when hot add
@@ -1355,128 +1223,122 @@ acpi_add_single_object(struct acpi_device **child,
1355 } 1223 }
1356 1224
1357end: 1225end:
1358 if (!result) 1226 if (!result) {
1227 acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
1228 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
1229 "Adding %s [%s] parent %s\n", dev_name(&device->dev),
1230 (char *) buffer.pointer,
1231 device->parent ? dev_name(&device->parent->dev) :
1232 "(null)"));
1233 kfree(buffer.pointer);
1359 *child = device; 1234 *child = device;
1360 else 1235 } else
1361 acpi_device_release(&device->dev); 1236 acpi_device_release(&device->dev);
1362 1237
1363 return result; 1238 return result;
1364} 1239}
1365 1240
1366static int acpi_bus_scan(struct acpi_device *start, struct acpi_bus_ops *ops) 1241#define ACPI_STA_DEFAULT (ACPI_STA_DEVICE_PRESENT | ACPI_STA_DEVICE_ENABLED | \
1242 ACPI_STA_DEVICE_UI | ACPI_STA_DEVICE_FUNCTIONING)
1243
1244static int acpi_bus_type_and_status(acpi_handle handle, int *type,
1245 unsigned long long *sta)
1367{ 1246{
1368 acpi_status status = AE_OK; 1247 acpi_status status;
1369 struct acpi_device *parent = NULL; 1248 acpi_object_type acpi_type;
1370 struct acpi_device *child = NULL;
1371 acpi_handle phandle = NULL;
1372 acpi_handle chandle = NULL;
1373 acpi_object_type type = 0;
1374 u32 level = 1;
1375 1249
1250 status = acpi_get_type(handle, &acpi_type);
1251 if (ACPI_FAILURE(status))
1252 return -ENODEV;
1376 1253
1377 if (!start) 1254 switch (acpi_type) {
1378 return -EINVAL; 1255 case ACPI_TYPE_ANY: /* for ACPI_ROOT_OBJECT */
1256 case ACPI_TYPE_DEVICE:
1257 *type = ACPI_BUS_TYPE_DEVICE;
1258 status = acpi_bus_get_status_handle(handle, sta);
1259 if (ACPI_FAILURE(status))
1260 return -ENODEV;
1261 break;
1262 case ACPI_TYPE_PROCESSOR:
1263 *type = ACPI_BUS_TYPE_PROCESSOR;
1264 status = acpi_bus_get_status_handle(handle, sta);
1265 if (ACPI_FAILURE(status))
1266 return -ENODEV;
1267 break;
1268 case ACPI_TYPE_THERMAL:
1269 *type = ACPI_BUS_TYPE_THERMAL;
1270 *sta = ACPI_STA_DEFAULT;
1271 break;
1272 case ACPI_TYPE_POWER:
1273 *type = ACPI_BUS_TYPE_POWER;
1274 *sta = ACPI_STA_DEFAULT;
1275 break;
1276 default:
1277 return -ENODEV;
1278 }
1379 1279
1380 parent = start; 1280 return 0;
1381 phandle = start->handle; 1281}
1382 1282
1383 /* 1283static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl,
1384 * Parse through the ACPI namespace, identify all 'devices', and 1284 void *context, void **return_value)
1385 * create a new 'struct acpi_device' for each. 1285{
1386 */ 1286 struct acpi_bus_ops *ops = context;
1387 while ((level > 0) && parent) { 1287 int type;
1288 unsigned long long sta;
1289 struct acpi_device *device;
1290 acpi_status status;
1291 int result;
1388 1292
1389 status = acpi_get_next_object(ACPI_TYPE_ANY, phandle, 1293 result = acpi_bus_type_and_status(handle, &type, &sta);
1390 chandle, &chandle); 1294 if (result)
1295 return AE_OK;
1391 1296
1392 /* 1297 if (!(sta & ACPI_STA_DEVICE_PRESENT) &&
1393 * If this scope is exhausted then move our way back up. 1298 !(sta & ACPI_STA_DEVICE_FUNCTIONING))
1394 */ 1299 return AE_CTRL_DEPTH;
1395 if (ACPI_FAILURE(status)) {
1396 level--;
1397 chandle = phandle;
1398 acpi_get_parent(phandle, &phandle);
1399 if (parent->parent)
1400 parent = parent->parent;
1401 continue;
1402 }
1403 1300
1404 status = acpi_get_type(chandle, &type); 1301 /*
1405 if (ACPI_FAILURE(status)) 1302 * We may already have an acpi_device from a previous enumeration. If
1406 continue; 1303 * so, we needn't add it again, but we may still have to start it.
1304 */
1305 device = NULL;
1306 acpi_bus_get_device(handle, &device);
1307 if (ops->acpi_op_add && !device)
1308 acpi_add_single_object(&device, handle, type, sta, ops);
1407 1309
1408 /* 1310 if (!device)
1409 * If this is a scope object then parse it (depth-first). 1311 return AE_CTRL_DEPTH;
1410 */
1411 if (type == ACPI_TYPE_LOCAL_SCOPE) {
1412 level++;
1413 phandle = chandle;
1414 chandle = NULL;
1415 continue;
1416 }
1417 1312
1418 /* 1313 if (ops->acpi_op_start && !(ops->acpi_op_add)) {
1419 * We're only interested in objects that we consider 'devices'. 1314 status = acpi_start_single_object(device);
1420 */ 1315 if (ACPI_FAILURE(status))
1421 switch (type) { 1316 return AE_CTRL_DEPTH;
1422 case ACPI_TYPE_DEVICE: 1317 }
1423 type = ACPI_BUS_TYPE_DEVICE;
1424 break;
1425 case ACPI_TYPE_PROCESSOR:
1426 type = ACPI_BUS_TYPE_PROCESSOR;
1427 break;
1428 case ACPI_TYPE_THERMAL:
1429 type = ACPI_BUS_TYPE_THERMAL;
1430 break;
1431 case ACPI_TYPE_POWER:
1432 type = ACPI_BUS_TYPE_POWER;
1433 break;
1434 default:
1435 continue;
1436 }
1437 1318
1438 if (ops->acpi_op_add) 1319 if (!*return_value)
1439 status = acpi_add_single_object(&child, parent, 1320 *return_value = device;
1440 chandle, type, ops); 1321 return AE_OK;
1441 else 1322}
1442 status = acpi_bus_get_device(chandle, &child);
1443 1323
1444 if (ACPI_FAILURE(status)) 1324static int acpi_bus_scan(acpi_handle handle, struct acpi_bus_ops *ops,
1445 continue; 1325 struct acpi_device **child)
1326{
1327 acpi_status status;
1328 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
1329 void *device = NULL;
1446 1330
1447 if (ops->acpi_op_start && !(ops->acpi_op_add)) { 1331 acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
1448 status = acpi_start_single_object(child); 1332 printk(KERN_INFO PREFIX "Enumerating devices from [%s]\n",
1449 if (ACPI_FAILURE(status)) 1333 (char *) buffer.pointer);
1450 continue;
1451 }
1452 1334
1453 /* 1335 status = acpi_bus_check_add(handle, 0, ops, &device);
1454 * If the device is present, enabled, and functioning then 1336 if (ACPI_SUCCESS(status))
1455 * parse its scope (depth-first). Note that we need to 1337 acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX,
1456 * represent absent devices to facilitate PnP notifications 1338 acpi_bus_check_add, ops, &device);
1457 * -- but only the subtree head (not all of its children,
1458 * which will be enumerated when the parent is inserted).
1459 *
1460 * TBD: Need notifications and other detection mechanisms
1461 * in place before we can fully implement this.
1462 */
1463 /*
1464 * When the device is not present but functional, it is also
1465 * necessary to scan the children of this device.
1466 */
1467 if (child->status.present || (!child->status.present &&
1468 child->status.functional)) {
1469 status = acpi_get_next_object(ACPI_TYPE_ANY, chandle,
1470 NULL, NULL);
1471 if (ACPI_SUCCESS(status)) {
1472 level++;
1473 phandle = chandle;
1474 chandle = NULL;
1475 parent = child;
1476 }
1477 }
1478 }
1479 1339
1340 if (child)
1341 *child = device;
1480 return 0; 1342 return 0;
1481} 1343}
1482 1344
@@ -1484,36 +1346,25 @@ int
1484acpi_bus_add(struct acpi_device **child, 1346acpi_bus_add(struct acpi_device **child,
1485 struct acpi_device *parent, acpi_handle handle, int type) 1347 struct acpi_device *parent, acpi_handle handle, int type)
1486{ 1348{
1487 int result;
1488 struct acpi_bus_ops ops; 1349 struct acpi_bus_ops ops;
1489 1350
1490 memset(&ops, 0, sizeof(ops)); 1351 memset(&ops, 0, sizeof(ops));
1491 ops.acpi_op_add = 1; 1352 ops.acpi_op_add = 1;
1492 1353
1493 result = acpi_add_single_object(child, parent, handle, type, &ops); 1354 acpi_bus_scan(handle, &ops, child);
1494 if (!result) 1355 return 0;
1495 result = acpi_bus_scan(*child, &ops);
1496
1497 return result;
1498} 1356}
1499EXPORT_SYMBOL(acpi_bus_add); 1357EXPORT_SYMBOL(acpi_bus_add);
1500 1358
1501int acpi_bus_start(struct acpi_device *device) 1359int acpi_bus_start(struct acpi_device *device)
1502{ 1360{
1503 int result;
1504 struct acpi_bus_ops ops; 1361 struct acpi_bus_ops ops;
1505 1362
1363 memset(&ops, 0, sizeof(ops));
1364 ops.acpi_op_start = 1;
1506 1365
1507 if (!device) 1366 acpi_bus_scan(device->handle, &ops, NULL);
1508 return -EINVAL; 1367 return 0;
1509
1510 result = acpi_start_single_object(device);
1511 if (!result) {
1512 memset(&ops, 0, sizeof(ops));
1513 ops.acpi_op_start = 1;
1514 result = acpi_bus_scan(device, &ops);
1515 }
1516 return result;
1517} 1368}
1518EXPORT_SYMBOL(acpi_bus_start); 1369EXPORT_SYMBOL(acpi_bus_start);
1519 1370
@@ -1572,15 +1423,12 @@ int acpi_bus_trim(struct acpi_device *start, int rmdevice)
1572} 1423}
1573EXPORT_SYMBOL_GPL(acpi_bus_trim); 1424EXPORT_SYMBOL_GPL(acpi_bus_trim);
1574 1425
1575static int acpi_bus_scan_fixed(struct acpi_device *root) 1426static int acpi_bus_scan_fixed(void)
1576{ 1427{
1577 int result = 0; 1428 int result = 0;
1578 struct acpi_device *device = NULL; 1429 struct acpi_device *device = NULL;
1579 struct acpi_bus_ops ops; 1430 struct acpi_bus_ops ops;
1580 1431
1581 if (!root)
1582 return -ENODEV;
1583
1584 memset(&ops, 0, sizeof(ops)); 1432 memset(&ops, 0, sizeof(ops));
1585 ops.acpi_op_add = 1; 1433 ops.acpi_op_add = 1;
1586 ops.acpi_op_start = 1; 1434 ops.acpi_op_start = 1;
@@ -1589,16 +1437,16 @@ static int acpi_bus_scan_fixed(struct acpi_device *root)
1589 * Enumerate all fixed-feature devices. 1437 * Enumerate all fixed-feature devices.
1590 */ 1438 */
1591 if ((acpi_gbl_FADT.flags & ACPI_FADT_POWER_BUTTON) == 0) { 1439 if ((acpi_gbl_FADT.flags & ACPI_FADT_POWER_BUTTON) == 0) {
1592 result = acpi_add_single_object(&device, acpi_root, 1440 result = acpi_add_single_object(&device, NULL,
1593 NULL,
1594 ACPI_BUS_TYPE_POWER_BUTTON, 1441 ACPI_BUS_TYPE_POWER_BUTTON,
1442 ACPI_STA_DEFAULT,
1595 &ops); 1443 &ops);
1596 } 1444 }
1597 1445
1598 if ((acpi_gbl_FADT.flags & ACPI_FADT_SLEEP_BUTTON) == 0) { 1446 if ((acpi_gbl_FADT.flags & ACPI_FADT_SLEEP_BUTTON) == 0) {
1599 result = acpi_add_single_object(&device, acpi_root, 1447 result = acpi_add_single_object(&device, NULL,
1600 NULL,
1601 ACPI_BUS_TYPE_SLEEP_BUTTON, 1448 ACPI_BUS_TYPE_SLEEP_BUTTON,
1449 ACPI_STA_DEFAULT,
1602 &ops); 1450 &ops);
1603 } 1451 }
1604 1452
@@ -1621,24 +1469,15 @@ int __init acpi_scan_init(void)
1621 } 1469 }
1622 1470
1623 /* 1471 /*
1624 * Create the root device in the bus's device tree
1625 */
1626 result = acpi_add_single_object(&acpi_root, NULL, ACPI_ROOT_OBJECT,
1627 ACPI_BUS_TYPE_SYSTEM, &ops);
1628 if (result)
1629 goto Done;
1630
1631 /*
1632 * Enumerate devices in the ACPI namespace. 1472 * Enumerate devices in the ACPI namespace.
1633 */ 1473 */
1634 result = acpi_bus_scan_fixed(acpi_root); 1474 result = acpi_bus_scan(ACPI_ROOT_OBJECT, &ops, &acpi_root);
1635 1475
1636 if (!result) 1476 if (!result)
1637 result = acpi_bus_scan(acpi_root, &ops); 1477 result = acpi_bus_scan_fixed();
1638 1478
1639 if (result) 1479 if (result)
1640 acpi_device_unregister(acpi_root, ACPI_BUS_REMOVAL_NORMAL); 1480 acpi_device_unregister(acpi_root, ACPI_BUS_REMOVAL_NORMAL);
1641 1481
1642Done:
1643 return result; 1482 return result;
1644} 1483}
diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
index a9d926b7d805..e7be66dbac21 100644
--- a/drivers/pci/hotplug/acpiphp_ibm.c
+++ b/drivers/pci/hotplug/acpiphp_ibm.c
@@ -406,7 +406,6 @@ static acpi_status __init ibm_find_acpi_device(acpi_handle handle,
406 __func__, status); 406 __func__, status);
407 return retval; 407 return retval;
408 } 408 }
409 info->hardware_id.string[sizeof(info->hardware_id.length) - 1] = '\0';
410 409
411 if (info->current_status && (info->valid & ACPI_VALID_HID) && 410 if (info->current_status && (info->valid & ACPI_VALID_HID) &&
412 (!strcmp(info->hardware_id.string, IBM_HARDWARE_ID1) || 411 (!strcmp(info->hardware_id.string, IBM_HARDWARE_ID1) ||
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c
index c07fdb94d665..83b8b5ac49c9 100644
--- a/drivers/pnp/pnpacpi/core.c
+++ b/drivers/pnp/pnpacpi/core.c
@@ -153,6 +153,7 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
153 acpi_handle temp = NULL; 153 acpi_handle temp = NULL;
154 acpi_status status; 154 acpi_status status;
155 struct pnp_dev *dev; 155 struct pnp_dev *dev;
156 struct acpi_hardware_id *id;
156 157
157 /* 158 /*
158 * If a PnPacpi device is not present , the device 159 * If a PnPacpi device is not present , the device
@@ -193,15 +194,12 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
193 if (dev->capabilities & PNP_CONFIGURABLE) 194 if (dev->capabilities & PNP_CONFIGURABLE)
194 pnpacpi_parse_resource_option_data(dev); 195 pnpacpi_parse_resource_option_data(dev);
195 196
196 if (device->flags.compatible_ids) { 197 list_for_each_entry(id, &device->pnp.ids, list) {
197 struct acpica_device_id_list *cid_list = device->pnp.cid_list; 198 if (!strcmp(id->id, acpi_device_hid(device)))
198 int i; 199 continue;
199 200 if (!ispnpidacpi(id->id))
200 for (i = 0; i < cid_list->count; i++) { 201 continue;
201 if (!ispnpidacpi(cid_list->ids[i].string)) 202 pnp_add_id(dev, id->id);
202 continue;
203 pnp_add_id(dev, cid_list->ids[i].string);
204 }
205 } 203 }
206 204
207 /* clear out the damaged flags */ 205 /* clear out the damaged flags */
@@ -232,9 +230,8 @@ static int __init acpi_pnp_match(struct device *dev, void *_pnp)
232 struct pnp_dev *pnp = _pnp; 230 struct pnp_dev *pnp = _pnp;
233 231
234 /* true means it matched */ 232 /* true means it matched */
235 return acpi->flags.hardware_id 233 return !acpi_get_physical_device(acpi->handle)
236 && !acpi_get_physical_device(acpi->handle) 234 && compare_pnp_id(pnp->id, acpi_device_hid(acpi));
237 && compare_pnp_id(pnp->id, acpi->pnp.hardware_id);
238} 235}
239 236
240static int __init acpi_pnp_find_device(struct device *dev, acpi_handle * handle) 237static int __init acpi_pnp_find_device(struct device *dev, acpi_handle * handle)
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 1cef1398e358..3cd9ccdcbd8f 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -70,7 +70,6 @@ enum acpi_bus_device_type {
70 ACPI_BUS_TYPE_POWER, 70 ACPI_BUS_TYPE_POWER,
71 ACPI_BUS_TYPE_PROCESSOR, 71 ACPI_BUS_TYPE_PROCESSOR,
72 ACPI_BUS_TYPE_THERMAL, 72 ACPI_BUS_TYPE_THERMAL,
73 ACPI_BUS_TYPE_SYSTEM,
74 ACPI_BUS_TYPE_POWER_BUTTON, 73 ACPI_BUS_TYPE_POWER_BUTTON,
75 ACPI_BUS_TYPE_SLEEP_BUTTON, 74 ACPI_BUS_TYPE_SLEEP_BUTTON,
76 ACPI_BUS_DEVICE_TYPE_COUNT 75 ACPI_BUS_DEVICE_TYPE_COUNT
@@ -142,10 +141,7 @@ struct acpi_device_status {
142 141
143struct acpi_device_flags { 142struct acpi_device_flags {
144 u32 dynamic_status:1; 143 u32 dynamic_status:1;
145 u32 hardware_id:1;
146 u32 compatible_ids:1;
147 u32 bus_address:1; 144 u32 bus_address:1;
148 u32 unique_id:1;
149 u32 removable:1; 145 u32 removable:1;
150 u32 ejectable:1; 146 u32 ejectable:1;
151 u32 lockable:1; 147 u32 lockable:1;
@@ -154,7 +150,7 @@ struct acpi_device_flags {
154 u32 performance_manageable:1; 150 u32 performance_manageable:1;
155 u32 wake_capable:1; /* Wakeup(_PRW) supported? */ 151 u32 wake_capable:1; /* Wakeup(_PRW) supported? */
156 u32 force_power_state:1; 152 u32 force_power_state:1;
157 u32 reserved:19; 153 u32 reserved:22;
158}; 154};
159 155
160/* File System */ 156/* File System */
@@ -172,20 +168,23 @@ typedef unsigned long acpi_bus_address;
172typedef char acpi_device_name[40]; 168typedef char acpi_device_name[40];
173typedef char acpi_device_class[20]; 169typedef char acpi_device_class[20];
174 170
171struct acpi_hardware_id {
172 struct list_head list;
173 char *id;
174};
175
175struct acpi_device_pnp { 176struct acpi_device_pnp {
176 acpi_bus_id bus_id; /* Object name */ 177 acpi_bus_id bus_id; /* Object name */
177 acpi_bus_address bus_address; /* _ADR */ 178 acpi_bus_address bus_address; /* _ADR */
178 char *hardware_id; /* _HID */
179 struct acpica_device_id_list *cid_list; /* _CIDs */
180 char *unique_id; /* _UID */ 179 char *unique_id; /* _UID */
180 struct list_head ids; /* _HID and _CIDs */
181 acpi_device_name device_name; /* Driver-determined */ 181 acpi_device_name device_name; /* Driver-determined */
182 acpi_device_class device_class; /* " */ 182 acpi_device_class device_class; /* " */
183}; 183};
184 184
185#define acpi_device_bid(d) ((d)->pnp.bus_id) 185#define acpi_device_bid(d) ((d)->pnp.bus_id)
186#define acpi_device_adr(d) ((d)->pnp.bus_address) 186#define acpi_device_adr(d) ((d)->pnp.bus_address)
187#define acpi_device_hid(d) ((d)->pnp.hardware_id) 187char *acpi_device_hid(struct acpi_device *device);
188#define acpi_device_uid(d) ((d)->pnp.unique_id)
189#define acpi_device_name(d) ((d)->pnp.device_name) 188#define acpi_device_name(d) ((d)->pnp.device_name)
190#define acpi_device_class(d) ((d)->pnp.device_class) 189#define acpi_device_class(d) ((d)->pnp.device_class)
191 190
@@ -262,7 +261,8 @@ struct acpi_device_wakeup {
262/* Device */ 261/* Device */
263 262
264struct acpi_device { 263struct acpi_device {
265 acpi_handle handle; 264 int device_type;
265 acpi_handle handle; /* no handle for fixed hardware */
266 struct acpi_device *parent; 266 struct acpi_device *parent;
267 struct list_head children; 267 struct list_head children;
268 struct list_head node; 268 struct list_head node;
@@ -322,6 +322,8 @@ extern void unregister_acpi_bus_notifier(struct notifier_block *nb);
322 322
323int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device); 323int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device);
324void acpi_bus_data_handler(acpi_handle handle, void *context); 324void acpi_bus_data_handler(acpi_handle handle, void *context);
325acpi_status acpi_bus_get_status_handle(acpi_handle handle,
326 unsigned long long *sta);
325int acpi_bus_get_status(struct acpi_device *device); 327int acpi_bus_get_status(struct acpi_device *device);
326int acpi_bus_get_power(acpi_handle handle, int *state); 328int acpi_bus_get_power(acpi_handle handle, int *state);
327int acpi_bus_set_power(acpi_handle handle, int state); 329int acpi_bus_set_power(acpi_handle handle, int state);