From patchwork Sun Jun 4 15:22:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 103034 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2206482vqr; Sun, 4 Jun 2023 09:00:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ56Ivhwb1DIoS0rUE7rlMlB+CRM42r2WSLQS/a1FJtxGIlFS0ZOSRIcCmTxi/ir+1dLDWCc X-Received: by 2002:a17:903:18e:b0:1b0:6a99:cfe0 with SMTP id z14-20020a170903018e00b001b06a99cfe0mr5689333plg.17.1685894402061; Sun, 04 Jun 2023 09:00:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685894402; cv=none; d=google.com; s=arc-20160816; b=zYAO+AZOuQPITIDJlcmNaJe/w6TDJwPPS08H5WGquJ0ykEK2sRhJfOyC4a0l0OskVI bOvIQhJinMj6FfH43ee3rMJi8F9uEw6rjWbntD/cyRipdKAKZo9nxbH26Wy9oGx1w0iX SLzcoEp5Hv1prNEWwZvAzNvvHE74xMIcuPK6OHAIGkQuv2ot567HBY2VleJxuHBDiSnG 40mcph5i1YVbrEY8Y6VpWpGuOed3rjLjWquLL3xyPcIvuD+Au3gqel6yjlqrnoK1kaFL TtXSG50QenhrnkaWh+/7Oz1tCjqC7Kcef0RmdKM7aquI1juT0lLvW4nS640+RMq4RRKz Yuzw== 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=2MGFo3nsIfI5B5K9GXzIUc6O8gs4zd/38b21mcn12MM=; b=nyxSmb/foew5xf1xc5tyPNUMObprzJ5owsBREgTJaMftRO/851xJoIa3m9zMejq8QQ D6OtHfDJsuxzFqp2GRqY+bVyvUmzFd3JTfdChlLMJwp8LfEo3ZsLu9Ao/5qbicfXNsFf CC9W37GVIxkvXLQAWig5sxV9App09vGvrFDRUZJZYc0N3p5dKL0b522MmpZ0+BG9nm5u 7lah7tL4jdtzBBgZDm3IOa2UR5sCIs/5gc4eY33M/tq+S97z4JnIZqgSqtDtEUGTu2Zk 9L7QmkwISt93NAwCqxgA3vCPoJpHB7MecIqY76kl65HvP2538a5Yag/twxfd5id7anGw tHjw== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e12-20020a170902ed8c00b001ae5b59462asi4084975plj.309.2023.06.04.08.59.48; Sun, 04 Jun 2023 09:00:02 -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 S230392AbjFDPYh (ORCPT + 99 others); Sun, 4 Jun 2023 11:24:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229449AbjFDPYf (ORCPT ); Sun, 4 Jun 2023 11:24:35 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63349CE; 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 4b94dd63f174b4c0; Sun, 4 Jun 2023 17:24:32 +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 69A92961C82; Sun, 4 Jun 2023 17:24:32 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux ACPI Cc: LKML , Michal Wilczynski , Josh Triplett , Hanjun Guo Subject: [RFT][PATCH v1 3/4] ACPI: tiny-power-button: Eliminate the driver notify callback Date: Sun, 04 Jun 2023 17:22:48 +0200 Message-ID: <5392458.Sb9uPGUboI@kreacher> In-Reply-To: <1847933.atdPhlSkOF@kreacher> References: <1847933.atdPhlSkOF@kreacher> MIME-Version: 1.0 X-CLIENT-IP: 195.136.19.94 X-CLIENT-HOSTNAME: 195.136.19.94 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvhedrfeeljedgkeekucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepvdffueeitdfgvddtudegueejtdffteetgeefkeffvdeftddttdeuhfegfedvjefhnecukfhppeduleehrddufeeirdduledrleegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepudelhedrudefiedrudelrdelgedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohephedprhgtphhtthhopehlihhnuhigqdgrtghpihesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehmihgthhgrlhdrfihilhgtiiihnhhskhhisehinhhtvghlrdgtohhmpdhrtghpthhtohepjhhoshhhsehjohhshhhtrhhiphhlvghtthdrohhrghdprhgtphht thhopehguhhohhgrnhhjuhhnsehhuhgrfigvihdrtghomh X-DCC--Metrics: v370.home.net.pl 1024; Body=5 Fuz1=5 Fuz2=5 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767788408200162637?= X-GMAIL-MSGID: =?utf-8?q?1767788408200162637?= From: Rafael J. Wysocki Rework the ACPI tiny-power-button driver to install a notify handler or a fixed event handler for the device it binds to by itself and drop its notify callback. This will allow acpi_device_install_notify_handler() and acpi_device_remove_notify_handler() to be simplified going forward. Signed-off-by: Rafael J. Wysocki --- drivers/acpi/tiny-power-button.c | 49 ++++++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 8 deletions(-) Index: linux-pm/drivers/acpi/tiny-power-button.c =================================================================== --- linux-pm.orig/drivers/acpi/tiny-power-button.c +++ linux-pm/drivers/acpi/tiny-power-button.c @@ -19,18 +19,52 @@ static const struct acpi_device_id tiny_ }; MODULE_DEVICE_TABLE(acpi, tiny_power_button_device_ids); -static int acpi_noop_add(struct acpi_device *device) +static void acpi_tiny_power_button_notify(acpi_handle handle, u32 event, void *data) { - return 0; + kill_cad_pid(power_signal, 1); } -static void acpi_noop_remove(struct acpi_device *device) +static void acpi_tiny_power_button_notify_run(void *not_used) { + acpi_tiny_power_button_notify(NULL, ACPI_FIXED_HARDWARE_EVENT, NULL); } -static void acpi_tiny_power_button_notify(struct acpi_device *device, u32 event) +static u32 acpi_tiny_power_button_event(void *not_used) { - kill_cad_pid(power_signal, 1); + acpi_os_execute(OSL_NOTIFY_HANDLER, acpi_tiny_power_button_notify_run, NULL); + return ACPI_INTERRUPT_HANDLED; +} + +static int acpi_tiny_power_button_add(struct acpi_device *device) +{ + acpi_status status; + + if (device->device_type == ACPI_BUS_TYPE_POWER_BUTTON) { + status = acpi_install_fixed_event_handler(ACPI_EVENT_POWER_BUTTON, + acpi_tiny_power_button_event, + NULL); + } else { + status = acpi_install_notify_handler(device->handle, + ACPI_DEVICE_NOTIFY, + acpi_tiny_power_button_notify, + NULL); + } + if (ACPI_FAILURE(status)) + return -ENODEV; + + return 0; +} + +static void acpi_tiny_power_button_remove(struct acpi_device *device) +{ + if (device->device_type == ACPI_BUS_TYPE_POWER_BUTTON) { + acpi_remove_fixed_event_handler(ACPI_EVENT_POWER_BUTTON, + acpi_tiny_power_button_event); + } else { + acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, + acpi_tiny_power_button_notify); + } + acpi_os_wait_events_complete(); } static struct acpi_driver acpi_tiny_power_button_driver = { @@ -38,9 +72,8 @@ static struct acpi_driver acpi_tiny_powe .class = "tiny-power-button", .ids = tiny_power_button_device_ids, .ops = { - .add = acpi_noop_add, - .remove = acpi_noop_remove, - .notify = acpi_tiny_power_button_notify, + .add = acpi_tiny_power_button_add, + .remove = acpi_tiny_power_button_remove, }, };