From patchwork Thu Jun 1 13:17:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 688324 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6527FC77B7E for ; Thu, 1 Jun 2023 13:43:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233357AbjFANnZ (ORCPT ); Thu, 1 Jun 2023 09:43:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233887AbjFANnT (ORCPT ); Thu, 1 Jun 2023 09:43:19 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6227D18B; Thu, 1 Jun 2023 06:43:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685626996; x=1717162996; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fkEaRIb+aCgkppCjudGHedC6J4w9GYBp7R496rzIUY4=; b=hiPowNVq6Lwu4V5pb818dvIcM4BtbnDhGG+SJeMGLXxa0LiHAPH3mBM3 c20+lEdHUfiKtevklRAYlx3ulj9o8Cw2C8xBZ47/yP0xDH8AkWPnNLZsV m4SUBbfrbJdb5/ljE/NeJn/YeR8kLv1hjglsQSPMDPR8xEJ9QFT/7H++a /ygFVGav7Au1AN5iW7i3PtjxNCjyo0TNixpeq1JZB6fF+dgo8PFfnwvDO vzhMpSwqI7O+XB89wZPPHkWWlORAun2wJI1G73tIQNUH0kV5S3nunW2gC L9i+mLfRh4ueyECQy0/oX9evXcWsElGe207QV7qtb7pJiniC+JN48QWVO A==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="419067027" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="419067027" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:18:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="881601590" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="881601590" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:18:46 -0700 From: Michal Wilczynski To: "Rafael J. Wysocki" , Len Brown Cc: Michal Wilczynski , linux-acpi@vger.kernel.org, platform-driver-x86@vger.kernel.org Subject: [PATCH v4 09/35] acpi/tiny-power-button: Move handler installing logic to driver Date: Thu, 1 Jun 2023 15:17:12 +0200 Message-Id: <20230601131739.300760-10-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230601131739.300760-3-michal.wilczynski@intel.com> References: <20230601131739.300760-3-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Currently logic for installing notifications from ACPI devices is implemented using notify callback in struct acpi_driver. Preparations are being made to replace acpi_driver with more generic struct platform_driver, which doesn't contain notify callback. Furthermore as of now handlers are being called indirectly through acpi_notify_device(), which decreases performance. Call acpi_device_install_event_handler() at the end of .add() callback. Call acpi_device_remove_event_handler() at the beginning of .remove() callback. Change arguments passed to the notify callback to match with what's required by acpi_device_install_event_handler(). Signed-off-by: Michal Wilczynski --- drivers/acpi/tiny-power-button.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/acpi/tiny-power-button.c b/drivers/acpi/tiny-power-button.c index 598f548b21f3..9c8e8b8cc19f 100644 --- a/drivers/acpi/tiny-power-button.c +++ b/drivers/acpi/tiny-power-button.c @@ -19,18 +19,21 @@ static const struct acpi_device_id tiny_power_button_device_ids[] = { }; 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 int acpi_tiny_power_button_add(struct acpi_device *device) { + return acpi_device_install_event_handler(device, ACPI_DEVICE_NOTIFY, + acpi_tiny_power_button_notify); } -static void acpi_tiny_power_button_notify(struct acpi_device *device, u32 event) +static void acpi_tiny_power_button_remove(struct acpi_device *device) { - kill_cad_pid(power_signal, 1); + acpi_device_remove_event_handler(device, ACPI_DEVICE_NOTIFY, + acpi_tiny_power_button_notify); } static struct acpi_driver acpi_tiny_power_button_driver = { @@ -38,9 +41,8 @@ static struct acpi_driver acpi_tiny_power_button_driver = { .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, }, };