From: https://bugzilla.kernel.org/show_bug.cgi?id=89211 Index: for_debug/drivers/acpi/button.c =================================================================== --- for_debug.orig/drivers/acpi/button.c +++ for_debug/drivers/acpi/button.c @@ -101,6 +101,7 @@ struct acpi_button { char phys[32]; /* for input device */ unsigned long pushed; bool suspended; + unsigned long long cache_state; }; static BLOCKING_NOTIFIER_HEAD(acpi_lid_notifier); @@ -118,8 +119,12 @@ static int acpi_button_state_seq_show(st struct acpi_device *device = seq->private; acpi_status status; unsigned long long state; + struct acpi_button *button = acpi_driver_data(device); status = acpi_evaluate_integer(device->handle, "_LID", NULL, &state); + if (!button) + return 0; + state = button->cache_state; seq_printf(seq, "state: %s\n", ACPI_FAILURE(status) ? "unsupported" : (state ? "open" : "closed")); @@ -233,15 +238,20 @@ int acpi_lid_open(void) { acpi_status status; unsigned long long state; + struct acpi_button *button; if (!lid_device) return -ENODEV; + button = acpi_driver_data(lid_device); + if (!button) + return -ENODEV; status = acpi_evaluate_integer(lid_device->handle, "_LID", NULL, &state); if (ACPI_FAILURE(status)) return -ENODEV; + state = button->cache_state; return !!state; } EXPORT_SYMBOL(acpi_lid_open); @@ -257,6 +267,8 @@ static int acpi_lid_send_state(struct ac if (ACPI_FAILURE(status)) return -ENODEV; + state = button->cache_state; + printk("***********LID is trying to send state:%lld to input/netlink layer****\n",state); /* input layer checks if event is redundant */ input_report_switch(button->input, SW_LID, !state); input_sync(button->input); @@ -290,6 +302,7 @@ static void acpi_button_notify(struct ac case ACPI_BUTTON_NOTIFY_STATUS: input = button->input; if (button->type == ACPI_BUTTON_TYPE_LID) { + button->cache_state = !button->cache_state; acpi_lid_send_state(device); } else { int keycode; @@ -325,6 +338,7 @@ static int acpi_button_suspend(struct de struct acpi_button *button = acpi_driver_data(device); button->suspended = true; + button->cache_state = 0; return 0; } @@ -334,8 +348,10 @@ static int acpi_button_resume(struct dev struct acpi_button *button = acpi_driver_data(device); button->suspended = false; - if (button->type == ACPI_BUTTON_TYPE_LID) + if (button->type == ACPI_BUTTON_TYPE_LID) { + button->cache_state = 1; return acpi_lid_send_state(device); + } return 0; } #endif @@ -416,6 +432,7 @@ static int acpi_button_add(struct acpi_d if (error) goto err_remove_fs; if (button->type == ACPI_BUTTON_TYPE_LID) { + button->cache_state = 1; acpi_lid_send_state(device); /* * This assumes there's only one lid device, or if there are