|
Lines 394-399
static int acpi_memory_device_add(struct
Link Here
|
| 394 |
/* Set the device state */ |
394 |
/* Set the device state */ |
| 395 |
mem_device->state = MEMORY_POWER_ON_STATE; |
395 |
mem_device->state = MEMORY_POWER_ON_STATE; |
| 396 |
|
396 |
|
|
|
397 |
/* register notify handler, ignore error if there could be any */ |
| 398 |
acpi_install_notify_handler(device->handle, ACPI_SYSTEM_NOTIFY, |
| 399 |
acpi_memory_device_notify, NULL); |
| 400 |
|
| 397 |
printk(KERN_INFO "%s \n", acpi_device_name(device)); |
401 |
printk(KERN_INFO "%s \n", acpi_device_name(device)); |
| 398 |
|
402 |
|
| 399 |
return_VALUE(result); |
403 |
return_VALUE(result); |
|
Lines 408-491
static int acpi_memory_device_remove(str
Link Here
|
| 408 |
if (!device || !acpi_driver_data(device)) |
412 |
if (!device || !acpi_driver_data(device)) |
| 409 |
return_VALUE(-EINVAL); |
413 |
return_VALUE(-EINVAL); |
| 410 |
|
414 |
|
|
|
415 |
acpi_remove_notify_handler(device->handle, |
| 416 |
ACPI_SYSTEM_NOTIFY, |
| 417 |
acpi_memory_device_notify); |
| 418 |
|
| 411 |
mem_device = (struct acpi_memory_device *)acpi_driver_data(device); |
419 |
mem_device = (struct acpi_memory_device *)acpi_driver_data(device); |
| 412 |
kfree(mem_device); |
420 |
kfree(mem_device); |
| 413 |
|
421 |
|
| 414 |
return_VALUE(0); |
422 |
return_VALUE(0); |
| 415 |
} |
423 |
} |
| 416 |
|
424 |
|
| 417 |
/* |
|
|
| 418 |
* Helper function to check for memory device |
| 419 |
*/ |
| 420 |
static acpi_status is_memory_device(acpi_handle handle) |
| 421 |
{ |
| 422 |
char *hardware_id; |
| 423 |
acpi_status status; |
| 424 |
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; |
| 425 |
struct acpi_device_info *info; |
| 426 |
|
| 427 |
ACPI_FUNCTION_TRACE("is_memory_device"); |
| 428 |
|
| 429 |
status = acpi_get_object_info(handle, &buffer); |
| 430 |
if (ACPI_FAILURE(status)) |
| 431 |
return_ACPI_STATUS(status); |
| 432 |
|
| 433 |
info = buffer.pointer; |
| 434 |
if (!(info->valid & ACPI_VALID_HID)) { |
| 435 |
acpi_os_free(buffer.pointer); |
| 436 |
return_ACPI_STATUS(AE_ERROR); |
| 437 |
} |
| 438 |
|
| 439 |
hardware_id = info->hardware_id.value; |
| 440 |
if ((hardware_id == NULL) || |
| 441 |
(strcmp(hardware_id, ACPI_MEMORY_DEVICE_HID))) |
| 442 |
status = AE_ERROR; |
| 443 |
|
| 444 |
acpi_os_free(buffer.pointer); |
| 445 |
return_ACPI_STATUS(status); |
| 446 |
} |
| 447 |
|
| 448 |
static acpi_status |
| 449 |
acpi_memory_register_notify_handler(acpi_handle handle, |
| 450 |
u32 level, void *ctxt, void **retv) |
| 451 |
{ |
| 452 |
acpi_status status; |
| 453 |
|
| 454 |
ACPI_FUNCTION_TRACE("acpi_memory_register_notify_handler"); |
| 455 |
|
| 456 |
status = is_memory_device(handle); |
| 457 |
if (ACPI_FAILURE(status)){ |
| 458 |
ACPI_EXCEPTION((AE_INFO, status, "handle is no memory device")); |
| 459 |
return_ACPI_STATUS(AE_OK); /* continue */ |
| 460 |
} |
| 461 |
|
| 462 |
status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, |
| 463 |
acpi_memory_device_notify, NULL); |
| 464 |
/* continue */ |
| 465 |
return_ACPI_STATUS(AE_OK); |
| 466 |
} |
| 467 |
|
| 468 |
static acpi_status |
| 469 |
acpi_memory_deregister_notify_handler(acpi_handle handle, |
| 470 |
u32 level, void *ctxt, void **retv) |
| 471 |
{ |
| 472 |
acpi_status status; |
| 473 |
|
| 474 |
ACPI_FUNCTION_TRACE("acpi_memory_deregister_notify_handler"); |
| 475 |
|
| 476 |
status = is_memory_device(handle); |
| 477 |
if (ACPI_FAILURE(status)){ |
| 478 |
ACPI_EXCEPTION((AE_INFO, status, "handle is no memory device")); |
| 479 |
return_ACPI_STATUS(AE_OK); /* continue */ |
| 480 |
} |
| 481 |
|
| 482 |
status = acpi_remove_notify_handler(handle, |
| 483 |
ACPI_SYSTEM_NOTIFY, |
| 484 |
acpi_memory_device_notify); |
| 485 |
|
| 486 |
return_ACPI_STATUS(AE_OK); /* continue */ |
| 487 |
} |
| 488 |
|
| 489 |
static int __init acpi_memory_device_init(void) |
425 |
static int __init acpi_memory_device_init(void) |
| 490 |
{ |
426 |
{ |
| 491 |
int result; |
427 |
int result; |
|
Lines 498-514
static int __init acpi_memory_device_ini
Link Here
|
| 498 |
if (result < 0) |
434 |
if (result < 0) |
| 499 |
return_VALUE(-ENODEV); |
435 |
return_VALUE(-ENODEV); |
| 500 |
|
436 |
|
| 501 |
status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, |
|
|
| 502 |
ACPI_UINT32_MAX, |
| 503 |
acpi_memory_register_notify_handler, |
| 504 |
NULL, NULL); |
| 505 |
|
| 506 |
if (ACPI_FAILURE(status)) { |
| 507 |
ACPI_EXCEPTION((AE_INFO, status, "walk_namespace failed")); |
| 508 |
acpi_bus_unregister_driver(&acpi_memory_device_driver); |
| 509 |
return_VALUE(-ENODEV); |
| 510 |
} |
| 511 |
|
| 512 |
return_VALUE(0); |
437 |
return_VALUE(0); |
| 513 |
} |
438 |
} |
| 514 |
|
439 |
|
|
Lines 518-535
static void __exit acpi_memory_device_ex
Link Here
|
| 518 |
|
443 |
|
| 519 |
ACPI_FUNCTION_TRACE("acpi_memory_device_exit"); |
444 |
ACPI_FUNCTION_TRACE("acpi_memory_device_exit"); |
| 520 |
|
445 |
|
| 521 |
/* |
|
|
| 522 |
* Adding this to un-install notification handlers for all the device |
| 523 |
* handles. |
| 524 |
*/ |
| 525 |
status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, |
| 526 |
ACPI_UINT32_MAX, |
| 527 |
acpi_memory_deregister_notify_handler, |
| 528 |
NULL, NULL); |
| 529 |
|
| 530 |
if (ACPI_FAILURE(status)) |
| 531 |
ACPI_EXCEPTION((AE_INFO, status, "walk_namespace failed")); |
| 532 |
|
| 533 |
acpi_bus_unregister_driver(&acpi_memory_device_driver); |
446 |
acpi_bus_unregister_driver(&acpi_memory_device_driver); |
| 534 |
|
447 |
|
| 535 |
return_VOID; |
448 |
return_VOID; |