From: Rafael J. Wysocki Date: Mon, 1 Jun 2026 17:05:31 +0000 (+0200) Subject: ACPI: button: Merge two switch () statements in acpi_button_probe() X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=a99d758f2b2c83808348908aab00b06f5043aac0;p=thirdparty%2Fkernel%2Flinux.git ACPI: button: Merge two switch () statements in acpi_button_probe() Two switch () statements in acpi_button_probe() operate on the same value and the statements between them can be reordered with respect to the second one, so merge them. No intentional functional impact. Signed-off-by: Rafael J. Wysocki Link: https://patch.msgid.link/3352815.5fSG56mABF@rafael.j.wysocki --- diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c index a8c43f1951cd..0946995c93aa 100644 --- a/drivers/acpi/button.c +++ b/drivers/acpi/button.c @@ -582,14 +582,19 @@ static int acpi_button_probe(struct platform_device *pdev) switch (button_type) { case ACPI_BUTTON_TYPE_LID: input->name = ACPI_BUTTON_DEVICE_NAME_LID; + input_set_capability(input, EV_SW, SW_LID); + input->open = acpi_lid_input_open; + handler = acpi_lid_notify; sprintf(class, "%s/%s", ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_LID); - input->open = acpi_lid_input_open; break; case ACPI_BUTTON_TYPE_POWER: input->name = ACPI_BUTTON_DEVICE_NAME_POWER; + input_set_capability(input, EV_KEY, KEY_POWER); + input_set_capability(input, EV_KEY, KEY_WAKEUP); + handler = acpi_button_notify; sprintf(class, "%s/%s", ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_POWER); @@ -597,6 +602,8 @@ static int acpi_button_probe(struct platform_device *pdev) case ACPI_BUTTON_TYPE_SLEEP: input->name = ACPI_BUTTON_DEVICE_NAME_SLEEP; + input_set_capability(input, EV_KEY, KEY_SLEEP); + handler = acpi_button_notify; sprintf(class, "%s/%s", ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_SLEEP); @@ -614,28 +621,14 @@ static int acpi_button_probe(struct platform_device *pdev) goto err_free_button; } - snprintf(button->phys, sizeof(button->phys), "%s/button/input0", id->id); + snprintf(button->phys, sizeof(button->phys), "%s/button/input0", + acpi_device_hid(device)); input->phys = button->phys; input->id.bustype = BUS_HOST; input->id.product = button_type; input->dev.parent = dev; - switch (button_type) { - case ACPI_BUTTON_TYPE_POWER: - input_set_capability(input, EV_KEY, KEY_POWER); - input_set_capability(input, EV_KEY, KEY_WAKEUP); - break; - - case ACPI_BUTTON_TYPE_SLEEP: - input_set_capability(input, EV_KEY, KEY_SLEEP); - break; - - case ACPI_BUTTON_TYPE_LID: - input_set_capability(input, EV_SW, SW_LID); - break; - } - input_set_drvdata(input, button); error = input_register_device(input); if (error) {