scan.c 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381
  1. /*
  2. * scan.c - support for transforming the ACPI namespace into individual objects
  3. */
  4. #include <linux/module.h>
  5. #include <linux/init.h>
  6. #include <linux/acpi.h>
  7. #include <acpi/acpi_drivers.h>
  8. #include <acpi/acinterp.h> /* for acpi_ex_eisa_id_to_string() */
  9. #define _COMPONENT ACPI_BUS_COMPONENT
  10. ACPI_MODULE_NAME ("scan")
  11. #define STRUCT_TO_INT(s) (*((int*)&s))
  12. extern struct acpi_device *acpi_root;
  13. #define ACPI_BUS_CLASS "system_bus"
  14. #define ACPI_BUS_HID "ACPI_BUS"
  15. #define ACPI_BUS_DRIVER_NAME "ACPI Bus Driver"
  16. #define ACPI_BUS_DEVICE_NAME "System Bus"
  17. static LIST_HEAD(acpi_device_list);
  18. DEFINE_SPINLOCK(acpi_device_lock);
  19. LIST_HEAD(acpi_wakeup_device_list);
  20. static int
  21. acpi_bus_trim(struct acpi_device *start,
  22. int rmdevice);
  23. static void acpi_device_release(struct kobject * kobj)
  24. {
  25. struct acpi_device * dev = container_of(kobj,struct acpi_device,kobj);
  26. if (dev->pnp.cid_list)
  27. kfree(dev->pnp.cid_list);
  28. kfree(dev);
  29. }
  30. struct acpi_device_attribute {
  31. struct attribute attr;
  32. ssize_t (*show)(struct acpi_device *, char *);
  33. ssize_t (*store)(struct acpi_device *, const char *, size_t);
  34. };
  35. typedef void acpi_device_sysfs_files(struct kobject *,
  36. const struct attribute *);
  37. static void setup_sys_fs_device_files(struct acpi_device *dev,
  38. acpi_device_sysfs_files *func);
  39. #define create_sysfs_device_files(dev) \
  40. setup_sys_fs_device_files(dev, (acpi_device_sysfs_files *)&sysfs_create_file)
  41. #define remove_sysfs_device_files(dev) \
  42. setup_sys_fs_device_files(dev, (acpi_device_sysfs_files *)&sysfs_remove_file)
  43. #define to_acpi_device(n) container_of(n, struct acpi_device, kobj)
  44. #define to_handle_attr(n) container_of(n, struct acpi_device_attribute, attr);
  45. static ssize_t acpi_device_attr_show(struct kobject *kobj,
  46. struct attribute *attr, char *buf)
  47. {
  48. struct acpi_device *device = to_acpi_device(kobj);
  49. struct acpi_device_attribute *attribute = to_handle_attr(attr);
  50. return attribute->show ? attribute->show(device, buf) : 0;
  51. }
  52. static ssize_t acpi_device_attr_store(struct kobject *kobj,
  53. struct attribute *attr, const char *buf, size_t len)
  54. {
  55. struct acpi_device *device = to_acpi_device(kobj);
  56. struct acpi_device_attribute *attribute = to_handle_attr(attr);
  57. return attribute->store ? attribute->store(device, buf, len) : len;
  58. }
  59. static struct sysfs_ops acpi_device_sysfs_ops = {
  60. .show = acpi_device_attr_show,
  61. .store = acpi_device_attr_store,
  62. };
  63. static struct kobj_type ktype_acpi_ns = {
  64. .sysfs_ops = &acpi_device_sysfs_ops,
  65. .release = acpi_device_release,
  66. };
  67. static int namespace_hotplug(struct kset *kset, struct kobject *kobj,
  68. char **envp, int num_envp, char *buffer,
  69. int buffer_size)
  70. {
  71. struct acpi_device *dev = to_acpi_device(kobj);
  72. int i = 0;
  73. int len = 0;
  74. if (!dev->driver)
  75. return 0;
  76. if (add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size, &len,
  77. "PHYSDEVDRIVER=%s", dev->driver->name))
  78. return -ENOMEM;
  79. envp[i] = NULL;
  80. return 0;
  81. }
  82. static struct kset_hotplug_ops namespace_hotplug_ops = {
  83. .hotplug = &namespace_hotplug,
  84. };
  85. static struct kset acpi_namespace_kset = {
  86. .kobj = {
  87. .name = "namespace",
  88. },
  89. .subsys = &acpi_subsys,
  90. .ktype = &ktype_acpi_ns,
  91. .hotplug_ops = &namespace_hotplug_ops,
  92. };
  93. static void acpi_device_register(struct acpi_device * device, struct acpi_device * parent)
  94. {
  95. /*
  96. * Linkage
  97. * -------
  98. * Link this device to its parent and siblings.
  99. */
  100. INIT_LIST_HEAD(&device->children);
  101. INIT_LIST_HEAD(&device->node);
  102. INIT_LIST_HEAD(&device->g_list);
  103. INIT_LIST_HEAD(&device->wakeup_list);
  104. spin_lock(&acpi_device_lock);
  105. if (device->parent) {
  106. list_add_tail(&device->node, &device->parent->children);
  107. list_add_tail(&device->g_list,&device->parent->g_list);
  108. } else
  109. list_add_tail(&device->g_list,&acpi_device_list);
  110. if (device->wakeup.flags.valid)
  111. list_add_tail(&device->wakeup_list,&acpi_wakeup_device_list);
  112. spin_unlock(&acpi_device_lock);
  113. strlcpy(device->kobj.name,device->pnp.bus_id,KOBJ_NAME_LEN);
  114. if (parent)
  115. device->kobj.parent = &parent->kobj;
  116. device->kobj.ktype = &ktype_acpi_ns;
  117. device->kobj.kset = &acpi_namespace_kset;
  118. kobject_register(&device->kobj);
  119. create_sysfs_device_files(device);
  120. }
  121. static int
  122. acpi_device_unregister (
  123. struct acpi_device *device,
  124. int type)
  125. {
  126. spin_lock(&acpi_device_lock);
  127. if (device->parent) {
  128. list_del(&device->node);
  129. list_del(&device->g_list);
  130. } else
  131. list_del(&device->g_list);
  132. list_del(&device->wakeup_list);
  133. spin_unlock(&acpi_device_lock);
  134. acpi_detach_data(device->handle, acpi_bus_data_handler);
  135. remove_sysfs_device_files(device);
  136. kobject_unregister(&device->kobj);
  137. return 0;
  138. }
  139. void
  140. acpi_bus_data_handler (
  141. acpi_handle handle,
  142. u32 function,
  143. void *context)
  144. {
  145. ACPI_FUNCTION_TRACE("acpi_bus_data_handler");
  146. /* TBD */
  147. return_VOID;
  148. }
  149. static int
  150. acpi_bus_get_power_flags (
  151. struct acpi_device *device)
  152. {
  153. acpi_status status = 0;
  154. acpi_handle handle = NULL;
  155. u32 i = 0;
  156. ACPI_FUNCTION_TRACE("acpi_bus_get_power_flags");
  157. /*
  158. * Power Management Flags
  159. */
  160. status = acpi_get_handle(device->handle, "_PSC", &handle);
  161. if (ACPI_SUCCESS(status))
  162. device->power.flags.explicit_get = 1;
  163. status = acpi_get_handle(device->handle, "_IRC", &handle);
  164. if (ACPI_SUCCESS(status))
  165. device->power.flags.inrush_current = 1;
  166. /*
  167. * Enumerate supported power management states
  168. */
  169. for (i = ACPI_STATE_D0; i <= ACPI_STATE_D3; i++) {
  170. struct acpi_device_power_state *ps = &device->power.states[i];
  171. char object_name[5] = {'_','P','R','0'+i,'\0'};
  172. /* Evaluate "_PRx" to se if power resources are referenced */
  173. acpi_evaluate_reference(device->handle, object_name, NULL,
  174. &ps->resources);
  175. if (ps->resources.count) {
  176. device->power.flags.power_resources = 1;
  177. ps->flags.valid = 1;
  178. }
  179. /* Evaluate "_PSx" to see if we can do explicit sets */
  180. object_name[2] = 'S';
  181. status = acpi_get_handle(device->handle, object_name, &handle);
  182. if (ACPI_SUCCESS(status)) {
  183. ps->flags.explicit_set = 1;
  184. ps->flags.valid = 1;
  185. }
  186. /* State is valid if we have some power control */
  187. if (ps->resources.count || ps->flags.explicit_set)
  188. ps->flags.valid = 1;
  189. ps->power = -1; /* Unknown - driver assigned */
  190. ps->latency = -1; /* Unknown - driver assigned */
  191. }
  192. /* Set defaults for D0 and D3 states (always valid) */
  193. device->power.states[ACPI_STATE_D0].flags.valid = 1;
  194. device->power.states[ACPI_STATE_D0].power = 100;
  195. device->power.states[ACPI_STATE_D3].flags.valid = 1;
  196. device->power.states[ACPI_STATE_D3].power = 0;
  197. /* TBD: System wake support and resource requirements. */
  198. device->power.state = ACPI_STATE_UNKNOWN;
  199. return_VALUE(0);
  200. }
  201. int
  202. acpi_match_ids (
  203. struct acpi_device *device,
  204. char *ids)
  205. {
  206. int error = 0;
  207. struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
  208. if (device->flags.hardware_id)
  209. if (strstr(ids, device->pnp.hardware_id))
  210. goto Done;
  211. if (device->flags.compatible_ids) {
  212. struct acpi_compatible_id_list *cid_list = device->pnp.cid_list;
  213. int i;
  214. /* compare multiple _CID entries against driver ids */
  215. for (i = 0; i < cid_list->count; i++)
  216. {
  217. if (strstr(ids, cid_list->id[i].value))
  218. goto Done;
  219. }
  220. }
  221. error = -ENOENT;
  222. Done:
  223. if (buffer.pointer)
  224. acpi_os_free(buffer.pointer);
  225. return error;
  226. }
  227. static acpi_status
  228. acpi_bus_extract_wakeup_device_power_package (
  229. struct acpi_device *device,
  230. union acpi_object *package)
  231. {
  232. int i = 0;
  233. union acpi_object *element = NULL;
  234. if (!device || !package || (package->package.count < 2))
  235. return AE_BAD_PARAMETER;
  236. element = &(package->package.elements[0]);
  237. if (!element)
  238. return AE_BAD_PARAMETER;
  239. if (element->type == ACPI_TYPE_PACKAGE) {
  240. if ((element->package.count < 2) ||
  241. (element->package.elements[0].type != ACPI_TYPE_LOCAL_REFERENCE) ||
  242. (element->package.elements[1].type != ACPI_TYPE_INTEGER))
  243. return AE_BAD_DATA;
  244. device->wakeup.gpe_device = element->package.elements[0].reference.handle;
  245. device->wakeup.gpe_number = (u32)element->package.elements[1].integer.value;
  246. }else if (element->type == ACPI_TYPE_INTEGER) {
  247. device->wakeup.gpe_number = element->integer.value;
  248. }else
  249. return AE_BAD_DATA;
  250. element = &(package->package.elements[1]);
  251. if (element->type != ACPI_TYPE_INTEGER) {
  252. return AE_BAD_DATA;
  253. }
  254. device->wakeup.sleep_state = element->integer.value;
  255. if ((package->package.count - 2) > ACPI_MAX_HANDLES) {
  256. return AE_NO_MEMORY;
  257. }
  258. device->wakeup.resources.count = package->package.count - 2;
  259. for (i=0; i < device->wakeup.resources.count; i++) {
  260. element = &(package->package.elements[i + 2]);
  261. if (element->type != ACPI_TYPE_ANY ) {
  262. return AE_BAD_DATA;
  263. }
  264. device->wakeup.resources.handles[i] = element->reference.handle;
  265. }
  266. return AE_OK;
  267. }
  268. static int
  269. acpi_bus_get_wakeup_device_flags (
  270. struct acpi_device *device)
  271. {
  272. acpi_status status = 0;
  273. struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
  274. union acpi_object *package = NULL;
  275. ACPI_FUNCTION_TRACE("acpi_bus_get_wakeup_flags");
  276. /* _PRW */
  277. status = acpi_evaluate_object(device->handle, "_PRW", NULL, &buffer);
  278. if (ACPI_FAILURE(status)) {
  279. ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PRW\n"));
  280. goto end;
  281. }
  282. package = (union acpi_object *) buffer.pointer;
  283. status = acpi_bus_extract_wakeup_device_power_package(device, package);
  284. if (ACPI_FAILURE(status)) {
  285. ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error extracting _PRW package\n"));
  286. goto end;
  287. }
  288. acpi_os_free(buffer.pointer);
  289. device->wakeup.flags.valid = 1;
  290. /* Power button, Lid switch always enable wakeup*/
  291. if (!acpi_match_ids(device, "PNP0C0D,PNP0C0C,PNP0C0E"))
  292. device->wakeup.flags.run_wake = 1;
  293. end:
  294. if (ACPI_FAILURE(status))
  295. device->flags.wake_capable = 0;
  296. return_VALUE(0);
  297. }
  298. /* --------------------------------------------------------------------------
  299. ACPI hotplug sysfs device file support
  300. -------------------------------------------------------------------------- */
  301. static ssize_t acpi_eject_store(struct acpi_device *device,
  302. const char *buf, size_t count);
  303. #define ACPI_DEVICE_ATTR(_name,_mode,_show,_store) \
  304. static struct acpi_device_attribute acpi_device_attr_##_name = \
  305. __ATTR(_name, _mode, _show, _store)
  306. ACPI_DEVICE_ATTR(eject, 0200, NULL, acpi_eject_store);
  307. /**
  308. * setup_sys_fs_device_files - sets up the device files under device namespace
  309. * @dev: acpi_device object
  310. * @func: function pointer to create or destroy the device file
  311. */
  312. static void
  313. setup_sys_fs_device_files (
  314. struct acpi_device *dev,
  315. acpi_device_sysfs_files *func)
  316. {
  317. acpi_status status;
  318. acpi_handle temp = NULL;
  319. /*
  320. * If device has _EJ0, 'eject' file is created that is used to trigger
  321. * hot-removal function from userland.
  322. */
  323. status = acpi_get_handle(dev->handle, "_EJ0", &temp);
  324. if (ACPI_SUCCESS(status))
  325. (*(func))(&dev->kobj,&acpi_device_attr_eject.attr);
  326. }
  327. static int
  328. acpi_eject_operation(acpi_handle handle, int lockable)
  329. {
  330. struct acpi_object_list arg_list;
  331. union acpi_object arg;
  332. acpi_status status = AE_OK;
  333. /*
  334. * TBD: evaluate _PS3?
  335. */
  336. if (lockable) {
  337. arg_list.count = 1;
  338. arg_list.pointer = &arg;
  339. arg.type = ACPI_TYPE_INTEGER;
  340. arg.integer.value = 0;
  341. acpi_evaluate_object(handle, "_LCK", &arg_list, NULL);
  342. }
  343. arg_list.count = 1;
  344. arg_list.pointer = &arg;
  345. arg.type = ACPI_TYPE_INTEGER;
  346. arg.integer.value = 1;
  347. /*
  348. * TBD: _EJD support.
  349. */
  350. status = acpi_evaluate_object(handle, "_EJ0", &arg_list, NULL);
  351. if (ACPI_FAILURE(status)) {
  352. return(-ENODEV);
  353. }
  354. return(0);
  355. }
  356. static ssize_t
  357. acpi_eject_store(struct acpi_device *device, const char *buf, size_t count)
  358. {
  359. int result;
  360. int ret = count;
  361. int islockable;
  362. acpi_status status;
  363. acpi_handle handle;
  364. acpi_object_type type = 0;
  365. if ((!count) || (buf[0] != '1')) {
  366. return -EINVAL;
  367. }
  368. #ifndef FORCE_EJECT
  369. if (device->driver == NULL) {
  370. ret = -ENODEV;
  371. goto err;
  372. }
  373. #endif
  374. status = acpi_get_type(device->handle, &type);
  375. if (ACPI_FAILURE(status) || (!device->flags.ejectable) ) {
  376. ret = -ENODEV;
  377. goto err;
  378. }
  379. islockable = device->flags.lockable;
  380. handle = device->handle;
  381. if (type == ACPI_TYPE_PROCESSOR)
  382. result = acpi_bus_trim(device, 0);
  383. else
  384. result = acpi_bus_trim(device, 1);
  385. if (!result)
  386. result = acpi_eject_operation(handle, islockable);
  387. if (result) {
  388. ret = -EBUSY;
  389. }
  390. err:
  391. return ret;
  392. }
  393. /* --------------------------------------------------------------------------
  394. Performance Management
  395. -------------------------------------------------------------------------- */
  396. static int
  397. acpi_bus_get_perf_flags (
  398. struct acpi_device *device)
  399. {
  400. device->performance.state = ACPI_STATE_UNKNOWN;
  401. return 0;
  402. }
  403. /* --------------------------------------------------------------------------
  404. Driver Management
  405. -------------------------------------------------------------------------- */
  406. static LIST_HEAD(acpi_bus_drivers);
  407. static DECLARE_MUTEX(acpi_bus_drivers_lock);
  408. /**
  409. * acpi_bus_match
  410. * --------------
  411. * Checks the device's hardware (_HID) or compatible (_CID) ids to see if it
  412. * matches the specified driver's criteria.
  413. */
  414. static int
  415. acpi_bus_match (
  416. struct acpi_device *device,
  417. struct acpi_driver *driver)
  418. {
  419. if (driver && driver->ops.match)
  420. return driver->ops.match(device, driver);
  421. return acpi_match_ids(device, driver->ids);
  422. }
  423. /**
  424. * acpi_bus_driver_init
  425. * --------------------
  426. * Used to initialize a device via its device driver. Called whenever a
  427. * driver is bound to a device. Invokes the driver's add() and start() ops.
  428. */
  429. static int
  430. acpi_bus_driver_init (
  431. struct acpi_device *device,
  432. struct acpi_driver *driver)
  433. {
  434. int result = 0;
  435. ACPI_FUNCTION_TRACE("acpi_bus_driver_init");
  436. if (!device || !driver)
  437. return_VALUE(-EINVAL);
  438. if (!driver->ops.add)
  439. return_VALUE(-ENOSYS);
  440. result = driver->ops.add(device);
  441. if (result) {
  442. device->driver = NULL;
  443. acpi_driver_data(device) = NULL;
  444. return_VALUE(result);
  445. }
  446. device->driver = driver;
  447. /*
  448. * TBD - Configuration Management: Assign resources to device based
  449. * upon possible configuration and currently allocated resources.
  450. */
  451. if (driver->ops.start) {
  452. result = driver->ops.start(device);
  453. if (result && driver->ops.remove)
  454. driver->ops.remove(device, ACPI_BUS_REMOVAL_NORMAL);
  455. return_VALUE(result);
  456. }
  457. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Driver successfully bound to device\n"));
  458. if (driver->ops.scan) {
  459. driver->ops.scan(device);
  460. }
  461. return_VALUE(0);
  462. }
  463. static int acpi_driver_attach(struct acpi_driver * drv)
  464. {
  465. struct list_head * node, * next;
  466. int count = 0;
  467. ACPI_FUNCTION_TRACE("acpi_driver_attach");
  468. spin_lock(&acpi_device_lock);
  469. list_for_each_safe(node, next, &acpi_device_list) {
  470. struct acpi_device * dev = container_of(node, struct acpi_device, g_list);
  471. if (dev->driver || !dev->status.present)
  472. continue;
  473. spin_unlock(&acpi_device_lock);
  474. if (!acpi_bus_match(dev, drv)) {
  475. if (!acpi_bus_driver_init(dev, drv)) {
  476. atomic_inc(&drv->references);
  477. count++;
  478. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found driver [%s] for device [%s]\n",
  479. drv->name, dev->pnp.bus_id));
  480. }
  481. }
  482. spin_lock(&acpi_device_lock);
  483. }
  484. spin_unlock(&acpi_device_lock);
  485. return_VALUE(count);
  486. }
  487. static int acpi_driver_detach(struct acpi_driver * drv)
  488. {
  489. struct list_head * node, * next;
  490. ACPI_FUNCTION_TRACE("acpi_driver_detach");
  491. spin_lock(&acpi_device_lock);
  492. list_for_each_safe(node,next,&acpi_device_list) {
  493. struct acpi_device * dev = container_of(node,struct acpi_device,g_list);
  494. if (dev->driver == drv) {
  495. spin_unlock(&acpi_device_lock);
  496. if (drv->ops.remove)
  497. drv->ops.remove(dev,ACPI_BUS_REMOVAL_NORMAL);
  498. spin_lock(&acpi_device_lock);
  499. dev->driver = NULL;
  500. dev->driver_data = NULL;
  501. atomic_dec(&drv->references);
  502. }
  503. }
  504. spin_unlock(&acpi_device_lock);
  505. return_VALUE(0);
  506. }
  507. /**
  508. * acpi_bus_register_driver
  509. * ------------------------
  510. * Registers a driver with the ACPI bus. Searches the namespace for all
  511. * devices that match the driver's criteria and binds. Returns the
  512. * number of devices that were claimed by the driver, or a negative
  513. * error status for failure.
  514. */
  515. int
  516. acpi_bus_register_driver (
  517. struct acpi_driver *driver)
  518. {
  519. int count;
  520. ACPI_FUNCTION_TRACE("acpi_bus_register_driver");
  521. if (acpi_disabled)
  522. return_VALUE(-ENODEV);
  523. if (!driver)
  524. return_VALUE(-EINVAL);
  525. spin_lock(&acpi_device_lock);
  526. list_add_tail(&driver->node, &acpi_bus_drivers);
  527. spin_unlock(&acpi_device_lock);
  528. count = acpi_driver_attach(driver);
  529. return_VALUE(count);
  530. }
  531. EXPORT_SYMBOL(acpi_bus_register_driver);
  532. /**
  533. * acpi_bus_unregister_driver
  534. * --------------------------
  535. * Unregisters a driver with the ACPI bus. Searches the namespace for all
  536. * devices that match the driver's criteria and unbinds.
  537. */
  538. int
  539. acpi_bus_unregister_driver (
  540. struct acpi_driver *driver)
  541. {
  542. int error = 0;
  543. ACPI_FUNCTION_TRACE("acpi_bus_unregister_driver");
  544. if (driver) {
  545. acpi_driver_detach(driver);
  546. if (!atomic_read(&driver->references)) {
  547. spin_lock(&acpi_device_lock);
  548. list_del_init(&driver->node);
  549. spin_unlock(&acpi_device_lock);
  550. }
  551. } else
  552. error = -EINVAL;
  553. return_VALUE(error);
  554. }
  555. EXPORT_SYMBOL(acpi_bus_unregister_driver);
  556. /**
  557. * acpi_bus_find_driver
  558. * --------------------
  559. * Parses the list of registered drivers looking for a driver applicable for
  560. * the specified device.
  561. */
  562. static int
  563. acpi_bus_find_driver (
  564. struct acpi_device *device)
  565. {
  566. int result = 0;
  567. struct list_head * node, *next;
  568. ACPI_FUNCTION_TRACE("acpi_bus_find_driver");
  569. spin_lock(&acpi_device_lock);
  570. list_for_each_safe(node,next,&acpi_bus_drivers) {
  571. struct acpi_driver * driver = container_of(node,struct acpi_driver,node);
  572. atomic_inc(&driver->references);
  573. spin_unlock(&acpi_device_lock);
  574. if (!acpi_bus_match(device, driver)) {
  575. result = acpi_bus_driver_init(device, driver);
  576. if (!result)
  577. goto Done;
  578. }
  579. atomic_dec(&driver->references);
  580. spin_lock(&acpi_device_lock);
  581. }
  582. spin_unlock(&acpi_device_lock);
  583. Done:
  584. return_VALUE(result);
  585. }
  586. /* --------------------------------------------------------------------------
  587. Device Enumeration
  588. -------------------------------------------------------------------------- */
  589. static int
  590. acpi_bus_get_flags (
  591. struct acpi_device *device)
  592. {
  593. acpi_status status = AE_OK;
  594. acpi_handle temp = NULL;
  595. ACPI_FUNCTION_TRACE("acpi_bus_get_flags");
  596. /* Presence of _STA indicates 'dynamic_status' */
  597. status = acpi_get_handle(device->handle, "_STA", &temp);
  598. if (ACPI_SUCCESS(status))
  599. device->flags.dynamic_status = 1;
  600. /* Presence of _CID indicates 'compatible_ids' */
  601. status = acpi_get_handle(device->handle, "_CID", &temp);
  602. if (ACPI_SUCCESS(status))
  603. device->flags.compatible_ids = 1;
  604. /* Presence of _RMV indicates 'removable' */
  605. status = acpi_get_handle(device->handle, "_RMV", &temp);
  606. if (ACPI_SUCCESS(status))
  607. device->flags.removable = 1;
  608. /* Presence of _EJD|_EJ0 indicates 'ejectable' */
  609. status = acpi_get_handle(device->handle, "_EJD", &temp);
  610. if (ACPI_SUCCESS(status))
  611. device->flags.ejectable = 1;
  612. else {
  613. status = acpi_get_handle(device->handle, "_EJ0", &temp);
  614. if (ACPI_SUCCESS(status))
  615. device->flags.ejectable = 1;
  616. }
  617. /* Presence of _LCK indicates 'lockable' */
  618. status = acpi_get_handle(device->handle, "_LCK", &temp);
  619. if (ACPI_SUCCESS(status))
  620. device->flags.lockable = 1;
  621. /* Presence of _PS0|_PR0 indicates 'power manageable' */
  622. status = acpi_get_handle(device->handle, "_PS0", &temp);
  623. if (ACPI_FAILURE(status))
  624. status = acpi_get_handle(device->handle, "_PR0", &temp);
  625. if (ACPI_SUCCESS(status))
  626. device->flags.power_manageable = 1;
  627. /* Presence of _PRW indicates wake capable */
  628. status = acpi_get_handle(device->handle, "_PRW", &temp);
  629. if (ACPI_SUCCESS(status))
  630. device->flags.wake_capable = 1;
  631. /* TBD: Peformance management */
  632. return_VALUE(0);
  633. }
  634. static void acpi_device_get_busid(struct acpi_device * device, acpi_handle handle, int type)
  635. {
  636. char bus_id[5] = {'?',0};
  637. struct acpi_buffer buffer = {sizeof(bus_id), bus_id};
  638. int i = 0;
  639. /*
  640. * Bus ID
  641. * ------
  642. * The device's Bus ID is simply the object name.
  643. * TBD: Shouldn't this value be unique (within the ACPI namespace)?
  644. */
  645. switch (type) {
  646. case ACPI_BUS_TYPE_SYSTEM:
  647. strcpy(device->pnp.bus_id, "ACPI");
  648. break;
  649. case ACPI_BUS_TYPE_POWER_BUTTON:
  650. strcpy(device->pnp.bus_id, "PWRF");
  651. break;
  652. case ACPI_BUS_TYPE_SLEEP_BUTTON:
  653. strcpy(device->pnp.bus_id, "SLPF");
  654. break;
  655. default:
  656. acpi_get_name(handle, ACPI_SINGLE_NAME, &buffer);
  657. /* Clean up trailing underscores (if any) */
  658. for (i = 3; i > 1; i--) {
  659. if (bus_id[i] == '_')
  660. bus_id[i] = '\0';
  661. else
  662. break;
  663. }
  664. strcpy(device->pnp.bus_id, bus_id);
  665. break;
  666. }
  667. }
  668. static void acpi_device_set_id(struct acpi_device * device, struct acpi_device * parent,
  669. acpi_handle handle, int type)
  670. {
  671. struct acpi_device_info *info;
  672. struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
  673. char *hid = NULL;
  674. char *uid = NULL;
  675. struct acpi_compatible_id_list *cid_list = NULL;
  676. acpi_status status;
  677. switch (type) {
  678. case ACPI_BUS_TYPE_DEVICE:
  679. status = acpi_get_object_info(handle, &buffer);
  680. if (ACPI_FAILURE(status)) {
  681. printk("%s: Error reading device info\n",__FUNCTION__);
  682. return;
  683. }
  684. info = buffer.pointer;
  685. if (info->valid & ACPI_VALID_HID)
  686. hid = info->hardware_id.value;
  687. if (info->valid & ACPI_VALID_UID)
  688. uid = info->unique_id.value;
  689. if (info->valid & ACPI_VALID_CID)
  690. cid_list = &info->compatibility_id;
  691. if (info->valid & ACPI_VALID_ADR) {
  692. device->pnp.bus_address = info->address;
  693. device->flags.bus_address = 1;
  694. }
  695. break;
  696. case ACPI_BUS_TYPE_POWER:
  697. hid = ACPI_POWER_HID;
  698. break;
  699. case ACPI_BUS_TYPE_PROCESSOR:
  700. hid = ACPI_PROCESSOR_HID;
  701. break;
  702. case ACPI_BUS_TYPE_SYSTEM:
  703. hid = ACPI_SYSTEM_HID;
  704. break;
  705. case ACPI_BUS_TYPE_THERMAL:
  706. hid = ACPI_THERMAL_HID;
  707. break;
  708. case ACPI_BUS_TYPE_POWER_BUTTON:
  709. hid = ACPI_BUTTON_HID_POWERF;
  710. break;
  711. case ACPI_BUS_TYPE_SLEEP_BUTTON:
  712. hid = ACPI_BUTTON_HID_SLEEPF;
  713. break;
  714. }
  715. /*
  716. * \_SB
  717. * ----
  718. * Fix for the system root bus device -- the only root-level device.
  719. */
  720. if ((parent == ACPI_ROOT_OBJECT) && (type == ACPI_BUS_TYPE_DEVICE)) {
  721. hid = ACPI_BUS_HID;
  722. strcpy(device->pnp.device_name, ACPI_BUS_DEVICE_NAME);
  723. strcpy(device->pnp.device_class, ACPI_BUS_CLASS);
  724. }
  725. if (hid) {
  726. strcpy(device->pnp.hardware_id, hid);
  727. device->flags.hardware_id = 1;
  728. }
  729. if (uid) {
  730. strcpy(device->pnp.unique_id, uid);
  731. device->flags.unique_id = 1;
  732. }
  733. if (cid_list) {
  734. device->pnp.cid_list = kmalloc(cid_list->size, GFP_KERNEL);
  735. if (device->pnp.cid_list)
  736. memcpy(device->pnp.cid_list, cid_list, cid_list->size);
  737. else
  738. printk(KERN_ERR "Memory allocation error\n");
  739. }
  740. acpi_os_free(buffer.pointer);
  741. }
  742. static int acpi_device_set_context(struct acpi_device * device, int type)
  743. {
  744. acpi_status status = AE_OK;
  745. int result = 0;
  746. /*
  747. * Context
  748. * -------
  749. * Attach this 'struct acpi_device' to the ACPI object. This makes
  750. * resolutions from handle->device very efficient. Note that we need
  751. * to be careful with fixed-feature devices as they all attach to the
  752. * root object.
  753. */
  754. if (type != ACPI_BUS_TYPE_POWER_BUTTON &&
  755. type != ACPI_BUS_TYPE_SLEEP_BUTTON) {
  756. status = acpi_attach_data(device->handle,
  757. acpi_bus_data_handler, device);
  758. if (ACPI_FAILURE(status)) {
  759. printk("Error attaching device data\n");
  760. result = -ENODEV;
  761. }
  762. }
  763. return result;
  764. }
  765. static void acpi_device_get_debug_info(struct acpi_device * device, acpi_handle handle, int type)
  766. {
  767. #ifdef CONFIG_ACPI_DEBUG_OUTPUT
  768. char *type_string = NULL;
  769. char name[80] = {'?','\0'};
  770. struct acpi_buffer buffer = {sizeof(name), name};
  771. switch (type) {
  772. case ACPI_BUS_TYPE_DEVICE:
  773. type_string = "Device";
  774. acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
  775. break;
  776. case ACPI_BUS_TYPE_POWER:
  777. type_string = "Power Resource";
  778. acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
  779. break;
  780. case ACPI_BUS_TYPE_PROCESSOR:
  781. type_string = "Processor";
  782. acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
  783. break;
  784. case ACPI_BUS_TYPE_SYSTEM:
  785. type_string = "System";
  786. acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
  787. break;
  788. case ACPI_BUS_TYPE_THERMAL:
  789. type_string = "Thermal Zone";
  790. acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
  791. break;
  792. case ACPI_BUS_TYPE_POWER_BUTTON:
  793. type_string = "Power Button";
  794. sprintf(name, "PWRB");
  795. break;
  796. case ACPI_BUS_TYPE_SLEEP_BUTTON:
  797. type_string = "Sleep Button";
  798. sprintf(name, "SLPB");
  799. break;
  800. }
  801. printk(KERN_DEBUG "Found %s %s [%p]\n", type_string, name, handle);
  802. #endif /*CONFIG_ACPI_DEBUG_OUTPUT*/
  803. }
  804. static int
  805. acpi_bus_remove (
  806. struct acpi_device *dev,
  807. int rmdevice)
  808. {
  809. int result = 0;
  810. struct acpi_driver *driver;
  811. ACPI_FUNCTION_TRACE("acpi_bus_remove");
  812. if (!dev)
  813. return_VALUE(-EINVAL);
  814. driver = dev->driver;
  815. if ((driver) && (driver->ops.remove)) {
  816. if (driver->ops.stop) {
  817. result = driver->ops.stop(dev, ACPI_BUS_REMOVAL_EJECT);
  818. if (result)
  819. return_VALUE(result);
  820. }
  821. result = dev->driver->ops.remove(dev, ACPI_BUS_REMOVAL_EJECT);
  822. if (result) {
  823. return_VALUE(result);
  824. }
  825. atomic_dec(&dev->driver->references);
  826. dev->driver = NULL;
  827. acpi_driver_data(dev) = NULL;
  828. }
  829. if (!rmdevice)
  830. return_VALUE(0);
  831. if (dev->flags.bus_address) {
  832. if ((dev->parent) && (dev->parent->ops.unbind))
  833. dev->parent->ops.unbind(dev);
  834. }
  835. acpi_device_unregister(dev, ACPI_BUS_REMOVAL_EJECT);
  836. return_VALUE(0);
  837. }
  838. int
  839. acpi_bus_add (
  840. struct acpi_device **child,
  841. struct acpi_device *parent,
  842. acpi_handle handle,
  843. int type)
  844. {
  845. int result = 0;
  846. struct acpi_device *device = NULL;
  847. ACPI_FUNCTION_TRACE("acpi_bus_add");
  848. if (!child)
  849. return_VALUE(-EINVAL);
  850. device = kmalloc(sizeof(struct acpi_device), GFP_KERNEL);
  851. if (!device) {
  852. ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Memory allocation error\n"));
  853. return_VALUE(-ENOMEM);
  854. }
  855. memset(device, 0, sizeof(struct acpi_device));
  856. device->handle = handle;
  857. device->parent = parent;
  858. acpi_device_get_busid(device,handle,type);
  859. /*
  860. * Flags
  861. * -----
  862. * Get prior to calling acpi_bus_get_status() so we know whether
  863. * or not _STA is present. Note that we only look for object
  864. * handles -- cannot evaluate objects until we know the device is
  865. * present and properly initialized.
  866. */
  867. result = acpi_bus_get_flags(device);
  868. if (result)
  869. goto end;
  870. /*
  871. * Status
  872. * ------
  873. * See if the device is present. We always assume that non-Device
  874. * and non-Processor objects (e.g. thermal zones, power resources,
  875. * etc.) are present, functioning, etc. (at least when parent object
  876. * is present). Note that _STA has a different meaning for some
  877. * objects (e.g. power resources) so we need to be careful how we use
  878. * it.
  879. */
  880. switch (type) {
  881. case ACPI_BUS_TYPE_PROCESSOR:
  882. case ACPI_BUS_TYPE_DEVICE:
  883. result = acpi_bus_get_status(device);
  884. if (ACPI_FAILURE(result) || !device->status.present) {
  885. result = -ENOENT;
  886. goto end;
  887. }
  888. break;
  889. default:
  890. STRUCT_TO_INT(device->status) = 0x0F;
  891. break;
  892. }
  893. /*
  894. * Initialize Device
  895. * -----------------
  896. * TBD: Synch with Core's enumeration/initialization process.
  897. */
  898. /*
  899. * Hardware ID, Unique ID, & Bus Address
  900. * -------------------------------------
  901. */
  902. acpi_device_set_id(device,parent,handle,type);
  903. /*
  904. * Power Management
  905. * ----------------
  906. */
  907. if (device->flags.power_manageable) {
  908. result = acpi_bus_get_power_flags(device);
  909. if (result)
  910. goto end;
  911. }
  912. /*
  913. * Wakeup device management
  914. *-----------------------
  915. */
  916. if (device->flags.wake_capable) {
  917. result = acpi_bus_get_wakeup_device_flags(device);
  918. if (result)
  919. goto end;
  920. }
  921. /*
  922. * Performance Management
  923. * ----------------------
  924. */
  925. if (device->flags.performance_manageable) {
  926. result = acpi_bus_get_perf_flags(device);
  927. if (result)
  928. goto end;
  929. }
  930. if ((result = acpi_device_set_context(device,type)))
  931. goto end;
  932. acpi_device_get_debug_info(device,handle,type);
  933. acpi_device_register(device,parent);
  934. /*
  935. * Bind _ADR-Based Devices
  936. * -----------------------
  937. * If there's a a bus address (_ADR) then we utilize the parent's
  938. * 'bind' function (if exists) to bind the ACPI- and natively-
  939. * enumerated device representations.
  940. */
  941. if (device->flags.bus_address) {
  942. if (device->parent && device->parent->ops.bind)
  943. device->parent->ops.bind(device);
  944. }
  945. /*
  946. * Locate & Attach Driver
  947. * ----------------------
  948. * If there's a hardware id (_HID) or compatible ids (_CID) we check
  949. * to see if there's a driver installed for this kind of device. Note
  950. * that drivers can install before or after a device is enumerated.
  951. *
  952. * TBD: Assumes LDM provides driver hot-plug capability.
  953. */
  954. acpi_bus_find_driver(device);
  955. end:
  956. if (!result)
  957. *child = device;
  958. else {
  959. if (device->pnp.cid_list)
  960. kfree(device->pnp.cid_list);
  961. kfree(device);
  962. }
  963. return_VALUE(result);
  964. }
  965. EXPORT_SYMBOL(acpi_bus_add);
  966. int acpi_bus_scan (struct acpi_device *start)
  967. {
  968. acpi_status status = AE_OK;
  969. struct acpi_device *parent = NULL;
  970. struct acpi_device *child = NULL;
  971. acpi_handle phandle = NULL;
  972. acpi_handle chandle = NULL;
  973. acpi_object_type type = 0;
  974. u32 level = 1;
  975. ACPI_FUNCTION_TRACE("acpi_bus_scan");
  976. if (!start)
  977. return_VALUE(-EINVAL);
  978. parent = start;
  979. phandle = start->handle;
  980. /*
  981. * Parse through the ACPI namespace, identify all 'devices', and
  982. * create a new 'struct acpi_device' for each.
  983. */
  984. while ((level > 0) && parent) {
  985. status = acpi_get_next_object(ACPI_TYPE_ANY, phandle,
  986. chandle, &chandle);
  987. /*
  988. * If this scope is exhausted then move our way back up.
  989. */
  990. if (ACPI_FAILURE(status)) {
  991. level--;
  992. chandle = phandle;
  993. acpi_get_parent(phandle, &phandle);
  994. if (parent->parent)
  995. parent = parent->parent;
  996. continue;
  997. }
  998. status = acpi_get_type(chandle, &type);
  999. if (ACPI_FAILURE(status))
  1000. continue;
  1001. /*
  1002. * If this is a scope object then parse it (depth-first).
  1003. */
  1004. if (type == ACPI_TYPE_LOCAL_SCOPE) {
  1005. level++;
  1006. phandle = chandle;
  1007. chandle = NULL;
  1008. continue;
  1009. }
  1010. /*
  1011. * We're only interested in objects that we consider 'devices'.
  1012. */
  1013. switch (type) {
  1014. case ACPI_TYPE_DEVICE:
  1015. type = ACPI_BUS_TYPE_DEVICE;
  1016. break;
  1017. case ACPI_TYPE_PROCESSOR:
  1018. type = ACPI_BUS_TYPE_PROCESSOR;
  1019. break;
  1020. case ACPI_TYPE_THERMAL:
  1021. type = ACPI_BUS_TYPE_THERMAL;
  1022. break;
  1023. case ACPI_TYPE_POWER:
  1024. type = ACPI_BUS_TYPE_POWER;
  1025. break;
  1026. default:
  1027. continue;
  1028. }
  1029. status = acpi_bus_add(&child, parent, chandle, type);
  1030. if (ACPI_FAILURE(status))
  1031. continue;
  1032. /*
  1033. * If the device is present, enabled, and functioning then
  1034. * parse its scope (depth-first). Note that we need to
  1035. * represent absent devices to facilitate PnP notifications
  1036. * -- but only the subtree head (not all of its children,
  1037. * which will be enumerated when the parent is inserted).
  1038. *
  1039. * TBD: Need notifications and other detection mechanisms
  1040. * in place before we can fully implement this.
  1041. */
  1042. if (child->status.present) {
  1043. status = acpi_get_next_object(ACPI_TYPE_ANY, chandle,
  1044. NULL, NULL);
  1045. if (ACPI_SUCCESS(status)) {
  1046. level++;
  1047. phandle = chandle;
  1048. chandle = NULL;
  1049. parent = child;
  1050. }
  1051. }
  1052. }
  1053. return_VALUE(0);
  1054. }
  1055. EXPORT_SYMBOL(acpi_bus_scan);
  1056. static int
  1057. acpi_bus_trim(struct acpi_device *start,
  1058. int rmdevice)
  1059. {
  1060. acpi_status status;
  1061. struct acpi_device *parent, *child;
  1062. acpi_handle phandle, chandle;
  1063. acpi_object_type type;
  1064. u32 level = 1;
  1065. int err = 0;
  1066. parent = start;
  1067. phandle = start->handle;
  1068. child = chandle = NULL;
  1069. while ((level > 0) && parent && (!err)) {
  1070. status = acpi_get_next_object(ACPI_TYPE_ANY, phandle,
  1071. chandle, &chandle);
  1072. /*
  1073. * If this scope is exhausted then move our way back up.
  1074. */
  1075. if (ACPI_FAILURE(status)) {
  1076. level--;
  1077. chandle = phandle;
  1078. acpi_get_parent(phandle, &phandle);
  1079. child = parent;
  1080. parent = parent->parent;
  1081. if (level == 0)
  1082. err = acpi_bus_remove(child, rmdevice);
  1083. else
  1084. err = acpi_bus_remove(child, 1);
  1085. continue;
  1086. }
  1087. status = acpi_get_type(chandle, &type);
  1088. if (ACPI_FAILURE(status)) {
  1089. continue;
  1090. }
  1091. /*
  1092. * If there is a device corresponding to chandle then
  1093. * parse it (depth-first).
  1094. */
  1095. if (acpi_bus_get_device(chandle, &child) == 0) {
  1096. level++;
  1097. phandle = chandle;
  1098. chandle = NULL;
  1099. parent = child;
  1100. }
  1101. continue;
  1102. }
  1103. return err;
  1104. }
  1105. static int
  1106. acpi_bus_scan_fixed (
  1107. struct acpi_device *root)
  1108. {
  1109. int result = 0;
  1110. struct acpi_device *device = NULL;
  1111. ACPI_FUNCTION_TRACE("acpi_bus_scan_fixed");
  1112. if (!root)
  1113. return_VALUE(-ENODEV);
  1114. /*
  1115. * Enumerate all fixed-feature devices.
  1116. */
  1117. if (acpi_fadt.pwr_button == 0)
  1118. result = acpi_bus_add(&device, acpi_root,
  1119. NULL, ACPI_BUS_TYPE_POWER_BUTTON);
  1120. if (acpi_fadt.sleep_button == 0)
  1121. result = acpi_bus_add(&device, acpi_root,
  1122. NULL, ACPI_BUS_TYPE_SLEEP_BUTTON);
  1123. return_VALUE(result);
  1124. }
  1125. static int __init acpi_scan_init(void)
  1126. {
  1127. int result;
  1128. ACPI_FUNCTION_TRACE("acpi_scan_init");
  1129. if (acpi_disabled)
  1130. return_VALUE(0);
  1131. kset_register(&acpi_namespace_kset);
  1132. /*
  1133. * Create the root device in the bus's device tree
  1134. */
  1135. result = acpi_bus_add(&acpi_root, NULL, ACPI_ROOT_OBJECT,
  1136. ACPI_BUS_TYPE_SYSTEM);
  1137. if (result)
  1138. goto Done;
  1139. /*
  1140. * Enumerate devices in the ACPI namespace.
  1141. */
  1142. result = acpi_bus_scan_fixed(acpi_root);
  1143. if (!result)
  1144. result = acpi_bus_scan(acpi_root);
  1145. if (result)
  1146. acpi_device_unregister(acpi_root, ACPI_BUS_REMOVAL_NORMAL);
  1147. Done:
  1148. return_VALUE(result);
  1149. }
  1150. subsys_initcall(acpi_scan_init);