aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/scan.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2009-07-03 18:13:18 -0400
committerTejun Heo <tj@kernel.org>2009-07-03 18:13:18 -0400
commitc43768cbb7655ea5ff782ae250f6e2ef4297cf98 (patch)
tree3982e41dde3eecaa3739a5d1a8ed18d04bd74f01 /drivers/acpi/scan.c
parent1a8dd307cc0a2119be4e578c517795464e6dabba (diff)
parent746a99a5af60ee676afa2ba469ccd1373493c7e7 (diff)
Merge branch 'master' into for-next
Pull linus#master to merge PER_CPU_DEF_ATTRIBUTES and alpha build fix changes. As alpha in percpu tree uses 'weak' attribute instead of inline assembly, there's no need for __used attribute. Conflicts: arch/alpha/include/asm/percpu.h arch/mn10300/kernel/vmlinux.lds.S include/linux/percpu-defs.h
Diffstat (limited to 'drivers/acpi/scan.c')
-rw-r--r--drivers/acpi/scan.c69
1 files changed, 30 insertions, 39 deletions
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 8ff510b91d88..781435d7e369 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -95,7 +95,7 @@ acpi_device_modalias_show(struct device *dev, struct device_attribute *attr, cha
95} 95}
96static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL); 96static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL);
97 97
98static int acpi_bus_hot_remove_device(void *context) 98static void acpi_bus_hot_remove_device(void *context)
99{ 99{
100 struct acpi_device *device; 100 struct acpi_device *device;
101 acpi_handle handle = context; 101 acpi_handle handle = context;
@@ -104,10 +104,10 @@ static int acpi_bus_hot_remove_device(void *context)
104 acpi_status status = AE_OK; 104 acpi_status status = AE_OK;
105 105
106 if (acpi_bus_get_device(handle, &device)) 106 if (acpi_bus_get_device(handle, &device))
107 return 0; 107 return;
108 108
109 if (!device) 109 if (!device)
110 return 0; 110 return;
111 111
112 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 112 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
113 "Hot-removing device %s...\n", dev_name(&device->dev))); 113 "Hot-removing device %s...\n", dev_name(&device->dev)));
@@ -115,7 +115,7 @@ static int acpi_bus_hot_remove_device(void *context)
115 if (acpi_bus_trim(device, 1)) { 115 if (acpi_bus_trim(device, 1)) {
116 printk(KERN_ERR PREFIX 116 printk(KERN_ERR PREFIX
117 "Removing device failed\n"); 117 "Removing device failed\n");
118 return -1; 118 return;
119 } 119 }
120 120
121 /* power off device */ 121 /* power off device */
@@ -142,9 +142,10 @@ static int acpi_bus_hot_remove_device(void *context)
142 */ 142 */
143 status = acpi_evaluate_object(handle, "_EJ0", &arg_list, NULL); 143 status = acpi_evaluate_object(handle, "_EJ0", &arg_list, NULL);
144 if (ACPI_FAILURE(status)) 144 if (ACPI_FAILURE(status))
145 return -ENODEV; 145 printk(KERN_WARNING PREFIX
146 "Eject device failed\n");
146 147
147 return 0; 148 return;
148} 149}
149 150
150static ssize_t 151static ssize_t
@@ -155,7 +156,6 @@ acpi_eject_store(struct device *d, struct device_attribute *attr,
155 acpi_status status; 156 acpi_status status;
156 acpi_object_type type = 0; 157 acpi_object_type type = 0;
157 struct acpi_device *acpi_device = to_acpi_device(d); 158 struct acpi_device *acpi_device = to_acpi_device(d);
158 struct task_struct *task;
159 159
160 if ((!count) || (buf[0] != '1')) { 160 if ((!count) || (buf[0] != '1')) {
161 return -EINVAL; 161 return -EINVAL;
@@ -172,11 +172,7 @@ acpi_eject_store(struct device *d, struct device_attribute *attr,
172 goto err; 172 goto err;
173 } 173 }
174 174
175 /* remove the device in another thread to fix the deadlock issue */ 175 acpi_os_hotplug_execute(acpi_bus_hot_remove_device, acpi_device->handle);
176 task = kthread_run(acpi_bus_hot_remove_device,
177 acpi_device->handle, "acpi_hot_remove_device");
178 if (IS_ERR(task))
179 ret = PTR_ERR(task);
180err: 176err:
181 return ret; 177 return ret;
182} 178}
@@ -198,12 +194,12 @@ acpi_device_path_show(struct device *dev, struct device_attribute *attr, char *b
198 int result; 194 int result;
199 195
200 result = acpi_get_name(acpi_dev->handle, ACPI_FULL_PATHNAME, &path); 196 result = acpi_get_name(acpi_dev->handle, ACPI_FULL_PATHNAME, &path);
201 if(result) 197 if (result)
202 goto end; 198 goto end;
203 199
204 result = sprintf(buf, "%s\n", (char*)path.pointer); 200 result = sprintf(buf, "%s\n", (char*)path.pointer);
205 kfree(path.pointer); 201 kfree(path.pointer);
206 end: 202end:
207 return result; 203 return result;
208} 204}
209static DEVICE_ATTR(path, 0444, acpi_device_path_show, NULL); 205static DEVICE_ATTR(path, 0444, acpi_device_path_show, NULL);
@@ -217,21 +213,21 @@ static int acpi_device_setup_files(struct acpi_device *dev)
217 /* 213 /*
218 * Devices gotten from FADT don't have a "path" attribute 214 * Devices gotten from FADT don't have a "path" attribute
219 */ 215 */
220 if(dev->handle) { 216 if (dev->handle) {
221 result = device_create_file(&dev->dev, &dev_attr_path); 217 result = device_create_file(&dev->dev, &dev_attr_path);
222 if(result) 218 if (result)
223 goto end; 219 goto end;
224 } 220 }
225 221
226 if(dev->flags.hardware_id) { 222 if (dev->flags.hardware_id) {
227 result = device_create_file(&dev->dev, &dev_attr_hid); 223 result = device_create_file(&dev->dev, &dev_attr_hid);
228 if(result) 224 if (result)
229 goto end; 225 goto end;
230 } 226 }
231 227
232 if (dev->flags.hardware_id || dev->flags.compatible_ids){ 228 if (dev->flags.hardware_id || dev->flags.compatible_ids) {
233 result = device_create_file(&dev->dev, &dev_attr_modalias); 229 result = device_create_file(&dev->dev, &dev_attr_modalias);
234 if(result) 230 if (result)
235 goto end; 231 goto end;
236 } 232 }
237 233
@@ -242,7 +238,7 @@ static int acpi_device_setup_files(struct acpi_device *dev)
242 status = acpi_get_handle(dev->handle, "_EJ0", &temp); 238 status = acpi_get_handle(dev->handle, "_EJ0", &temp);
243 if (ACPI_SUCCESS(status)) 239 if (ACPI_SUCCESS(status))
244 result = device_create_file(&dev->dev, &dev_attr_eject); 240 result = device_create_file(&dev->dev, &dev_attr_eject);
245 end: 241end:
246 return result; 242 return result;
247} 243}
248 244
@@ -262,9 +258,9 @@ static void acpi_device_remove_files(struct acpi_device *dev)
262 if (dev->flags.hardware_id || dev->flags.compatible_ids) 258 if (dev->flags.hardware_id || dev->flags.compatible_ids)
263 device_remove_file(&dev->dev, &dev_attr_modalias); 259 device_remove_file(&dev->dev, &dev_attr_modalias);
264 260
265 if(dev->flags.hardware_id) 261 if (dev->flags.hardware_id)
266 device_remove_file(&dev->dev, &dev_attr_hid); 262 device_remove_file(&dev->dev, &dev_attr_hid);
267 if(dev->handle) 263 if (dev->handle)
268 device_remove_file(&dev->dev, &dev_attr_path); 264 device_remove_file(&dev->dev, &dev_attr_path);
269} 265}
270/* -------------------------------------------------------------------------- 266/* --------------------------------------------------------------------------
@@ -512,7 +508,7 @@ static int acpi_device_register(struct acpi_device *device,
512 break; 508 break;
513 } 509 }
514 } 510 }
515 if(!found) { 511 if (!found) {
516 acpi_device_bus_id = new_bus_id; 512 acpi_device_bus_id = new_bus_id;
517 strcpy(acpi_device_bus_id->bus_id, device->flags.hardware_id ? device->pnp.hardware_id : "device"); 513 strcpy(acpi_device_bus_id->bus_id, device->flags.hardware_id ? device->pnp.hardware_id : "device");
518 acpi_device_bus_id->instance_no = 0; 514 acpi_device_bus_id->instance_no = 0;
@@ -530,22 +526,21 @@ static int acpi_device_register(struct acpi_device *device,
530 if (device->parent) 526 if (device->parent)
531 device->dev.parent = &parent->dev; 527 device->dev.parent = &parent->dev;
532 device->dev.bus = &acpi_bus_type; 528 device->dev.bus = &acpi_bus_type;
533 device_initialize(&device->dev);
534 device->dev.release = &acpi_device_release; 529 device->dev.release = &acpi_device_release;
535 result = device_add(&device->dev); 530 result = device_register(&device->dev);
536 if(result) { 531 if (result) {
537 dev_err(&device->dev, "Error adding device\n"); 532 dev_err(&device->dev, "Error registering device\n");
538 goto end; 533 goto end;
539 } 534 }
540 535
541 result = acpi_device_setup_files(device); 536 result = acpi_device_setup_files(device);
542 if(result) 537 if (result)
543 printk(KERN_ERR PREFIX "Error creating sysfs interface for device %s\n", 538 printk(KERN_ERR PREFIX "Error creating sysfs interface for device %s\n",
544 dev_name(&device->dev)); 539 dev_name(&device->dev));
545 540
546 device->removal_type = ACPI_BUS_REMOVAL_NORMAL; 541 device->removal_type = ACPI_BUS_REMOVAL_NORMAL;
547 return 0; 542 return 0;
548 end: 543end:
549 mutex_lock(&acpi_device_lock); 544 mutex_lock(&acpi_device_lock);
550 if (device->parent) 545 if (device->parent)
551 list_del(&device->node); 546 list_del(&device->node);
@@ -577,7 +572,7 @@ static void acpi_device_unregister(struct acpi_device *device, int type)
577 * @device: the device to add and initialize 572 * @device: the device to add and initialize
578 * @driver: driver for the device 573 * @driver: driver for the device
579 * 574 *
580 * Used to initialize a device via its device driver. Called whenever a 575 * Used to initialize a device via its device driver. Called whenever a
581 * driver is bound to a device. Invokes the driver's add() ops. 576 * driver is bound to a device. Invokes the driver's add() ops.
582 */ 577 */
583static int 578static int
@@ -585,7 +580,6 @@ acpi_bus_driver_init(struct acpi_device *device, struct acpi_driver *driver)
585{ 580{
586 int result = 0; 581 int result = 0;
587 582
588
589 if (!device || !driver) 583 if (!device || !driver)
590 return -EINVAL; 584 return -EINVAL;
591 585
@@ -802,7 +796,7 @@ static int acpi_bus_get_wakeup_device_flags(struct acpi_device *device)
802 if (!acpi_match_device_ids(device, button_device_ids)) 796 if (!acpi_match_device_ids(device, button_device_ids))
803 device->wakeup.flags.run_wake = 1; 797 device->wakeup.flags.run_wake = 1;
804 798
805 end: 799end:
806 if (ACPI_FAILURE(status)) 800 if (ACPI_FAILURE(status))
807 device->flags.wake_capable = 0; 801 device->flags.wake_capable = 0;
808 return 0; 802 return 0;
@@ -1070,7 +1064,7 @@ static void acpi_device_set_id(struct acpi_device *device,
1070 break; 1064 break;
1071 } 1065 }
1072 1066
1073 /* 1067 /*
1074 * \_SB 1068 * \_SB
1075 * ---- 1069 * ----
1076 * Fix for the system root bus device -- the only root-level device. 1070 * Fix for the system root bus device -- the only root-level device.
@@ -1320,7 +1314,7 @@ acpi_add_single_object(struct acpi_device **child,
1320 device->parent->ops.bind(device); 1314 device->parent->ops.bind(device);
1321 } 1315 }
1322 1316
1323 end: 1317end:
1324 if (!result) 1318 if (!result)
1325 *child = device; 1319 *child = device;
1326 else { 1320 else {
@@ -1464,7 +1458,6 @@ acpi_bus_add(struct acpi_device **child,
1464 1458
1465 return result; 1459 return result;
1466} 1460}
1467
1468EXPORT_SYMBOL(acpi_bus_add); 1461EXPORT_SYMBOL(acpi_bus_add);
1469 1462
1470int acpi_bus_start(struct acpi_device *device) 1463int acpi_bus_start(struct acpi_device *device)
@@ -1484,7 +1477,6 @@ int acpi_bus_start(struct acpi_device *device)
1484 } 1477 }
1485 return result; 1478 return result;
1486} 1479}
1487
1488EXPORT_SYMBOL(acpi_bus_start); 1480EXPORT_SYMBOL(acpi_bus_start);
1489 1481
1490int acpi_bus_trim(struct acpi_device *start, int rmdevice) 1482int acpi_bus_trim(struct acpi_device *start, int rmdevice)
@@ -1542,7 +1534,6 @@ int acpi_bus_trim(struct acpi_device *start, int rmdevice)
1542} 1534}
1543EXPORT_SYMBOL_GPL(acpi_bus_trim); 1535EXPORT_SYMBOL_GPL(acpi_bus_trim);
1544 1536
1545
1546static int acpi_bus_scan_fixed(struct acpi_device *root) 1537static int acpi_bus_scan_fixed(struct acpi_device *root)
1547{ 1538{
1548 int result = 0; 1539 int result = 0;
@@ -1610,6 +1601,6 @@ int __init acpi_scan_init(void)
1610 if (result) 1601 if (result)
1611 acpi_device_unregister(acpi_root, ACPI_BUS_REMOVAL_NORMAL); 1602 acpi_device_unregister(acpi_root, ACPI_BUS_REMOVAL_NORMAL);
1612 1603
1613 Done: 1604Done:
1614 return result; 1605 return result;
1615} 1606}