scan.c 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379
  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) : -EIO;
  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) : -EIO;
  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. * objects (e.g. thermal zones, power resources, processors, etc.) are
  875. * present, functioning, etc. (at least when parent object is present).
  876. * Note that _STA has a different meaning for some objects (e.g.
  877. * power resources) so we need to be careful how we use it.
  878. */
  879. switch (type) {
  880. case ACPI_BUS_TYPE_DEVICE:
  881. result = acpi_bus_get_status(device);
  882. if (ACPI_FAILURE(result) || !device->status.present) {
  883. result = -ENOENT;
  884. goto end;
  885. }
  886. break;
  887. default:
  888. STRUCT_TO_INT(device->status) = 0x0F;
  889. break;
  890. }
  891. /*
  892. * Initialize Device
  893. * -----------------
  894. * TBD: Synch with Core's enumeration/initialization process.
  895. */
  896. /*
  897. * Hardware ID, Unique ID, & Bus Address
  898. * -------------------------------------
  899. */
  900. acpi_device_set_id(device,parent,handle,type);
  901. /*
  902. * Power Management
  903. * ----------------
  904. */
  905. if (device->flags.power_manageable) {
  906. result = acpi_bus_get_power_flags(device);
  907. if (result)
  908. goto end;
  909. }
  910. /*
  911. * Wakeup device management
  912. *-----------------------
  913. */
  914. if (device->flags.wake_capable) {
  915. result = acpi_bus_get_wakeup_device_flags(device);
  916. if (result)
  917. goto end;
  918. }
  919. /*
  920. * Performance Management
  921. * ----------------------
  922. */
  923. if (device->flags.performance_manageable) {
  924. result = acpi_bus_get_perf_flags(device);
  925. if (result)
  926. goto end;
  927. }
  928. if ((result = acpi_device_set_context(device,type)))
  929. goto end;
  930. acpi_device_get_debug_info(device,handle,type);
  931. acpi_device_register(device,parent);
  932. /*
  933. * Bind _ADR-Based Devices
  934. * -----------------------
  935. * If there's a a bus address (_ADR) then we utilize the parent's
  936. * 'bind' function (if exists) to bind the ACPI- and natively-
  937. * enumerated device representations.
  938. */
  939. if (device->flags.bus_address) {
  940. if (device->parent && device->parent->ops.bind)
  941. device->parent->ops.bind(device);
  942. }
  943. /*
  944. * Locate & Attach Driver
  945. * ----------------------
  946. * If there's a hardware id (_HID) or compatible ids (_CID) we check
  947. * to see if there's a driver installed for this kind of device. Note
  948. * that drivers can install before or after a device is enumerated.
  949. *
  950. * TBD: Assumes LDM provides driver hot-plug capability.
  951. */
  952. acpi_bus_find_driver(device);
  953. end:
  954. if (!result)
  955. *child = device;
  956. else {
  957. if (device->pnp.cid_list)
  958. kfree(device->pnp.cid_list);
  959. kfree(device);
  960. }
  961. return_VALUE(result);
  962. }
  963. EXPORT_SYMBOL(acpi_bus_add);
  964. int acpi_bus_scan (struct acpi_device *start)
  965. {
  966. acpi_status status = AE_OK;
  967. struct acpi_device *parent = NULL;
  968. struct acpi_device *child = NULL;
  969. acpi_handle phandle = NULL;
  970. acpi_handle chandle = NULL;
  971. acpi_object_type type = 0;
  972. u32 level = 1;
  973. ACPI_FUNCTION_TRACE("acpi_bus_scan");
  974. if (!start)
  975. return_VALUE(-EINVAL);
  976. parent = start;
  977. phandle = start->handle;
  978. /*
  979. * Parse through the ACPI namespace, identify all 'devices', and
  980. * create a new 'struct acpi_device' for each.
  981. */
  982. while ((level > 0) && parent) {
  983. status = acpi_get_next_object(ACPI_TYPE_ANY, phandle,
  984. chandle, &chandle);
  985. /*
  986. * If this scope is exhausted then move our way back up.
  987. */
  988. if (ACPI_FAILURE(status)) {
  989. level--;
  990. chandle = phandle;
  991. acpi_get_parent(phandle, &phandle);
  992. if (parent->parent)
  993. parent = parent->parent;
  994. continue;
  995. }
  996. status = acpi_get_type(chandle, &type);
  997. if (ACPI_FAILURE(status))
  998. continue;
  999. /*
  1000. * If this is a scope object then parse it (depth-first).
  1001. */
  1002. if (type == ACPI_TYPE_LOCAL_SCOPE) {
  1003. level++;
  1004. phandle = chandle;
  1005. chandle = NULL;
  1006. continue;
  1007. }
  1008. /*
  1009. * We're only interested in objects that we consider 'devices'.
  1010. */
  1011. switch (type) {
  1012. case ACPI_TYPE_DEVICE:
  1013. type = ACPI_BUS_TYPE_DEVICE;
  1014. break;
  1015. case ACPI_TYPE_PROCESSOR:
  1016. type = ACPI_BUS_TYPE_PROCESSOR;
  1017. break;
  1018. case ACPI_TYPE_THERMAL:
  1019. type = ACPI_BUS_TYPE_THERMAL;
  1020. break;
  1021. case ACPI_TYPE_POWER:
  1022. type = ACPI_BUS_TYPE_POWER;
  1023. break;
  1024. default:
  1025. continue;
  1026. }
  1027. status = acpi_bus_add(&child, parent, chandle, type);
  1028. if (ACPI_FAILURE(status))
  1029. continue;
  1030. /*
  1031. * If the device is present, enabled, and functioning then
  1032. * parse its scope (depth-first). Note that we need to
  1033. * represent absent devices to facilitate PnP notifications
  1034. * -- but only the subtree head (not all of its children,
  1035. * which will be enumerated when the parent is inserted).
  1036. *
  1037. * TBD: Need notifications and other detection mechanisms
  1038. * in place before we can fully implement this.
  1039. */
  1040. if (child->status.present) {
  1041. status = acpi_get_next_object(ACPI_TYPE_ANY, chandle,
  1042. NULL, NULL);
  1043. if (ACPI_SUCCESS(status)) {
  1044. level++;
  1045. phandle = chandle;
  1046. chandle = NULL;
  1047. parent = child;
  1048. }
  1049. }
  1050. }
  1051. return_VALUE(0);
  1052. }
  1053. EXPORT_SYMBOL(acpi_bus_scan);
  1054. static int
  1055. acpi_bus_trim(struct acpi_device *start,
  1056. int rmdevice)
  1057. {
  1058. acpi_status status;
  1059. struct acpi_device *parent, *child;
  1060. acpi_handle phandle, chandle;
  1061. acpi_object_type type;
  1062. u32 level = 1;
  1063. int err = 0;
  1064. parent = start;
  1065. phandle = start->handle;
  1066. child = chandle = NULL;
  1067. while ((level > 0) && parent && (!err)) {
  1068. status = acpi_get_next_object(ACPI_TYPE_ANY, phandle,
  1069. chandle, &chandle);
  1070. /*
  1071. * If this scope is exhausted then move our way back up.
  1072. */
  1073. if (ACPI_FAILURE(status)) {
  1074. level--;
  1075. chandle = phandle;
  1076. acpi_get_parent(phandle, &phandle);
  1077. child = parent;
  1078. parent = parent->parent;
  1079. if (level == 0)
  1080. err = acpi_bus_remove(child, rmdevice);
  1081. else
  1082. err = acpi_bus_remove(child, 1);
  1083. continue;
  1084. }
  1085. status = acpi_get_type(chandle, &type);
  1086. if (ACPI_FAILURE(status)) {
  1087. continue;
  1088. }
  1089. /*
  1090. * If there is a device corresponding to chandle then
  1091. * parse it (depth-first).
  1092. */
  1093. if (acpi_bus_get_device(chandle, &child) == 0) {
  1094. level++;
  1095. phandle = chandle;
  1096. chandle = NULL;
  1097. parent = child;
  1098. }
  1099. continue;
  1100. }
  1101. return err;
  1102. }
  1103. static int
  1104. acpi_bus_scan_fixed (
  1105. struct acpi_device *root)
  1106. {
  1107. int result = 0;
  1108. struct acpi_device *device = NULL;
  1109. ACPI_FUNCTION_TRACE("acpi_bus_scan_fixed");
  1110. if (!root)
  1111. return_VALUE(-ENODEV);
  1112. /*
  1113. * Enumerate all fixed-feature devices.
  1114. */
  1115. if (acpi_fadt.pwr_button == 0)
  1116. result = acpi_bus_add(&device, acpi_root,
  1117. NULL, ACPI_BUS_TYPE_POWER_BUTTON);
  1118. if (acpi_fadt.sleep_button == 0)
  1119. result = acpi_bus_add(&device, acpi_root,
  1120. NULL, ACPI_BUS_TYPE_SLEEP_BUTTON);
  1121. return_VALUE(result);
  1122. }
  1123. static int __init acpi_scan_init(void)
  1124. {
  1125. int result;
  1126. ACPI_FUNCTION_TRACE("acpi_scan_init");
  1127. if (acpi_disabled)
  1128. return_VALUE(0);
  1129. kset_register(&acpi_namespace_kset);
  1130. /*
  1131. * Create the root device in the bus's device tree
  1132. */
  1133. result = acpi_bus_add(&acpi_root, NULL, ACPI_ROOT_OBJECT,
  1134. ACPI_BUS_TYPE_SYSTEM);
  1135. if (result)
  1136. goto Done;
  1137. /*
  1138. * Enumerate devices in the ACPI namespace.
  1139. */
  1140. result = acpi_bus_scan_fixed(acpi_root);
  1141. if (!result)
  1142. result = acpi_bus_scan(acpi_root);
  1143. if (result)
  1144. acpi_device_unregister(acpi_root, ACPI_BUS_REMOVAL_NORMAL);
  1145. Done:
  1146. return_VALUE(result);
  1147. }
  1148. subsys_initcall(acpi_scan_init);