Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4606528rwd; Sun, 4 Jun 2023 08:45:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ40BTXFHfFPtu0VObABNhwowTlw7qY8tkdK8axJlmhUJGfi8EmpXHBdw/cSU456ypx412w6 X-Received: by 2002:a05:6a20:a12c:b0:10b:cb77:5403 with SMTP id q44-20020a056a20a12c00b0010bcb775403mr5016239pzk.52.1685893523848; Sun, 04 Jun 2023 08:45:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685893523; cv=none; d=google.com; s=arc-20160816; b=a4BYn7XMQp1CxyaCDdxW4Ojt8HIVev5blVCneO4OKz0wvFYygkdRnaiR5VDFB6E6gM doT3+CwIn5tI6Or1g9PIZO5Dt2YE5eWN+/Xd4SDaQMGFcO05TYPOZCJpBaKD4wXbzp19 sW+ZIpD8GKKegWI5VyQnLH9FBjXrnG1cyHRKVKpRxjWvqCLRwuYBcvt9XMeL8JVtACPT ofN5qBSOahVBR3LdqaATRRZIGxLiWrzWJxiCyNpUnV24D+WfcsjvVj+2zwzyWmL/SSiF 6pSnocfUkCaiQXOcrnCh0NmiS4LJNJD5Gd1o5YGXHJFs27qjmxRtQl9gpGARnr0blj87 2nvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=NyoA0AFM08aJvqotbodIilTobuZGxvdnJGGXGYA0BeA=; b=f3lHBtFP8nCm/gIoJtIiHe4kBo6eP5jL9mZdMraltR6CDEnwO7Q3ImqKyvCk7UoAyh s7vBal3r/Q2lnH6Y3B3K2ZBTM1Hw8t9BagqKd7kBki1yX2bOQIoA/5raaTUBkeD/gWGW yrosqs8Na9/mqHArUg6JXdwSpR0bvRIUjauAjhSkBGneLqj8Vpv7fV4nJmp0wCxyiWHd ks5ZAyKqH8Xz7Q7GTF2Yn4ylgeObz5CbeqHZDNVB0lqcXDqP3Yo8OygZ43MxPBEdiqu8 VlyGd18+I8kmKF8CW/PWsNdZSSLWEo4GwR4k/0csHQ40Dq4NgO56eA2JQIWRuvqZ4oSu 8Z0g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a127-20020a624d85000000b006519ca72dc6si3901536pfb.161.2023.06.04.08.45.10; Sun, 04 Jun 2023 08:45:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231481AbjFDPYn (ORCPT + 99 others); Sun, 4 Jun 2023 11:24:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230005AbjFDPYg (ORCPT ); Sun, 4 Jun 2023 11:24:36 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 118FBD2; Sun, 4 Jun 2023 08:24:34 -0700 (PDT) Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 5.2.0) id 80b17cd337c071f1; Sun, 4 Jun 2023 17:24:33 +0200 Received: from kreacher.localnet (unknown [195.136.19.94]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by v370.home.net.pl (Postfix) with ESMTPSA id 1D1C1961C82; Sun, 4 Jun 2023 17:24:33 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux ACPI Cc: LKML , Michal Wilczynski Subject: [RFT][PATCH v1 2/4] ACPI: button: Use different notify handlers for lid and buttons Date: Sun, 04 Jun 2023 17:20:27 +0200 Message-ID: <2438693.jE0xQCEvom@kreacher> In-Reply-To: <1847933.atdPhlSkOF@kreacher> References: <1847933.atdPhlSkOF@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 195.136.19.94 X-CLIENT-HOSTNAME: 195.136.19.94 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvhedrfeeljedgkeekucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepvdffueeitdfgvddtudegueejtdffteetgeefkeffvdeftddttdeuhfegfedvjefhnecukfhppeduleehrddufeeirdduledrleegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepudelhedrudefiedrudelrdelgedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohepfedprhgtphhtthhopehlihhnuhigqdgrtghpihesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehmihgthhgrlhdrfihilhgtiiihnhhskhhisehinhhtvghlrdgtohhm X-DCC--Metrics: v370.home.net.pl 1024; Body=3 Fuz1=3 Fuz2=3 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rafael J. Wysocki 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 --- drivers/acpi/button.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) Index: linux-pm/drivers/acpi/button.c =================================================================== --- linux-pm.orig/drivers/acpi/button.c +++ linux-pm/drivers/acpi/button.c @@ -407,12 +407,10 @@ static void acpi_lid_initialize_state(st button->lid_state_initialized = true; } -static void acpi_button_notify(acpi_handle handle, u32 event, void *data) +static void acpi_lid_notify(acpi_handle handle, u32 event, void *data) { struct acpi_device *device = data; struct acpi_button *button; - struct input_dev *input; - int keycode; if (event != ACPI_BUTTON_NOTIFY_STATUS) { acpi_handle_debug(device->handle, "Unsupported event [0x%x]\n", @@ -421,16 +419,28 @@ static void acpi_button_notify(acpi_hand } button = acpi_driver_data(device); + if (!button->lid_state_initialized) + return; - if (button->type == ACPI_BUTTON_TYPE_LID) { - if (button->lid_state_initialized) - acpi_lid_update_state(device, true); + acpi_lid_update_state(device, true); +} +static void acpi_button_notify(acpi_handle handle, u32 event, void *data) +{ + struct acpi_device *device = data; + struct acpi_button *button; + struct input_dev *input; + int keycode; + + if (event != ACPI_BUTTON_NOTIFY_STATUS) { + acpi_handle_debug(device->handle, "Unsupported event [0x%x]\n", + event); return; } acpi_pm_wakeup_event(&device->dev); + button = acpi_driver_data(device); if (button->suspended) return; @@ -497,6 +507,7 @@ static int acpi_lid_input_open(struct in static int acpi_button_add(struct acpi_device *device) { + acpi_notify_handler handler; struct acpi_button *button; struct input_dev *input; const char *hid = acpi_device_hid(device); @@ -526,17 +537,20 @@ static int acpi_button_add(struct acpi_d if (!strcmp(hid, ACPI_BUTTON_HID_POWER) || !strcmp(hid, ACPI_BUTTON_HID_POWERF)) { button->type = ACPI_BUTTON_TYPE_POWER; + handler = acpi_button_notify; strcpy(name, ACPI_BUTTON_DEVICE_NAME_POWER); sprintf(class, "%s/%s", ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_POWER); } else if (!strcmp(hid, ACPI_BUTTON_HID_SLEEP) || !strcmp(hid, ACPI_BUTTON_HID_SLEEPF)) { button->type = ACPI_BUTTON_TYPE_SLEEP; + handler = acpi_button_notify; strcpy(name, ACPI_BUTTON_DEVICE_NAME_SLEEP); sprintf(class, "%s/%s", ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_SLEEP); } else if (!strcmp(hid, ACPI_BUTTON_HID_LID)) { button->type = ACPI_BUTTON_TYPE_LID; + handler = acpi_lid_notify; strcpy(name, ACPI_BUTTON_DEVICE_NAME_LID); sprintf(class, "%s/%s", ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_LID); @@ -594,8 +608,7 @@ static int acpi_button_add(struct acpi_d break; default: status = acpi_install_notify_handler(device->handle, - ACPI_DEVICE_NOTIFY, - acpi_button_notify, + ACPI_DEVICE_NOTIFY, handler, device); break; } @@ -640,7 +653,9 @@ static void acpi_button_remove(struct ac break; default: acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, - acpi_button_notify); + button->type == ACPI_BUTTON_TYPE_LID ? + acpi_lid_notify : + acpi_button_notify); break; } acpi_os_wait_events_complete();