From: Rafael J. Wysocki Date: Mon, 1 Jun 2026 16:58:13 +0000 (+0200) Subject: ACPI: button: Use bool for representing boolean values X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c0e0b84d9e6fd74f9390aa4014dd265947f1c0d7;p=thirdparty%2Fkernel%2Flinux.git ACPI: button: Use bool for representing boolean values Change the data type of the last_state field in struct acpi_button and the data type of the acpi_lid_notify_state() second argument to bool because they both are used for storing boolean values. Update the callers of acpi_lid_notify_state() accordingly and while at it, remove the unnecessary (void) cast from the acpi_lid_update_state() call in acpi_lid_initialize_state() for consistency. No intentional functional impact. Signed-off-by: Rafael J. Wysocki Link: https://patch.msgid.link/2274778.irdbgypaU6@rafael.j.wysocki --- diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c index d2c2b81056391..21a10da8b60b3 100644 --- a/drivers/acpi/button.c +++ b/drivers/acpi/button.c @@ -175,7 +175,7 @@ struct acpi_button { struct input_dev *input; char phys[32]; /* for input device */ unsigned long pushed; - int last_state; + bool last_state; ktime_t last_time; bool suspended; bool lid_state_initialized; @@ -204,7 +204,7 @@ static int acpi_lid_evaluate_state(acpi_handle lid_handle) return lid_state ? 1 : 0; } -static int acpi_lid_notify_state(struct acpi_button *button, int state) +static int acpi_lid_notify_state(struct acpi_button *button, bool state) { struct acpi_device *device = button->adev; ktime_t next_report; @@ -218,14 +218,14 @@ static int acpi_lid_notify_state(struct acpi_button *button, int state) * switch. */ if (lid_init_state != ACPI_BUTTON_LID_INIT_IGNORE || - button->last_state != !!state) + button->last_state != state) do_update = true; else do_update = false; next_report = ktime_add(button->last_time, ms_to_ktime(lid_report_interval)); - if (button->last_state == !!state && + if (button->last_state == state && ktime_after(ktime_get(), next_report)) { /* Complain about the buggy firmware. */ pr_warn_once(FW_BUG "Unexpected lid state reported by firmware\n"); @@ -279,7 +279,7 @@ static int acpi_lid_notify_state(struct acpi_button *button, int state) state ? "open" : "closed"); input_report_switch(button->input, SW_LID, !state); input_sync(button->input); - button->last_state = !!state; + button->last_state = state; button->last_time = ktime_get(); } @@ -426,10 +426,10 @@ static void acpi_lid_initialize_state(struct acpi_button *button) { switch (lid_init_state) { case ACPI_BUTTON_LID_INIT_OPEN: - (void)acpi_lid_notify_state(button, 1); + acpi_lid_notify_state(button, true); break; case ACPI_BUTTON_LID_INIT_METHOD: - (void)acpi_lid_update_state(button, false); + acpi_lid_update_state(button, false); break; case ACPI_BUTTON_LID_INIT_IGNORE: default: