Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ACPI: button: Use different notify handlers for lid and buttons

Since the lid handling in acpi_button_notify() is special, introduce
acpi_lid_notify() specifically for handling lid notifications.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

+27 -12
+27 -12
drivers/acpi/button.c
··· 398 398 button->lid_state_initialized = true; 399 399 } 400 400 401 + static void acpi_lid_notify(acpi_handle handle, u32 event, void *data) 402 + { 403 + struct acpi_device *device = data; 404 + struct acpi_button *button; 405 + 406 + if (event != ACPI_BUTTON_NOTIFY_STATUS) { 407 + acpi_handle_debug(device->handle, "Unsupported event [0x%x]\n", 408 + event); 409 + return; 410 + } 411 + 412 + button = acpi_driver_data(device); 413 + if (!button->lid_state_initialized) 414 + return; 415 + 416 + acpi_lid_update_state(device, true); 417 + } 418 + 401 419 static void acpi_button_notify(acpi_handle handle, u32 event, void *data) 402 420 { 403 421 struct acpi_device *device = data; ··· 429 411 return; 430 412 } 431 413 432 - button = acpi_driver_data(device); 433 - 434 - if (button->type == ACPI_BUTTON_TYPE_LID) { 435 - if (button->lid_state_initialized) 436 - acpi_lid_update_state(device, true); 437 - 438 - return; 439 - } 440 - 441 414 acpi_pm_wakeup_event(&device->dev); 442 415 416 + button = acpi_driver_data(device); 443 417 if (button->suspended) 444 418 return; 445 419 ··· 498 488 499 489 static int acpi_button_add(struct acpi_device *device) 500 490 { 491 + acpi_notify_handler handler; 501 492 struct acpi_button *button; 502 493 struct input_dev *input; 503 494 const char *hid = acpi_device_hid(device); ··· 528 517 if (!strcmp(hid, ACPI_BUTTON_HID_POWER) || 529 518 !strcmp(hid, ACPI_BUTTON_HID_POWERF)) { 530 519 button->type = ACPI_BUTTON_TYPE_POWER; 520 + handler = acpi_button_notify; 531 521 strcpy(name, ACPI_BUTTON_DEVICE_NAME_POWER); 532 522 sprintf(class, "%s/%s", 533 523 ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_POWER); 534 524 } else if (!strcmp(hid, ACPI_BUTTON_HID_SLEEP) || 535 525 !strcmp(hid, ACPI_BUTTON_HID_SLEEPF)) { 536 526 button->type = ACPI_BUTTON_TYPE_SLEEP; 527 + handler = acpi_button_notify; 537 528 strcpy(name, ACPI_BUTTON_DEVICE_NAME_SLEEP); 538 529 sprintf(class, "%s/%s", 539 530 ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_SLEEP); 540 531 } else if (!strcmp(hid, ACPI_BUTTON_HID_LID)) { 541 532 button->type = ACPI_BUTTON_TYPE_LID; 533 + handler = acpi_lid_notify; 542 534 strcpy(name, ACPI_BUTTON_DEVICE_NAME_LID); 543 535 sprintf(class, "%s/%s", 544 536 ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_LID); ··· 599 585 break; 600 586 default: 601 587 status = acpi_install_notify_handler(device->handle, 602 - ACPI_DEVICE_NOTIFY, 603 - acpi_button_notify, 588 + ACPI_DEVICE_NOTIFY, handler, 604 589 device); 605 590 break; 606 591 } ··· 644 631 break; 645 632 default: 646 633 acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, 647 - acpi_button_notify); 634 + button->type == ACPI_BUTTON_TYPE_LID ? 635 + acpi_lid_notify : 636 + acpi_button_notify); 648 637 break; 649 638 } 650 639 acpi_os_wait_events_complete();