From patchwork Fri May 12 14:01:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 681252 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 62930C77B7C for ; Fri, 12 May 2023 14:03:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241371AbjELOC7 (ORCPT ); Fri, 12 May 2023 10:02:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241353AbjELOC7 (ORCPT ); Fri, 12 May 2023 10:02:59 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3E38197 for ; Fri, 12 May 2023 07:02:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683900175; x=1715436175; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XSKAK7VNXsc/8KMxEQHR3nZjCfolNQwCVJqoTMqbTbo=; b=GLc2aBurxvweDBVcekuxDKKGAREbbioxGcU2cinm23FfOPZxCiFBbdZc W/JiGDhCbsCLYbvjnnpzvE6oY24NaLEJmaObTuSR/loiZonKvWmGTO3vv XjuNhhWrH0AUzkg8jgWlkiIPfLjCs4UIYxXKuYz3OAm4PSTsnpMBP4AHy by6LwGvPYOLmS4BRzsFV5oayhyD+wilEML9CrRzBlQ+DwKsnmM6DTY8FV 9sbBwe8AyB5yHz6FXiK3guhx64c7sOAbUOrC8p2ItwAiRPavfYfz9JelL dF540cr0FG+E6PoHcUouyeqc8m1iKI9RGXTOIonebj/SMOh4mnvRm4SlK Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="378930974" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="378930974" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:02:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="650648894" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="650648894" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:02:43 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, Michal Wilczynski Subject: [PATCH v1 01/34] acpi: Adjust functions installing bus event handlers Date: Fri, 12 May 2023 16:01:49 +0200 Message-Id: <20230512140222.124868-2-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230512140222.124868-1-michal.wilczynski@intel.com> References: <20230512140222.124868-1-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Currently acpi_device_install_notify_handler() and acpi_device_remove_notify_handler() always install acpi_notify_device() as a function handler, and only then the real .notify callback gets called. This is not efficient and doesn't provide any real advantage. Introduce new acpi_device_install_event_handler() and acpi_device_remove_event_handler(). Those functions are replacing old installers, and after all drivers switch to the new model, old installers will be removed at the end of the patchset. Make new installer/removal function arguments to take function pointer as an argument instead of using .notify callback. Introduce new variable in struct acpi_device, as fixed events still needs to be handled by an intermediary that would schedule them for later execution. This is due to fixed hardware event handlers being executed in interrupt context. Make acpi_device_install_event_handler() and acpi_device_remove_event_handler() non-static, and export symbols. This will allow the drivers to call them directly, instead of relying on .notify callback. Signed-off-by: Michal Wilczynski --- drivers/acpi/bus.c | 56 ++++++++++++++++++++++++++++++++++++++++- include/acpi/acpi_bus.h | 7 ++++++ 2 files changed, 62 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index d161ff707de4..00309df56c24 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -535,7 +535,7 @@ static void acpi_notify_device_fixed(void *data) struct acpi_device *device = data; /* Fixed hardware devices have no handles */ - acpi_notify_device(NULL, ACPI_FIXED_HARDWARE_EVENT, device); + device->fixed_event_notify(NULL, ACPI_FIXED_HARDWARE_EVENT, device); } static u32 acpi_device_fixed_event(void *data) @@ -550,11 +550,13 @@ static int acpi_device_install_notify_handler(struct acpi_device *device, acpi_status status; if (device->device_type == ACPI_BUS_TYPE_POWER_BUTTON) { + device->fixed_event_notify = acpi_notify_device; status = acpi_install_fixed_event_handler(ACPI_EVENT_POWER_BUTTON, acpi_device_fixed_event, device); } else if (device->device_type == ACPI_BUS_TYPE_SLEEP_BUTTON) { + device->fixed_event_notify = acpi_notify_device; status = acpi_install_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON, acpi_device_fixed_event, @@ -579,9 +581,11 @@ static void acpi_device_remove_notify_handler(struct acpi_device *device, if (device->device_type == ACPI_BUS_TYPE_POWER_BUTTON) { acpi_remove_fixed_event_handler(ACPI_EVENT_POWER_BUTTON, acpi_device_fixed_event); + device->fixed_event_notify = NULL; } else if (device->device_type == ACPI_BUS_TYPE_SLEEP_BUTTON) { acpi_remove_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON, acpi_device_fixed_event); + device->fixed_event_notify = NULL; } else { u32 type = acpi_drv->flags & ACPI_DRIVER_ALL_NOTIFY_EVENTS ? ACPI_ALL_NOTIFY : ACPI_DEVICE_NOTIFY; @@ -592,6 +596,56 @@ static void acpi_device_remove_notify_handler(struct acpi_device *device, acpi_os_wait_events_complete(); } +int acpi_device_install_event_handler(struct acpi_device *device, + u32 type, + void (*notify)(acpi_handle, u32, void*)) +{ + acpi_status status; + + if (device->device_type == ACPI_BUS_TYPE_POWER_BUTTON) { + device->fixed_event_notify = notify; + status = + acpi_install_fixed_event_handler(ACPI_EVENT_POWER_BUTTON, + acpi_device_fixed_event, + device); + } else if (device->device_type == ACPI_BUS_TYPE_SLEEP_BUTTON) { + device->fixed_event_notify = notify; + status = + acpi_install_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON, + acpi_device_fixed_event, + device); + } else { + status = acpi_install_notify_handler(device->handle, type, + notify, + device); + } + + if (ACPI_FAILURE(status)) + return -EINVAL; + return 0; +} +EXPORT_SYMBOL(acpi_device_install_event_handler); + +void acpi_device_remove_event_handler(struct acpi_device *device, + u32 type, + void (*notify)(acpi_handle, u32, void*)) +{ + if (device->device_type == ACPI_BUS_TYPE_POWER_BUTTON) { + acpi_remove_fixed_event_handler(ACPI_EVENT_POWER_BUTTON, + acpi_device_fixed_event); + device->fixed_event_notify = NULL; + } else if (device->device_type == ACPI_BUS_TYPE_SLEEP_BUTTON) { + acpi_remove_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON, + acpi_device_fixed_event); + device->fixed_event_notify = NULL; + } else { + acpi_remove_notify_handler(device->handle, type, + notify); + } + acpi_os_wait_events_complete(); +} +EXPORT_SYMBOL(acpi_device_remove_event_handler); + /* Handle events targeting \_SB device (at present only graceful shutdown) */ #define ACPI_SB_NOTIFY_SHUTDOWN_REQUEST 0x81 diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index a6affc0550b0..7fb411438b6f 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -387,6 +387,7 @@ struct acpi_device { struct list_head physical_node_list; struct mutex physical_node_lock; void (*remove)(struct acpi_device *); + void (*fixed_event_notify)(acpi_handle handle, u32 type, void *data); }; /* Non-device subnode */ @@ -513,6 +514,12 @@ void acpi_bus_private_data_handler(acpi_handle, void *); int acpi_bus_get_private_data(acpi_handle, void **); int acpi_bus_attach_private_data(acpi_handle, void *); void acpi_bus_detach_private_data(acpi_handle); +int acpi_device_install_event_handler(struct acpi_device *device, + u32 type, + void (*notify)(acpi_handle, u32, void*)); +void acpi_device_remove_event_handler(struct acpi_device *device, + u32 type, + void (*notify)(acpi_handle, u32, void*)); extern int acpi_notifier_call_chain(struct acpi_device *, u32, u32); extern int register_acpi_notifier(struct notifier_block *); extern int unregister_acpi_notifier(struct notifier_block *); From patchwork Fri May 12 14:01:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 681615 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 80CDAC77B75 for ; Fri, 12 May 2023 14:03:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241378AbjELODA (ORCPT ); Fri, 12 May 2023 10:03:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241368AbjELOC7 (ORCPT ); Fri, 12 May 2023 10:02:59 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 659B2B8 for ; Fri, 12 May 2023 07:02:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683900178; x=1715436178; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Ri95ibnY+6HXM8Tf3VpgD5BvYyPmbN6W16pWbNmQNHY=; b=gxXs+y4FE+oHdDWO7WGQhfdVsAaD8xXEFB9RyI1hBXAJStQ0GjCss59n 0Dvir4XBHIl0NqmL+vaqzwekggmfPWqMimICyh+GJXtnumrcZ/OaBFI4O j2nVWlV+7ZwuWvgrUFMzqy6qAOQz2mSSMTfMRgc35mFhTLvt7ETr1CV40 qXJ5xuRp2li81sTBQHxGAsR0yss51j2Mni4MauyxakvlR4Bh1o0GnCnh0 yCbghxsJbVl2su13tp5iGR8JJ7NqHNtw/pMM7eJAVMZtoM4QIppL4Gdyi aO9abOaGvztTZlGCoLSRy5JfJfeQjUjYkM1LE4n7wpEkXvwMAv0vBR1NT w==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="378930990" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="378930990" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:02:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="650648901" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="650648901" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:02:46 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, Michal Wilczynski Subject: [PATCH v1 02/34] acpi/ac: Move handler installing logic to driver Date: Fri, 12 May 2023 16:01:50 +0200 Message-Id: <20230512140222.124868-3-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230512140222.124868-1-michal.wilczynski@intel.com> References: <20230512140222.124868-1-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_install_event_handler(). Signed-off-by: Michal Wilczynski --- drivers/acpi/ac.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c index 1ace70b831cd..208af5a3106e 100644 --- a/drivers/acpi/ac.c +++ b/drivers/acpi/ac.c @@ -34,7 +34,7 @@ MODULE_LICENSE("GPL"); static int acpi_ac_add(struct acpi_device *device); static void acpi_ac_remove(struct acpi_device *device); -static void acpi_ac_notify(struct acpi_device *device, u32 event); +static void acpi_ac_notify(acpi_handle handle, u32 event, void *data); static const struct acpi_device_id ac_device_ids[] = { {"ACPI0003", 0}, @@ -54,11 +54,9 @@ static struct acpi_driver acpi_ac_driver = { .name = "ac", .class = ACPI_AC_CLASS, .ids = ac_device_ids, - .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS, .ops = { .add = acpi_ac_add, .remove = acpi_ac_remove, - .notify = acpi_ac_notify, }, .drv.pm = &acpi_ac_pm, }; @@ -128,9 +126,12 @@ static enum power_supply_property ac_props[] = { }; /* Driver Model */ -static void acpi_ac_notify(struct acpi_device *device, u32 event) +static void acpi_ac_notify(acpi_handle handle, u32 event, void *data) { - struct acpi_ac *ac = acpi_driver_data(device); + struct acpi_device *device = data; + struct acpi_ac *ac; + + ac = acpi_driver_data(device); if (!ac) return; @@ -256,6 +257,8 @@ static int acpi_ac_add(struct acpi_device *device) ac->battery_nb.notifier_call = acpi_ac_battery_notify; register_acpi_notifier(&ac->battery_nb); + + result = acpi_device_install_event_handler(device, ACPI_ALL_NOTIFY, acpi_ac_notify); end: if (result) kfree(ac); @@ -297,6 +300,7 @@ static void acpi_ac_remove(struct acpi_device *device) ac = acpi_driver_data(device); + acpi_device_remove_event_handler(device, ACPI_ALL_NOTIFY, acpi_ac_notify); power_supply_unregister(ac->charger); unregister_acpi_notifier(&ac->battery_nb); From patchwork Fri May 12 14:01:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 681614 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 3E22CC77B7C for ; Fri, 12 May 2023 14:03:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241385AbjELODH (ORCPT ); Fri, 12 May 2023 10:03:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241380AbjELODB (ORCPT ); Fri, 12 May 2023 10:03:01 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FE76197 for ; Fri, 12 May 2023 07:02:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683900179; x=1715436179; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2GbV0P1CvPEQGkReiS1XP+SO7s2AdGYiVfzqGrM4eXI=; b=ILZDEDL+RiZu0cVE7rFPeFB279k/4c2pG2rKWobINUqECCa7uR/PZVeh 2lbT8WsdASwDATouAc+fZW0ojINxLcNxWySOZctt5jy2tnu2EuNph0edQ VAUEW0rjCwk4JEri94obBSyOmbU3oBzNEYwJydmrcEhIGbEA0bAOnIEXD Q4d0LeoHenqOsA2ViDEPx5yuGZlom4ZPa3iZE4mhBu/OUVTVHJsF9IQCr lOnxrWQpitZuC4UdNXrYPbzY9UT6pPEpq7R60G9NHM+ylMLywFxVNF5oU LzfQ5GOWabUs5CrGKXCUXV/qWccyIOIhqxRmoRiXIBqMyGY+3HzucpCZC A==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="378931022" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="378931022" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:02:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="650648907" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="650648907" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:02:49 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, Michal Wilczynski Subject: [PATCH v1 03/34] acpi/video: Move handler installing logic to driver Date: Fri, 12 May 2023 16:01:51 +0200 Message-Id: <20230512140222.124868-4-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230512140222.124868-1-michal.wilczynski@intel.com> References: <20230512140222.124868-1-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/acpi_video.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c index 62f4364e4460..c94f36f14980 100644 --- a/drivers/acpi/acpi_video.c +++ b/drivers/acpi/acpi_video.c @@ -77,7 +77,7 @@ static DEFINE_MUTEX(video_list_lock); static LIST_HEAD(video_bus_head); static int acpi_video_bus_add(struct acpi_device *device); static void acpi_video_bus_remove(struct acpi_device *device); -static void acpi_video_bus_notify(struct acpi_device *device, u32 event); +static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data); /* * Indices in the _BCL method response: the first two items are special, @@ -104,7 +104,6 @@ static struct acpi_driver acpi_video_bus = { .ops = { .add = acpi_video_bus_add, .remove = acpi_video_bus_remove, - .notify = acpi_video_bus_notify, }, }; @@ -1527,12 +1526,15 @@ static int acpi_video_bus_stop_devices(struct acpi_video_bus *video) acpi_osi_is_win8() ? 0 : 1); } -static void acpi_video_bus_notify(struct acpi_device *device, u32 event) +static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data) { - struct acpi_video_bus *video = acpi_driver_data(device); + struct acpi_device *device = data; + struct acpi_video_bus *video; struct input_dev *input; int keycode = 0; + video = acpi_driver_data(device); + if (!video || !video->input) return; @@ -2053,7 +2055,12 @@ static int acpi_video_bus_add(struct acpi_device *device) acpi_video_bus_add_notify_handler(video); - return 0; + error = acpi_device_install_event_handler(device, ACPI_DEVICE_NOTIFY, + acpi_video_bus_notify); + if (error) + goto err_put_video; + + return error; err_put_video: acpi_video_bus_put_devices(video); @@ -2075,6 +2082,7 @@ static void acpi_video_bus_remove(struct acpi_device *device) video = acpi_driver_data(device); + acpi_device_remove_event_handler(device, ACPI_DEVICE_NOTIFY, acpi_video_bus_notify); mutex_lock(&video_list_lock); list_del(&video->entry); mutex_unlock(&video_list_lock); From patchwork Fri May 12 14:01:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 681251 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 067EAC7EE23 for ; Fri, 12 May 2023 14:03:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241368AbjELODB (ORCPT ); Fri, 12 May 2023 10:03:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241353AbjELODA (ORCPT ); Fri, 12 May 2023 10:03:00 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52286198E for ; Fri, 12 May 2023 07:02:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683900179; x=1715436179; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cQOhgVN9KktkwIdn69lUFA14KuHTSV40NQJJxX6i+1c=; b=epVF8xWbn7LUVJez0VmXIiycZvbRXkB59XhWk1wbgx0XyPV2rgypVTi4 BHxxn2V8mZ7OWM4+FvgKvcDgmvERz78HVFPgIQu2YwuE3WSfGQP1Qyq6I x1sFRpoNO5Prj4F6tr6h3YJpffmNM4SDiE/iHnoMKPMVABExkIaaGOCpK OWFrl9AXbUZqVfvyhZDu2AFH+r2MSDkn6dfAkOA1cB488F9FElzvdNiZl 4sjDhW+0ydUiUlH352DCjGzK+2W/tKli4Awf0vLshooRYxRvJjIqrI2ss MaiDIq+M1llhvRojbEB7YU9rr6cQ0Ot7EfJi82ZEy3iJHin7+FpBFJUDj w==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="378931017" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="378931017" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:02:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="650648911" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="650648911" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:02:51 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, Michal Wilczynski Subject: [PATCH v1 04/34] acpi/battery: Move handler installing logic to driver Date: Fri, 12 May 2023 16:01:52 +0200 Message-Id: <20230512140222.124868-5-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230512140222.124868-1-michal.wilczynski@intel.com> References: <20230512140222.124868-1-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/battery.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 9c67ed02d797..18c496f76d42 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -1034,11 +1034,14 @@ static void acpi_battery_refresh(struct acpi_battery *battery) } /* Driver Interface */ -static void acpi_battery_notify(struct acpi_device *device, u32 event) +static void acpi_battery_notify(acpi_handle handle, u32 event, void *data) { - struct acpi_battery *battery = acpi_driver_data(device); + struct acpi_device *device = data; + struct acpi_battery *battery; struct power_supply *old; + battery = acpi_driver_data(device); + if (!battery) return; old = battery->bat; @@ -1212,6 +1215,10 @@ static int acpi_battery_add(struct acpi_device *device) device_init_wakeup(&device->dev, 1); + result = acpi_device_install_event_handler(device, ACPI_ALL_NOTIFY, acpi_battery_notify); + if (result) + goto fail; + return result; fail: @@ -1228,6 +1235,7 @@ static void acpi_battery_remove(struct acpi_device *device) if (!device || !acpi_driver_data(device)) return; + acpi_device_remove_event_handler(device, ACPI_ALL_NOTIFY, acpi_battery_notify); device_init_wakeup(&device->dev, 0); battery = acpi_driver_data(device); unregister_pm_notifier(&battery->pm_nb); @@ -1264,11 +1272,9 @@ static struct acpi_driver acpi_battery_driver = { .name = "battery", .class = ACPI_BATTERY_CLASS, .ids = battery_device_ids, - .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS, .ops = { .add = acpi_battery_add, .remove = acpi_battery_remove, - .notify = acpi_battery_notify, }, .drv.pm = &acpi_battery_pm, }; From patchwork Fri May 12 14:01:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 681250 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 BCFB4C77B75 for ; Fri, 12 May 2023 14:03:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241420AbjELODH (ORCPT ); Fri, 12 May 2023 10:03:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241387AbjELODB (ORCPT ); Fri, 12 May 2023 10:03:01 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A563D19BE for ; Fri, 12 May 2023 07:02:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683900179; x=1715436179; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9ornG7hWOY6i8oXxZC9eMfmzDrjvXb8WBsDPkaTucWY=; b=ICqOlo8UmgjlHjihcX8udwCDRTANg/WtPHjQ7BlBwmndTDzvbiDwOWFc qqKusTA/qvsRJGmV9tf1Y+IK8QAAc/hoIBVmd63rysvYvfusMNvpzzIje zFH6w0exGk/soukYO7K4bNOeLMSweW8T4REv+EM250CG8La2dRlh6YwdC kyv657NJoLKmvUzYmbS7rIvvyad+8gErfsYt73/x+RF1xpcPJvzbE+mf3 YeJ1XH9PlvKdIFCtN4gXxihR+AdHWrwHDSkroB/XWjkWW/Lo+gMT7pQnA 5Wp3xcglWQ7B7CPW+ALN0Kl/9JhPogaV5iI4CgZIVP1ZoLUXT1xhwbt33 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="378931024" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="378931024" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:02:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="650648915" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="650648915" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:02:53 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, Michal Wilczynski Subject: [PATCH v1 05/34] acpi/button: Move handler installing logic to driver Date: Fri, 12 May 2023 16:01:53 +0200 Message-Id: <20230512140222.124868-6-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230512140222.124868-1-michal.wilczynski@intel.com> References: <20230512140222.124868-1-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/button.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c index 475e1eddfa3b..e978b2eafb27 100644 --- a/drivers/acpi/button.c +++ b/drivers/acpi/button.c @@ -126,7 +126,7 @@ static const struct dmi_system_id dmi_lid_quirks[] = { static int acpi_button_add(struct acpi_device *device); static void acpi_button_remove(struct acpi_device *device); -static void acpi_button_notify(struct acpi_device *device, u32 event); +static void acpi_button_notify(acpi_handle handle, u32 event, void *data); #ifdef CONFIG_PM_SLEEP static int acpi_button_suspend(struct device *dev); @@ -144,7 +144,6 @@ static struct acpi_driver acpi_button_driver = { .ops = { .add = acpi_button_add, .remove = acpi_button_remove, - .notify = acpi_button_notify, }, .drv.pm = &acpi_button_pm, }; @@ -400,11 +399,14 @@ static void acpi_lid_initialize_state(struct acpi_device *device) button->lid_state_initialized = true; } -static void acpi_button_notify(struct acpi_device *device, u32 event) +static void acpi_button_notify(acpi_handle handle, u32 event, void *data) { - struct acpi_button *button = acpi_driver_data(device); + struct acpi_device *device = data; + struct acpi_button *button; struct input_dev *input; + button = acpi_driver_data(device); + switch (event) { case ACPI_FIXED_HARDWARE_EVENT: event = ACPI_BUTTON_NOTIFY_STATUS; @@ -569,7 +571,12 @@ static int acpi_button_add(struct acpi_device *device) device_init_wakeup(&device->dev, true); pr_info("%s [%s]\n", name, acpi_device_bid(device)); - return 0; + + error = acpi_device_install_event_handler(device, ACPI_DEVICE_NOTIFY, acpi_button_notify); + if (error) + goto err_remove_fs; + + return error; err_remove_fs: acpi_button_remove_fs(device); @@ -584,6 +591,7 @@ static void acpi_button_remove(struct acpi_device *device) { struct acpi_button *button = acpi_driver_data(device); + acpi_device_remove_event_handler(device, ACPI_DEVICE_NOTIFY, acpi_button_notify); acpi_button_remove_fs(device); input_unregister_device(button->input); kfree(button); From patchwork Fri May 12 14:01:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 681613 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 BEBEEC7EE23 for ; Fri, 12 May 2023 14:03:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241388AbjELODI (ORCPT ); Fri, 12 May 2023 10:03:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241353AbjELODB (ORCPT ); Fri, 12 May 2023 10:03:01 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFD341729 for ; Fri, 12 May 2023 07:03:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683900180; x=1715436180; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=P7ODO9EjsRSMUU+TF25N7oGxInxqbR3bwLw9wwr0pYY=; b=GERB+Ro14/AqgRSGslxklC4vhNl5KBvCMxecDIgYzGKcvCusmyx61z9U yrzMzh9uUbbKpB1EUzO6Q4m91dps0dAObIYpAnN2viCK8fi5WPeF0SIKF 6l3vbZM2TrYJY9bEEp9ryPz7asa5ZxSarGjQ+Ji7W5LuKVSaGnIg5cFS8 4SQRrsy6KNlVxN0FCu69wZZddCVb5Iir6DRRJzUcAjDqvxlLNWVsiIB8q Bt1Maot1NhX9G2JP87yZW6Tss9G6xOShTyCAclHvZJ6HHR1jn6l13pnjh OWEJfdq8toxwEIbGInAceElR2UmZkH935nygsZlkIbAy2rw1cJ7xp+UOg g==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="378931033" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="378931033" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:02:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="650648920" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="650648920" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:02:56 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, Michal Wilczynski Subject: [PATCH v1 06/34] acpi/hed: Move handler installing logic to driver Date: Fri, 12 May 2023 16:01:54 +0200 Message-Id: <20230512140222.124868-7-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230512140222.124868-1-michal.wilczynski@intel.com> References: <20230512140222.124868-1-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/hed.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/acpi/hed.c b/drivers/acpi/hed.c index 78d44e3fe129..2a476415817f 100644 --- a/drivers/acpi/hed.c +++ b/drivers/acpi/hed.c @@ -42,7 +42,7 @@ EXPORT_SYMBOL_GPL(unregister_acpi_hed_notifier); * it is used by HEST Generic Hardware Error Source with notify type * SCI. */ -static void acpi_hed_notify(struct acpi_device *device, u32 event) +static void acpi_hed_notify(acpi_handle handle, u32 event, void *data) { blocking_notifier_call_chain(&acpi_hed_notify_list, 0, NULL); } @@ -53,11 +53,12 @@ static int acpi_hed_add(struct acpi_device *device) if (hed_handle) return -EINVAL; hed_handle = device->handle; - return 0; + return acpi_device_install_event_handler(device, ACPI_DEVICE_NOTIFY, acpi_hed_notify); } static void acpi_hed_remove(struct acpi_device *device) { + acpi_device_remove_event_handler(device, ACPI_DEVICE_NOTIFY, acpi_hed_notify); hed_handle = NULL; } @@ -68,7 +69,6 @@ static struct acpi_driver acpi_hed_driver = { .ops = { .add = acpi_hed_add, .remove = acpi_hed_remove, - .notify = acpi_hed_notify, }, }; module_acpi_driver(acpi_hed_driver); From patchwork Fri May 12 14:01:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 681249 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 56F9CC7EE2A for ; Fri, 12 May 2023 14:03:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241353AbjELODJ (ORCPT ); Fri, 12 May 2023 10:03:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241397AbjELODG (ORCPT ); Fri, 12 May 2023 10:03:06 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2CBE1710 for ; Fri, 12 May 2023 07:03:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683900182; x=1715436182; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cKUWfqMu2Js1onBYo4CIiZvIbK10uMibsAiFvs+BEGU=; b=mlEYoXxxOiLGTKrjxsgeGbnXp6plnaoD9r7dx7QKlMlc0GaklYqtYhdS Gp8HkUXi5Lbed25YRJsWMa6Bz/roO6rDXqrtN2UxT1LvZjDZNtPxOQi3o yUTtmduCrvwi9bjQ9FgpGBbHm55Ya4jh6YFTR+73hfJecM1PBwSanvbyb 3EhMXLziqPsSJGNo83i0AOyH0kRY6MFuFmQQUNOEE7e4n2c8jgUxrYgeu YRZf0Yz6wISQstCXlhTPkKUNk2ogB3kYW4JCHIlc2K3CrV94uOs1d4wAj y31WQBSxI/y30bhrcc0y0/5CHLHA46TWd/MgA+ZWZePUVCGrH3rWhhnwz w==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="378931044" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="378931044" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:02:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="650648925" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="650648925" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:02:58 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, Michal Wilczynski Subject: [PATCH v1 07/34] acpi/nfit: Move handler installing logic to driver Date: Fri, 12 May 2023 16:01:55 +0200 Message-Id: <20230512140222.124868-8-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230512140222.124868-1-michal.wilczynski@intel.com> References: <20230512140222.124868-1-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/nfit/core.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c index 07204d482968..2029f0fca9bc 100644 --- a/drivers/acpi/nfit/core.c +++ b/drivers/acpi/nfit/core.c @@ -3368,11 +3368,17 @@ static int acpi_nfit_add(struct acpi_device *adev) if (rc) return rc; - return devm_add_action_or_reset(dev, acpi_nfit_shutdown, acpi_desc); + + rc = devm_add_action_or_reset(dev, acpi_nfit_shutdown, acpi_desc); + if (rc) + return rc; + + return acpi_device_install_event_handler(device, ACPI_DEVICE_NOTIFY, acpi_nfit_notify); } static void acpi_nfit_remove(struct acpi_device *adev) { + acpi_device_remove_event_handler(device, ACPI_DEVICE_NOTIFY, acpi_nfit_notify); /* see acpi_nfit_unregister */ } @@ -3446,7 +3452,7 @@ void __acpi_nfit_notify(struct device *dev, acpi_handle handle, u32 event) } EXPORT_SYMBOL_GPL(__acpi_nfit_notify); -static void acpi_nfit_notify(struct acpi_device *adev, u32 event) +static void acpi_nfit_notify(acpi_handle handle, u32 event, void *data) { device_lock(&adev->dev); __acpi_nfit_notify(&adev->dev, adev->handle, event); @@ -3465,7 +3471,6 @@ static struct acpi_driver acpi_nfit_driver = { .ops = { .add = acpi_nfit_add, .remove = acpi_nfit_remove, - .notify = acpi_nfit_notify, }, }; From patchwork Fri May 12 14:01:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 681248 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 125F8C77B75 for ; Fri, 12 May 2023 14:03:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241387AbjELODS (ORCPT ); Fri, 12 May 2023 10:03:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241400AbjELODH (ORCPT ); Fri, 12 May 2023 10:03:07 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47127B8 for ; Fri, 12 May 2023 07:03:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683900184; x=1715436184; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GQNj46+iNJIriUwneXK3Qk25Ow1EZQtg/SyKPWSfBgo=; b=IFL23ExqiRBaeQmpUluTDAOqb3hjicctyyE5N1nbmvF13Vzm2vs7lUGp +eJZpxw1RpHl9/o2IABIzhVuucdBO/mQxy8CWhTGQKSEIwhe6C0TdkePd K7psFQl+apiEkiKqMScXsNNlUSEWOaxX/vxDcvQ8qb96ZvHUB5W5ij/qr Vq9xPTJv1RMjbJnNA5eJQbT73BlFYjgwdPUkJ9WAwr2G5MdAZKIfKWxTB SE557ovuznvXOwgYGTHAwKM7JO1Ai9URmD6xWRchP9cwh2g6gTdpXJ5Ql CWKGXmlnewutPACHhRtBh+5yD9lobiEnMdqcVfDheL86Vzd7Xza0kTpyx A==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="378931056" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="378931056" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="650648928" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="650648928" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:02:59 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, Michal Wilczynski Subject: [PATCH v1 08/34] acpi/thermal: Move handler installing logic to driver Date: Fri, 12 May 2023 16:01:56 +0200 Message-Id: <20230512140222.124868-9-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230512140222.124868-1-michal.wilczynski@intel.com> References: <20230512140222.124868-1-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/thermal.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index 4720a3649a61..45367bb77a87 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c @@ -75,7 +75,7 @@ static struct workqueue_struct *acpi_thermal_pm_queue; static int acpi_thermal_add(struct acpi_device *device); static void acpi_thermal_remove(struct acpi_device *device); -static void acpi_thermal_notify(struct acpi_device *device, u32 event); +static void acpi_thermal_notify(acpi_handle handle, u32 event, void *data); static const struct acpi_device_id thermal_device_ids[] = { {ACPI_THERMAL_HID, 0}, @@ -99,7 +99,6 @@ static struct acpi_driver acpi_thermal_driver = { .ops = { .add = acpi_thermal_add, .remove = acpi_thermal_remove, - .notify = acpi_thermal_notify, }, .drv.pm = &acpi_thermal_pm, }; @@ -894,9 +893,12 @@ static void acpi_queue_thermal_check(struct acpi_thermal *tz) queue_work(acpi_thermal_pm_queue, &tz->thermal_check_work); } -static void acpi_thermal_notify(struct acpi_device *device, u32 event) +static void acpi_thermal_notify(acpi_handle handle, u32 event, void *data) { - struct acpi_thermal *tz = acpi_driver_data(device); + struct acpi_device *device = data; + struct acpi_thermal *tz; + + tz = acpi_driver_data(device); if (!tz) return; @@ -1067,11 +1069,16 @@ static int acpi_thermal_add(struct acpi_device *device) pr_info("%s [%s] (%ld C)\n", acpi_device_name(device), acpi_device_bid(device), deci_kelvin_to_celsius(tz->temperature)); - goto end; + + result = acpi_device_install_event_handler(device, ACPI_DEVICE_NOTIFY, + acpi_thermal_notify); + if (result) + goto free_memory; + + return result; free_memory: kfree(tz); -end: return result; } @@ -1082,6 +1089,7 @@ static void acpi_thermal_remove(struct acpi_device *device) if (!device || !acpi_driver_data(device)) return; + acpi_device_remove_event_handler(device, ACPI_DEVICE_NOTIFY, acpi_thermal_notify); flush_workqueue(acpi_thermal_pm_queue); tz = acpi_driver_data(device); From patchwork Fri May 12 14:01:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 681612 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 713F4C77B7C for ; Fri, 12 May 2023 14:03:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241380AbjELODR (ORCPT ); Fri, 12 May 2023 10:03:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241404AbjELODH (ORCPT ); Fri, 12 May 2023 10:03:07 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9EAC5FD3 for ; Fri, 12 May 2023 07:03:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683900184; x=1715436184; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9vog9QTAcRXotsdmJgCax9RGQS9sfs3MI5wmRFwzndc=; b=ntd7CMtZu64i2+QO//ROBzC5/yZm0PRnrSk7jtApRDsdHS189cQ7Tqig eOliD/ZKrne9R2UZjBNKmsaimJfHGo5vs3DmECVHcJh6f6IMs6v6T4eko uMRoB73crkVguzqC8kslxTyxWBka5XS1SaSbBYbojl+1JH/bYqzteMtEc 0X4fmgNl0GArul61q6Un/7vFwC5OnvT4RnjmXl0vBMxGivEJBVtkL8dZ7 V2Vqwmv1EE6ekiONpQise72I9goXG9obhez6k4AyDpq/4SY/MW7cX4zGx +/MNhFyhwUsoKH+g73rY/x+TddIuYgRirlufNY4O9p3sHQmbPUvSDni8i w==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="378931063" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="378931063" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="650648932" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="650648932" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:01 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, Michal Wilczynski Subject: [PATCH v1 09/34] acpi/tiny-power-button: Move handler installing logic to driver Date: Fri, 12 May 2023 16:01:57 +0200 Message-Id: <20230512140222.124868-10-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230512140222.124868-1-michal.wilczynski@intel.com> References: <20230512140222.124868-1-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 | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/acpi/tiny-power-button.c b/drivers/acpi/tiny-power-button.c index 598f548b21f3..b14ba2f0dd3f 100644 --- a/drivers/acpi/tiny-power-button.c +++ b/drivers/acpi/tiny-power-button.c @@ -19,16 +19,19 @@ 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 int acpi_tiny_power_button_add(struct acpi_device *device) { - return 0; + return acpi_device_install_event_handler(device, ACPI_DEVICE_NOTIFY, + acpi_tiny_power_button_notify); } -static void acpi_noop_remove(struct acpi_device *device) +static void acpi_tiny_power_button_remove(struct acpi_device *device) { + acpi_device_remove_event_handler(device->handle, 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_notify(acpi_handle handle, u32 event, void *data) { kill_cad_pid(power_signal, 1); } @@ -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, }, }; From patchwork Fri May 12 14:01:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 681611 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 062D5C7EE26 for ; Fri, 12 May 2023 14:03:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241397AbjELODS (ORCPT ); Fri, 12 May 2023 10:03:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241418AbjELODH (ORCPT ); Fri, 12 May 2023 10:03:07 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EC51D870 for ; Fri, 12 May 2023 07:03:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683900185; x=1715436185; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Lgd7x7Bnml9coFe2bi4F5qUfTMLc8L2VVJ/ZbUhhytg=; b=kqIy6IPOLSxElnd61gObx6hWPDvujYTVJDySBpWL53ufvnl1o3vYlP17 P200K1AC7Q6ljE25bIVcWQmGDrop+1OQD702x8WCbwu3ijqr2XcxSodnG d/Rlm+5I0bjshnqh11wbqbyCmZ4f9JXwkVBiuaC7OzFRIhe2/zgaLjhR6 XWSZne/8NGse8hSSroZbeYpHRCLJXEPxgUtd0+L1Mv7UUkfbUPaYV0gr9 Klttq57lR1hsNNsBwWy7oioBOAqNrTQWbPmM1OUlrnuIvOlu4PmwPzp+7 xi9WnErk19grDP/dxciHCrzYb086Ck3O1K00hMv1Xw8XI33hEEUvtDvZQ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="378931067" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="378931067" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="650648937" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="650648937" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:03 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, Michal Wilczynski Subject: [PATCH v1 10/34] hwmon: Move handler installing logic to driver Date: Fri, 12 May 2023 16:01:58 +0200 Message-Id: <20230512140222.124868-11-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230512140222.124868-1-michal.wilczynski@intel.com> References: <20230512140222.124868-1-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/hwmon/acpi_power_meter.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c index fa28d447f0df..4c31f3cede61 100644 --- a/drivers/hwmon/acpi_power_meter.c +++ b/drivers/hwmon/acpi_power_meter.c @@ -817,9 +817,10 @@ static int read_capabilities(struct acpi_power_meter_resource *resource) } /* Handle ACPI event notifications */ -static void acpi_power_meter_notify(struct acpi_device *device, u32 event) +static void acpi_power_meter_notify(acpi_handle handle, u32 event, void *data) { struct acpi_power_meter_resource *resource; + struct acpi_device *device = data; int res; if (!device || !acpi_driver_data(device)) @@ -897,8 +898,12 @@ static int acpi_power_meter_add(struct acpi_device *device) goto exit_remove; } - res = 0; - goto exit; + res = acpi_device_install_event_handler(device, ACPI_DEVICE_NOTIFY, + acpi_power_meter_notify); + if (res) + goto exit_remove; + + return res; exit_remove: remove_attrs(resource); @@ -906,8 +911,6 @@ static int acpi_power_meter_add(struct acpi_device *device) free_capabilities(resource); exit_free: kfree(resource); -exit: - return res; } static void acpi_power_meter_remove(struct acpi_device *device) @@ -917,6 +920,7 @@ static void acpi_power_meter_remove(struct acpi_device *device) if (!device || !acpi_driver_data(device)) return; + acpi_device_remove_event_handler(device, ACPI_DEVICE_NOTIFY, acpi_power_meter_notify); resource = acpi_driver_data(device); hwmon_device_unregister(resource->hwmon_dev); @@ -953,7 +957,6 @@ static struct acpi_driver acpi_power_meter_driver = { .ops = { .add = acpi_power_meter_add, .remove = acpi_power_meter_remove, - .notify = acpi_power_meter_notify, }, .drv.pm = pm_sleep_ptr(&acpi_power_meter_pm), }; From patchwork Fri May 12 14:01:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 681247 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 F3B4EC77B7C for ; Fri, 12 May 2023 14:03:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241403AbjELODT (ORCPT ); Fri, 12 May 2023 10:03:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241421AbjELODI (ORCPT ); Fri, 12 May 2023 10:03:08 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FF1D197 for ; Fri, 12 May 2023 07:03:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683900187; x=1715436187; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rJgaY1FU/75lBv6vEcB+hMPhB8HcWGYocSjNGF+hErU=; b=G8FQJFwaJ4uemB2tvovHOTls0S7n9vwGJ4J43p12SJ5uL3ul46V13Xft /+mZlA3BQnZmyCpIK6kIjlsqICx6t25MCMa7TNhtR2Ztu4LazebO2LYAS B7wV0JerxQhsRvQvKk/K3l76f7LJAgmt9y5gUZg89s0D1YCxYkg7wjZx5 BZIn9/Bdn8ZgBzrryMvLRtTsxlWip9OfGZ/wd4qWpABTdqXeApRvPD3FT ZQNHpk6WTHKH2UCSynK0bCZQNZpWqA5D67H7T0c4ddSc7rUKk1cv7zh5p pTrVsiwumcHmKABPZuK+wF+OnLoJ2sLzoQWEody0jfl0aGCYEmCd9fZNf A==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="378931073" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="378931073" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="650648941" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="650648941" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:05 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, Michal Wilczynski Subject: [PATCH v1 11/34] iio/acpi-als: Move handler installing logic to driver Date: Fri, 12 May 2023 16:01:59 +0200 Message-Id: <20230512140222.124868-12-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230512140222.124868-1-michal.wilczynski@intel.com> References: <20230512140222.124868-1-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/iio/light/acpi-als.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/iio/light/acpi-als.c b/drivers/iio/light/acpi-als.c index 2d91caf24dd0..cf97b717650d 100644 --- a/drivers/iio/light/acpi-als.c +++ b/drivers/iio/light/acpi-als.c @@ -100,10 +100,14 @@ static int acpi_als_read_value(struct acpi_als *als, char *prop, s32 *val) return 0; } -static void acpi_als_notify(struct acpi_device *device, u32 event) +static void acpi_als_notify(acpi_handle handle, u32 event, void *data) { - struct iio_dev *indio_dev = acpi_driver_data(device); - struct acpi_als *als = iio_priv(indio_dev); + struct acpi_device *device = data; + struct iio_dev *indio_dev; + struct acpi_als *als; + + indio_dev = acpi_driver_data(device); + als = iio_priv(indio_dev); if (iio_buffer_enabled(indio_dev) && iio_trigger_using_own(indio_dev)) { switch (event) { @@ -225,9 +229,18 @@ static int acpi_als_add(struct acpi_device *device) if (ret) return ret; + ret = acpi_device_install_event_handler(device, ACPI_DEVICE_NOTIFY, acpi_als_notify); + if (ret) + return ret; + return devm_iio_device_register(dev, indio_dev); } +static void acpi_als_remove(struct acpi_device *device) +{ + acpi_device_remove_event_handler(device, ACPI_DEVICE_NOTIFY, acpi_als_notify); +} + static const struct acpi_device_id acpi_als_device_ids[] = { {"ACPI0008", 0}, {}, @@ -241,7 +254,7 @@ static struct acpi_driver acpi_als_driver = { .ids = acpi_als_device_ids, .ops = { .add = acpi_als_add, - .notify = acpi_als_notify, + .remove = acpi_als_remove, }, }; From patchwork Fri May 12 14:02:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 681610 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 BA93CC77B75 for ; Fri, 12 May 2023 14:03:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241421AbjELODU (ORCPT ); Fri, 12 May 2023 10:03:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241379AbjELODJ (ORCPT ); Fri, 12 May 2023 10:03:09 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB06F1B1 for ; Fri, 12 May 2023 07:03:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683900188; x=1715436188; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rKnJsXc5SXda6k+1QyFHn1GBFF395qP1NAcf6VFSCKc=; b=EiSBov0pXy3IMQRYPstH5QwQsGBQqkM0bhRQPQVO9rF6mHLIiJlf251T u80yv3jsJ0Q8BM07CbMFY1u1XWtswgrNG4E98Xt4pKv2Sra5n7dNk8tLU vxAKs3U1x3aEwgfj5sUB6tlVkNcLrXOw+SA+bNL8/RGGkiU789nL8fycM 8JvaM8AefAVP8h828EGMQoIqL+NIOStBmwQXv1P4hkTJraM+LJNlqJdaq /Yw2NTowMNx2v7PoVPk3uO/riMy8Fr3zYfUg/kJVY2ltBoEF02+S1xpcT re9gk6BFRvlLHl/7mRC14+ZxXDmxTjkqbpZG3jEuswp39dCV5PMiEf7bf Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="378931080" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="378931080" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="650648946" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="650648946" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:07 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, Michal Wilczynski Subject: [PATCH v1 12/34] platform/chromeos_tbmc: Move handler installing logic to driver Date: Fri, 12 May 2023 16:02:00 +0200 Message-Id: <20230512140222.124868-13-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230512140222.124868-1-michal.wilczynski@intel.com> References: <20230512140222.124868-1-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/platform/chrome/chromeos_tbmc.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/platform/chrome/chromeos_tbmc.c b/drivers/platform/chrome/chromeos_tbmc.c index d1cf8f3463ce..399429bd7635 100644 --- a/drivers/platform/chrome/chromeos_tbmc.c +++ b/drivers/platform/chrome/chromeos_tbmc.c @@ -45,8 +45,10 @@ static __maybe_unused int chromeos_tbmc_resume(struct device *dev) return chromeos_tbmc_query_switch(adev, adev->driver_data); } -static void chromeos_tbmc_notify(struct acpi_device *adev, u32 event) +static void chromeos_tbmc_notify(acpi_handle handle, u32 event, void *data) { + struct acpi_device *adev = data; + acpi_pm_wakeup_event(&adev->dev); switch (event) { case 0x80: @@ -92,7 +94,13 @@ static int chromeos_tbmc_add(struct acpi_device *adev) return ret; } device_init_wakeup(dev, true); - return 0; + + return acpi_device_install_event_handler(device, ACPI_DEVICE_NOTIFY, chromeos_tbmc_notify); +} + +static void chromeos_tbmc_remove(struct acpi_device *device) +{ + acpi_device_remove_event_handler(device, ACPI_DEVICE_NOTIFY, chromeos_tbmc_notify); } static const struct acpi_device_id chromeos_tbmc_acpi_device_ids[] = { @@ -110,7 +118,7 @@ static struct acpi_driver chromeos_tbmc_driver = { .ids = chromeos_tbmc_acpi_device_ids, .ops = { .add = chromeos_tbmc_add, - .notify = chromeos_tbmc_notify, + .remove = chromeos_tbmc_remove, }, .drv.pm = &chromeos_tbmc_pm_ops, }; From patchwork Fri May 12 14:02:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 681246 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 495E3C77B7C for ; Fri, 12 May 2023 14:03:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241423AbjELODV (ORCPT ); Fri, 12 May 2023 10:03:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241425AbjELODN (ORCPT ); Fri, 12 May 2023 10:03:13 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 794561729 for ; Fri, 12 May 2023 07:03:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683900190; x=1715436190; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ylOa+MP5gTe7qVPfZv72klAlbk2ksb9dPDlpSZU21sQ=; b=ez4rsLmrMcry4ukujfpn7HqoqTRYI14lXSPrXx3rHyV3shtoKQ3mls4c ZkF79bQa0gCkCHVUzhZEY1uZgeDgzwVtCTgc/U8JgTUahYRwbucukSZzS n1If5tM8jOaR9rWBFQwUyz7YsKuSdmsdPjaNhsvdEAS+teamxjNBVm40o pVypGMPZuDnABL3XJOpIwLK29I8sywb8xaUllQ1ZVx+Xo1x6mNx4v/TL2 qWfOdNDxr0YYbdLTTYW+m0J33GKxERceS1zi4kGA3hk30f1QBh/bjLBCr FKXuNw8qWmS89X7ibRO0QmPKcseOy8O5ieOQMX3VLuuar4XiOYGKIuIjQ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="378931084" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="378931084" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="650648953" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="650648953" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:09 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, Michal Wilczynski Subject: [PATCH v1 13/34] platform/wilco_ec: Move handler installing logic to driver Date: Fri, 12 May 2023 16:02:01 +0200 Message-Id: <20230512140222.124868-14-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230512140222.124868-1-michal.wilczynski@intel.com> References: <20230512140222.124868-1-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/platform/chrome/wilco_ec/event.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/platform/chrome/wilco_ec/event.c b/drivers/platform/chrome/wilco_ec/event.c index a40f60bcefb6..572462610853 100644 --- a/drivers/platform/chrome/wilco_ec/event.c +++ b/drivers/platform/chrome/wilco_ec/event.c @@ -251,16 +251,10 @@ static int enqueue_events(struct acpi_device *adev, const u8 *buf, u32 length) return 0; } -/** - * event_device_notify() - Callback when EC generates an event over ACPI. - * @adev: The device that the event is coming from. - * @value: Value passed to Notify() in ACPI. - * - * This function will read the events from the device and enqueue them. - */ -static void event_device_notify(struct acpi_device *adev, u32 value) +static void event_device_notify(acpi_handle handle, u32 value, void *data) { - struct acpi_buffer event_buffer = { ACPI_ALLOCATE_BUFFER, NULL }; + struct acpi_buffer event_buffer; = { ACPI_ALLOCATE_BUFFER, NULL }; + struct acpi_device *adev = data; union acpi_object *obj; acpi_status status; @@ -490,7 +484,12 @@ static int event_device_add(struct acpi_device *adev) if (error) goto free_dev_data; - return 0; + error = acpi_device_install_event_handler(device, ACPI_DEVICE_NOTIFY, + event_device_notify); + if (error) + goto free_dev_data; + + return error; free_dev_data: hangup_device(dev_data); @@ -503,6 +502,7 @@ static void event_device_remove(struct acpi_device *adev) { struct event_device_data *dev_data = adev->driver_data; + acpi_device_remove_event_handler(device, ACPI_DEVICE_NOTIFY, event_device_notify); cdev_device_del(&dev_data->cdev, &dev_data->dev); ida_simple_remove(&event_ida, MINOR(dev_data->dev.devt)); hangup_device(dev_data); @@ -520,7 +520,6 @@ static struct acpi_driver event_driver = { .ids = event_acpi_ids, .ops = { .add = event_device_add, - .notify = event_device_notify, .remove = event_device_remove, }, .owner = THIS_MODULE, From patchwork Fri May 12 14:02:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 681609 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 A8F96C7EE26 for ; Fri, 12 May 2023 14:03:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241425AbjELODW (ORCPT ); Fri, 12 May 2023 10:03:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241426AbjELODQ (ORCPT ); Fri, 12 May 2023 10:03:16 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 988B71BC8 for ; Fri, 12 May 2023 07:03:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683900192; x=1715436192; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GCWBKlFM/THadBMuqknyHdfdQ7OSOB6vhXPpbRYrzmg=; b=ioKzwzh1RBVx1aa12mDfvhEDh6AQp11Ds80GKAfktIIAqaWpKCXDUJq7 inPqxEsgVHRRzzZncxKVrp85ehDTGpPy6CyzwARlCrfT1xWksJ7Dmr/qL VzZgL/W9fPWz2/cePaLlz5b+2Peeu/xfdgM6vwBoRpyT3DcmSYkfYNdPH YaK4mIaUtH3yu8kyMwi2TYRXztTAeRRV40sKGgGgR04Bj1mMUJpOK9LXI Jbi0KBXn/KiUd+jyUN/ecMClJW0dxglgNcchrWussiWPlT3rAU42heyS3 cI88jQincV25gdE82PYUs4dbkTCMXBTDqakmQBMVHOB2n4G/RS3i5F2aJ A==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="378931094" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="378931094" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="650648960" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="650648960" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:10 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, Michal Wilczynski Subject: [PATCH v1 14/34] platform/surface/button: Move handler installing logic to driver Date: Fri, 12 May 2023 16:02:02 +0200 Message-Id: <20230512140222.124868-15-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230512140222.124868-1-michal.wilczynski@intel.com> References: <20230512140222.124868-1-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/platform/surface/surfacepro3_button.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/platform/surface/surfacepro3_button.c b/drivers/platform/surface/surfacepro3_button.c index 2755601f979c..ec070ce9de53 100644 --- a/drivers/platform/surface/surfacepro3_button.c +++ b/drivers/platform/surface/surfacepro3_button.c @@ -71,13 +71,16 @@ struct surface_button { bool suspended; }; -static void surface_button_notify(struct acpi_device *device, u32 event) +static void surface_button_notify(acpi_handle handle, u32 event, void *data) { - struct surface_button *button = acpi_driver_data(device); - struct input_dev *input; + struct acpi_device *device = data; + struct surface_button *button; int key_code = KEY_RESERVED; + struct input_dev *input; bool pressed = false; + button = acpi_driver_data(device); + switch (event) { /* Power button press,release handle */ case SURFACE_BUTTON_NOTIFY_PRESS_POWER: @@ -230,7 +233,13 @@ static int surface_button_add(struct acpi_device *device) device_init_wakeup(&device->dev, true); dev_info(&device->dev, "%s [%s]\n", name, acpi_device_bid(device)); - return 0; + + error = acpi_device_install_event_handler(device, ACPI_DEVICE_NOTIFY, + surface_button_notify); + if (error) + goto err_free_input; + + return error; err_free_input: input_free_device(input); @@ -243,6 +252,7 @@ static void surface_button_remove(struct acpi_device *device) { struct surface_button *button = acpi_driver_data(device); + acpi_device_remove_event_handler(device, ACPI_DEVICE_NOTIFY, surface_button_notify); input_unregister_device(button->input); kfree(button); } @@ -257,7 +267,6 @@ static struct acpi_driver surface_button_driver = { .ops = { .add = surface_button_add, .remove = surface_button_remove, - .notify = surface_button_notify, }, .drv.pm = &surface_button_pm, }; From patchwork Fri May 12 14:02:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 681245 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 DCBAEC77B7C for ; Fri, 12 May 2023 14:03:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241448AbjELODe (ORCPT ); Fri, 12 May 2023 10:03:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241398AbjELODQ (ORCPT ); Fri, 12 May 2023 10:03:16 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B45F10DD for ; Fri, 12 May 2023 07:03:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683900194; x=1715436194; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZUbSep0pdTiKrpeVtzP63h/qO8K83Xh8tZa8dvUFxTw=; b=NKIE0sB/yI5mvfJ+5twBJMjyNIjZKwKZO9duqqD1YrIq3obG5U181PHj mX58RJib9A1E/3hwR3mePyqUbxTm0sx+X7DKUn4isUiktrNp27eEpW5dO 6t54LAMwmby2wTQaMdfytKVd+wyvgfaNNq7O2FIVBuiSQN6JOFb4cGK7n 8EBVGt5mV/8AWQTQSMoUrQzNpjbCv7gNPFznbnG9EhjhFi5u9UyBdflnc tyCCIk7kOLRzAa/yBt6avM3OTzfV4LXVvgL0rOZtYThtOmeKl7yJYoiHL lR54Fc9f5kLed+hkwPTWiPVzvya00ZjnQgfVt1cYfp3I3bsWj+xR9SA/t g==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="378931104" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="378931104" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="650648966" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="650648966" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:13 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, Michal Wilczynski Subject: [PATCH v1 15/34] platform/x86/acer-wireless: Move handler installing logic to driver Date: Fri, 12 May 2023 16:02:03 +0200 Message-Id: <20230512140222.124868-16-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230512140222.124868-1-michal.wilczynski@intel.com> References: <20230512140222.124868-1-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/platform/x86/acer-wireless.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/platform/x86/acer-wireless.c b/drivers/platform/x86/acer-wireless.c index 1b5d935d085a..275215fd18c2 100644 --- a/drivers/platform/x86/acer-wireless.c +++ b/drivers/platform/x86/acer-wireless.c @@ -18,9 +18,12 @@ static const struct acpi_device_id acer_wireless_acpi_ids[] = { }; MODULE_DEVICE_TABLE(acpi, acer_wireless_acpi_ids); -static void acer_wireless_notify(struct acpi_device *adev, u32 event) +static void acer_wireless_notify(acpi_handle handle, u32 event, void *data) { - struct input_dev *idev = acpi_driver_data(adev); + struct acpi_device *adev = data; + struct input_dev *idev; + + idev = acpi_driver_data(adev); dev_dbg(&adev->dev, "event=%#x\n", event); if (event != 0x80) { @@ -36,6 +39,7 @@ static void acer_wireless_notify(struct acpi_device *adev, u32 event) static int acer_wireless_add(struct acpi_device *adev) { struct input_dev *idev; + int ret; idev = devm_input_allocate_device(&adev->dev); if (!idev) @@ -50,7 +54,17 @@ static int acer_wireless_add(struct acpi_device *adev) set_bit(EV_KEY, idev->evbit); set_bit(KEY_RFKILL, idev->keybit); - return input_register_device(idev); + ret = input_register_device(idev); + + if (ret) + return ret; + + return acpi_device_install_event_handler(device, ACPI_DEVICE_NOTIFY, acer_wireless_notify); +} + +static void acer_wireless_remove(struct acpi_device *adev) +{ + acpi_device_remove_event_handler(device, ACPI_DEVICE_NOTIFY, acer_wireless_notify); } static struct acpi_driver acer_wireless_driver = { @@ -59,7 +73,7 @@ static struct acpi_driver acer_wireless_driver = { .ids = acer_wireless_acpi_ids, .ops = { .add = acer_wireless_add, - .notify = acer_wireless_notify, + .remove = acer_wireless_remove, }, }; module_acpi_driver(acer_wireless_driver); From patchwork Fri May 12 14:02:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 681608 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 6319EC77B75 for ; Fri, 12 May 2023 14:03:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241434AbjELODk (ORCPT ); Fri, 12 May 2023 10:03:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241430AbjELODR (ORCPT ); Fri, 12 May 2023 10:03:17 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5F21124B6 for ; Fri, 12 May 2023 07:03:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683900195; x=1715436195; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/JtMl547iYpyECwmCftqBv8Oj+zJ2NXV2HrJ5r7Ez4M=; b=BD+GxbEaocF3jGs9FD7CP9c1H2cNi/UAsTWQse4y6hCY9VIl9RRkCrva e9sZGXyqL6FWirvHsjIxznwSXiKnNId8/8ym4HDV4C8S3rw1Uh7jDufmm eCCUCt4XFIxS1gAN1exkeg6b/C+on6+E7zc6jBO8YcBEEOPe3mkRqtb6u 98Wh4D+n7Zy/QiO0pCDcN0UcSQ37LTI17m2krzFMT8abre781hNSdzsCw yd+6VLHmNZMtOqTh3+Iyasx7B2wBQqK58tcVqDtLC6yHK118JBZg0zTc5 9FG8IhF7MBoYQWzW7EL+/mpx3zTm5435O5Q1HyGTG+Yn1SeGchpqrRsWE g==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="378931107" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="378931107" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="650648971" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="650648971" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:14 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, Michal Wilczynski Subject: [PATCH v1 16/34] platform/x86/asus-laptop: Move handler installing logic to driver Date: Fri, 12 May 2023 16:02:04 +0200 Message-Id: <20230512140222.124868-17-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230512140222.124868-1-michal.wilczynski@intel.com> References: <20230512140222.124868-1-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/platform/x86/asus-laptop.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c index 761029f39314..fa348c96be16 100644 --- a/drivers/platform/x86/asus-laptop.c +++ b/drivers/platform/x86/asus-laptop.c @@ -1515,11 +1515,14 @@ static void asus_input_exit(struct asus_laptop *asus) /* * ACPI driver */ -static void asus_acpi_notify(struct acpi_device *device, u32 event) +static void asus_acpi_notify(acpi_handle handle, u32 event, void *data) { - struct asus_laptop *asus = acpi_driver_data(device); + struct acpi_device *device = data; + struct asus_laptop *asus; u16 count; + asus = acpi_driver_data(device); + /* TODO Find a better way to handle events count. */ count = asus->event_count[event % 128]++; acpi_bus_generate_netlink_event(asus->device->pnp.device_class, @@ -1880,8 +1883,12 @@ static int asus_acpi_add(struct acpi_device *device) if (result && result != -ENODEV) goto fail_pega_rfkill; + result = acpi_device_install_event_handler(device, ACPI_ALL_NOTIFY, asus_acpi_notify); + if (result) + goto fail_pega_rfkill; + asus_device_present = true; - return 0; + return result; fail_pega_rfkill: pega_accel_exit(asus); @@ -1905,6 +1912,7 @@ static void asus_acpi_remove(struct acpi_device *device) { struct asus_laptop *asus = acpi_driver_data(device); + acpi_device_remove_event_handler(device, ACPI_ALL_NOTIFY, asus_acpi_notify); asus_backlight_exit(asus); asus_rfkill_exit(asus); asus_led_exit(asus); @@ -1928,11 +1936,9 @@ static struct acpi_driver asus_acpi_driver = { .class = ASUS_LAPTOP_CLASS, .owner = THIS_MODULE, .ids = asus_device_ids, - .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS, .ops = { .add = asus_acpi_add, .remove = asus_acpi_remove, - .notify = asus_acpi_notify, }, }; From patchwork Fri May 12 14:02:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 681607 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 0B3BAC7EE2A for ; Fri, 12 May 2023 14:03:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241418AbjELODl (ORCPT ); Fri, 12 May 2023 10:03:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241400AbjELODS (ORCPT ); Fri, 12 May 2023 10:03:18 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 098DDB8 for ; Fri, 12 May 2023 07:03:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683900196; x=1715436196; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Y4JSKytL16UQ3yiDlPjXF1qi2MF02RmJQVVc5oDWZQ0=; b=CDxumuqe8C8w96AMcWQEe4WtW6YvZ0mblxZVLIhEwb5lfiG9ysyMJlMY P0JgwL8QbZNFeTqpZDo3xgYzwBJ4OPpaVmgbJIFfPSnWUcROAUFGLwooV xMk7noG9UPCLbuIxrqhrUNC7dMaoxbFthtywh+KbyHnxU7w6l3LzN1Wqp 2FOKhc3cvSef1pT69qobt6SnDhiGpiA/SNmqYYwGpem6InSq9eHZ3NiPL mZfEspxlqymF4U+LaFQ5w0ib4XPQ4YfBbTaTZEdbpAHsIFpYGQwvPsAMQ pllvQ5AhlZ0/8xBoSqISwLaJ/VRr+dUebebPGqRJWkbU67Nc51phVUmAF Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="378931112" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="378931112" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="650648974" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="650648974" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:15 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, Michal Wilczynski Subject: [PATCH v1 17/34] platform/x86/asus-wireless: Move handler installing logic to driver Date: Fri, 12 May 2023 16:02:05 +0200 Message-Id: <20230512140222.124868-18-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230512140222.124868-1-michal.wilczynski@intel.com> References: <20230512140222.124868-1-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/platform/x86/asus-wireless.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/drivers/platform/x86/asus-wireless.c b/drivers/platform/x86/asus-wireless.c index abf01e00b799..6544e3419ae4 100644 --- a/drivers/platform/x86/asus-wireless.c +++ b/drivers/platform/x86/asus-wireless.c @@ -108,19 +108,22 @@ static void led_state_set(struct led_classdev *led, enum led_brightness value) queue_work(data->wq, &data->led_work); } -static void asus_wireless_notify(struct acpi_device *adev, u32 event) +static void asus_wireless_notify(acpi_handle handle, u32 event, void *data) { - struct asus_wireless_data *data = acpi_driver_data(adev); + struct asus_wireless_data *w_data; + struct acpi_device *adev = data; + + w_data = acpi_driver_data(adev); dev_dbg(&adev->dev, "event=%#x\n", event); if (event != 0x88) { dev_notice(&adev->dev, "Unknown ASHS event: %#x\n", event); return; } - input_report_key(data->idev, KEY_RFKILL, 1); - input_sync(data->idev); - input_report_key(data->idev, KEY_RFKILL, 0); - input_sync(data->idev); + input_report_key(w_data->idev, KEY_RFKILL, 1); + input_sync(w_data->idev); + input_report_key(w_data->idev, KEY_RFKILL, 0); + input_sync(w_data->idev); } static int asus_wireless_add(struct acpi_device *adev) @@ -169,16 +172,20 @@ static int asus_wireless_add(struct acpi_device *adev) data->led.max_brightness = 1; data->led.default_trigger = "rfkill-none"; err = devm_led_classdev_register(&adev->dev, &data->led); - if (err) + if (err) { destroy_workqueue(data->wq); + return err; + } - return err; + return acpi_device_install_event_handler(adev, ACPI_DEVICE_NOTIFY, asus_wireless_notify); } static void asus_wireless_remove(struct acpi_device *adev) { struct asus_wireless_data *data = acpi_driver_data(adev); + acpi_device_remove_event_handler(adev, ACPI_DEVICE_NOTIFY, asus_wireless_notify); + if (data->wq) { devm_led_classdev_unregister(&adev->dev, &data->led); destroy_workqueue(data->wq); @@ -192,7 +199,6 @@ static struct acpi_driver asus_wireless_driver = { .ops = { .add = asus_wireless_add, .remove = asus_wireless_remove, - .notify = asus_wireless_notify, }, }; module_acpi_driver(asus_wireless_driver); From patchwork Fri May 12 14:02:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 681243 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 91405C7EE26 for ; Fri, 12 May 2023 14:03:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241424AbjELODl (ORCPT ); Fri, 12 May 2023 10:03:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241418AbjELODT (ORCPT ); Fri, 12 May 2023 10:03:19 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7293C1B1 for ; Fri, 12 May 2023 07:03:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683900198; x=1715436198; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XkKJ8TM3GYnv3u7IL03ncZgdAXLi2ZTXpbAt2ivi4h0=; b=DcJlYIDsGB5GK5WmSLUsTnVim2hKtdcyWstS/VYRRNElZW6jQ+c7cuow IAIL1cOEv2T76u9oDb71c0PH02SLzxrvbv7z8LeTQf116iyOCSLncVnXv yRmZrv1jgQPpYWZ1B1hCukL158/Y0bBg+9zm0OhkOxDxi7sPhbLJ0D5F2 XPLcCnOhz6zHLHfmjrXGTn7sezu3j34tZkjqq4ub4riv1MJjRILvg5QsE CnreqW+3dEC7c5CM4FG04ImU4zXb+wDu9NwDigefemRqB54j3u4izSi6c EdouP6T6PlM+fTl21FzJzobLXJXPZRUxQypjH+j0YZl95oWNBCuIgV/ni g==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="378931119" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="378931119" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="650648977" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="650648977" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:16 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, Michal Wilczynski Subject: [PATCH v1 18/34] platform/x86/classmate-laptop: Move handler installing logic to driver Date: Fri, 12 May 2023 16:02:06 +0200 Message-Id: <20230512140222.124868-19-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230512140222.124868-1-michal.wilczynski@intel.com> References: <20230512140222.124868-1-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/platform/x86/classmate-laptop.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/platform/x86/classmate-laptop.c b/drivers/platform/x86/classmate-laptop.c index 2edaea2492df..51a0dd28b8ec 100644 --- a/drivers/platform/x86/classmate-laptop.c +++ b/drivers/platform/x86/classmate-laptop.c @@ -180,8 +180,9 @@ static acpi_status cmpc_get_accel_v4(acpi_handle handle, return status; } -static void cmpc_accel_handler_v4(struct acpi_device *dev, u32 event) +static void cmpc_accel_handler_v4(acpi_handle handle, u32 event, void *data) { + struct acpi_device *dev = data; if (event == 0x81) { int16_t x, y, z; acpi_status status; @@ -407,7 +408,12 @@ static int cmpc_accel_add_v4(struct acpi_device *acpi) inputdev = dev_get_drvdata(&acpi->dev); dev_set_drvdata(&inputdev->dev, accel); - return 0; + error = acpi_device_install_event_handler(device, ACPI_DEVICE_NOTIFY, + cmpc_accel_handler_v4); + if (error) + goto failed_input; + + return error; failed_input: device_remove_file(&acpi->dev, &cmpc_accel_g_select_attr_v4); @@ -420,6 +426,7 @@ static int cmpc_accel_add_v4(struct acpi_device *acpi) static void cmpc_accel_remove_v4(struct acpi_device *acpi) { + acpi_device_remove_event_handler(device, ACPI_DEVICE_NOTIFY, cmpc_accel_handler_v4); device_remove_file(&acpi->dev, &cmpc_accel_sensitivity_attr_v4); device_remove_file(&acpi->dev, &cmpc_accel_g_select_attr_v4); cmpc_remove_acpi_notify_device(acpi); @@ -1071,7 +1078,6 @@ static struct acpi_driver cmpc_keys_acpi_driver = { .ops = { .add = cmpc_keys_add, .remove = cmpc_keys_remove, - .notify = cmpc_keys_handler, } }; From patchwork Fri May 12 14:02:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 681244 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 8266CC7EE23 for ; Fri, 12 May 2023 14:03:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241400AbjELODm (ORCPT ); Fri, 12 May 2023 10:03:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241435AbjELODV (ORCPT ); Fri, 12 May 2023 10:03:21 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D99E1729 for ; Fri, 12 May 2023 07:03:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683900200; x=1715436200; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oJv43mtzy6+CJK5yy6JwXPkNgWqSQNkVyqt5EQi4dTI=; b=FaPhmqA2LkNm5lTDHzGeaBGlZi+CvdfVCjDVFvHtyTCxnYbjttddfIuq C8bKlfmi1PUPpzN/NfsmaXxQdZnz8S8Puk2NyqoS6/k2yXLt4xqO9u8Oz 4jBZi6CdRXmtt0YSSihCPwMq0xsFePbFRHRFdeCcIzA4rXWnQ3pSXW4nd W4HCuCHxFin/HpaicjUz3y/nKu/d1HJx8zBHgS0CB0z+MsqITRQInCjbF A6+qKKg9uYg27mu83LmBKvtl/gA0KWzxLyd0nCFK64vKH/oBuZNZ+Afpc KD9yV4thHOREqj5qiQK9hgRSG2LVMqbcLGXpz8fyTRKZnADl/PEKMKBIk Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="378931124" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="378931124" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="650648980" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="650648980" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:18 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, Michal Wilczynski Subject: [PATCH v1 19/34] platform/x86/dell/dell-rbtn: Move handler installing logic to driver Date: Fri, 12 May 2023 16:02:07 +0200 Message-Id: <20230512140222.124868-20-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230512140222.124868-1-michal.wilczynski@intel.com> References: <20230512140222.124868-1-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/platform/x86/dell/dell-rbtn.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/platform/x86/dell/dell-rbtn.c b/drivers/platform/x86/dell/dell-rbtn.c index aa0e6c907494..679ff2d6adbf 100644 --- a/drivers/platform/x86/dell/dell-rbtn.c +++ b/drivers/platform/x86/dell/dell-rbtn.c @@ -293,7 +293,6 @@ static struct acpi_driver rbtn_driver = { .ops = { .add = rbtn_add, .remove = rbtn_remove, - .notify = rbtn_notify, }, .owner = THIS_MODULE, }; @@ -422,7 +421,10 @@ static int rbtn_add(struct acpi_device *device) ret = -EINVAL; } - return ret; + if (ret) + return ret; + + return acpi_device_install_event_handler(device, ACPI_DEVICE_NOTIFY, rbtn_notify); } @@ -430,6 +432,8 @@ static void rbtn_remove(struct acpi_device *device) { struct rbtn_data *rbtn_data = device->driver_data; + acpi_device_remove_event_handler(device, ACPI_DEVICE_NOTIFY, rbtn_notify); + switch (rbtn_data->type) { case RBTN_TOGGLE: rbtn_input_exit(rbtn_data); @@ -445,9 +449,12 @@ static void rbtn_remove(struct acpi_device *device) device->driver_data = NULL; } -static void rbtn_notify(struct acpi_device *device, u32 event) +static void rbtn_notify(acpi_handle handle, u32 event, void *data) { - struct rbtn_data *rbtn_data = device->driver_data; + struct acpi_device *device = data; + struct rbtn_data *rbtn_data; + + rbtn_data = device->driver_data; /* * Some BIOSes send a notification at resume. From patchwork Fri May 12 14:02:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 681606 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 239A5C77B75 for ; Fri, 12 May 2023 14:03:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241430AbjELODn (ORCPT ); Fri, 12 May 2023 10:03:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241437AbjELODW (ORCPT ); Fri, 12 May 2023 10:03:22 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7115E19B2 for ; Fri, 12 May 2023 07:03:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683900201; x=1715436201; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3YaqGO9LFaIBj1gukzA8XXwIj/NiaYsVTjoox1IRCUI=; b=k6+UtgfHSByd/EmsIAJnuL2iWTyiaunYM7CtBWY7rkOyoEd0VlcG/vd3 Q2/rctnrVLzozmg6b2Ya7AlWv/r+E1ozHI+8TpjyzLURnY2E19Ist8YTG /q5S5kM9HmkO/Cp792y8HD/mbpPK5MQEZ0Xh+7/QWnhsnFHB0SgNN7h33 nX4cXuzoY+0Q0E0Zpf6sZ3YL3DUnHCInvzT4OqkHg/IMb8eIoJxdV+hEw 6Tl55JC9jGpUpenBdx7/6uCDKrvBEx6mjaiu/lJfeZ0XakHlYQxIwp5iY /HIDxb4IGWxt77ccaQoxftKJDO+IvahLt1H2ST6sSKaLYcHV6bbxd26cB g==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="378931129" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="378931129" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="650648983" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="650648983" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:19 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, Michal Wilczynski Subject: [PATCH v1 20/34] platform/x86/eeepc-laptop: Move handler installing logic to driver Date: Fri, 12 May 2023 16:02:08 +0200 Message-Id: <20230512140222.124868-21-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230512140222.124868-1-michal.wilczynski@intel.com> References: <20230512140222.124868-1-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/platform/x86/eeepc-laptop.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c index 62b71e8e3567..d96e0dce586a 100644 --- a/drivers/platform/x86/eeepc-laptop.c +++ b/drivers/platform/x86/eeepc-laptop.c @@ -1204,12 +1204,15 @@ static void eeepc_input_notify(struct eeepc_laptop *eeepc, int event) pr_info("Unknown key %x pressed\n", event); } -static void eeepc_acpi_notify(struct acpi_device *device, u32 event) +static void eeepc_acpi_notify(acpi_handle handle, u32 event, void *data) { - struct eeepc_laptop *eeepc = acpi_driver_data(device); int old_brightness, new_brightness; + struct acpi_device *device = data; + struct eeepc_laptop *eeepc; u16 count; + eeepc = acpi_driver_data(device); + if (event > ACPI_MAX_SYS_NOTIFY) return; count = eeepc->event_count[event % 128]++; @@ -1423,7 +1426,12 @@ static int eeepc_acpi_add(struct acpi_device *device) goto fail_rfkill; eeepc_device_present = true; - return 0; + result = acpi_install_notify_handler(device->handle, ACPI_ALL_NOTIFY, + eeepc_acpi_notify, device); + if (result) + goto fail_rfkill; + + return result; fail_rfkill: eeepc_led_exit(eeepc); @@ -1451,6 +1459,8 @@ static void eeepc_acpi_remove(struct acpi_device *device) eeepc_platform_exit(eeepc); kfree(eeepc); + acpi_remove_notify_handler(device->handle, ACPI_ALL_NOTIFY, + eeepc_acpi_notify); } @@ -1465,11 +1475,9 @@ static struct acpi_driver eeepc_acpi_driver = { .class = EEEPC_ACPI_CLASS, .owner = THIS_MODULE, .ids = eeepc_device_ids, - .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS, .ops = { .add = eeepc_acpi_add, .remove = eeepc_acpi_remove, - .notify = eeepc_acpi_notify, }, }; From patchwork Fri May 12 14:02:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 681605 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 8BCFDC7EE2D for ; Fri, 12 May 2023 14:03:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241435AbjELODn (ORCPT ); Fri, 12 May 2023 10:03:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241438AbjELODX (ORCPT ); Fri, 12 May 2023 10:03:23 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC03619BE for ; Fri, 12 May 2023 07:03:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683900202; x=1715436202; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Ys9ewJUgBUZ9ekdZ5BrEpzLsnBlD7fhgsExeqDNnm0M=; b=eUld9rfCoCCZ9XIbk7ShesTYrpu2dYw+zQnhQKE7gz4nAOyRxNAa8Azk 1SU+B0EX2F+z9XobEKwjmydK2CWhB1M5qGIUGx1W5h2EHa87PYUO1I5+N lxYtsFCO5BhR7KJiDwRpbqProGrNIrelrV3+2u99pBBkk+HEBbouZWIwb xOI3/Ojr0DJ/SZkN4+vMt89zERD+u7fa0vSkZQ3qZLVzK5YcBb7GTXHyt jnPAkPyKBx5n1OQRww3oEJJV4+GSw+9eKeODyIHjwVZZo+eKNQLgKU4S4 fX5GXXZwKww4CGKkNyb8AIGuMKW96vdz2jb9WgTST462nQ8xKiO2O8k21 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="378931136" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="378931136" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="650648986" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="650648986" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:20 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, Michal Wilczynski Subject: [PATCH v1 21/34] platform/x86/fujitsu-laptop: Move handler installing logic to driver Date: Fri, 12 May 2023 16:02:09 +0200 Message-Id: <20230512140222.124868-22-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230512140222.124868-1-michal.wilczynski@intel.com> References: <20230512140222.124868-1-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/platform/x86/fujitsu-laptop.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c index 085e044e888e..0f1483da730e 100644 --- a/drivers/platform/x86/fujitsu-laptop.c +++ b/drivers/platform/x86/fujitsu-laptop.c @@ -839,7 +839,12 @@ static int acpi_fujitsu_laptop_add(struct acpi_device *device) if (ret) goto err_free_fifo; - return 0; + ret = acpi_device_install_event_handler(device, ACPI_DEVICE_NOTIFY, + acpi_fujitsu_laptop_notify); + if (ret) + goto err_free_fifo; + + return ret; err_free_fifo: kfifo_free(&priv->fifo); @@ -851,6 +856,8 @@ static void acpi_fujitsu_laptop_remove(struct acpi_device *device) { struct fujitsu_laptop *priv = acpi_driver_data(device); + acpi_device_remove_event_handler(device, ACPI_DEVICE_NOTIFY, acpi_fujitsu_laptop_notify); + fujitsu_laptop_platform_remove(device); kfifo_free(&priv->fifo); @@ -889,13 +896,16 @@ static void acpi_fujitsu_laptop_release(struct acpi_device *device) } } -static void acpi_fujitsu_laptop_notify(struct acpi_device *device, u32 event) +static void acpi_fujitsu_laptop_notify(acpi_handle handle, u32 event, void *data) { - struct fujitsu_laptop *priv = acpi_driver_data(device); + struct acpi_device *device = data; + struct fujitsu_laptop *priv; unsigned long flags; int scancode, i = 0; unsigned int irb; + priv = acpi_driver_data(device); + if (event != ACPI_FUJITSU_NOTIFY_CODE) { acpi_handle_info(device->handle, "Unsupported event [0x%x]\n", event); @@ -963,7 +973,6 @@ static struct acpi_driver acpi_fujitsu_laptop_driver = { .ops = { .add = acpi_fujitsu_laptop_add, .remove = acpi_fujitsu_laptop_remove, - .notify = acpi_fujitsu_laptop_notify, }, }; From patchwork Fri May 12 14:02:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 681242 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 429D1C77B7C for ; Fri, 12 May 2023 14:03:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241436AbjELODo (ORCPT ); Fri, 12 May 2023 10:03:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241426AbjELODY (ORCPT ); Fri, 12 May 2023 10:03:24 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAF161BC8 for ; Fri, 12 May 2023 07:03:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683900203; x=1715436203; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PkjZ6qDSEVxr3FTGVDws70MoSSjFjJxqrVlvUsZr32w=; b=RR9tH+VLEdOUkPsqB5p9uN7tTYE4V6aLfQHQ0Y5X64s+5fpcCld21ZZx +irFwmavTa6Z4QZ2I9AoExk8SZMNtBn826uHW8Bv2JST+V4B5NYtETh2S guC13d9Y4WiO4IKd0QbFhbeefYhIPGwb8cxyErtu+2ROSEnxe0GOJSgGU ANbyGxdQ+M9m+39gyVocKRA9OqPm4V1QS/NauehGbMH6EUjYxej3kGswo FyvDqukZ4lxesU7q/XRknnmOgBdHY2ITGNs2F5t1kOqnFbWC9ExbQC+mV YBofPHw56ljg3ly2VPjSa7uD6ZU7u3RbS4KolGm336MZGVcCNyfvbz7Rl w==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="378931143" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="378931143" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="650648990" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="650648990" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:21 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, Michal Wilczynski Subject: [PATCH v1 22/34] platform/x86/lg-laptop: Move handler installing logic to driver Date: Fri, 12 May 2023 16:02:10 +0200 Message-Id: <20230512140222.124868-23-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230512140222.124868-1-michal.wilczynski@intel.com> References: <20230512140222.124868-1-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/platform/x86/lg-laptop.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/platform/x86/lg-laptop.c b/drivers/platform/x86/lg-laptop.c index ad3c39e9e9f5..79c02df3cb11 100644 --- a/drivers/platform/x86/lg-laptop.c +++ b/drivers/platform/x86/lg-laptop.c @@ -270,8 +270,9 @@ static void wmi_input_setup(void) } } -static void acpi_notify(struct acpi_device *device, u32 event) +static void acpi_notify(acpi_handle handle, u32 event, void *data) { + struct acpi_device *device = data; struct key_entry *key; acpi_handle_debug(device->handle, "notify: %d\n", event); @@ -752,7 +753,11 @@ static int acpi_add(struct acpi_device *device) wmi_input_setup(); battery_hook_register(&battery_hook); - return 0; + ret = acpi_device_install_event_handler(device, ACPI_DEVICE_NOTIFY, acpi_notify); + if (ret) + goto out_platform_device; + + return ret; out_platform_device: platform_device_unregister(pf_device); @@ -763,6 +768,8 @@ static int acpi_add(struct acpi_device *device) static void acpi_remove(struct acpi_device *device) { + acpi_device_remove_event_handler(device, ACPI_DEVICE_NOTIFY, acpi_notify); + sysfs_remove_group(&pf_device->dev.kobj, &dev_attribute_group); led_classdev_unregister(&tpad_led); @@ -788,7 +795,6 @@ static struct acpi_driver acpi_driver = { .ops = { .add = acpi_add, .remove = acpi_remove, - .notify = acpi_notify, }, .owner = THIS_MODULE, }; From patchwork Fri May 12 14:02:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 681241 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 C77B2C7EE2F for ; Fri, 12 May 2023 14:03:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241426AbjELODo (ORCPT ); Fri, 12 May 2023 10:03:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241441AbjELODZ (ORCPT ); Fri, 12 May 2023 10:03:25 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1F763C23 for ; Fri, 12 May 2023 07:03:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683900204; x=1715436204; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=T/p7wXwgggq+ONStRo5Sa0RISORO8YEbXInY81s2yOk=; b=JHFCcBykLjypMNTgc9SmvJ1FOEcIZ4lZz10dcTBlnkZSvrOLGY98E/HZ SriBc3EPWYktaE+6Pd7c69Kl+kXNG/kHt6zLFzPm5TYlIm1Mdg0Lh9Y3R t3iLM9KgHMne3m5LYSLIGBad1ysEL5CUtt/Sl47l5gn6tjbXwRfVq8viN mayPW6mcCx/zg4wWEudM6P+leVTSQQ5Op/aDKnyh7IRPckDhBEQBwCnq7 CD8CD649jM24oewolnJATK1G/mi+d1N0vOXHOO0FRiBYl5BrzTq+UvDmo GaOC/OLLo7DyKbbvQMbRwhxnzYVHoh5WhRePx8z/Fz+MV+/2Yq6iIJ4ie g==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="378931150" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="378931150" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="650648993" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="650648993" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:23 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, Michal Wilczynski Subject: [PATCH v1 23/34] platform/x86/panasonic-laptop: Move handler installing logic to driver Date: Fri, 12 May 2023 16:02:11 +0200 Message-Id: <20230512140222.124868-24-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230512140222.124868-1-michal.wilczynski@intel.com> References: <20230512140222.124868-1-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/platform/x86/panasonic-laptop.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/platform/x86/panasonic-laptop.c b/drivers/platform/x86/panasonic-laptop.c index cf845ee1c7b1..3f845802c1d3 100644 --- a/drivers/platform/x86/panasonic-laptop.c +++ b/drivers/platform/x86/panasonic-laptop.c @@ -833,9 +833,12 @@ static void acpi_pcc_generate_keyinput(struct pcc_acpi *pcc) pr_err("Unknown hotkey event: 0x%04llx\n", result); } -static void acpi_pcc_hotkey_notify(struct acpi_device *device, u32 event) +static void acpi_pcc_hotkey_notify(acpi_handle handle, u32 event, void *data) { - struct pcc_acpi *pcc = acpi_driver_data(device); + struct acpi_device *device = data; + struct pcc_acpi *pcc; + + pcc = acpi_driver_data(device); switch (event) { case HKEY_NOTIFY: @@ -1049,7 +1052,13 @@ static int acpi_pcc_hotkey_add(struct acpi_device *device) } i8042_install_filter(panasonic_i8042_filter); - return 0; + + result = acpi_device_install_event_handler(device, ACPI_DEVICE_NOTIFY, + acpi_pcc_hotkey_notify); + if (result) + goto out_platform; + + return result; out_platform: platform_device_unregister(pcc->platform); @@ -1072,6 +1081,8 @@ static void acpi_pcc_hotkey_remove(struct acpi_device *device) if (!device || !pcc) return; + acpi_device_remove_event_handler(device, ACPI_DEVICE_NOTIFY, acpi_pcc_hotkey_notify); + i8042_remove_filter(panasonic_i8042_filter); if (pcc->platform) { From patchwork Fri May 12 14:02: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: 681604 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 C319DC7EE23 for ; Fri, 12 May 2023 14:03:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241438AbjELODp (ORCPT ); Fri, 12 May 2023 10:03:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241443AbjELOD0 (ORCPT ); Fri, 12 May 2023 10:03:26 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA3C259D0 for ; Fri, 12 May 2023 07:03:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683900205; x=1715436205; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8f1zF/CYjsR0VEmhcV9UTOXYcizlKE93MgFKQdhrbi4=; b=A+YeB2pNc8gfH4szWA7Vd5YhtBPo8HFk2iUEF3aPRr+9nBS78zpeqROm 481XIereQeRXdVHEW5ko9Mqp0rbiXMQIjfHq4s9LQOxgmO0Es+1HXh1AS tt8joCvIyNyq7d27lAIXz7MdGpc25RK3Z+E+3lO0VjIf9eyu97wFiOqH3 8O2Jl2AkVU01y5yn2G7/Ak7gLPMDUCWIxZHPN1Jat9earQmiptkLoZqYj cbz0DLz0CvUL/bRc7mTAo4/nXqSXUG7hijOU5ww3VwOJQJydS9y+n0Pai NJFjuEwA/RTpXOuQ5ct4OgTRndJ3t15krFFf7bII39/6Un5AkaWFppQ/s A==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="378931159" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="378931159" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="650648996" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="650648996" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:24 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, Michal Wilczynski Subject: [PATCH v1 24/34] platform/x86/system76_acpi: Move handler installing logic to driver Date: Fri, 12 May 2023 16:02:12 +0200 Message-Id: <20230512140222.124868-25-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230512140222.124868-1-michal.wilczynski@intel.com> References: <20230512140222.124868-1-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/platform/x86/system76_acpi.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/drivers/platform/x86/system76_acpi.c b/drivers/platform/x86/system76_acpi.c index 97f5a8255b91..3e729ec08b8b 100644 --- a/drivers/platform/x86/system76_acpi.c +++ b/drivers/platform/x86/system76_acpi.c @@ -627,29 +627,30 @@ static void input_key(struct system76_data *data, unsigned int code) } // Handle ACPI notification -static void system76_notify(struct acpi_device *acpi_dev, u32 event) +static void system76_notify(acpi_handle handle, u32 event, void *data) { - struct system76_data *data; + struct acpi_device *acpi_dev = data; + struct system76_data *s_data; - data = acpi_driver_data(acpi_dev); + s_data = acpi_driver_data(acpi_dev); switch (event) { case 0x80: - kb_led_hotkey_hardware(data); + kb_led_hotkey_hardware(s_data); break; case 0x81: - kb_led_hotkey_toggle(data); + kb_led_hotkey_toggle(s_data); break; case 0x82: - kb_led_hotkey_down(data); + kb_led_hotkey_down(s_data); break; case 0x83: - kb_led_hotkey_up(data); + kb_led_hotkey_up(s_data); break; case 0x84: - kb_led_hotkey_color(data); + kb_led_hotkey_color(s_data); break; case 0x85: - input_key(data, KEY_SCREENLOCK); + input_key(s_data, KEY_SCREENLOCK); break; } } @@ -733,7 +734,11 @@ static int system76_add(struct acpi_device *acpi_dev) system76_battery_init(); } - return 0; + err = acpi_device_install_event_handler(acpi_dev, ACPI_DEVICE_NOTIFY, system76_notify); + if (err) + goto error; + + return err; error: if (data->has_open_ec) { @@ -750,6 +755,8 @@ static void system76_remove(struct acpi_device *acpi_dev) data = acpi_driver_data(acpi_dev); + acpi_device_remove_event_handler(acpi_dev, ACPI_DEVICE_NOTIFY, system76_notify); + if (data->has_open_ec) { system76_battery_exit(); kfree(data->nfan); @@ -769,7 +776,6 @@ static struct acpi_driver system76_driver = { .ops = { .add = system76_add, .remove = system76_remove, - .notify = system76_notify, }, }; module_acpi_driver(system76_driver); From patchwork Fri May 12 14:02:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 681240 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 D5174C77B7C for ; Fri, 12 May 2023 14:03:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241428AbjELODq (ORCPT ); Fri, 12 May 2023 10:03:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241444AbjELODd (ORCPT ); Fri, 12 May 2023 10:03:33 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22FF8D870 for ; Fri, 12 May 2023 07:03:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683900207; x=1715436207; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nbCBiSyuCy2m+4Tz/iazNSbMP/gr+s3bj2lE55c9N3A=; b=lc/MdTMbw2yt2kmDPx0HpO3RFv/yx/CfWuLqqwru0CZgrokntL8OBVcC Cg4RescfSV0U8NXXxjMftTFLFwIZ1UMh2Ye9Dts3XfjbciHBujWDMgIDD +xvdcOMt6Ctrsk8j7cfra0AXmarGu78HZe06ArBMj13henHtUKnaKGb1a jW53dl6nYezyHtNxDjs9Ae4+Tt2wd93ZmSQn3hAf9VDnC5pLyy7tU8y9Z fyLzSf3ok/qrVY6yanMFx4TYMR590F0670NzpMGnlcaDBWswnKV0sOZVO 7x8t9e5MKbVjpb984RdERKrzoKY715SgWvUMWAW+fsz5LnBP4zNwtsgBk A==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="378931169" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="378931169" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="650648999" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="650648999" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:25 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, Michal Wilczynski Subject: [PATCH v1 25/34] platform/x86/topstar-laptop: Move handler installing logic to driver Date: Fri, 12 May 2023 16:02:13 +0200 Message-Id: <20230512140222.124868-26-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230512140222.124868-1-michal.wilczynski@intel.com> References: <20230512140222.124868-1-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/platform/x86/topstar-laptop.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/platform/x86/topstar-laptop.c b/drivers/platform/x86/topstar-laptop.c index 20df1ebefc30..31cc3ce9bff3 100644 --- a/drivers/platform/x86/topstar-laptop.c +++ b/drivers/platform/x86/topstar-laptop.c @@ -232,12 +232,15 @@ static int topstar_acpi_fncx_switch(struct acpi_device *device, bool state) return 0; } -static void topstar_acpi_notify(struct acpi_device *device, u32 event) +static void topstar_acpi_notify(acpi_handle handle, u32 event, void *data) { - struct topstar_laptop *topstar = acpi_driver_data(device); + struct acpi_device *device = data; + struct topstar_laptop *topstar; static bool dup_evnt[2]; bool *dup; + topstar = acpi_driver_data(device); + /* 0x83 and 0x84 key events comes duplicated... */ if (event == 0x83 || event == 0x84) { dup = &dup_evnt[event - 0x83]; @@ -319,7 +322,11 @@ static int topstar_acpi_add(struct acpi_device *device) goto err_input_exit; } - return 0; + err = acpi_device_install_event_handler(acpi_dev, ACPI_DEVICE_NOTIFY, topstar_acpi_notify); + if (err) + goto err_input_exit; + + return err; err_input_exit: topstar_input_exit(topstar); @@ -336,6 +343,8 @@ static void topstar_acpi_remove(struct acpi_device *device) { struct topstar_laptop *topstar = acpi_driver_data(device); + acpi_device_remove_event_handler(acpi_dev, ACPI_DEVICE_NOTIFY, topstar_acpi_notify); + if (led_workaround) topstar_led_exit(topstar); @@ -360,7 +369,6 @@ static struct acpi_driver topstar_acpi_driver = { .ops = { .add = topstar_acpi_add, .remove = topstar_acpi_remove, - .notify = topstar_acpi_notify, }, }; From patchwork Fri May 12 14:02:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 681603 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 414E4C7EE26 for ; Fri, 12 May 2023 14:03:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241440AbjELODr (ORCPT ); Fri, 12 May 2023 10:03:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241398AbjELODi (ORCPT ); Fri, 12 May 2023 10:03:38 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 623F9106CB for ; Fri, 12 May 2023 07:03:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683900208; x=1715436208; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PJi/rzJx0JG0jTlQQjDqVY9CNtM024TPNfwM6gh0Gug=; b=C9Dk4xrXZBA998H1lMdvjujJcgcn/UwJWL+SGV+v9JJ3fnfjh2SUjAgf Zafb0K71SUfQ0JMZlrl3pjpTKGTXckMvWsslLtNfg2ck6j1A+ztMcg54B zb75FSl+EmiBI7zHJidj1Gg/6o+1dx6caWrUDYhr7CP0kWDfBrTt/+fVX oAB1JlNPuq49cqJx4CwPM0e2rXNmKqH5eLETUq+rj7hW3zG3tkMHhSNeF RsaCy+U83AQk4kaDOv6+SH0aDxpeJvgIAj++H8oHKWPGfZ8xICaWPJwJx IGCiEwx22+OGZkv0pC4YpYhJMSPxXAdJZhZY7m6OK5tbW1pP9Aqmrg96Z A==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="378931181" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="378931181" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="650649002" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="650649002" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:26 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, Michal Wilczynski Subject: [PATCH v1 26/34] platform/x86/toshiba_acpi: Move handler installing logic to driver Date: Fri, 12 May 2023 16:02:14 +0200 Message-Id: <20230512140222.124868-27-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230512140222.124868-1-michal.wilczynski@intel.com> References: <20230512140222.124868-1-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/platform/x86/toshiba_acpi.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c index b34984bbee33..29980c84d189 100644 --- a/drivers/platform/x86/toshiba_acpi.c +++ b/drivers/platform/x86/toshiba_acpi.c @@ -3190,6 +3190,8 @@ static void toshiba_acpi_remove(struct acpi_device *acpi_dev) { struct toshiba_acpi_dev *dev = acpi_driver_data(acpi_dev); + acpi_device_remove_event_handler(acpi_dev, ACPI_ALL_NOTIFY, toshiba_acpi_notify); + misc_deregister(&dev->miscdev); remove_toshiba_proc_entries(dev); @@ -3473,16 +3475,23 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev) if (dev->battery_charge_mode_supported) battery_hook_register(&battery_hook); - return 0; + ret = acpi_device_install_event_handler(acpi_dev, ACPI_ALL_NOTIFY, toshiba_acpi_notify); + if (ret) + goto error; + + return ret; error: toshiba_acpi_remove(acpi_dev); return ret; } -static void toshiba_acpi_notify(struct acpi_device *acpi_dev, u32 event) +static void toshiba_acpi_notify(acpi_handle handle, u32 event, void *data) { - struct toshiba_acpi_dev *dev = acpi_driver_data(acpi_dev); + struct acpi_device *acpi_dev = data; + struct toshiba_acpi_dev *dev; + + dev = acpi_driver_data(acpi_dev); switch (event) { case 0x80: /* Hotkeys and some system events */ @@ -3583,11 +3592,9 @@ static struct acpi_driver toshiba_acpi_driver = { .name = "Toshiba ACPI driver", .owner = THIS_MODULE, .ids = toshiba_device_ids, - .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS, .ops = { .add = toshiba_acpi_add, .remove = toshiba_acpi_remove, - .notify = toshiba_acpi_notify, }, .drv.pm = &toshiba_acpi_pm, }; From patchwork Fri May 12 14:02:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 681239 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 21AC3C77B75 for ; Fri, 12 May 2023 14:03:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241443AbjELODr (ORCPT ); Fri, 12 May 2023 10:03:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241449AbjELODi (ORCPT ); Fri, 12 May 2023 10:03:38 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C48ED12EA1 for ; Fri, 12 May 2023 07:03:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683900209; x=1715436209; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Cq01VFhjgj/mEhu0HxUgKXpUNPjV4fQitrA3AnSxcpE=; b=LG+ewfXvd0UFAagpBO/KAwIJv1/W6vrZPAX5t9f6c+vW3J4wy9KZcZfZ oPo9eVtemJEWCMYsdpTAYsKOly3OUzT2m0PqkapWIBQZU+ZYOn0mlmnHd dnorvjR1GX3gUxPOyn8g4NT0Up3sd2uf6NwzlE4elB+6gy9v/qIdxjLHQ fhrXBI1qMlg+SgPnhE+4DYFX89ZDuvoabbCKTHu67Lq66pyX5lLewnxRz eTC+gjOSFudZBQNEThnVqUMW9F2Y3Lj4FTsJJxtTauCvPa4iwXnRGAJTv 9r0nV6FjIKlHUzbxiV4OR57N/pJL19eRgXCjKoMxEPMeO5E1zRJO86pgD w==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="378931186" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="378931186" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="650649005" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="650649005" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:28 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, Michal Wilczynski Subject: [PATCH v1 27/34] platform/x86/toshiba_bluetooth: Move handler installing logic to driver Date: Fri, 12 May 2023 16:02:15 +0200 Message-Id: <20230512140222.124868-28-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230512140222.124868-1-michal.wilczynski@intel.com> References: <20230512140222.124868-1-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/platform/x86/toshiba_bluetooth.c | 27 ++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/drivers/platform/x86/toshiba_bluetooth.c b/drivers/platform/x86/toshiba_bluetooth.c index d8f81962a240..7d8bd5f73eae 100644 --- a/drivers/platform/x86/toshiba_bluetooth.c +++ b/drivers/platform/x86/toshiba_bluetooth.c @@ -204,9 +204,12 @@ static const struct rfkill_ops rfk_ops = { }; /* ACPI driver functions */ -static void toshiba_bt_rfkill_notify(struct acpi_device *device, u32 event) +static void toshiba_bt_rfkill_notify(acpi_handle handle, u32 event, void *data) { - struct toshiba_bluetooth_dev *bt_dev = acpi_driver_data(device); + struct toshiba_bluetooth_dev *bt_dev; + struct acpi_device *device = data; + + bt_dev = acpi_driver_data(device); if (toshiba_bluetooth_sync_status(bt_dev)) return; @@ -263,8 +266,8 @@ static int toshiba_bt_rfkill_add(struct acpi_device *device) bt_dev); if (!bt_dev->rfk) { pr_err("Unable to allocate rfkill device\n"); - kfree(bt_dev); - return -ENOMEM; + result = -ENOMEM; + goto fail_allocate; } rfkill_set_hw_state(bt_dev->rfk, !bt_dev->killswitch); @@ -272,10 +275,20 @@ static int toshiba_bt_rfkill_add(struct acpi_device *device) result = rfkill_register(bt_dev->rfk); if (result) { pr_err("Unable to register rfkill device\n"); - rfkill_destroy(bt_dev->rfk); - kfree(bt_dev); + goto fail_register; } + result = acpi_device_install_event_handler(acpi_dev, ACPI_DEVICE_NOTIFY, + toshiba_bt_rfkill_notify); + if (result) + goto fail_register; + + return result; + +fail_register: + rfkill_destroy(bt_dev->rfk); +fail_allocate: + kfree(bt_dev); return result; } @@ -283,6 +296,8 @@ static void toshiba_bt_rfkill_remove(struct acpi_device *device) { struct toshiba_bluetooth_dev *bt_dev = acpi_driver_data(device); + acpi_device_remove_event_handler(acpi_dev, ACPI_DEVICE_NOTIFY, toshiba_bt_rfkill_notify); + /* clean up */ if (bt_dev->rfk) { rfkill_unregister(bt_dev->rfk); From patchwork Fri May 12 14:02:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 681238 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 C7766C7EE2A for ; Fri, 12 May 2023 14:03:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241445AbjELODs (ORCPT ); Fri, 12 May 2023 10:03:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241450AbjELODj (ORCPT ); Fri, 12 May 2023 10:03:39 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED406132B4 for ; Fri, 12 May 2023 07:03:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683900210; x=1715436210; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WLKJ1EHMeHpdKP/vBtOYJQNkoa4IDwWxTq1fyvbh/mM=; b=VEveL3h4qt1cY4Si7maf2D41PqQrSv/sW2tfdvQgkpoKJCZceI+cx0+2 IFWKP6USWPW5VnO9QWPMD356rikXqkXxEwNX3caWkeDh7wvR/yeu//Vff vDnWz2P4zyrBGBVKYa041VyPrB2FTqz+bAn7ZEqIo0r2GzHEZQt7FV25f yXEaRfzL0441qRymS/KhWyf9ndgITfT05SvIGaG4OW4vWT51NYCjZmXHa gJK45GAYvAxsKKfqLnnDAsidaO4S+fqRXvyS8ouSfR5gaoxYKYETdlPuV C9Ycftv+Ju1tEzV9g0WxCZ/+buJX7HEw4H+TZGgm2yuFWodscNx5hhUHq w==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="378931192" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="378931192" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="650649009" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="650649009" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:29 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, Michal Wilczynski Subject: [PATCH v1 28/34] platform/x86/toshiba_haps: Move handler installing logic to driver Date: Fri, 12 May 2023 16:02:16 +0200 Message-Id: <20230512140222.124868-29-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230512140222.124868-1-michal.wilczynski@intel.com> References: <20230512140222.124868-1-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/platform/x86/toshiba_haps.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/platform/x86/toshiba_haps.c b/drivers/platform/x86/toshiba_haps.c index 8c9f76286b08..ec0ffae3516c 100644 --- a/drivers/platform/x86/toshiba_haps.c +++ b/drivers/platform/x86/toshiba_haps.c @@ -129,8 +129,10 @@ static const struct attribute_group haps_attr_group = { /* * ACPI stuff */ -static void toshiba_haps_notify(struct acpi_device *device, u32 event) +static void toshiba_haps_notify(acpi_handle handle, u32 event, void *data) { + struct acpi_device *device = data; + pr_debug("Received event: 0x%x\n", event); acpi_bus_generate_netlink_event(device->pnp.device_class, @@ -140,6 +142,7 @@ static void toshiba_haps_notify(struct acpi_device *device, u32 event) static void toshiba_haps_remove(struct acpi_device *device) { + acpi_device_remove_event_handler(acpi_dev, ACPI_ALL_NOTIFY, toshiba_haps_notify); sysfs_remove_group(&device->dev.kobj, &haps_attr_group); if (toshiba_haps) @@ -203,7 +206,7 @@ static int toshiba_haps_add(struct acpi_device *acpi_dev) toshiba_haps = haps; - return 0; + return acpi_device_install_event_handler(acpi_dev, ACPI_ALL_NOTIFY, toshiba_haps_notify); } #ifdef CONFIG_PM_SLEEP @@ -253,11 +256,9 @@ static struct acpi_driver toshiba_haps_driver = { .name = "Toshiba HAPS", .owner = THIS_MODULE, .ids = haps_device_ids, - .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS, .ops = { .add = toshiba_haps_add, .remove = toshiba_haps_remove, - .notify = toshiba_haps_notify, }, .drv.pm = &toshiba_haps_pm, }; From patchwork Fri May 12 14:02:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 681602 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 3B411C77B7C for ; Fri, 12 May 2023 14:03:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241450AbjELODt (ORCPT ); Fri, 12 May 2023 10:03:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241453AbjELODj (ORCPT ); Fri, 12 May 2023 10:03:39 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C86D213854 for ; Fri, 12 May 2023 07:03:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683900212; x=1715436212; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+DuzAcBIoQKvNVVST5kArg3jtPsfRDK7DxEi4uAzm3s=; b=DdZpC8Fso7R0EjlMeNCVHaZ0VtiURDIIr5GNS0hfMaHxrAQpb/8vYy7h P4iZrD4kJIl4fM09vNqDeHDiGJSThhkDOnw1vXEeF9flf4v4w+NrSmV3g JnP3dkFZ+WMNIC453vkxQJ0ZJp7Dq8NHpFbMeKZLsJibwGVgakEawwyOD EodVCIVPN5Qcg31WHMuCURrjmc8VuRAR0ZBy+HIZ66bErT6xV7ItBqy/D VSAKz2jKpsFBK1YckRhqiGJvuEx5mUJRGjzxyZJf07g92hYMElObf/6Ea RkUejDOVVJzgyWR0KbkwBbt3eMRNOdlbMeuK/y5iWxr68NaKFkRR/G5Qd A==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="378931196" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="378931196" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="650649013" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="650649013" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:30 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, Michal Wilczynski Subject: [PATCH v1 29/34] platform/x86/wireless-hotkey: Move handler installing logic to driver Date: Fri, 12 May 2023 16:02:17 +0200 Message-Id: <20230512140222.124868-30-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230512140222.124868-1-michal.wilczynski@intel.com> References: <20230512140222.124868-1-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/platform/x86/wireless-hotkey.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/platform/x86/wireless-hotkey.c b/drivers/platform/x86/wireless-hotkey.c index 4422863f47bb..51169509fea1 100644 --- a/drivers/platform/x86/wireless-hotkey.c +++ b/drivers/platform/x86/wireless-hotkey.c @@ -68,9 +68,12 @@ static void wireless_input_destroy(struct acpi_device *device) kfree(button); } -static void wl_notify(struct acpi_device *acpi_dev, u32 event) +static void wl_notify(acpi_handle handle, u32 event, void *data) { - struct wl_button *button = acpi_driver_data(acpi_dev); + struct acpi_device *acpi_dev = data; + struct wl_button *button; + + button = acpi_driver_data(acpi_dev); if (event != 0x80) { pr_info("Received unknown event (0x%x)\n", event); @@ -95,16 +98,24 @@ static int wl_add(struct acpi_device *device) device->driver_data = button; err = wireless_input_setup(device); - if (err) { - pr_err("Failed to setup wireless hotkeys\n"); - kfree(button); - } + if (err) + goto fail; + err = acpi_device_install_event_handler(device, ACPI_DEVICE_NOTIFY, wl_notify); + if (err) + goto fail; + + return err; + +fail: + pr_err("Failed to setup wireless hotkeys\n"); + kfree(button); return err; } static void wl_remove(struct acpi_device *device) { + acpi_device_remove_event_handler(device, ACPI_DEVICE_NOTIFY, wl_notify); wireless_input_destroy(device); } From patchwork Fri May 12 14:02:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 681237 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 8B066C77B7C for ; Fri, 12 May 2023 14:04:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241455AbjELOEA (ORCPT ); Fri, 12 May 2023 10:04:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241456AbjELODj (ORCPT ); Fri, 12 May 2023 10:03:39 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06E2413859 for ; Fri, 12 May 2023 07:03:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683900213; x=1715436213; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WEpTBts2uTodF7cAKNj6FMRZNi9l8sfosWjBo4qNrm0=; b=RXjkfmh4GvA5nqUdicVar9Ih4uPdmMaOtMnJl1NnmYBl+t/dNijfu4Lk J8bFFmfnNerQW011Uq8jOj8Z7ItZAE1sXLXCQBmm7/ImoN1U1b6k4l8Q0 i4zCVC5+Y4aN+Sm/T8zQzzrh7SQZPCjFLI0pFy15Os0gThBCcOb48m09J UQOBlpDsgqcOG/WtGiupawcwFSw+vEyHD3a9YcPsuzOKONdYBnEwq7RZw Y0mZuaIyB9qLTKyaT4n8Fyx6AoTSljB52sQ3BQbBG2XBF/Vk08Ndtq33/ UtNrH0SExS/pYCrCQvb3FcuhQxwy9PBrCRt5hYZFwn1sq77Aeo/s/doSy w==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="378931205" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="378931205" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="650649016" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="650649016" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:32 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, Michal Wilczynski Subject: [PATCH v1 30/34] platform/x86/xo15-ebook: Move handler installing logic to driver Date: Fri, 12 May 2023 16:02:18 +0200 Message-Id: <20230512140222.124868-31-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230512140222.124868-1-michal.wilczynski@intel.com> References: <20230512140222.124868-1-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/platform/x86/xo15-ebook.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/platform/x86/xo15-ebook.c b/drivers/platform/x86/xo15-ebook.c index 391f7ea4431e..8b5b05429889 100644 --- a/drivers/platform/x86/xo15-ebook.c +++ b/drivers/platform/x86/xo15-ebook.c @@ -56,8 +56,9 @@ static int ebook_send_state(struct acpi_device *device) return 0; } -static void ebook_switch_notify(struct acpi_device *device, u32 event) +static void ebook_switch_notify(acpi_handle handle, u32 event, void *data) { + struct acpi_device *device = data; switch (event) { case ACPI_FIXED_HARDWARE_EVENT: case XO15_EBOOK_NOTIFY_STATUS: @@ -134,7 +135,11 @@ static int ebook_switch_add(struct acpi_device *device) device_set_wakeup_enable(&device->dev, true); } - return 0; + error = acpi_device_install_event_handler(device, ACPI_DEVICE_NOTIFY, ebook_switch_notify); + if (error) + goto err_free_input; + + return error; err_free_input: input_free_device(input); @@ -147,6 +152,7 @@ static void ebook_switch_remove(struct acpi_device *device) { struct ebook_switch *button = acpi_driver_data(device); + acpi_device_remove_event_handler(device, ACPI_DEVICE_NOTIFY, ebook_switch_notify); input_unregister_device(button->input); kfree(button); } @@ -158,7 +164,6 @@ static struct acpi_driver xo15_ebook_driver = { .ops = { .add = ebook_switch_add, .remove = ebook_switch_remove, - .notify = ebook_switch_notify, }, .drv.pm = &ebook_switch_pm, }; From patchwork Fri May 12 14:02:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 681601 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 5B1D6C77B75 for ; Fri, 12 May 2023 14:04:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241471AbjELOD7 (ORCPT ); Fri, 12 May 2023 10:03:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241455AbjELODj (ORCPT ); Fri, 12 May 2023 10:03:39 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D62201385F for ; Fri, 12 May 2023 07:03:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683900214; x=1715436214; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2g43mjaPSJayDX4co/+nvjJtHmwHMaNW0cV9F4N1udc=; b=PRVNmQAzEPNWaeSDpEI7MmJjNnGMKYgkX1aAlmsxHEggA4lYtAYhJAq0 wedDNcyksrgoBO6wRZ3IUSDA9fC8w9bWeTCeVDQGNim+h2aBiafre4+97 Omm4/lkO+2D2DA900Gk/ziaDDj+azpmNhYaFt1Sc+ZAEs3Wsxn6x9A/aQ 00RPvSqRgoFfR20z9SZn4k1zoZZLz2CcMkMTLOJt4/n0pz95667X1UH+K gdGd3W2yizfIi/SmChWxsx/4SldJc6FVVqlOVY8NiI1lP8wrfCNqozV0P sTCYW7Ax5ncBZJSAGI9PHsIzCxthTG4bZBZbZSqTpoz0n6citdcKd+ZR6 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="378931211" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="378931211" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="650649019" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="650649019" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:33 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, Michal Wilczynski Subject: [PATCH v1 31/34] virt/vmgenid: Move handler installing logic to driver Date: Fri, 12 May 2023 16:02:19 +0200 Message-Id: <20230512140222.124868-32-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230512140222.124868-1-michal.wilczynski@intel.com> References: <20230512140222.124868-1-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/virt/vmgenid.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/virt/vmgenid.c b/drivers/virt/vmgenid.c index a1c467a0e9f7..b5532215e476 100644 --- a/drivers/virt/vmgenid.c +++ b/drivers/virt/vmgenid.c @@ -60,16 +60,26 @@ static int vmgenid_add(struct acpi_device *device) device->driver_data = state; + ret = acpi_device_install_event_handler(device, ACPI_DEVICE_NOTIFY, vmgenid_notify); + out: ACPI_FREE(parsed.pointer); return ret; } -static void vmgenid_notify(struct acpi_device *device, u32 event) +static void vmgenid_remove(struct acpi_device *device) +{ + acpi_device_remove_event_handler(device, ACPI_DEVICE_NOTIFY, vmgenid_notify); +} + +static void vmgenid_notify(acpi_handle handle, u32 event, void *data) { - struct vmgenid_state *state = acpi_driver_data(device); + struct acpi_device *device = data; + struct vmgenid_state *state; u8 old_id[VMGENID_SIZE]; + state = acpi_driver_data(device); + memcpy(old_id, state->this_id, sizeof(old_id)); memcpy(state->this_id, state->next_id, sizeof(state->this_id)); if (!memcmp(old_id, state->this_id, sizeof(old_id))) @@ -89,7 +99,7 @@ static struct acpi_driver vmgenid_driver = { .owner = THIS_MODULE, .ops = { .add = vmgenid_add, - .notify = vmgenid_notify + .remove = vmgenid_remove, } }; From patchwork Fri May 12 14:02:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 681600 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 4FE1FC77B75 for ; Fri, 12 May 2023 14:04:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241458AbjELOEP (ORCPT ); Fri, 12 May 2023 10:04:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241405AbjELODj (ORCPT ); Fri, 12 May 2023 10:03:39 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AA3813C02 for ; Fri, 12 May 2023 07:03:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683900216; x=1715436216; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZIELIisXLuT7XWw63Y22+2MpV7DcrBhlODB+fjpGyhE=; b=AGBcUj4VMghzFDguzXfXkAzS59qPAlZp8BVDeDAcT1iiiHLXxwD/ZrmC SBgKVMRN5c2qGN5ACbthYdW4PDbmCp03c5FaUlvuEav63DQGcd278lLNs uQeNjvbZLN51CLe3jLpPmKJl3dQ557CGL9vt6judhI89Zow9H7H7vBaCa ZNZf+Ia7O1tEJGwdsZJWt6EAOxAdFNElZKDIVJ1LsWczz9o/IuF6LSFv6 6/Ps6Z/KpM034D6JUNQxKCD9OR0nNR4XGRdONFVgt/SM1Omc2pUXxa3tC e93d5ThVPdLnWT1PzaXYuc0FRcPSuI4hSW05ZgwzXscLTESX+rv31KMjS w==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="378931219" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="378931219" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="650649022" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="650649022" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:34 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, Michal Wilczynski Subject: [PATCH v1 32/34] acpi/bus: Remove installing/removing notify handlers from probe/remove Date: Fri, 12 May 2023 16:02:20 +0200 Message-Id: <20230512140222.124868-33-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230512140222.124868-1-michal.wilczynski@intel.com> References: <20230512140222.124868-1-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Remove installing/removing .notify callback handlers, to prepare for notify callback removal. Remove logic calling .remove callback, as .add should be expected to clean after itself in case of the failure, and event handler installation will be moved to .add in following commits. Signed-off-by: Michal Wilczynski --- drivers/acpi/bus.c | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 00309df56c24..3eeeec70e70b 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -1086,20 +1086,6 @@ static int acpi_device_probe(struct device *dev) pr_debug("Driver [%s] successfully bound to device [%s]\n", acpi_drv->name, acpi_dev->pnp.bus_id); - if (acpi_drv->ops.notify) { - ret = acpi_device_install_notify_handler(acpi_dev, acpi_drv); - if (ret) { - if (acpi_drv->ops.remove) - acpi_drv->ops.remove(acpi_dev); - - acpi_dev->driver_data = NULL; - return ret; - } - } - - pr_debug("Found driver [%s] for device [%s]\n", acpi_drv->name, - acpi_dev->pnp.bus_id); - get_device(dev); return 0; } @@ -1109,9 +1095,6 @@ static void acpi_device_remove(struct device *dev) struct acpi_device *acpi_dev = to_acpi_device(dev); struct acpi_driver *acpi_drv = to_acpi_driver(dev->driver); - if (acpi_drv->ops.notify) - acpi_device_remove_notify_handler(acpi_dev, acpi_drv); - if (acpi_drv->ops.remove) acpi_drv->ops.remove(acpi_dev); From patchwork Fri May 12 14:02:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 681236 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 EDEB0C7EE2A for ; Fri, 12 May 2023 14:04:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241379AbjELOEQ (ORCPT ); Fri, 12 May 2023 10:04:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241429AbjELODj (ORCPT ); Fri, 12 May 2023 10:03:39 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F81C526F for ; Fri, 12 May 2023 07:03:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683900217; x=1715436217; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kEzEz2OTalUP65K0ey9fMviY/+IrUGpeYbTO2YVCrqw=; b=O8FxlKsZFD8U1Zd5hO6sJCqp08NoFALHkANtH80pMg2IzLYyNFNdOUYF MIB/GpQpqVqnLQtDgoNNGUhinz2MNB5H+Gus2z+aHXxPBOAGwiNJNARXI Kn9BW2fLlLzrSj4UVCNW7m/LvVREZVNAmR52PS23nJX7kIs55Li4ysSSt lV1j8yNde6w/N1UoMXt9ETJETUNBCt2sBhnLERMd2J0MbYHWFhqm2wqUP 7hM4BTSIs6wvT7rF9VKXLAexGYZXkU+TZLtcVoKqws5UAtKTvPGMHFg8n 7mMkHcCLx6IvRizezIIz1uR01flu3eaKadGgoGviB9FufSu1ny/UtnCsF g==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="378931227" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="378931227" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="650649025" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="650649025" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:35 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, Michal Wilczynski Subject: [PATCH v1 33/34] acpi/bus: Remove redundant functions Date: Fri, 12 May 2023 16:02:21 +0200 Message-Id: <20230512140222.124868-34-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230512140222.124868-1-michal.wilczynski@intel.com> References: <20230512140222.124868-1-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org By this point all drivers switched from using .notify callback to installing event handlers on their own. Remove redundant functions acpi_device_install_notify_handler(), acpi_device_remove_notify_handler() and acpi_notify_device(). Signed-off-by: Michal Wilczynski --- drivers/acpi/bus.c | 60 ---------------------------------------------- 1 file changed, 60 deletions(-) diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 3eeeec70e70b..bf0704bf8e04 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -522,14 +522,6 @@ static void acpi_bus_notify(acpi_handle handle, u32 type, void *data) acpi_evaluate_ost(handle, type, ACPI_OST_SC_NON_SPECIFIC_FAILURE, NULL); } -static void acpi_notify_device(acpi_handle handle, u32 event, void *data) -{ - struct acpi_device *device = data; - struct acpi_driver *acpi_drv = to_acpi_driver(device->dev.driver); - - acpi_drv->ops.notify(device, event); -} - static void acpi_notify_device_fixed(void *data) { struct acpi_device *device = data; @@ -544,58 +536,6 @@ static u32 acpi_device_fixed_event(void *data) return ACPI_INTERRUPT_HANDLED; } -static int acpi_device_install_notify_handler(struct acpi_device *device, - struct acpi_driver *acpi_drv) -{ - acpi_status status; - - if (device->device_type == ACPI_BUS_TYPE_POWER_BUTTON) { - device->fixed_event_notify = acpi_notify_device; - status = - acpi_install_fixed_event_handler(ACPI_EVENT_POWER_BUTTON, - acpi_device_fixed_event, - device); - } else if (device->device_type == ACPI_BUS_TYPE_SLEEP_BUTTON) { - device->fixed_event_notify = acpi_notify_device; - status = - acpi_install_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON, - acpi_device_fixed_event, - device); - } else { - u32 type = acpi_drv->flags & ACPI_DRIVER_ALL_NOTIFY_EVENTS ? - ACPI_ALL_NOTIFY : ACPI_DEVICE_NOTIFY; - - status = acpi_install_notify_handler(device->handle, type, - acpi_notify_device, - device); - } - - if (ACPI_FAILURE(status)) - return -EINVAL; - return 0; -} - -static void acpi_device_remove_notify_handler(struct acpi_device *device, - struct acpi_driver *acpi_drv) -{ - if (device->device_type == ACPI_BUS_TYPE_POWER_BUTTON) { - acpi_remove_fixed_event_handler(ACPI_EVENT_POWER_BUTTON, - acpi_device_fixed_event); - device->fixed_event_notify = NULL; - } else if (device->device_type == ACPI_BUS_TYPE_SLEEP_BUTTON) { - acpi_remove_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON, - acpi_device_fixed_event); - device->fixed_event_notify = NULL; - } else { - u32 type = acpi_drv->flags & ACPI_DRIVER_ALL_NOTIFY_EVENTS ? - ACPI_ALL_NOTIFY : ACPI_DEVICE_NOTIFY; - - acpi_remove_notify_handler(device->handle, type, - acpi_notify_device); - } - acpi_os_wait_events_complete(); -} - int acpi_device_install_event_handler(struct acpi_device *device, u32 type, void (*notify)(acpi_handle, u32, void*)) From patchwork Fri May 12 14:02:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 681599 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 2A3C7C7EE26 for ; Fri, 12 May 2023 14:04:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241405AbjELOEP (ORCPT ); Fri, 12 May 2023 10:04:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241459AbjELODj (ORCPT ); Fri, 12 May 2023 10:03:39 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AC4513C16 for ; Fri, 12 May 2023 07:03:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683900218; x=1715436218; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=J0PI22rnw+GYC5C6NqjiXOlKuANTYa1On/ROwJ+FKUU=; b=NXNo/nsQzO/vLe8af4pmzodylzgeRWI8ciZ64c6NVrGRYn3io8NjeZMK aIkEPGPqaXwcBjCYNnSRKvHFtVbgRWA84ayJzi0OwuGY/gePeG3M70jJY qqUQgJhE5LYNibb/NjTHXFHo404dY25FlqvLBqT6NddhULV0JgWl24Xmq Q/zn379WYdCOraZtMXl5tu7P6HqbTDME5wBdHvXL9+WgD+TPUEFLcGkOh xq8tP+VAJnICAoFNFFjHvMbtkQODC5hkJkt1wB++ayoRCgKljk6eDQs5/ xOl8vasbq6NUN0/uzjoC3hEzp4mcLnYztuvkhTzs1+pkA2f3gpmlX50rw g==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="378931232" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="378931232" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="650649028" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="650649028" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:37 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, Michal Wilczynski Subject: [PATCH v1 34/34] acpi/bus: Remove notify callback and flags Date: Fri, 12 May 2023 16:02:22 +0200 Message-Id: <20230512140222.124868-35-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230512140222.124868-1-michal.wilczynski@intel.com> References: <20230512140222.124868-1-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org As callback has been replaced by drivers installing their handlers in .add it's presence is not useful anymore. Remove notify callback from struct acpi_driver, and flags as it's not needed anymore. Signed-off-by: Michal Wilczynski --- include/acpi/acpi_bus.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index 7fb411438b6f..3326794d5b70 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -151,12 +151,10 @@ struct acpi_hotplug_context { typedef int (*acpi_op_add) (struct acpi_device * device); typedef void (*acpi_op_remove) (struct acpi_device *device); -typedef void (*acpi_op_notify) (struct acpi_device * device, u32 event); struct acpi_device_ops { acpi_op_add add; acpi_op_remove remove; - acpi_op_notify notify; }; #define ACPI_DRIVER_ALL_NOTIFY_EVENTS 0x1 /* system AND device events */ @@ -165,7 +163,6 @@ struct acpi_driver { char name[80]; char class[80]; const struct acpi_device_id *ids; /* Supported Hardware IDs */ - unsigned int flags; struct acpi_device_ops ops; struct device_driver drv; struct module *owner;