From patchwork Thu Jun 1 13:17:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13263750 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 6051AC7EE2E for ; Thu, 1 Jun 2023 13:43:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233179AbjFANnh (ORCPT ); Thu, 1 Jun 2023 09:43:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233215AbjFANng (ORCPT ); Thu, 1 Jun 2023 09:43:36 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FB6E13E; Thu, 1 Jun 2023 06:43:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685627015; x=1717163015; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=xy9OgUL61th3jROVwjpCmagDUUoL2L/+PFsZiahG3m4=; b=k/hFLdDspdeYNgByIMpob5ABSkLTdVRkHMkSujI3O1+BRt22fcupYY76 lAJ8h58oNHKuQWiKeeVvbCB1+I1YBweWZYTqFbi3y3EEjmM0Gaz/I0Rgk 0hmRXbJBoiEybcHY5X21giuE9BH5r1WGCQAv/rVR6gAl1nmmnSHBoxzZg 65Ifd4sLzTyeIErvlnAJ9P478IVx4w0r3NPcQNPAANIfJNK7pd4Fl8Y8e Gv1LIWmOFddh4/t7vC/teRX1r+q9ylltBZP1G9o1ou0m8emUwpSFmxBc/ xzaBINsHlpaE71ZXY54UffAnRd4XiNGxKb9iA1aqjz8HnnFmohQDID3JZ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="421350828" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="421350828" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:17:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="851678057" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="851678057" Received: from hextor.igk.intel.com ([10.123.220.6]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:17:23 -0700 From: Michal Wilczynski To: rafael@kernel.org, lenb@kernel.org, dan.j.williams@intel.com, vishal.l.verma@intel.com, dave.jiang@intel.com, ira.weiny@intel.com, rui.zhang@intel.com, jdelvare@suse.com, linux@roeck-us.net, jic23@kernel.org, lars@metafoo.de, bleung@chromium.org, yu.c.chen@intel.com, hdegoede@redhat.com, markgross@kernel.org, luzmaximilian@gmail.com, corentin.chary@gmail.com, jprvita@gmail.com, cascardo@holoscopio.com, don@syst.com.br, pali@kernel.org, jwoithe@just42.net, matan@svgalib.org, kenneth.t.chan@gmail.com, malattia@linux.it, jeremy@system76.com, productdev@system76.com, herton@canonical.com, coproscefalo@gmail.com, tytso@mit.edu, Jason@zx2c4.com, robert.moore@intel.com Cc: linux-acpi@vger.kernel.org, nvdimm@lists.linux.dev, linux-hwmon@vger.kernel.org, linux-iio@vger.kernel.org, chrome-platform@lists.linux.dev, platform-driver-x86@vger.kernel.org, acpi4asus-user@lists.sourceforge.net, Michal Wilczynski , acpica-devel@lists.linuxfoundation.org Subject: [PATCH v4 01/35] acpi: Adjust functions installing bus event handlers Date: Thu, 1 Jun 2023 15:17:19 +0200 Message-Id: <20230601131719.300720-1-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 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 | 59 ++++++++++++++++++++++++++++++++++++++++- include/acpi/acpi_bus.h | 7 +++++ 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index d161ff707de4..cf2c2bfe29a0 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,59 @@ 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 (!notify) + return -EINVAL; + + 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 Thu Jun 1 13:17:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13263742 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 156F8C7EE2A for ; Thu, 1 Jun 2023 13:41:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233565AbjFANlX (ORCPT ); Thu, 1 Jun 2023 09:41:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233470AbjFANlW (ORCPT ); Thu, 1 Jun 2023 09:41:22 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 626B1189; Thu, 1 Jun 2023 06:41: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=1685626881; x=1717162881; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=wNzFAp+2Askmwe3Z0I4i+TRfnPUKD8KrFQAyDNVZazs=; b=IfO8gzl3TR7LAVAuHxEYiTqv5MiTI1Q+x0/fTfqs4D4greAvY/pqUIiQ t9FzLrBkG6cbThGrkcUuvvvgcgiwFmoNsAa1BQV84A92b3hGm6Ecq2Qqf 9/1p4u2vuqb1Le/J86MtwMnXy4Mrn26Iqh/dG3Dx+tmfucGHe7dmcizKK 264RuaCBaVRldfg5kN2Jvf6H5zYAQz0zQYr6P/pPjL9Spzbw+y5+KMaBJ htDybXtu1kuD+8VcM/uhQXeHHiqpt265DHMIvM5zamnDe8RjSg275asLs Dfa3JuUc0KBTMqjX/ulZVa5CKiI73KRQ37ql2GrcBI3HStB6JK0lLRGNw w==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="419066129" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="419066129" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:18:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="881601091" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="881601091" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:18:03 -0700 From: Michal Wilczynski To: "Rafael J. Wysocki" , Len Brown Cc: Michal Wilczynski , linux-acpi@vger.kernel.org, platform-driver-x86@vger.kernel.org Subject: [PATCH v4 02/35] acpi/ac: Move handler installing logic to driver Date: Thu, 1 Jun 2023 15:17:05 +0200 Message-Id: <20230601131739.300760-3-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 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 Thu Jun 1 13:17:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13263743 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 3BA73C7EE2A for ; Thu, 1 Jun 2023 13:41:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233614AbjFANli (ORCPT ); Thu, 1 Jun 2023 09:41:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233470AbjFANlh (ORCPT ); Thu, 1 Jun 2023 09:41:37 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69406180; Thu, 1 Jun 2023 06:41: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=1685626896; x=1717162896; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FCMoj4Gj8XZ5msdccA3UmP66sLs7lLh7QR48M0Uz8Xg=; b=UOVf3cPhL/Zxb7dsySVYxKX9KeNTa+hZMZ+59rwCNmPgGsN/qSs0Rd49 Q9DNOHEyvGGqAw3Nb5+v/mPEej6avLfrYDM4KVw8VTqkT/8DQAlR8sAT6 M+bcES7VbR68b2ECN7Y14PQVvPfzcy6Nf+iDeZQCkXmBGsU6/M8nL7kQb +Vzh1SHPmh9oV9UulXEH0ycLfKhEZ6RC5WptYHaj7s3cPnpBRnlEdvBp6 W/e12B48ygAc6nSGkVAvrr7PZt35meMSG4A/lyU6VH8nCZsuGpm3OjxWk INRJaY85yRoM6VGtrX9iLff9ny7phw9lQGjEP24qH8RrNyXD50Cw1BEfv w==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="419066293" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="419066293" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:18:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="881601181" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="881601181" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:18:11 -0700 From: Michal Wilczynski To: "Rafael J. Wysocki" , Len Brown Cc: Michal Wilczynski , linux-acpi@vger.kernel.org, platform-driver-x86@vger.kernel.org Subject: [PATCH v4 03/35] acpi/video: Move handler installing logic to driver Date: Thu, 1 Jun 2023 15:17:06 +0200 Message-Id: <20230601131739.300760-4-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230601131739.300760-3-michal.wilczynski@intel.com> References: <20230601131739.300760-3-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Currently logic for installing notifications from ACPI devices is implemented using notify callback in struct acpi_driver. Preparations are being made to replace acpi_driver with more generic struct platform_driver, which doesn't contain notify callback. Furthermore as of now handlers are being called indirectly through acpi_notify_device(), which decreases performance. Call acpi_device_install_event_handler() at the end of .add() callback. Call acpi_device_remove_event_handler() at the beginning of .remove() callback. Change arguments passed to the notify callback to match with what's required by acpi_device_install_event_handler(). Signed-off-by: Michal Wilczynski --- drivers/acpi/acpi_video.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c index 62f4364e4460..f1623fcc3973 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,6 +2055,11 @@ static int acpi_video_bus_add(struct acpi_device *device) acpi_video_bus_add_notify_handler(video); + error = acpi_device_install_event_handler(device, ACPI_DEVICE_NOTIFY, + acpi_video_bus_notify); + if (error) + goto err_put_video; + return 0; err_put_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 Thu Jun 1 13:17:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13263744 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 4B14EC77B7E for ; Thu, 1 Jun 2023 13:41:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233470AbjFANl4 (ORCPT ); Thu, 1 Jun 2023 09:41:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232699AbjFANlz (ORCPT ); Thu, 1 Jun 2023 09:41:55 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7344C138; Thu, 1 Jun 2023 06:41:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685626914; x=1717162914; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=J2m0TGOiRoBd/ax/IBNGAB4gn5LdAqZnUKRaqrOD26M=; b=fImHP365NyyfPVIZKULo3F4MPqxf1F+SMfphRvmXwBer0nkUReOgs+zj tR5yndRG72N3N4UBOrdg9mjnlki4urWbvv6qqQ7TT90d3GwcSDRG3pXkF 7jHCT0aOszYT1U1Ua1AN/Bmnsmz24kX6I0FT2yQYh+Y5fkkt+Xnc1uZ9d +ecJ9l+157qYbX04SULUc/gk2VK3WYv2b9VrqBYggjtV+L1WKGNDwvdVn RJ+CJHjpToGG0wuSo4Q42gGI/9ceiRHflOWMUQ8eeX3TgwmnZUg3/7ONH MPhAKB4bK/c2j3VveqYTnjfQzFqVqLzLwyddU8EAU4UlUJAUnqGDpIDWk w==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="419066480" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="419066480" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:18:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="881601301" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="881601301" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:18:18 -0700 From: Michal Wilczynski To: "Rafael J. Wysocki" , Len Brown Cc: Michal Wilczynski , linux-acpi@vger.kernel.org, platform-driver-x86@vger.kernel.org Subject: [PATCH v4 04/35] acpi/battery: Move handler installing logic to driver Date: Thu, 1 Jun 2023 15:17:07 +0200 Message-Id: <20230601131739.300760-5-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230601131739.300760-3-michal.wilczynski@intel.com> References: <20230601131739.300760-3-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Currently logic for installing notifications from ACPI devices is implemented using notify callback in struct acpi_driver. Preparations are being made to replace acpi_driver with more generic struct platform_driver, which doesn't contain notify callback. Furthermore as of now handlers are being called indirectly through acpi_notify_device(), which decreases performance. Call acpi_device_install_event_handler() at the end of .add() callback. Call acpi_device_remove_event_handler() at the beginning of .remove() callback. Change arguments passed to the notify callback to match with what's required by acpi_device_install_event_handler(). Signed-off-by: Michal Wilczynski --- drivers/acpi/battery.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 9c67ed02d797..37449c33771b 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,7 +1215,11 @@ static int acpi_battery_add(struct acpi_device *device) device_init_wakeup(&device->dev, 1); - return result; + result = acpi_device_install_event_handler(device, ACPI_ALL_NOTIFY, acpi_battery_notify); + if (result) + goto fail; + + return 0; fail: sysfs_remove_battery(battery); @@ -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 Thu Jun 1 13:17:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13263745 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 464D7C7EE2A for ; Thu, 1 Jun 2023 13:42:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233394AbjFANmI (ORCPT ); Thu, 1 Jun 2023 09:42:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232699AbjFANmH (ORCPT ); Thu, 1 Jun 2023 09:42:07 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5968C138; Thu, 1 Jun 2023 06:42:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685626926; x=1717162926; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HeoLSGt6pPNEEutOyliAyAZ1IupbH/0zizPbH0EBwxQ=; b=C8Pyg5pqgAOeaLCy+fDZrF+4vMWA0PX/YADCj1cilO8mikRKHjrKUIpw tuxkY6llR3XsZo6lqbFyCzI0CCQUPkJ+4gEIzaM/m4L5P7SioJtQ+M/4L 6z0tC2osomuP6ef7K+Sq9SOD5nsfuZgKuwkTUlYedLKxEFoF/etZbD3Yp 55c7Us9z5JGOj7qiBU2pq2a06sWoxejN4kZ5k65LkanKoVxUYSTcgx8cU uUfVTSWO9NvjJJL7uukSGJTV70psEVkl1MFoSjqZTBofhuSps1XUJtuOC h/iWAqsqjDMsxjcMPcJ4drsk2Nb8FKDS8ys5IazFvPuZ/zHomeR0vqz9I g==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="419066592" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="419066592" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:18:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="881601431" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="881601431" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:18:23 -0700 From: Michal Wilczynski To: "Rafael J. Wysocki" , Len Brown Cc: Michal Wilczynski , linux-acpi@vger.kernel.org, platform-driver-x86@vger.kernel.org Subject: [PATCH v4 05/35] acpi/button: Move handler installing logic to driver Date: Thu, 1 Jun 2023 15:17:08 +0200 Message-Id: <20230601131739.300760-6-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230601131739.300760-3-michal.wilczynski@intel.com> References: <20230601131739.300760-3-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Currently logic for installing notifications from ACPI devices is implemented using notify callback in struct acpi_driver. Preparations are being made to replace acpi_driver with more generic struct platform_driver, which doesn't contain notify callback. Furthermore as of now handlers are being called indirectly through acpi_notify_device(), which decreases performance. Call acpi_device_install_event_handler() at the end of .add() callback. Call acpi_device_remove_event_handler() at the beginning of .remove() callback. Change arguments passed to the notify callback to match with what's required by acpi_device_install_event_handler(). Signed-off-by: Michal Wilczynski --- drivers/acpi/button.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c index ef77c14c72a9..96ed1877a61a 100644 --- a/drivers/acpi/button.c +++ b/drivers/acpi/button.c @@ -135,7 +135,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); @@ -153,7 +153,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, }; @@ -409,11 +408,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; @@ -578,6 +580,11 @@ 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)); + + error = acpi_device_install_event_handler(device, ACPI_DEVICE_NOTIFY, acpi_button_notify); + if (error) + goto err_remove_fs; + return 0; err_remove_fs: @@ -593,6 +600,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 Thu Jun 1 13:17:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13263746 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 B4481C7EE2E for ; Thu, 1 Jun 2023 13:42:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233764AbjFANmO (ORCPT ); Thu, 1 Jun 2023 09:42:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232699AbjFANmN (ORCPT ); Thu, 1 Jun 2023 09:42:13 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56613107; Thu, 1 Jun 2023 06:42: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=1685626932; x=1717162932; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RMXzdiOBSbBrEGO848QqqOUg26vmic3LwcjuYH6g9HU=; b=LsMfDeQnaqjdP0eSOwKIp9036L3ZdvqjUsxRZaEd7an9bOxEvUonhzMA fiKy8uGhd8mQZ9MBFsS9REivyGWQm1R4w9NYR77hmx8De2RUt9NqfYRoD W2o5AUM28igrNLdp/Nvio0Ns2T5HYwHfaL89ms+GLGFK3rHjlQ/Y9Ec1e c6eURdNTVcCaswKzK3lULEFCItSnscxTcvSMoHmIGL1ty3d9G929qdClJ ASiJIe+b91FKzYhOQsb8xU1BF2ISflTblFx2rKucC7JcdRsz9l1iFgjIm FJ860SY7suBpybn40wvo1HcesfjnJQLFO8NbIGkTd6yq6fMcErSQ6BB5g Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="419066655" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="419066655" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:18:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="881601461" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="881601461" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:18:28 -0700 From: Michal Wilczynski To: "Rafael J. Wysocki" , Len Brown Cc: Michal Wilczynski , linux-acpi@vger.kernel.org, platform-driver-x86@vger.kernel.org Subject: [PATCH v4 06/35] acpi/hed: Move handler installing logic to driver Date: Thu, 1 Jun 2023 15:17:09 +0200 Message-Id: <20230601131739.300760-7-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230601131739.300760-3-michal.wilczynski@intel.com> References: <20230601131739.300760-3-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Currently logic for installing notifications from ACPI devices is implemented using notify callback in struct acpi_driver. Preparations are being made to replace acpi_driver with more generic struct platform_driver, which doesn't contain notify callback. Furthermore as of now handlers are being called indirectly through acpi_notify_device(), which decreases performance. Call acpi_device_install_event_handler() at the end of .add() callback. Call acpi_device_remove_event_handler() at the beginning of .remove() callback. Change arguments passed to the notify callback to match with what's required by acpi_device_install_event_handler(). Signed-off-by: Michal Wilczynski --- drivers/acpi/hed.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/acpi/hed.c b/drivers/acpi/hed.c index 78d44e3fe129..5217b7082b29 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,13 @@ 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 +70,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 Thu Jun 1 13:17:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13263747 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 3BE4CC7EE2A for ; Thu, 1 Jun 2023 13:42:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233839AbjFANmj (ORCPT ); Thu, 1 Jun 2023 09:42:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233179AbjFANmi (ORCPT ); Thu, 1 Jun 2023 09:42:38 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FA4618C; Thu, 1 Jun 2023 06:42: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=1685626956; x=1717162956; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hM51g4LvmO5TXW4gm++QbkwmPKMxxaZZYt1NUl8p1KA=; b=Uh8nz0CcpaKrcQgcaoso66xxJNGZ29Qw/2XCBrFTZPAsTUkf3ujI21fg wtxLnuF7i6kteyEgVOe69o7I43hl4surDRqWlZ164HkmRZePCqxmuMjdG bZPA2qaX+dwBg27qsDT7hdT452jha3F1OZaGLZr/Dt+p/vzqJjfdalwJ8 wSzBJu5dGhTz4CwzgChcjjmgD2qPLsBd50MPTvI819RoVLwUJRxUywLTA cz/top/aPrNopZQB4mCp7e0asruBsTvLFWK6XTxPyn48T9iPbKV8+XOpB 0ni7Ap/IgA4kLLI8vLcqlddhtwZOXb2KqIuu9p/qd5S/rbPPyt3/rnE3O g==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="419066880" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="419066880" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:18:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="881601530" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="881601530" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:18:38 -0700 From: Michal Wilczynski To: Dan Williams , Vishal Verma , Dave Jiang , Ira Weiny , "Rafael J. Wysocki" , Len Brown Cc: Michal Wilczynski , nvdimm@lists.linux.dev, linux-acpi@vger.kernel.org, platform-driver-x86@vger.kernel.org Subject: [PATCH v4 07/35] acpi/nfit: Move handler installing logic to driver Date: Thu, 1 Jun 2023 15:17:10 +0200 Message-Id: <20230601131739.300760-8-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230601131739.300760-3-michal.wilczynski@intel.com> References: <20230601131739.300760-3-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Currently logic for installing notifications from ACPI devices is implemented using notify callback in struct acpi_driver. Preparations are being made to replace acpi_driver with more generic struct platform_driver, which doesn't contain notify callback. Furthermore as of now handlers are being called indirectly through acpi_notify_device(), which decreases performance. Call acpi_device_install_event_handler() at the end of .add() callback. Call acpi_device_remove_event_handler() at the beginning of .remove() callback. Change arguments passed to the notify callback to match with what's required by acpi_device_install_event_handler(). Signed-off-by: Michal Wilczynski --- drivers/acpi/nfit/core.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c index 07204d482968..633c34513071 100644 --- a/drivers/acpi/nfit/core.c +++ b/drivers/acpi/nfit/core.c @@ -3312,6 +3312,15 @@ void acpi_nfit_shutdown(void *data) } EXPORT_SYMBOL_GPL(acpi_nfit_shutdown); +static void acpi_nfit_notify(acpi_handle handle, u32 event, void *data) +{ + struct acpi_device *device = data; + + device_lock(&device->dev); + __acpi_nfit_notify(&device->dev, handle, event); + device_unlock(&device->dev); +} + static int acpi_nfit_add(struct acpi_device *adev) { struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER, NULL }; @@ -3368,12 +3377,18 @@ 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(adev, ACPI_DEVICE_NOTIFY, acpi_nfit_notify); } static void acpi_nfit_remove(struct acpi_device *adev) { /* see acpi_nfit_unregister */ + acpi_device_remove_event_handler(adev, ACPI_DEVICE_NOTIFY, acpi_nfit_notify); } static void acpi_nfit_update_notify(struct device *dev, acpi_handle handle) @@ -3446,13 +3461,6 @@ 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) -{ - device_lock(&adev->dev); - __acpi_nfit_notify(&adev->dev, adev->handle, event); - device_unlock(&adev->dev); -} - static const struct acpi_device_id acpi_nfit_ids[] = { { "ACPI0012", 0 }, { "", 0 }, @@ -3465,7 +3473,6 @@ static struct acpi_driver acpi_nfit_driver = { .ops = { .add = acpi_nfit_add, .remove = acpi_nfit_remove, - .notify = acpi_nfit_notify, }, }; From patchwork Thu Jun 1 13:17:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13263748 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 065CCC7EE23 for ; Thu, 1 Jun 2023 13:43:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232229AbjFANnP (ORCPT ); Thu, 1 Jun 2023 09:43:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233035AbjFANnO (ORCPT ); Thu, 1 Jun 2023 09:43:14 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15E7C13D; Thu, 1 Jun 2023 06:43:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685626991; x=1717162991; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5vVrghpGOTA3RERE3zA1auppmXDXMvbIuTyU1BKRx+U=; b=mywKz4Xx2Stoj4NJbE4x/FObERWAZ3THmVc0BkiGH+Wk0iFNL4HdsiuV zNaz6387Iz6u61cekJbIhTdR9atebajCbV/p/b6vHLTOg7AexcgWYhvje ml/kmh/bWpuDFG8SlPB1LAaTJlEbpICVOb3/7NzAZhSdVPnVvbxg2IUeX ZO+9aVvXJRr69n5VoDOdSBJ+1OVEoo/dIjZ/P/QM3g4RrcY9mfhMamijj 8+5/tr+2EiqEMzsUTUVBvBYYfGg1AF1zp/lE8LipA48wP0yhW0TCK8odw rJ5lu53ISuACgIddL97KOA3D8i45J7ee5RFhQlgTlBWfHLAf8D4kTJ3Qv Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="419066973" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="419066973" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:18:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="881601564" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="881601564" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:18:43 -0700 From: Michal Wilczynski To: "Rafael J. Wysocki" , Zhang Rui , Len Brown Cc: Michal Wilczynski , linux-acpi@vger.kernel.org, platform-driver-x86@vger.kernel.org Subject: [PATCH v4 08/35] acpi/thermal: Move handler installing logic to driver Date: Thu, 1 Jun 2023 15:17:11 +0200 Message-Id: <20230601131739.300760-9-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230601131739.300760-3-michal.wilczynski@intel.com> References: <20230601131739.300760-3-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Currently logic for installing notifications from ACPI devices is implemented using notify callback in struct acpi_driver. Preparations are being made to replace acpi_driver with more generic struct platform_driver, which doesn't contain notify callback. Furthermore as of now handlers are being called indirectly through acpi_notify_device(), which decreases performance. Call acpi_device_install_event_handler() at the end of .add() callback. Call acpi_device_remove_event_handler() at the beginning of .remove() callback. Change arguments passed to the notify callback to match with what's required by acpi_device_install_event_handler(). Signed-off-by: Michal Wilczynski --- drivers/acpi/thermal.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index 4720a3649a61..66156c5998b7 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 0; 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 Thu Jun 1 13:17:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13263749 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6527FC77B7E for ; Thu, 1 Jun 2023 13:43:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233357AbjFANnZ (ORCPT ); Thu, 1 Jun 2023 09:43:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233887AbjFANnT (ORCPT ); Thu, 1 Jun 2023 09:43:19 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6227D18B; Thu, 1 Jun 2023 06:43:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685626996; x=1717162996; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fkEaRIb+aCgkppCjudGHedC6J4w9GYBp7R496rzIUY4=; b=hiPowNVq6Lwu4V5pb818dvIcM4BtbnDhGG+SJeMGLXxa0LiHAPH3mBM3 c20+lEdHUfiKtevklRAYlx3ulj9o8Cw2C8xBZ47/yP0xDH8AkWPnNLZsV m4SUBbfrbJdb5/ljE/NeJn/YeR8kLv1hjglsQSPMDPR8xEJ9QFT/7H++a /ygFVGav7Au1AN5iW7i3PtjxNCjyo0TNixpeq1JZB6fF+dgo8PFfnwvDO vzhMpSwqI7O+XB89wZPPHkWWlORAun2wJI1G73tIQNUH0kV5S3nunW2gC L9i+mLfRh4ueyECQy0/oX9evXcWsElGe207QV7qtb7pJiniC+JN48QWVO A==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="419067027" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="419067027" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:18:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="881601590" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="881601590" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:18:46 -0700 From: Michal Wilczynski To: "Rafael J. Wysocki" , Len Brown Cc: Michal Wilczynski , linux-acpi@vger.kernel.org, platform-driver-x86@vger.kernel.org Subject: [PATCH v4 09/35] acpi/tiny-power-button: Move handler installing logic to driver Date: Thu, 1 Jun 2023 15:17:12 +0200 Message-Id: <20230601131739.300760-10-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230601131739.300760-3-michal.wilczynski@intel.com> References: <20230601131739.300760-3-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Currently logic for installing notifications from ACPI devices is implemented using notify callback in struct acpi_driver. Preparations are being made to replace acpi_driver with more generic struct platform_driver, which doesn't contain notify callback. Furthermore as of now handlers are being called indirectly through acpi_notify_device(), which decreases performance. Call acpi_device_install_event_handler() at the end of .add() callback. Call acpi_device_remove_event_handler() at the beginning of .remove() callback. Change arguments passed to the notify callback to match with what's required by acpi_device_install_event_handler(). Signed-off-by: Michal Wilczynski --- drivers/acpi/tiny-power-button.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/acpi/tiny-power-button.c b/drivers/acpi/tiny-power-button.c index 598f548b21f3..9c8e8b8cc19f 100644 --- a/drivers/acpi/tiny-power-button.c +++ b/drivers/acpi/tiny-power-button.c @@ -19,18 +19,21 @@ static const struct acpi_device_id tiny_power_button_device_ids[] = { }; MODULE_DEVICE_TABLE(acpi, tiny_power_button_device_ids); -static int acpi_noop_add(struct acpi_device *device) +static void acpi_tiny_power_button_notify(acpi_handle handle, u32 event, void *data) { - return 0; + kill_cad_pid(power_signal, 1); } -static void acpi_noop_remove(struct acpi_device *device) +static int acpi_tiny_power_button_add(struct acpi_device *device) { + return acpi_device_install_event_handler(device, ACPI_DEVICE_NOTIFY, + acpi_tiny_power_button_notify); } -static void acpi_tiny_power_button_notify(struct acpi_device *device, u32 event) +static void acpi_tiny_power_button_remove(struct acpi_device *device) { - kill_cad_pid(power_signal, 1); + acpi_device_remove_event_handler(device, ACPI_DEVICE_NOTIFY, + acpi_tiny_power_button_notify); } static struct acpi_driver acpi_tiny_power_button_driver = { @@ -38,9 +41,8 @@ static struct acpi_driver acpi_tiny_power_button_driver = { .class = "tiny-power-button", .ids = tiny_power_button_device_ids, .ops = { - .add = acpi_noop_add, - .remove = acpi_noop_remove, - .notify = acpi_tiny_power_button_notify, + .add = acpi_tiny_power_button_add, + .remove = acpi_tiny_power_button_remove, }, }; From patchwork Thu Jun 1 13:17:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13263751 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 85D0FC7EE23 for ; Thu, 1 Jun 2023 13:43:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233678AbjFANno (ORCPT ); Thu, 1 Jun 2023 09:43:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233215AbjFANnj (ORCPT ); Thu, 1 Jun 2023 09:43:39 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D91F3139; Thu, 1 Jun 2023 06:43: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=1685627018; x=1717163018; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Jrn9jLUoNqgpgWSIlur6vSPLt4iltvZpRWGlDjKGO+w=; b=QJjTzim7JAl8VDpCUT6TyeZ4XB/xa0iyA8y1vBdqBeWtroIqCSWaic2z SZI4YdRFjAggYwIjmcoKsO6gaaBLcxXJ5hJqY87G2UY78k7TFE8ND/1dd LbqWfVwjNyELdg0gIflId1vL3kkC8HPEhma0DLo39kvSO8yRz/0TbWI/e kT5Ur6ZudmGg/HTA7g7+HvrG+6sd34g7Qvz0cc+f7Asf/p0lDJZjMFBQ3 uXZGcdYFH13LoRqGRiQ4pW4lTAIwyLCjtq6PzP+KEbVFoD8a2rTIvrvR3 2PD7l6UE7NbaeQgOYX0yS0qH8hdinT8BQF8OtjHnaU6Ar1Em+wXnnUKgV w==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="419067202" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="419067202" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:18:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="881601623" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="881601623" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:18:55 -0700 From: Michal Wilczynski To: Jean Delvare , Guenter Roeck Cc: Michal Wilczynski , linux-hwmon@vger.kernel.org, linux-acpi@vger.kernel.org, platform-driver-x86@vger.kernel.org, rafael@kernel.org Subject: [PATCH v4 10/35] hwmon/acpi_power_meter: Move handler installing logic to driver Date: Thu, 1 Jun 2023 15:17:13 +0200 Message-Id: <20230601131739.300760-11-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230601131739.300760-3-michal.wilczynski@intel.com> References: <20230601131739.300760-3-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Currently logic for installing notifications from ACPI devices is implemented using notify callback in struct acpi_driver. Preparations are being made to replace acpi_driver with more generic struct platform_driver, which doesn't contain notify callback. Furthermore as of now handlers are being called indirectly through acpi_notify_device(), which decreases performance. Call acpi_device_install_event_handler() at the end of .add() callback. Call acpi_device_remove_event_handler() at the beginning of .remove() callback. Change arguments passed to the notify callback to match with what's required by acpi_device_install_event_handler(). Signed-off-by: Michal Wilczynski Acked-by: Guenter Roeck --- drivers/hwmon/acpi_power_meter.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c index fa28d447f0df..7410ee8693ba 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 0; exit_remove: remove_attrs(resource); @@ -906,7 +911,7 @@ static int acpi_power_meter_add(struct acpi_device *device) free_capabilities(resource); exit_free: kfree(resource); -exit: + return res; } @@ -917,6 +922,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 +959,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 Thu Jun 1 13:17:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13263752 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 A37B3C7EE23 for ; Thu, 1 Jun 2023 13:43:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232640AbjFANnz (ORCPT ); Thu, 1 Jun 2023 09:43:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232984AbjFANny (ORCPT ); Thu, 1 Jun 2023 09:43:54 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07A3213E; Thu, 1 Jun 2023 06:43:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685627032; x=1717163032; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=eKaXqW+DRkqJGpmPjw5NP4F6Cx+mNw9LMr+YNIGyaoY=; b=mTTWcES/YP+EWHyKV+6oHmHn5Giy704tLYZRI1laQs7FFhi4uW1LZman FIeKt4xl/9eOUt+Q4x55vJOpRgZ3sQtsnybvJfNPqhx3lxq+/QOAdElg4 GjgNcwW9gCjB4LBFU/ChZs28xICNPQ0HkdWOhxREYML7dRZl+W5OwBemD dA+mp0WoT+M46hY2HVpejAz/8ArbYyJn//ZsenCHEtyKWr4MwkmsXuYOm c36VKnYyQMhmQ+BrY/e3E9KciVcMg/Y9oos8mYqENcm3MhSZfLBxaqaQR 78BmgoAxz64TY7/zZnoB40IQYNzVJU3/fLwztbD6ZjbM+2ui6bLyBIk10 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="419067333" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="419067333" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:19:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="881601655" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="881601655" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:19:01 -0700 From: Michal Wilczynski To: Jonathan Cameron , Lars-Peter Clausen Cc: Michal Wilczynski , linux-iio@vger.kernel.org, linux-acpi@vger.kernel.org, platform-driver-x86@vger.kernel.org, rafael@kernel.org Subject: [PATCH v4 11/35] iio/acpi-als: Move handler installing logic to driver Date: Thu, 1 Jun 2023 15:17:14 +0200 Message-Id: <20230601131739.300760-12-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230601131739.300760-3-michal.wilczynski@intel.com> References: <20230601131739.300760-3-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Currently logic for installing notifications from ACPI devices is implemented using notify callback in struct acpi_driver. Preparations are being made to replace acpi_driver with more generic struct platform_driver, which doesn't contain notify callback. Furthermore as of now handlers are being called indirectly through acpi_notify_device(), which decreases performance. Call acpi_device_install_event_handler() at the end of .add() callback. Call acpi_device_remove_event_handler() at the beginning of .remove() callback. Change arguments passed to the notify callback to match with what's required by acpi_device_install_event_handler(). Signed-off-by: Michal Wilczynski --- drivers/iio/light/acpi-als.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/drivers/iio/light/acpi-als.c b/drivers/iio/light/acpi-als.c index 2d91caf24dd0..5e200c6d91bc 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,7 +229,16 @@ static int acpi_als_add(struct acpi_device *device) if (ret) return ret; - return devm_iio_device_register(dev, indio_dev); + ret = devm_iio_device_register(dev, indio_dev); + if (ret) + return ret; + + return acpi_device_install_event_handler(device, ACPI_DEVICE_NOTIFY, acpi_als_notify); +} + +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[] = { @@ -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 Thu Jun 1 13:17:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13263753 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 BC00BC7EE2A for ; Thu, 1 Jun 2023 13:44:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233867AbjFANoJ (ORCPT ); Thu, 1 Jun 2023 09:44:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232984AbjFANoI (ORCPT ); Thu, 1 Jun 2023 09:44:08 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2008D13D; Thu, 1 Jun 2023 06:44: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=1685627047; x=1717163047; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kqgNW8OvryYyrV4L3xPcxq88n689A4LPp2Kr4WOs0mw=; b=FzLAAXFe6w8TCT/0niALQpj4bSC6Vy/6M5tH1UozmXOxGEaXYAZNL+iJ DtARd5tnOG97bzgfPAgTn9YGzuY1pX51NWB2hnaOhpRTX2MEiEybzhh1i iCJLh9EDS+VdwltVkQ6ToTFS4VmdG6CWos/fm0PAbfQTpozGMSOC3kinm 5ejDpIGD/6YoIWmLi7KACG2bNwMrVTNeL+BMdZDb/JehMp2C2KoDihzL9 +ZqVgdqdNI5zNRldqDBoDzanekyYZ84JBEoTuaaPlvuJa9vTq4jz6sKAb +G6cLxqw4LLQdhDILw23xoT0lAEW7Im+xf1GVgl+x+3WFIH8/cX2KSUl1 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="419067469" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="419067469" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:19:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="881601692" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="881601692" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:19:08 -0700 From: Michal Wilczynski To: Benson Leung Cc: Michal Wilczynski , chrome-platform@lists.linux.dev, linux-acpi@vger.kernel.org, platform-driver-x86@vger.kernel.org, rafael@kernel.org Subject: [PATCH v4 12/35] platform/chromeos_tbmc: Move handler installing logic to driver Date: Thu, 1 Jun 2023 15:17:15 +0200 Message-Id: <20230601131739.300760-13-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230601131739.300760-3-michal.wilczynski@intel.com> References: <20230601131739.300760-3-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Currently logic for installing notifications from ACPI devices is implemented using notify callback in struct acpi_driver. Preparations are being made to replace acpi_driver with more generic struct platform_driver, which doesn't contain notify callback. Furthermore as of now handlers are being called indirectly through acpi_notify_device(), which decreases performance. Call acpi_device_install_event_handler() at the end of .add() callback. Call acpi_device_remove_event_handler() at the beginning of .remove() callback. Change arguments passed to the notify callback to match with what's required by acpi_device_install_event_handler(). Signed-off-by: Michal Wilczynski --- drivers/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..ac0f43fc530a 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(adev, ACPI_DEVICE_NOTIFY, chromeos_tbmc_notify); +} + +static void chromeos_tbmc_remove(struct acpi_device *adev) +{ + acpi_device_remove_event_handler(adev, 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 Thu Jun 1 13:17:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13263754 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 9EDAAC7EE2A for ; Thu, 1 Jun 2023 13:44:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232984AbjFANoQ (ORCPT ); Thu, 1 Jun 2023 09:44:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229899AbjFANoQ (ORCPT ); Thu, 1 Jun 2023 09:44:16 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3825A107; Thu, 1 Jun 2023 06:44: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=1685627055; x=1717163055; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/zOt8Ip/74RNexXI8wybJ/13PRTBt2DlRVAtzxRcwFc=; b=TCoLlNyZPH740IEZ+hGFmnnN53Z3CJ7IoPNp/9zkfqtUcIY3e2QAETUs aZ3YV/9hyINPAMhxe5RtAvbQossA8WaZhFJ0v1vxGpgTLu5tR8Q4QKRti fJChG4NS7H1deVpCu8DpOjP7FyypgriJFvbVPhCA0rT/teJTpNYS0AwmN fuWpwbffmBuOIheDZ0E3VFk5nr9sCjc1ZFjeiECMh3BlmGIwPJnj2FwOU SWCphN3HvirLqB8AOJHhHKlKPxaqkztpEB22t1LPemN2vKo6r4f69B6yd uhIWAaLKe71eTstuxuX/6KplSBKv4NzEOImXXeXTEu0xMm8nY5o8oYMfI w==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="419067545" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="419067545" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:19:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="881601714" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="881601714" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:19:12 -0700 From: Michal Wilczynski To: Benson Leung Cc: Michal Wilczynski , chrome-platform@lists.linux.dev, linux-acpi@vger.kernel.org, platform-driver-x86@vger.kernel.org, rafael@kernel.org Subject: [PATCH v4 13/35] platform/wilco_ec: Move handler installing logic to driver Date: Thu, 1 Jun 2023 15:17:16 +0200 Message-Id: <20230601131739.300760-14-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230601131739.300760-3-michal.wilczynski@intel.com> References: <20230601131739.300760-3-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Currently logic for installing notifications from ACPI devices is implemented using notify callback in struct acpi_driver. Preparations are being made to replace acpi_driver with more generic struct platform_driver, which doesn't contain notify callback. Furthermore as of now handlers are being called indirectly through acpi_notify_device(), which decreases performance. Call acpi_device_install_event_handler() at the end of .add() callback. Call acpi_device_remove_event_handler() at the beginning of .remove() callback. Change arguments passed to the notify callback to match with what's required by acpi_device_install_event_handler(). Signed-off-by: Michal Wilczynski --- drivers/platform/chrome/wilco_ec/event.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/platform/chrome/wilco_ec/event.c b/drivers/platform/chrome/wilco_ec/event.c index a40f60bcefb6..23fd6de623f4 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_device *adev = data; union acpi_object *obj; acpi_status status; @@ -490,6 +484,11 @@ static int event_device_add(struct acpi_device *adev) if (error) goto free_dev_data; + error = acpi_device_install_event_handler(adev, ACPI_DEVICE_NOTIFY, + event_device_notify); + if (error) + goto free_dev_data; + return 0; free_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(adev, 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 Thu Jun 1 13:17:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13263755 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 ACB64C77B7E for ; Thu, 1 Jun 2023 13:44:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233353AbjFANoW (ORCPT ); Thu, 1 Jun 2023 09:44:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229899AbjFANoV (ORCPT ); Thu, 1 Jun 2023 09:44:21 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C83013E; Thu, 1 Jun 2023 06:44: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=1685627060; x=1717163060; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AUrLdSuup874aht3aizw4YqD6Igyfos0v1Ki2V0RotQ=; b=ivyDkiUxKTLVwSC7sn3linnHQKyZrMhr9/qiNFxNzRaOz4DFQT8NI/2u P+pGgxnNpc+AnnHpvNP0hVL7sIGnhwOKxrUvzwaq4NU/XRJ6wPva/kqu2 TYpHMbOtV6paO23FAVt/5u+oLOc6VCwMpGC4pMewKIMx50A9DcGB9I1my XtH85KnwiE9RUbkfhjHxK/HlCFwrnP4wcMlJbbrhaTbK5GtMZsogpXquI RVaQ7s7fBRNAtVFdYnP4cK8NdhP8kNTihx140i+x//UdZbKIZgInqudqy 1YXhLOk2v59gPxiHFf1fR5ut50HBX3atp0+qODBx0qZKhLv0GQ6GBCHSr Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="419067612" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="419067612" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:19:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="881601741" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="881601741" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:19:15 -0700 From: Michal Wilczynski To: Chen Yu , Hans de Goede , Mark Gross , Maximilian Luz Cc: Michal Wilczynski , platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org, rafael@kernel.org Subject: [PATCH v4 14/35] platform/surface/button: Move handler installing logic to driver Date: Thu, 1 Jun 2023 15:17:17 +0200 Message-Id: <20230601131739.300760-15-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230601131739.300760-3-michal.wilczynski@intel.com> References: <20230601131739.300760-3-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Currently logic for installing notifications from ACPI devices is implemented using notify callback in struct acpi_driver. Preparations are being made to replace acpi_driver with more generic struct platform_driver, which doesn't contain notify callback. Furthermore as of now handlers are being called indirectly through acpi_notify_device(), which decreases performance. Call acpi_device_install_event_handler() at the end of .add() callback. Call acpi_device_remove_event_handler() at the beginning of .remove() callback. Change arguments passed to the notify callback to match with what's required by acpi_device_install_event_handler(). Signed-off-by: Michal Wilczynski --- drivers/platform/surface/surfacepro3_button.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/platform/surface/surfacepro3_button.c b/drivers/platform/surface/surfacepro3_button.c index 2755601f979c..fa5f1e4c4abc 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,6 +233,12 @@ 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)); + + error = acpi_device_install_event_handler(device, ACPI_DEVICE_NOTIFY, + surface_button_notify); + if (error) + goto err_free_input; + return 0; err_free_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 Thu Jun 1 13:17:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13263756 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 975D0C7EE2A for ; Thu, 1 Jun 2023 13:44:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233287AbjFANof (ORCPT ); Thu, 1 Jun 2023 09:44:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229899AbjFANoe (ORCPT ); Thu, 1 Jun 2023 09:44:34 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08EB4139; Thu, 1 Jun 2023 06:44:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685627074; x=1717163074; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Ou2d7WNU5iGtvXSJSbVni3WkhDwCgDRi6B+45IXWcX4=; b=BB977zxOP3D7L6t+mqXOOZIx6I4MOkTwGG65M8yaL84E7wOUjtSfiBo2 nCEtpbV9GCSF0LePZeUZyS5vj2O6OKB3JZj2B+Ylmnf4flol1BSymd/WE eEj3iKCZvE/9+6C7mf53fiROHgcR7d7/PwSm+xthbzRkYmkNwJ4LpJoI3 VwWXIBfQ6lEYPHmq6amdckbGDp7L5qbgrOThaVFTOoSBcScNOWl0569mi aLRe7HiavbaivgwCAGmD03yCm/6Q0pR4TwrcIEFMH0FCG2ZTFH0P9QDLX TPVXR+T8WXWNdfNKWHd+6DOpEEg1iGGBHfc50GZBaT9WkMjk48up0ubbG Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="419067737" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="419067737" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:19:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="881601793" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="881601793" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:19:21 -0700 From: Michal Wilczynski To: Hans de Goede , Mark Gross Cc: Michal Wilczynski , platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org, rafael@kernel.org Subject: [PATCH v4 15/35] platform/x86/acer-wireless: Move handler installing logic to driver Date: Thu, 1 Jun 2023 15:17:18 +0200 Message-Id: <20230601131739.300760-16-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230601131739.300760-3-michal.wilczynski@intel.com> References: <20230601131739.300760-3-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Currently logic for installing notifications from ACPI devices is implemented using notify callback in struct acpi_driver. Preparations are being made to replace acpi_driver with more generic struct platform_driver, which doesn't contain notify callback. Furthermore as of now handlers are being called indirectly through acpi_notify_device(), which decreases performance. Call acpi_device_install_event_handler() at the end of .add() callback. Call acpi_device_remove_event_handler() at the beginning of .remove() callback. Change arguments passed to the notify callback to match with what's required by acpi_device_install_event_handler(). Signed-off-by: Michal Wilczynski --- drivers/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..af7aef27cdff 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(adev, ACPI_DEVICE_NOTIFY, acer_wireless_notify); +} + +static void acer_wireless_remove(struct acpi_device *adev) +{ + acpi_device_remove_event_handler(adev, 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 Thu Jun 1 13:17:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13263792 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 A48ADC7EE2A for ; Thu, 1 Jun 2023 13:44:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233421AbjFANoo (ORCPT ); Thu, 1 Jun 2023 09:44:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229899AbjFANon (ORCPT ); Thu, 1 Jun 2023 09:44:43 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6802107; Thu, 1 Jun 2023 06:44:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685627082; x=1717163082; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VjmFYoUk3ppWyxuHsT01mpbXu3uCoDZy5oj2DUuL4FI=; b=Rwm52EWNB6OZkjog/K3r13bXmzb+XSpT7t4yhMQJwLsliVvAPG29zNUt P+H7VQD6NF5zS/1sdG0rpZsoBf1cyxlOaVaTECvPzB1Zbrp2kU7+uJb8w 9nCZx+PDvG06D6aVx39CT9KN6L6CtDPgmzrBezrmLJMxpZbMba0e9pVOr dXAbwdlLgQIt1omzDKIAOsz2U+jtlxAx8quys9tm1t4f7O1Z0fl41riwZ 5LwJ2uxmvh94f9MYwxUGHNWfcr6aqylMrBpO1A1H+hn0W3FAUNKDQJCdr i2zUYr4WDMnBgu5Nbdlbx8MyKXOB7cuu1sjtzG/Ult+kx6PgfC/TWrGWv Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="419067813" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="419067813" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:19:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="881601822" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="881601822" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:19:24 -0700 From: Michal Wilczynski To: Corentin Chary , Hans de Goede , Mark Gross Cc: Michal Wilczynski , acpi4asus-user@lists.sourceforge.net, platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org, rafael@kernel.org Subject: [PATCH v4 16/35] platform/x86/asus-laptop: Move handler installing logic to driver Date: Thu, 1 Jun 2023 15:17:19 +0200 Message-Id: <20230601131739.300760-17-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230601131739.300760-3-michal.wilczynski@intel.com> References: <20230601131739.300760-3-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Currently logic for installing notifications from ACPI devices is implemented using notify callback in struct acpi_driver. Preparations are being made to replace acpi_driver with more generic struct platform_driver, which doesn't contain notify callback. Furthermore as of now handlers are being called indirectly through acpi_notify_device(), which decreases performance. Call acpi_device_install_event_handler() at the end of .add() callback. Call acpi_device_remove_event_handler() at the beginning of .remove() callback. Change arguments passed to the notify callback to match with what's required by acpi_device_install_event_handler(). Signed-off-by: Michal Wilczynski --- drivers/platform/x86/asus-laptop.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c index 761029f39314..6d2f5767bf70 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,6 +1883,10 @@ 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; @@ -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 Thu Jun 1 13:17:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13263793 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 3BDC6C7EE23 for ; Thu, 1 Jun 2023 13:45:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232834AbjFANpA (ORCPT ); Thu, 1 Jun 2023 09:45:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234110AbjFANo5 (ORCPT ); Thu, 1 Jun 2023 09:44:57 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76A3B107; Thu, 1 Jun 2023 06:44: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=1685627095; x=1717163095; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JrB7/4kncfIBImWpl4e3Fx27E14xF2xq5M7od+acmrA=; b=lqT2R7cND7IrYvGV+4wPpkRESYDmlJ1IupDwq4TQrbAtnTmk1cvFg7hN rm/O1zRxb0W1jgjWkCOI6XFEkiaAYjwcUgAp6O+4X0lc3d36L7gimCJFo VEVxFwXBJWj5+i9PigQ26Dhc80sC6QlUdFtNmiAwMTX5g7YbVlYrq8a/X P6GNfMhNolIEW8EhQG5ngdJQEr6sSWoulkB9YgkJHtOvVi7DFrKCUtvJT jpPQ2g6ykWoB06PEG+OZvpLIx4pXsL2iRRU9q+DTCg5UQeafgzvJH8z7w +mOvWS4dCkBAtONRNzxbrDFyE4L0RPNcNry47qZY0wHX60D6n+QOwoSQn A==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="419067942" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="419067942" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:19:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="881601848" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="881601848" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:19:30 -0700 From: Michal Wilczynski To: Corentin Chary , =?utf-8?q?Jo=C3=A3o_Paulo_Rec?= =?utf-8?q?hi_Vita?= , Hans de Goede , Mark Gross Cc: Michal Wilczynski , platform-driver-x86@vger.kernel.org, acpi4asus-user@lists.sourceforge.net, linux-acpi@vger.kernel.org, rafael@kernel.org Subject: [PATCH v4 17/35] platform/x86/asus-wireless: Move handler installing logic to driver Date: Thu, 1 Jun 2023 15:17:20 +0200 Message-Id: <20230601131739.300760-18-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230601131739.300760-3-michal.wilczynski@intel.com> References: <20230601131739.300760-3-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Currently logic for installing notifications from ACPI devices is implemented using notify callback in struct acpi_driver. Preparations are being made to replace acpi_driver with more generic struct platform_driver, which doesn't contain notify callback. Furthermore as of now handlers are being called indirectly through acpi_notify_device(), which decreases performance. Call acpi_device_install_event_handler() at the end of .add() callback. Call acpi_device_remove_event_handler() at the beginning of .remove() callback. Change arguments passed to the notify callback to match with what's required by acpi_device_install_event_handler(). Signed-off-by: Michal Wilczynski --- drivers/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 Thu Jun 1 13:17:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13263794 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 243FAC7EE2E for ; Thu, 1 Jun 2023 13:45:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233226AbjFANpJ (ORCPT ); Thu, 1 Jun 2023 09:45:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233300AbjFANpH (ORCPT ); Thu, 1 Jun 2023 09:45:07 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8364019F; Thu, 1 Jun 2023 06:45:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685627103; x=1717163103; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WoghFPLJJmwA8gTZVBZZPRlBetblz1Bh8YAjwgqBN48=; b=HlSomfq3qIzluzrQ7/jaNDMkTnxVWTMzTIGSr+jiIXHqcNXgB3Ar02TA a5FR8J8odidjr4phy3auSRYYh/1BF3fDnRF/gNhasV0yQBw/ZZYKnweCV TJbJUJODxEDr2/pXq+b0IJvFSDsKS5BuXm9dlxpW81mQdXMjsm4v7FDZD 4rOmA7dvMtSSxqCi6ck/RkCk6/xYikende8CFMgVJ8VZb+HTZWCZ+zWst t+i6VVIJAl+hJ4JhFPxQQreJWVBKlBtHC3x1+Dy8yZ54RJVkJBE/8SsNO 1LDQBcRiGh1VIo1aDYrpttfkzWph2kNKNWuPdm9vdGgcSI69m68D2JRIK Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="419068022" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="419068022" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:19:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="881601868" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="881601868" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:19:34 -0700 From: Michal Wilczynski To: Thadeu Lima de Souza Cascardo , Daniel Oliveira Nascimento , Hans de Goede , Mark Gross Cc: Michal Wilczynski , platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org, rafael@kernel.org Subject: [PATCH v4 18/35] platform/x86/classmate-laptop: Move handler installing logic to driver Date: Thu, 1 Jun 2023 15:17:21 +0200 Message-Id: <20230601131739.300760-19-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230601131739.300760-3-michal.wilczynski@intel.com> References: <20230601131739.300760-3-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Currently logic for installing notifications from ACPI devices is implemented using notify callback in struct acpi_driver. Preparations are being made to replace acpi_driver with more generic struct platform_driver, which doesn't contain notify callback. Furthermore as of now handlers are being called indirectly through acpi_notify_device(), which decreases performance. Call acpi_device_install_event_handler() at the end of .add() callback. Call acpi_device_remove_event_handler() at the beginning of .remove() callback. Change arguments passed to the notify callback to match with what's required by acpi_device_install_event_handler(). Signed-off-by: Michal Wilczynski --- drivers/platform/x86/classmate-laptop.c | 53 +++++++++++++++++++------ 1 file changed, 41 insertions(+), 12 deletions(-) diff --git a/drivers/platform/x86/classmate-laptop.c b/drivers/platform/x86/classmate-laptop.c index 2edaea2492df..2d36abf5ecfe 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,6 +408,11 @@ static int cmpc_accel_add_v4(struct acpi_device *acpi) inputdev = dev_get_drvdata(&acpi->dev); dev_set_drvdata(&inputdev->dev, accel); + error = acpi_device_install_event_handler(acpi, ACPI_DEVICE_NOTIFY, + cmpc_accel_handler_v4); + if (error) + goto failed_input; + return 0; failed_input: @@ -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(acpi, 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); @@ -441,7 +448,6 @@ static struct acpi_driver cmpc_accel_acpi_driver_v4 = { .ops = { .add = cmpc_accel_add_v4, .remove = cmpc_accel_remove_v4, - .notify = cmpc_accel_handler_v4, }, .drv.pm = &cmpc_accel_pm, }; @@ -523,8 +529,10 @@ static acpi_status cmpc_get_accel(acpi_handle handle, return status; } -static void cmpc_accel_handler(struct acpi_device *dev, u32 event) +static void cmpc_accel_handler(acpi_handle handle, u32 event, void *data) { + struct acpi_device *dev = data; + if (event == 0x81) { unsigned char x, y, z; acpi_status status; @@ -639,6 +647,11 @@ static int cmpc_accel_add(struct acpi_device *acpi) inputdev = dev_get_drvdata(&acpi->dev); dev_set_drvdata(&inputdev->dev, accel); + error = acpi_device_install_event_handler(acpi, ACPI_DEVICE_NOTIFY, + cmpc_accel_handler); + if (error) + goto failed_input; + return 0; failed_input: @@ -650,6 +663,7 @@ static int cmpc_accel_add(struct acpi_device *acpi) static void cmpc_accel_remove(struct acpi_device *acpi) { + acpi_device_remove_event_handler(acpi, ACPI_DEVICE_NOTIFY, cmpc_accel_handler); device_remove_file(&acpi->dev, &cmpc_accel_sensitivity_attr); cmpc_remove_acpi_notify_device(acpi); } @@ -667,7 +681,6 @@ static struct acpi_driver cmpc_accel_acpi_driver = { .ops = { .add = cmpc_accel_add, .remove = cmpc_accel_remove, - .notify = cmpc_accel_handler, } }; @@ -693,8 +706,9 @@ static acpi_status cmpc_get_tablet(acpi_handle handle, return status; } -static void cmpc_tablet_handler(struct acpi_device *dev, u32 event) +static void cmpc_tablet_handler(acpi_handle handle, u32 event, void *data) { + struct acpi_device *dev = data; unsigned long long val = 0; struct input_dev *inputdev = dev_get_drvdata(&dev->dev); @@ -723,12 +737,20 @@ static void cmpc_tablet_idev_init(struct input_dev *inputdev) static int cmpc_tablet_add(struct acpi_device *acpi) { - return cmpc_add_acpi_notify_device(acpi, "cmpc_tablet", - cmpc_tablet_idev_init); + int ret; + + ret = cmpc_add_acpi_notify_device(acpi, "cmpc_tablet", + cmpc_tablet_idev_init); + if (ret) + return ret; + + return acpi_device_install_event_handler(acpi, ACPI_DEVICE_NOTIFY, + cmpc_tablet_handler); } static void cmpc_tablet_remove(struct acpi_device *acpi) { + acpi_device_remove_event_handler(acpi, ACPI_DEVICE_NOTIFY, cmpc_tablet_handler); cmpc_remove_acpi_notify_device(acpi); } @@ -761,7 +783,6 @@ static struct acpi_driver cmpc_tablet_acpi_driver = { .ops = { .add = cmpc_tablet_add, .remove = cmpc_tablet_remove, - .notify = cmpc_tablet_handler, }, .drv.pm = &cmpc_tablet_pm, }; @@ -1026,8 +1047,9 @@ static int cmpc_keys_codes[] = { KEY_MAX }; -static void cmpc_keys_handler(struct acpi_device *dev, u32 event) +static void cmpc_keys_handler(acpi_handle handle, u32 event, void *data) { + struct acpi_device *dev = data; struct input_dev *inputdev; int code = KEY_MAX; @@ -1049,12 +1071,20 @@ static void cmpc_keys_idev_init(struct input_dev *inputdev) static int cmpc_keys_add(struct acpi_device *acpi) { - return cmpc_add_acpi_notify_device(acpi, "cmpc_keys", - cmpc_keys_idev_init); + int error; + + error = cmpc_add_acpi_notify_device(acpi, "cmpc_keys", + cmpc_keys_idev_init); + if (error) + return error; + + return acpi_device_install_event_handler(acpi, ACPI_DEVICE_NOTIFY, + cmpc_keys_handler); } static void cmpc_keys_remove(struct acpi_device *acpi) { + acpi_device_remove_event_handler(acpi, ACPI_DEVICE_NOTIFY, cmpc_keys_handler); cmpc_remove_acpi_notify_device(acpi); } @@ -1071,7 +1101,6 @@ static struct acpi_driver cmpc_keys_acpi_driver = { .ops = { .add = cmpc_keys_add, .remove = cmpc_keys_remove, - .notify = cmpc_keys_handler, } }; From patchwork Thu Jun 1 13:17:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13263795 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 E91C7C7EE2A for ; Thu, 1 Jun 2023 13:45:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233240AbjFANpS (ORCPT ); Thu, 1 Jun 2023 09:45:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234037AbjFANpQ (ORCPT ); Thu, 1 Jun 2023 09:45:16 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 423761A2; Thu, 1 Jun 2023 06:45: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=1685627110; x=1717163110; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NQLWnXWZae271CRjFuvZfxarWxX1dDRBywhMvrqXcx0=; b=Oojb5xdGjGhUKGW0c9jaS+z8+BExXEKRYGdhHdkovlCXpVbUl8yy1AQf CeHg0CUJX3YtJtoc95NvugZjlKFvWlaLefr39DC3PbZiqSXPFo8FmgDMj F6DN1z7YumaUb1hsaQsQ04YreOub/Jd4RY+oOQ42oIAGjW03koyX8D5pG Ys/4QVG7sz+7cPmGzM/Dbsz137pB0CEm0osZJEbFbbejLJoZkiG7p1egL wh7UouT31EX5n8WNz8QtYISzcLHG7T7NA0oKG38OkVyaT0Ygxmf6btA+T dPyZlhF+iOUEH5ZLYRPXpHfODSvNvXl7Rr/mOZN7GGWlVKzisVbxBwIVw w==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="419068093" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="419068093" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:19:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="881601895" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="881601895" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:19:37 -0700 From: Michal Wilczynski To: =?utf-8?q?Pali_Roh=C3=A1r?= , Hans de Goede , Mark Gross Cc: Michal Wilczynski , platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org, rafael@kernel.org Subject: [PATCH v4 19/35] platform/x86/dell/dell-rbtn: Move handler installing logic to driver Date: Thu, 1 Jun 2023 15:17:22 +0200 Message-Id: <20230601131739.300760-20-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230601131739.300760-3-michal.wilczynski@intel.com> References: <20230601131739.300760-3-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Currently logic for installing notifications from ACPI devices is implemented using notify callback in struct acpi_driver. Preparations are being made to replace acpi_driver with more generic struct platform_driver, which doesn't contain notify callback. Furthermore as of now handlers are being called indirectly through acpi_notify_device(), which decreases performance. Call acpi_device_install_event_handler() at the end of .add() callback. Call acpi_device_remove_event_handler() at the beginning of .remove() callback. Change arguments passed to the notify callback to match with what's required by acpi_device_install_event_handler(). Signed-off-by: Michal Wilczynski --- drivers/platform/x86/dell/dell-rbtn.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/platform/x86/dell/dell-rbtn.c b/drivers/platform/x86/dell/dell-rbtn.c index aa0e6c907494..4dcad59eb035 100644 --- a/drivers/platform/x86/dell/dell-rbtn.c +++ b/drivers/platform/x86/dell/dell-rbtn.c @@ -207,7 +207,7 @@ static void rbtn_input_event(struct rbtn_data *rbtn_data) static int rbtn_add(struct acpi_device *device); static void rbtn_remove(struct acpi_device *device); -static void rbtn_notify(struct acpi_device *device, u32 event); +static void rbtn_notify(acpi_handle handle, u32 event, void *data); static const struct acpi_device_id rbtn_ids[] = { { "DELRBTN", 0 }, @@ -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 Thu Jun 1 13:17:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13263796 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 54E7DC7EE2A for ; Thu, 1 Jun 2023 13:45:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232357AbjFANpZ (ORCPT ); Thu, 1 Jun 2023 09:45:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233419AbjFANpU (ORCPT ); Thu, 1 Jun 2023 09:45:20 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A482138; Thu, 1 Jun 2023 06:45: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=1685627117; x=1717163117; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ENJP73HXPeBgJ2fQ82QE/f5IGuVXsru7nSaUGYazssM=; b=CG5K4sOrIYbzdPuy8kapCEK2tJSiuFsaOG/ov7EtRiWcR5ZJ19pd6Y/H H+W9PFHiS39UStaOjdWrBiEWX8ljSbsoOHjNScplCpBaoBFkRzo7W44aW NqlyV/X9ZFlo3xwcygMKz0qpDupAdtAbsO2kqOt0DxrF6Kju+rTw9AcNL xi1n8z55qXymdbuIlxdsA2TG4zuNf3nkNNtT8Qzm0CRVf7sDyYwvDLSM1 CEkyYMIdBya6RFkBFQ200ZOh4MODuZVimDG37+YRSANs3F0n6g8TRUThY ukg37yDDXWr0CX2ZdcdmgvTIKRzO8Pvts13QaueTNdv3aoOPGYHMmBbXK Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="419068165" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="419068165" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:19:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="881601912" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="881601912" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:19:40 -0700 From: Michal Wilczynski To: Corentin Chary , Hans de Goede , Mark Gross Cc: Michal Wilczynski , acpi4asus-user@lists.sourceforge.net, platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org, rafael@kernel.org Subject: [PATCH v4 20/35] platform/x86/eeepc-laptop: Move handler installing logic to driver Date: Thu, 1 Jun 2023 15:17:23 +0200 Message-Id: <20230601131739.300760-21-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230601131739.300760-3-michal.wilczynski@intel.com> References: <20230601131739.300760-3-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Currently logic for installing notifications from ACPI devices is implemented using notify callback in struct acpi_driver. Preparations are being made to replace acpi_driver with more generic struct platform_driver, which doesn't contain notify callback. Furthermore as of now handlers are being called indirectly through acpi_notify_device(), which decreases performance. Call acpi_device_install_event_handler() at the end of .add() callback. Call acpi_device_remove_event_handler() at the beginning of .remove() callback. Change arguments passed to the notify callback to match with what's required by acpi_device_install_event_handler(). Signed-off-by: Michal Wilczynski --- drivers/platform/x86/eeepc-laptop.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c index 62b71e8e3567..bd6ada963d88 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,6 +1426,11 @@ static int eeepc_acpi_add(struct acpi_device *device) goto fail_rfkill; eeepc_device_present = true; + result = acpi_device_install_event_handler(device, ACPI_ALL_NOTIFY, + eeepc_acpi_notify); + if (result) + goto fail_rfkill; + return 0; fail_rfkill: @@ -1444,6 +1452,8 @@ static void eeepc_acpi_remove(struct acpi_device *device) { struct eeepc_laptop *eeepc = acpi_driver_data(device); + acpi_device_remove_event_handler(device, ACPI_ALL_NOTIFY, + eeepc_acpi_notify); eeepc_backlight_exit(eeepc); eeepc_rfkill_exit(eeepc); eeepc_input_exit(eeepc); @@ -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 Thu Jun 1 13:17:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13263797 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 E3890C7EE2F for ; Thu, 1 Jun 2023 13:45:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233427AbjFANp1 (ORCPT ); Thu, 1 Jun 2023 09:45:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233350AbjFANp0 (ORCPT ); Thu, 1 Jun 2023 09:45:26 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C6FF138; Thu, 1 Jun 2023 06:45: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=1685627124; x=1717163124; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HxqltkL7JKuD7ggSNuK4Mso9OsWPDE3czY/YrRlIRVE=; b=RXD35E7ezuXnOzuP1Hic1qqUPX/cHdnmAo6vDsGkH3pnH3kZKnG6e16d mhNB246MWwdH7P/dmYskPJVWM4sja2OCedW+eGBMDQvE8WSaDv7UYS4p6 gR86Wmbfdw/b7Xs6gZsdToc1WNPGp0A3/A/sfh76B1zx7xyNyu9nvKjPN +m5L0tMCPN60oPOltpdSmxEvotL4NKUZRUlHNISpgutZJh4rIxrh55FB3 II9jBJ0yw7LtOnXBZKX60QuF7aN6vQZZTTG30Hjd5PINTPEdG2wxk0ISt 42XLwXY5QAmwFw1vWnRGJh3V0TuxJRWxVexq9w/npD7VoUc6mQqiV0IzG w==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="419068235" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="419068235" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:19:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="881601931" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="881601931" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:19:44 -0700 From: Michal Wilczynski To: Jonathan Woithe , Hans de Goede , Mark Gross Cc: Michal Wilczynski , platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org, rafael@kernel.org Subject: [PATCH v4 21/35] platform/x86/fujitsu-laptop: Move handler installing logic to driver Date: Thu, 1 Jun 2023 15:17:24 +0200 Message-Id: <20230601131739.300760-22-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230601131739.300760-3-michal.wilczynski@intel.com> References: <20230601131739.300760-3-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Currently logic for installing notifications from ACPI devices is implemented using notify callback in struct acpi_driver. Preparations are being made to replace acpi_driver with more generic struct platform_driver, which doesn't contain notify callback. Furthermore as of now handlers are being called indirectly through acpi_notify_device(), which decreases performance. Call acpi_device_install_event_handler() at the end of .add() callback. Call acpi_device_remove_event_handler() at the beginning of .remove() callback. Change arguments passed to the notify callback to match with what's required by acpi_device_install_event_handler(). Signed-off-by: Michal Wilczynski --- drivers/platform/x86/fujitsu-laptop.c | 86 +++++++++++++++++---------- 1 file changed, 54 insertions(+), 32 deletions(-) diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c index 085e044e888e..001333edba9f 100644 --- a/drivers/platform/x86/fujitsu-laptop.c +++ b/drivers/platform/x86/fujitsu-laptop.c @@ -136,6 +136,8 @@ struct fujitsu_laptop { static struct acpi_device *fext; +static void acpi_fujitsu_laptop_notify(acpi_handle handle, u32 event, void *data); + /* Fujitsu ACPI interface function */ static int call_fext_func(struct acpi_device *device, @@ -382,6 +384,37 @@ static int fujitsu_backlight_register(struct acpi_device *device) return 0; } +static void acpi_fujitsu_bl_notify(acpi_handle handle, u32 event, void *data) +{ + struct acpi_device *device = data; + struct fujitsu_bl *priv; + int oldb, newb; + + priv = acpi_driver_data(device); + + if (event != ACPI_FUJITSU_NOTIFY_CODE) { + acpi_handle_info(device->handle, "unsupported event [0x%x]\n", + event); + sparse_keymap_report_event(priv->input, -1, 1, true); + return; + } + + oldb = priv->brightness_level; + get_lcd_level(device); + newb = priv->brightness_level; + + acpi_handle_debug(device->handle, + "brightness button event [%i -> %i]\n", oldb, newb); + + if (oldb == newb) + return; + + if (!disable_brightness_adjust) + set_lcd_level(device, newb); + + sparse_keymap_report_event(priv->input, oldb < newb, 1, true); +} + static int acpi_fujitsu_bl_add(struct acpi_device *device) { struct fujitsu_bl *priv; @@ -410,37 +443,17 @@ static int acpi_fujitsu_bl_add(struct acpi_device *device) if (ret) return ret; - return fujitsu_backlight_register(device); -} + ret = fujitsu_backlight_register(device); + if (ret) + return ret; -/* Brightness notify */ + return acpi_device_install_event_handler(device, ACPI_DEVICE_NOTIFY, + acpi_fujitsu_bl_notify); +} -static void acpi_fujitsu_bl_notify(struct acpi_device *device, u32 event) +static void acpi_fujitsu_bl_remove(struct acpi_device *device) { - struct fujitsu_bl *priv = acpi_driver_data(device); - int oldb, newb; - - if (event != ACPI_FUJITSU_NOTIFY_CODE) { - acpi_handle_info(device->handle, "unsupported event [0x%x]\n", - event); - sparse_keymap_report_event(priv->input, -1, 1, true); - return; - } - - oldb = priv->brightness_level; - get_lcd_level(device); - newb = priv->brightness_level; - - acpi_handle_debug(device->handle, - "brightness button event [%i -> %i]\n", oldb, newb); - - if (oldb == newb) - return; - - if (!disable_brightness_adjust) - set_lcd_level(device, newb); - - sparse_keymap_report_event(priv->input, oldb < newb, 1, true); + acpi_device_remove_event_handler(device, ACPI_DEVICE_NOTIFY, acpi_fujitsu_bl_notify); } /* ACPI device for hotkey handling */ @@ -839,6 +852,11 @@ static int acpi_fujitsu_laptop_add(struct acpi_device *device) if (ret) goto err_free_fifo; + ret = acpi_device_install_event_handler(device, ACPI_DEVICE_NOTIFY, + acpi_fujitsu_laptop_notify); + if (ret) + goto err_free_fifo; + return 0; err_free_fifo: @@ -851,6 +869,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 +909,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); @@ -947,7 +970,7 @@ static struct acpi_driver acpi_fujitsu_bl_driver = { .ids = fujitsu_bl_device_ids, .ops = { .add = acpi_fujitsu_bl_add, - .notify = acpi_fujitsu_bl_notify, + .remove = acpi_fujitsu_bl_remove, }, }; @@ -963,7 +986,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 Thu Jun 1 13:17:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13263798 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 D5720C77B7E for ; Thu, 1 Jun 2023 13:45:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229589AbjFANpg (ORCPT ); Thu, 1 Jun 2023 09:45:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233236AbjFANpf (ORCPT ); Thu, 1 Jun 2023 09:45:35 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A859139; Thu, 1 Jun 2023 06:45: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=1685627134; x=1717163134; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SZOg5MeriDI2PyRVKq7mP5oQrEzUGwUAhmDMpbWonIQ=; b=jq1n9VW/NOJfeX8PD5yPoveBoPEYjMDdu90DQl5/k6JrLR1a++PQm0tb WnRH+pFpIvHbY+lWilHzThD9oA+FdD13AN22iS8eHISU3hYzDu6P05zRe QyG/jpWtZ1FbN5PnAuRPKBqBZ1NdTCbqKKmVextqg1P8qyXy/XSRe+tyb PrfLe59Md81uqKPvCeZwv/fRD/IH2VEfZqZ9rQ59m3YBUbDekf0frVod0 GxSZLpVHwgiY962sRYCfib5rHeDxadAom71Mc+Tyb+51uP0x+EiIu3NSg rSGKjSdXKDTlclb5rhxuGM8xZXHdPtctHZ72pyuo2cYnFtTaefOFMnTyJ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="419068325" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="419068325" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:19:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="881601956" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="881601956" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:19:48 -0700 From: Michal Wilczynski To: Matan Ziv-Av , Hans de Goede , Mark Gross Cc: Michal Wilczynski , platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org, rafael@kernel.org Subject: [PATCH v4 22/35] platform/x86/lg-laptop: Move handler installing logic to driver Date: Thu, 1 Jun 2023 15:17:25 +0200 Message-Id: <20230601131739.300760-23-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230601131739.300760-3-michal.wilczynski@intel.com> References: <20230601131739.300760-3-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Currently logic for installing notifications from ACPI devices is implemented using notify callback in struct acpi_driver. Preparations are being made to replace acpi_driver with more generic struct platform_driver, which doesn't contain notify callback. Furthermore as of now handlers are being called indirectly through acpi_notify_device(), which decreases performance. Call acpi_device_install_event_handler() at the end of .add() callback. Call acpi_device_remove_event_handler() at the beginning of .remove() callback. Change arguments passed to the notify callback to match with what's required by acpi_device_install_event_handler(). Signed-off-by: Michal Wilczynski --- drivers/platform/x86/lg-laptop.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/lg-laptop.c b/drivers/platform/x86/lg-laptop.c index ad3c39e9e9f5..7469354c84d6 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,6 +753,10 @@ static int acpi_add(struct acpi_device *device) wmi_input_setup(); battery_hook_register(&battery_hook); + ret = acpi_device_install_event_handler(device, ACPI_DEVICE_NOTIFY, acpi_notify); + if (ret) + goto out_platform_device; + return 0; out_platform_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 Thu Jun 1 13:17:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13263799 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 2B4E6C77B7E for ; Thu, 1 Jun 2023 13:45:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232942AbjFANpu (ORCPT ); Thu, 1 Jun 2023 09:45:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233276AbjFANpn (ORCPT ); Thu, 1 Jun 2023 09:45:43 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 692A6180; Thu, 1 Jun 2023 06:45:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685627142; x=1717163142; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QBH5fW45n6DZLxzTgXmIAEJSQORppkpy6BU/i1JxNM4=; b=e/bLKkGMpWYkzJICjK2MGqt3lfzTdqLiYyLuFx8NMsnRY06fD3lLNi+m 0eZ8kEOX7rFb7qSR7iwaZkTo02QU+tOgyfHP9Zm122SsVMVnLwAkIkwc2 dehWdW4VserVYFq8x3FUXFBmAa/Z6JF8lYrj8Erec7zhh0Li1BUTh+xtW uCGrHUnf8Fk8toYF8X/BrHZt5p0kyAMJvtTr0ojuCk7Mbj2h7QpfkuWbF 9LbAdysDBDxf5L2Ch56Rv7nXo5S5rJp+xJmIWMkLlntDn37hwl/iTh+zF LDVIzEJTVAKSNd3lk/fi6nViW4X7PcTtHm7BMfcP7Fdyo0WZ0UHx+yNWg w==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="419068402" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="419068402" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:19:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="881601989" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="881601989" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:19:52 -0700 From: Michal Wilczynski To: Kenneth Chan , Hans de Goede , Mark Gross Cc: Michal Wilczynski , platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org, rafael@kernel.org Subject: [PATCH v4 23/35] platform/x86/panasonic-laptop: Move handler installing logic to driver Date: Thu, 1 Jun 2023 15:17:26 +0200 Message-Id: <20230601131739.300760-24-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230601131739.300760-3-michal.wilczynski@intel.com> References: <20230601131739.300760-3-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Currently logic for installing notifications from ACPI devices is implemented using notify callback in struct acpi_driver. Preparations are being made to replace acpi_driver with more generic struct platform_driver, which doesn't contain notify callback. Furthermore as of now handlers are being called indirectly through acpi_notify_device(), which decreases performance. Call acpi_device_install_event_handler() at the end of .add() callback. Call acpi_device_remove_event_handler() at the beginning of .remove() callback. Change arguments passed to the notify callback to match with what's required by acpi_device_install_event_handler(). Signed-off-by: Michal Wilczynski --- drivers/platform/x86/panasonic-laptop.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/platform/x86/panasonic-laptop.c b/drivers/platform/x86/panasonic-laptop.c index cf845ee1c7b1..723a898738d0 100644 --- a/drivers/platform/x86/panasonic-laptop.c +++ b/drivers/platform/x86/panasonic-laptop.c @@ -184,7 +184,7 @@ enum SINF_BITS { SINF_NUM_BATTERIES = 0, static int acpi_pcc_hotkey_add(struct acpi_device *device); static void acpi_pcc_hotkey_remove(struct acpi_device *device); -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); static const struct acpi_device_id pcc_device_ids[] = { { "MAT0012", 0}, @@ -207,7 +207,6 @@ static struct acpi_driver acpi_pcc_driver = { .ops = { .add = acpi_pcc_hotkey_add, .remove = acpi_pcc_hotkey_remove, - .notify = acpi_pcc_hotkey_notify, }, .drv.pm = &acpi_pcc_hotkey_pm, }; @@ -833,9 +832,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,6 +1051,12 @@ static int acpi_pcc_hotkey_add(struct acpi_device *device) } i8042_install_filter(panasonic_i8042_filter); + + result = acpi_device_install_event_handler(device, ACPI_DEVICE_NOTIFY, + acpi_pcc_hotkey_notify); + if (result) + goto out_platform; + return 0; out_platform: @@ -1072,6 +1080,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 Thu Jun 1 13:17:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13263800 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 63B6CC7EE2A for ; Thu, 1 Jun 2023 13:45:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233065AbjFANpx (ORCPT ); Thu, 1 Jun 2023 09:45:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230222AbjFANpv (ORCPT ); Thu, 1 Jun 2023 09:45:51 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2724A139; Thu, 1 Jun 2023 06:45:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685627150; x=1717163150; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=eJQx9O0afpNtxcu6WUqjCRA7U7VMijE7JVpJGwdDK0g=; b=UC13wwg5RQqTLou5w/CwqtkHJ42BDN1+lAogg1VAHw7scwH+M0wAs50Z X2zZq5fvvyQVfY+g0MHGxFdQ/xiAQZteUmHtcMxKJWz0uIWf4VheoLCMG 3wqT1Eg6ugj1WuQf1ooKsU30Or/2LllkXAYDugA+tlcUxkOF7GKe4yFKy 1CNFuGcRV4S9094ecz4jfK1+plSmzVzNN1n/MKpYpvGJ1u+6TuBy0EuGn t9Q5F49nHCZceDrmvtLfceCMIQKru7Y+nlOqPTNOeVMKXgD6QJBm/eABG ovAinFfkFaI0PgTX4rUnm03GMdb4tG+Vz8IuAM4wqhfWG02J/rZjPQMJ7 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="419068473" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="419068473" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:19:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="881602016" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="881602016" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:19:55 -0700 From: Michal Wilczynski To: Jeremy Soller , System76 Product Development , Hans de Goede , Mark Gross Cc: Michal Wilczynski , platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org, rafael@kernel.org Subject: [PATCH v4 24/35] platform/x86/system76_acpi: Move handler installing logic to driver Date: Thu, 1 Jun 2023 15:17:27 +0200 Message-Id: <20230601131739.300760-25-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230601131739.300760-3-michal.wilczynski@intel.com> References: <20230601131739.300760-3-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Currently logic for installing notifications from ACPI devices is implemented using notify callback in struct acpi_driver. Preparations are being made to replace acpi_driver with more generic struct platform_driver, which doesn't contain notify callback. Furthermore as of now handlers are being called indirectly through acpi_notify_device(), which decreases performance. Call acpi_device_install_event_handler() at the end of .add() callback. Call acpi_device_remove_event_handler() at the beginning of .remove() callback. Change arguments passed to the notify callback to match with what's required by acpi_device_install_event_handler(). Signed-off-by: Michal Wilczynski --- drivers/platform/x86/system76_acpi.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/platform/x86/system76_acpi.c b/drivers/platform/x86/system76_acpi.c index 97f5a8255b91..b08411b60993 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,6 +734,10 @@ static int system76_add(struct acpi_device *acpi_dev) system76_battery_init(); } + err = acpi_device_install_event_handler(acpi_dev, ACPI_DEVICE_NOTIFY, system76_notify); + if (err) + goto error; + return 0; error: @@ -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 Thu Jun 1 13:17:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13263801 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 41877C7EE2A for ; Thu, 1 Jun 2023 13:45:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232130AbjFANp6 (ORCPT ); Thu, 1 Jun 2023 09:45:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230222AbjFANp5 (ORCPT ); Thu, 1 Jun 2023 09:45:57 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF46C180; Thu, 1 Jun 2023 06:45: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=1685627155; x=1717163155; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4yduEeyJ1346QTcv/zmmPzhTWreP5vGV8AJ/QG13/tg=; b=H+QCz2PcEjDxzDiFMUrW9E3GmRksUYVmh+cZ1DRi6S8Lk0j0sfGgazUd qV9ETC3+8Q8CHzXDSv6xwvkSYLnP4uX3BrIAIzmBy3ql8fS/haiU/KmOh dC+t5F3tg8bgBOVudrctJqx5FD+NiGx+jHlZ4IX5g8ayRoStLg6buo4g3 taxiEzTiIBNP3AoBVWtvo44jGic75gfTVFfQFbNG5Ix9eoqGcwyEZ4Mvs fx41nCw6XV3/7J6SzSepJqtXbcIDPcOJYaWh8SB4pq3Rf7Z4iqAxwCiAv sDbWbMk6Ezmz1d9S5SKBeeN4sp31ZDAkSRpwoAgc38U04aEuXafRuaDud Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="419068536" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="419068536" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:20:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="881602042" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="881602042" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:19:59 -0700 From: Michal Wilczynski To: Herton Ronaldo Krzesinski , Hans de Goede , Mark Gross Cc: Michal Wilczynski , platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org, rafael@kernel.org Subject: [PATCH v4 25/35] platform/x86/topstar-laptop: Move handler installing logic to driver Date: Thu, 1 Jun 2023 15:17:28 +0200 Message-Id: <20230601131739.300760-26-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230601131739.300760-3-michal.wilczynski@intel.com> References: <20230601131739.300760-3-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Currently logic for installing notifications from ACPI devices is implemented using notify callback in struct acpi_driver. Preparations are being made to replace acpi_driver with more generic struct platform_driver, which doesn't contain notify callback. Furthermore as of now handlers are being called indirectly through acpi_notify_device(), which decreases performance. Call acpi_device_install_event_handler() at the end of .add() callback. Call acpi_device_remove_event_handler() at the beginning of .remove() callback. Change arguments passed to the notify callback to match with what's required by acpi_device_install_event_handler(). Signed-off-by: Michal Wilczynski --- drivers/platform/x86/topstar-laptop.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/platform/x86/topstar-laptop.c b/drivers/platform/x86/topstar-laptop.c index 20df1ebefc30..cfe2a92ef1f5 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,6 +322,10 @@ static int topstar_acpi_add(struct acpi_device *device) goto err_input_exit; } + err = acpi_device_install_event_handler(device, ACPI_DEVICE_NOTIFY, topstar_acpi_notify); + if (err) + goto err_input_exit; + return 0; err_input_exit: @@ -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(device, 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 Thu Jun 1 13:17:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13263802 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 A213CC7EE2A for ; Thu, 1 Jun 2023 13:46:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232840AbjFANqE (ORCPT ); Thu, 1 Jun 2023 09:46:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230222AbjFANqD (ORCPT ); Thu, 1 Jun 2023 09:46:03 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1821E188; Thu, 1 Jun 2023 06:46: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=1685627162; x=1717163162; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=J/vi7v1x/g1QVLh8luTgsyLNUrAYQyl3fwk+h50LQV4=; b=FGzp6qN3xkPhHHjaihWbwenEaA/Mo+V/9eIEKGMkQ1e6ZPjWlX9WI/2V 4qv13IPk5Hng/s57u1M9nI57zIG51+dZ+6Jwb/YKQMd3yvZYneNu72wag xrj8hGAblQgrzZJtfskXVgCCXZzkYeX+ek4litxmqMfMkrbwDqXEp1AEV krDxQoU2OfzkJLAIM3ZWzXu23Z1nsRbZIrhTh6DO4xviD4ARKpUCLhuhi EUCzn1+vj8bFw6FhDLqubtjNikZ0BTINb0IcaNrWoJcrCkcl5q2ARK6aM Z4Gt+2AtpoALvRTN3A3OccHEQ2KfdUdV6BI8VAP8wqCfZh5fpgXkz++39 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="419068607" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="419068607" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:20:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="881602077" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="881602077" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:20:02 -0700 From: Michal Wilczynski To: Azael Avalos , Hans de Goede , Mark Gross Cc: Michal Wilczynski , platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org, rafael@kernel.org Subject: [PATCH v4 26/35] platform/x86/toshiba_acpi: Move handler installing logic to driver Date: Thu, 1 Jun 2023 15:17:29 +0200 Message-Id: <20230601131739.300760-27-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230601131739.300760-3-michal.wilczynski@intel.com> References: <20230601131739.300760-3-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Currently logic for installing notifications from ACPI devices is implemented using notify callback in struct acpi_driver. Preparations are being made to replace acpi_driver with more generic struct platform_driver, which doesn't contain notify callback. Furthermore as of now handlers are being called indirectly through acpi_notify_device(), which decreases performance. Call acpi_device_install_event_handler() at the end of .add() callback. Call acpi_device_remove_event_handler() at the beginning of .remove() callback. Change arguments passed to the notify callback to match with what's required by acpi_device_install_event_handler(). Signed-off-by: Michal Wilczynski --- drivers/platform/x86/toshiba_acpi.c | 129 +++++++++++++++------------- 1 file changed, 68 insertions(+), 61 deletions(-) diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c index b34984bbee33..28d78b018547 100644 --- a/drivers/platform/x86/toshiba_acpi.c +++ b/drivers/platform/x86/toshiba_acpi.c @@ -3186,10 +3186,74 @@ static void print_supported_features(struct toshiba_acpi_dev *dev) pr_cont("\n"); } +static void toshiba_acpi_notify(acpi_handle handle, u32 event, void *data) +{ + 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 */ + /* + * Machines with this WMI GUID aren't supported due to bugs in + * their AML. + * + * Return silently to avoid triggering a netlink event. + */ + if (wmi_has_guid(TOSHIBA_WMI_EVENT_GUID)) + return; + toshiba_acpi_process_hotkeys(dev); + break; + case 0x81: /* Dock events */ + case 0x82: + case 0x83: + pr_info("Dock event received %x\n", event); + break; + case 0x88: /* Thermal events */ + pr_info("Thermal event received\n"); + break; + case 0x8f: /* LID closed */ + case 0x90: /* LID is closed and Dock has been ejected */ + break; + case 0x8c: /* SATA power events */ + case 0x8b: + pr_info("SATA power event received %x\n", event); + break; + case 0x92: /* Keyboard backlight mode changed */ + dev->kbd_event_generated = true; + /* Update sysfs entries */ + if (sysfs_update_group(&acpi_dev->dev.kobj, + &toshiba_attr_group)) + pr_err("Unable to update sysfs entries\n"); + /* Notify LED subsystem about keyboard backlight change */ + if (dev->kbd_type == 2 && dev->kbd_mode != SCI_KBD_MODE_AUTO) + led_classdev_notify_brightness_hw_changed(&dev->kbd_led, + (dev->kbd_mode == SCI_KBD_MODE_ON) ? + LED_FULL : LED_OFF); + break; + case 0x85: /* Unknown */ + case 0x8d: /* Unknown */ + case 0x8e: /* Unknown */ + case 0x94: /* Unknown */ + case 0x95: /* Unknown */ + default: + pr_info("Unknown event received %x\n", event); + break; + } + + acpi_bus_generate_netlink_event(acpi_dev->pnp.device_class, + dev_name(&acpi_dev->dev), + event, (event == 0x80) ? + dev->last_key_event : 0); +} + 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,6 +3537,10 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev) if (dev->battery_charge_mode_supported) battery_hook_register(&battery_hook); + ret = acpi_device_install_event_handler(acpi_dev, ACPI_ALL_NOTIFY, toshiba_acpi_notify); + if (ret) + goto error; + return 0; error: @@ -3480,65 +3548,6 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev) return ret; } -static void toshiba_acpi_notify(struct acpi_device *acpi_dev, u32 event) -{ - struct toshiba_acpi_dev *dev = acpi_driver_data(acpi_dev); - - switch (event) { - case 0x80: /* Hotkeys and some system events */ - /* - * Machines with this WMI GUID aren't supported due to bugs in - * their AML. - * - * Return silently to avoid triggering a netlink event. - */ - if (wmi_has_guid(TOSHIBA_WMI_EVENT_GUID)) - return; - toshiba_acpi_process_hotkeys(dev); - break; - case 0x81: /* Dock events */ - case 0x82: - case 0x83: - pr_info("Dock event received %x\n", event); - break; - case 0x88: /* Thermal events */ - pr_info("Thermal event received\n"); - break; - case 0x8f: /* LID closed */ - case 0x90: /* LID is closed and Dock has been ejected */ - break; - case 0x8c: /* SATA power events */ - case 0x8b: - pr_info("SATA power event received %x\n", event); - break; - case 0x92: /* Keyboard backlight mode changed */ - dev->kbd_event_generated = true; - /* Update sysfs entries */ - if (sysfs_update_group(&acpi_dev->dev.kobj, - &toshiba_attr_group)) - pr_err("Unable to update sysfs entries\n"); - /* Notify LED subsystem about keyboard backlight change */ - if (dev->kbd_type == 2 && dev->kbd_mode != SCI_KBD_MODE_AUTO) - led_classdev_notify_brightness_hw_changed(&dev->kbd_led, - (dev->kbd_mode == SCI_KBD_MODE_ON) ? - LED_FULL : LED_OFF); - break; - case 0x85: /* Unknown */ - case 0x8d: /* Unknown */ - case 0x8e: /* Unknown */ - case 0x94: /* Unknown */ - case 0x95: /* Unknown */ - default: - pr_info("Unknown event received %x\n", event); - break; - } - - acpi_bus_generate_netlink_event(acpi_dev->pnp.device_class, - dev_name(&acpi_dev->dev), - event, (event == 0x80) ? - dev->last_key_event : 0); -} - #ifdef CONFIG_PM_SLEEP static int toshiba_acpi_suspend(struct device *device) { @@ -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 Thu Jun 1 13:17:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13263803 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 54A4CC77B7E for ; Thu, 1 Jun 2023 13:46:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233352AbjFANqN (ORCPT ); Thu, 1 Jun 2023 09:46:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233276AbjFANqM (ORCPT ); Thu, 1 Jun 2023 09:46:12 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEC97107; Thu, 1 Jun 2023 06:46: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=1685627171; x=1717163171; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CHhVf9ySLsix+mE5RzK7lqt0XuxhrtmQCio3pLRwejA=; b=MNUHTVFRGBWtsH7sLRbIpkvRUmvfQPAPkjeuVADdDWYIYSHg4Kaj6kg9 9WNCYzzHQpJEiioTMatLGcUADSG4BzBj0LJaC6OryykRgbETdCk1J/IXG c7imh0QTRJQVCfrIQjpH935hAqNAZfDDbEPPG8DK9mQfyzewqqLVk6inT MX+7TQ23ep51yqFGoBFUfMt86E9yURN/W/kYnU8uGaHHk4z51SYTXceFv FdCsRgDUGv1lB4gDZTZirHVYvTYUc0f5B8tDnvm+5RDAf1C5UiiwVr9De gvZZ3fRhXKAoVD1vNynRdsEZQeMqTxqEYcKXV+aGW89P2U1P4GZoifUAQ w==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="419068683" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="419068683" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:20:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="881602095" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="881602095" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:20:05 -0700 From: Michal Wilczynski To: Azael Avalos , Hans de Goede , Mark Gross Cc: Michal Wilczynski , platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org, rafael@kernel.org Subject: [PATCH v4 27/35] platform/x86/toshiba_bluetooth: Move handler installing logic to driver Date: Thu, 1 Jun 2023 15:17:30 +0200 Message-Id: <20230601131739.300760-28-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230601131739.300760-3-michal.wilczynski@intel.com> References: <20230601131739.300760-3-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Currently logic for installing notifications from ACPI devices is implemented using notify callback in struct acpi_driver. Preparations are being made to replace acpi_driver with more generic struct platform_driver, which doesn't contain notify callback. Furthermore as of now handlers are being called indirectly through acpi_notify_device(), which decreases performance. Call acpi_device_install_event_handler() at the end of .add() callback. Call acpi_device_remove_event_handler() at the beginning of .remove() callback. Change arguments passed to the notify callback to match with what's required by acpi_device_install_event_handler(). Signed-off-by: Michal Wilczynski --- drivers/platform/x86/toshiba_bluetooth.c | 30 +++++++++++++++++------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/drivers/platform/x86/toshiba_bluetooth.c b/drivers/platform/x86/toshiba_bluetooth.c index d8f81962a240..a717bd5fcc88 100644 --- a/drivers/platform/x86/toshiba_bluetooth.c +++ b/drivers/platform/x86/toshiba_bluetooth.c @@ -37,7 +37,7 @@ struct toshiba_bluetooth_dev { static int toshiba_bt_rfkill_add(struct acpi_device *device); static void toshiba_bt_rfkill_remove(struct acpi_device *device); -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); static const struct acpi_device_id bt_device_ids[] = { { "TOS6205", 0}, @@ -57,7 +57,6 @@ static struct acpi_driver toshiba_bt_rfkill_driver = { .ops = { .add = toshiba_bt_rfkill_add, .remove = toshiba_bt_rfkill_remove, - .notify = toshiba_bt_rfkill_notify, }, .owner = THIS_MODULE, .drv.pm = &toshiba_bt_pm, @@ -204,9 +203,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 +265,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 +274,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(device, ACPI_DEVICE_NOTIFY, + toshiba_bt_rfkill_notify); + if (result) + goto fail_register; + + return 0; + +fail_register: + rfkill_destroy(bt_dev->rfk); +fail_allocate: + kfree(bt_dev); return result; } @@ -283,6 +295,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(device, ACPI_DEVICE_NOTIFY, toshiba_bt_rfkill_notify); + /* clean up */ if (bt_dev->rfk) { rfkill_unregister(bt_dev->rfk); From patchwork Thu Jun 1 13:17:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13263804 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 7374BC7EE23 for ; Thu, 1 Jun 2023 13:46:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232776AbjFANqV (ORCPT ); Thu, 1 Jun 2023 09:46:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230222AbjFANqU (ORCPT ); Thu, 1 Jun 2023 09:46:20 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 646C6107; Thu, 1 Jun 2023 06:46: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=1685627178; x=1717163178; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vPErQFvNbDQV5UxbBwjTeZS4Z3UrzYSQ/WcQgm1VIHs=; b=jb6L7p70QbJrNyxjSZXEMgrKEQFuJUtCfVT9XgLvDSzyNkXWoY0e5wp1 eculHMHGSNPtuKlxS7vcvLAcmzVB3p6+0ZywWadhquKfzqGj1gHjpKRbS jibnXjGy0XPcnl3LhHH8vivtl9QRHkOp09NaZ4+jfML3XJTr+1lgoomT2 ZhJH9FrrrwI3abNxjb/8FUHdVLAt1bqzLRwn4xFVG7GzbvfnohSZZ/6Pq 46+XeTgySbPj8Tox5k45PF6BRgTZjxiUCN6JiTr6S2XazOOX0vuNMii9s tYxgUwaSBpiWd7NAx3Uv1UP+kJ/UjgBGwRpNmmTnKi26rA1yPC8KOfje0 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="419068745" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="419068745" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:20:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="881602114" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="881602114" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:20:08 -0700 From: Michal Wilczynski To: Azael Avalos , Hans de Goede , Mark Gross Cc: Michal Wilczynski , platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org, rafael@kernel.org Subject: [PATCH v4 28/35] platform/x86/toshiba_haps: Move handler installing logic to driver Date: Thu, 1 Jun 2023 15:17:31 +0200 Message-Id: <20230601131739.300760-29-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230601131739.300760-3-michal.wilczynski@intel.com> References: <20230601131739.300760-3-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Currently logic for installing notifications from ACPI devices is implemented using notify callback in struct acpi_driver. Preparations are being made to replace acpi_driver with more generic struct platform_driver, which doesn't contain notify callback. Furthermore as of now handlers are being called indirectly through acpi_notify_device(), which decreases performance. Call acpi_device_install_event_handler() at the end of .add() callback. Call acpi_device_remove_event_handler() at the beginning of .remove() callback. Change arguments passed to the notify callback to match with what's required by acpi_device_install_event_handler(). Signed-off-by: Michal Wilczynski --- drivers/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..39e4c49847a8 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(device, 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 Thu Jun 1 13:17:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13263805 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 3E2F1C77B7E for ; Thu, 1 Jun 2023 13:46:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230222AbjFANq0 (ORCPT ); Thu, 1 Jun 2023 09:46:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232258AbjFANqZ (ORCPT ); Thu, 1 Jun 2023 09:46:25 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77A1F107; Thu, 1 Jun 2023 06:46: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=1685627184; x=1717163184; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UULP+c5xPWJ1lE10ag6xk4cqPGnw0HUxyzNsldjYr/M=; b=kF3ogZy7nHXUDdJsyKb2zuRTg/LGY/KrnzTEkSuVn1RNrpLhZ5oCPg8E C0QAX9lVrSbxEhHnZqtg+BKQp5s85eOXlbaspHTwsLH4T42CMZIuviI+8 0Qv9ygt2GTalnyKnErZeeWukvi11Kve9AlMcQcjZx7FZJ2VwGlpfImyzj yuo83ZuOAchAPbrJ5T7babzgkOQ84JgOoJzjxDWttXQiyozETE6hiWpHm IYdkNWNEBLAgfUbSGO/iHrV8U0v1HcD3FiZfVufUYYaDAYYuSSucAPoTj TDnEMltQrUolQqcRtruaTs6ryD/pKusvkLDk7rcC41Cfw1rwGu6r1zT/i w==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="419068812" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="419068812" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:20:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="881602132" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="881602132" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:20:11 -0700 From: Michal Wilczynski To: Hans de Goede , Mark Gross Cc: Michal Wilczynski , platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org, rafael@kernel.org Subject: [PATCH v4 29/35] platform/x86/wireless-hotkey: Move handler installing logic to driver Date: Thu, 1 Jun 2023 15:17:32 +0200 Message-Id: <20230601131739.300760-30-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230601131739.300760-3-michal.wilczynski@intel.com> References: <20230601131739.300760-3-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Currently logic for installing notifications from ACPI devices is implemented using notify callback in struct acpi_driver. Preparations are being made to replace acpi_driver with more generic struct platform_driver, which doesn't contain notify callback. Furthermore as of now handlers are being called indirectly through acpi_notify_device(), which decreases performance. Call acpi_device_install_event_handler() at the end of .add() callback. Call acpi_device_remove_event_handler() at the beginning of .remove() callback. Change arguments passed to the notify callback to match with what's required by acpi_device_install_event_handler(). Signed-off-by: Michal Wilczynski --- drivers/platform/x86/wireless-hotkey.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/drivers/platform/x86/wireless-hotkey.c b/drivers/platform/x86/wireless-hotkey.c index 4422863f47bb..6554ef2e9c70 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 0; + +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); } @@ -115,7 +126,6 @@ static struct acpi_driver wl_driver = { .ops = { .add = wl_add, .remove = wl_remove, - .notify = wl_notify, }, }; From patchwork Thu Jun 1 13:17:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13263806 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 F20C0C7EE2A for ; Thu, 1 Jun 2023 13:46:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233276AbjFANqd (ORCPT ); Thu, 1 Jun 2023 09:46:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233252AbjFANqc (ORCPT ); Thu, 1 Jun 2023 09:46:32 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7961113D; Thu, 1 Jun 2023 06:46:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685627191; x=1717163191; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=W6T4p4GhAjFrSW5KHP0koG6NdvXPbgd8/6BK9bkG2as=; b=E/wCS1FnNm6EQ1NLYrh8oiTW8AhwkWnBdILbiGgZeJQJFmIJ4BtNDSMu od8R7OoiOYF8mWecHONKrCw3ktMBcvAXKQ/soM/zGLJvSk2rrtXWGjzaM WKpaBbRNWa75tcorFMnsUorXwK+DkQTh7KHDsVr1A9l964vQtxR/8JU53 dzHP/AruZ5qUMHl7qsP0NMGdrzPnyn05IIAZnY/Ao0y1AW7qKosVd9BEs cUTspA6zQe5z1vdJRPFr+3BQHyeTMlWhNaWKQTK+dY4xRgLYgEbSeHNjb PEpwx9ZCa+BJ0szC7RgS46nLgH8Rhf+u5g8cEro6mAPjBCi19dsjvCwD+ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="419068875" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="419068875" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:20:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="881602159" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="881602159" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:20:14 -0700 From: Michal Wilczynski To: Hans de Goede , Mark Gross Cc: Michal Wilczynski , platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org, rafael@kernel.org Subject: [PATCH v4 30/35] platform/x86/xo15-ebook: Move handler installing logic to driver Date: Thu, 1 Jun 2023 15:17:33 +0200 Message-Id: <20230601131739.300760-31-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230601131739.300760-3-michal.wilczynski@intel.com> References: <20230601131739.300760-3-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Currently logic for installing notifications from ACPI devices is implemented using notify callback in struct acpi_driver. Preparations are being made to replace acpi_driver with more generic struct platform_driver, which doesn't contain notify callback. Furthermore as of now handlers are being called indirectly through acpi_notify_device(), which decreases performance. Call acpi_device_install_event_handler() at the end of .add() callback. Call acpi_device_remove_event_handler() at the beginning of .remove() callback. Change arguments passed to the notify callback to match with what's required by acpi_device_install_event_handler(). Signed-off-by: Michal Wilczynski --- drivers/platform/x86/xo15-ebook.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/xo15-ebook.c b/drivers/platform/x86/xo15-ebook.c index 391f7ea4431e..57d143e06d65 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,6 +135,10 @@ static int ebook_switch_add(struct acpi_device *device) device_set_wakeup_enable(&device->dev, true); } + error = acpi_device_install_event_handler(device, ACPI_DEVICE_NOTIFY, ebook_switch_notify); + if (error) + goto err_free_input; + return 0; err_free_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 Thu Jun 1 13:17:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13263807 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 10305C7EE2E for ; Thu, 1 Jun 2023 13:46:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233356AbjFANqj (ORCPT ); Thu, 1 Jun 2023 09:46:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233293AbjFANqh (ORCPT ); Thu, 1 Jun 2023 09:46:37 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5441107; Thu, 1 Jun 2023 06:46: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=1685627196; x=1717163196; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JYFmYUw76nAn3KyHhuquIXLpkkEfqoEDyhR2NxJSr40=; b=DO6Ess4hhYM7O7qjUZdAyeinG8FW+YpVw/ZKOKehMxy6dpBPlo/8Velx jXv7T1qTqD6bJMdnGuzyKuwyHz+hkUDNrxCfG6zFPNt8RJHXN/Wps+9xO 6OUXFqEj2cGfVjtGVxvfX3JCI7o9XpIUkNr7BlKEzcjNKqhydGtKBRifh N+AQceO1IMzZNS1Gxj99Ea8Z7A8+dxey7bbV0IfsDaCh9WDueMIq+u92e fEabD/BloMvk6CkcCveMq38qqaoMkDg+4isFsLbxBwp1osT2ZqVKEoWpo MJTO0rFjM2u724nG3wAOWZjdCa8u+4C34XPCrv8mHQI5Zmt/HjdgyJIR/ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="419068932" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="419068932" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:20:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="881602180" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="881602180" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:20:17 -0700 From: Michal Wilczynski To: Mattia Dongili , Hans de Goede , Mark Gross Cc: Michal Wilczynski , platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org, rafael@kernel.org Subject: [PATCH v4 31/35] platform/x86/sony-laptop: Move handler installing logic to driver Date: Thu, 1 Jun 2023 15:17:34 +0200 Message-Id: <20230601131739.300760-32-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230601131739.300760-3-michal.wilczynski@intel.com> References: <20230601131739.300760-3-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Currently logic for installing notifications from ACPI devices is implemented using notify callback in struct acpi_driver. Preparations are being made to replace acpi_driver with more generic struct platform_driver, which doesn't contain notify callback. Furthermore as of now handlers are being called indirectly through acpi_notify_device(), which decreases performance. Call acpi_device_install_event_handler() at the end of .add() callback. Call acpi_device_remove_event_handler() at the beginning of .remove() callback. Change arguments passed to the notify callback to match with what's required by acpi_device_install_event_handler(). Signed-off-by: Michal Wilczynski --- drivers/platform/x86/sony-laptop.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c index 9569f11dec8c..93e630d937a8 100644 --- a/drivers/platform/x86/sony-laptop.c +++ b/drivers/platform/x86/sony-laptop.c @@ -1178,7 +1178,7 @@ enum event_types { KILLSWITCH, GFX_SWITCH }; -static void sony_nc_notify(struct acpi_device *device, u32 event) +static void sony_nc_notify(acpi_handle handle, u32 event, void *data) { u32 real_ev = event; u8 ev_type = 0; @@ -3246,6 +3246,11 @@ static int sony_nc_add(struct acpi_device *device) } } + result = acpi_device_install_event_handler(device, ACPI_DEVICE_NOTIFY, + sony_nc_notify); + if (result) + goto out_sysfs; + pr_info("SNC setup done.\n"); return 0; @@ -3272,6 +3277,7 @@ static void sony_nc_remove(struct acpi_device *device) { struct sony_nc_value *item; + acpi_device_remove_event_handler(device, ACPI_DEVICE_NOTIFY, sony_nc_notify); sony_nc_backlight_cleanup(); sony_nc_acpi_device = NULL; @@ -3307,7 +3313,6 @@ static struct acpi_driver sony_nc_driver = { .ops = { .add = sony_nc_add, .remove = sony_nc_remove, - .notify = sony_nc_notify, }, .drv.pm = &sony_nc_pm, }; From patchwork Thu Jun 1 13:17:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13263808 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 33017C7EE23 for ; Thu, 1 Jun 2023 13:46:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233180AbjFANqq (ORCPT ); Thu, 1 Jun 2023 09:46:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233293AbjFANqo (ORCPT ); Thu, 1 Jun 2023 09:46:44 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD16918C; Thu, 1 Jun 2023 06:46:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685627203; x=1717163203; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+ts6C5JUZkQiwH7gJ6stxKKdR9KfqEVngICJLmKLlXY=; b=VTuEQ3yoH2vlz3KFgNYvrlpcm43lOqqFXUp4spn+BMcZPfw6bSKHF/T+ ZxcYZaQ70I9aoiznkBUIuxGWmEGwDxil4vh2dQ+F3Pj8SMm4VNG1mOSSG ocoqn8HCKUdpmVLAZB68hGf24Nvl/2Exnyt2vWKQ585maUOAUrIuGMgvh /vcV6M3cNXOOGg54noHoRKaDjAQ8/QscXKUDPeuaWj/4HiJZygtAAtbci R+FccF0uPWdHW/iRpP5g95aan7MwJ0FamK1ti9v2qe2aAUu1gpwMClDJA IriAwS/dwPUa3x36tFi/hCv+uUygj/a4HHv/fyWa7ZwX6rzI4WVZfte70 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="419068988" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="419068988" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:20:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="881602201" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="881602201" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:20:20 -0700 From: Michal Wilczynski To: "Theodore Ts'o" , "Jason A. Donenfeld" Cc: Michal Wilczynski , linux-acpi@vger.kernel.org, platform-driver-x86@vger.kernel.org, rafael@kernel.org Subject: [PATCH v4 32/35] virt/vmgenid: Move handler installing logic to driver Date: Thu, 1 Jun 2023 15:17:35 +0200 Message-Id: <20230601131739.300760-33-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230601131739.300760-3-michal.wilczynski@intel.com> References: <20230601131739.300760-3-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Currently logic for installing notifications from ACPI devices is implemented using notify callback in struct acpi_driver. Preparations are being made to replace acpi_driver with more generic struct platform_driver, which doesn't contain notify callback. Furthermore as of now handlers are being called indirectly through acpi_notify_device(), which decreases performance. Call acpi_device_install_event_handler() at the end of .add() callback. Call acpi_device_remove_event_handler() at the beginning of .remove() callback. Change arguments passed to the notify callback to match with what's required by acpi_device_install_event_handler(). Signed-off-by: Michal Wilczynski --- drivers/virt/vmgenid.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/drivers/virt/vmgenid.c b/drivers/virt/vmgenid.c index a1c467a0e9f7..50e7f4a82f99 100644 --- a/drivers/virt/vmgenid.c +++ b/drivers/virt/vmgenid.c @@ -21,6 +21,21 @@ struct vmgenid_state { u8 this_id[VMGENID_SIZE]; }; +static void vmgenid_notify(acpi_handle handle, u32 event, void *data) +{ + 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))) + return; + add_vmfork_randomness(state->this_id, sizeof(state->this_id)); +} + static int vmgenid_add(struct acpi_device *device) { struct acpi_buffer parsed = { ACPI_ALLOCATE_BUFFER }; @@ -60,21 +75,16 @@ 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) { - struct vmgenid_state *state = acpi_driver_data(device); - u8 old_id[VMGENID_SIZE]; - - 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))) - return; - add_vmfork_randomness(state->this_id, sizeof(state->this_id)); + acpi_device_remove_event_handler(device, ACPI_DEVICE_NOTIFY, vmgenid_notify); } static const struct acpi_device_id vmgenid_ids[] = { @@ -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 Thu Jun 1 13:21:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13263716 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 0B929C7EE2C for ; Thu, 1 Jun 2023 13:21:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233300AbjFANVS (ORCPT ); Thu, 1 Jun 2023 09:21:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229866AbjFANVQ (ORCPT ); Thu, 1 Jun 2023 09:21:16 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AA4497; Thu, 1 Jun 2023 06:21:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685625676; x=1717161676; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=WwIcbTmw5qfuyP7ZCrrzP68VAul4AG0APywRqVEBBYg=; b=Ailu3SZbl3p6iqkH0ht8PcNHg+TglhGd2ty+f1L+L6qvkNBgvmjzpgKa +jzSW/AvNZBNOsCij8pdwlRXEUScT3n553/SLZwCVBq+O/OJzRkcXrzco Y7dY52syeYdvVFTuE2hzJCYQUOsUtd2HxycQe8sTgM1bNFdvyHARGaumO gZDorGAc1gaHMI55mvxky8yQKgzNbTK4EE/dIueFrZr5k1hAoupusDHkg KjtEo2YqXsAzJbFSIW1bqciXPQqmvahp0sz/fvop1pQHFG+JZLNNjMgvj si1DV+R6evNd1yOef1ZP9suUzkh44lwqfXPODBO2oqVju/hVsV0jFooBT g==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="383826277" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="383826277" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:21:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="701539286" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="701539286" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:21:06 -0700 From: Michal Wilczynski To: rafael@kernel.org, lenb@kernel.org, dan.j.williams@intel.com, vishal.l.verma@intel.com, dave.jiang@intel.com, ira.weiny@intel.com, rui.zhang@intel.com, jdelvare@suse.com, linux@roeck-us.net, jic23@kernel.org, lars@metafoo.de, bleung@chromium.org, yu.c.chen@intel.com, hdegoede@redhat.com, markgross@kernel.org, luzmaximilian@gmail.com, corentin.chary@gmail.com, jprvita@gmail.com, cascardo@holoscopio.com, don@syst.com.br, pali@kernel.org, jwoithe@just42.net, matan@svgalib.org, kenneth.t.chan@gmail.com, malattia@linux.it, jeremy@system76.com, productdev@system76.com, herton@canonical.com, coproscefalo@gmail.com, tytso@mit.edu, Jason@zx2c4.com, robert.moore@intel.com Cc: linux-acpi@vger.kernel.org, nvdimm@lists.linux.dev, linux-hwmon@vger.kernel.org, linux-iio@vger.kernel.org, chrome-platform@lists.linux.dev, platform-driver-x86@vger.kernel.org, acpi4asus-user@lists.sourceforge.net, Michal Wilczynski Subject: [PATCH v4 33/35] acpi/bus: Remove installing/removing notify handlers from probe/remove Date: Thu, 1 Jun 2023 15:21:02 +0200 Message-Id: <20230601132102.301718-1-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 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 was moved to .add in all drivers already. 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 cf2c2bfe29a0..6436ac4d6322 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -1089,20 +1089,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; } @@ -1112,9 +1098,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 Thu Jun 1 13:21:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13263717 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 0900BC7EE2C for ; Thu, 1 Jun 2023 13:21:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233351AbjFANVf (ORCPT ); Thu, 1 Jun 2023 09:21:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229866AbjFANVe (ORCPT ); Thu, 1 Jun 2023 09:21:34 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDF77E7; Thu, 1 Jun 2023 06:21:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685625694; x=1717161694; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=D/DR88O008rjn2oDCy8f/NbpgBynR6wiHSrqme+u5DA=; b=MNNZRSf8nsplv0S1df1K8gU8X7aztZ1H6QyPqSt9NOYPCauqoQ+vOu3l AuBx4elvPlPRt58PekUhs28svf3p96YGZgCQr94+McaVGNxVONp7j9kwV LtxeWsMZK33WHYoqrG5rYGq5Zk5newyTXzY2lOCtZb7gkvPkTggVNDg7H LKMX/fH7m3ik4U8bWmxYGiHIXacSYNDQBDqDks6xilLzNxexukpZK5S3p CLZbil5LVJgelJxsxER9stduavPzZqkgYxPi/2KHCm/0HvK7jn+CgCrKy 6Vst/mFHqC65wEWrxrSUMSJCNENQKeoFvEDZ3j3vvMxlVumhCWd5Zxip3 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="441916176" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="441916176" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:21:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="797150450" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="797150450" Received: from hextor.igk.intel.com ([10.123.220.6]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:21:25 -0700 From: Michal Wilczynski To: rafael@kernel.org, lenb@kernel.org, dan.j.williams@intel.com, vishal.l.verma@intel.com, dave.jiang@intel.com, ira.weiny@intel.com, rui.zhang@intel.com, jdelvare@suse.com, linux@roeck-us.net, jic23@kernel.org, lars@metafoo.de, bleung@chromium.org, yu.c.chen@intel.com, hdegoede@redhat.com, markgross@kernel.org, luzmaximilian@gmail.com, corentin.chary@gmail.com, jprvita@gmail.com, cascardo@holoscopio.com, don@syst.com.br, pali@kernel.org, jwoithe@just42.net, matan@svgalib.org, kenneth.t.chan@gmail.com, malattia@linux.it, jeremy@system76.com, productdev@system76.com, herton@canonical.com, coproscefalo@gmail.com, tytso@mit.edu, Jason@zx2c4.com, robert.moore@intel.com Cc: linux-acpi@vger.kernel.org, nvdimm@lists.linux.dev, linux-hwmon@vger.kernel.org, linux-iio@vger.kernel.org, chrome-platform@lists.linux.dev, platform-driver-x86@vger.kernel.org, acpi4asus-user@lists.sourceforge.net, Michal Wilczynski Subject: [PATCH v4 34/35] acpi/bus: Remove redundant functions Date: Thu, 1 Jun 2023 15:21:21 +0200 Message-Id: <20230601132122.301760-1-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 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 6436ac4d6322..d700b65f5a37 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 Thu Jun 1 13:21:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13263718 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 5DCA6C7EE2F for ; Thu, 1 Jun 2023 13:21:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233543AbjFANVv (ORCPT ); Thu, 1 Jun 2023 09:21:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233499AbjFANVu (ORCPT ); Thu, 1 Jun 2023 09:21:50 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4958D125; Thu, 1 Jun 2023 06:21:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685625709; x=1717161709; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=LDh3/ulcjpVzc1kWMXWyk72lw2x2F5XCJG1Yb1dhhKw=; b=IIifFB/XN7cmxihAwzfPaOsSrnwyTQa4g/nwQeIkyX7s+6NMiOI4eNIW pw9v3j8cHzqARqPY5CIVqhW1z/SWMcWVNMXPsuQmv5svvEtSsP3nf/QRg ktc+Q5cXPm8l3nOXXWQTHTm6gwzyTKTbi9gsXg0H9lrC1eQMOJFhgeA4Y NsFbMX5X5IdobzoGGwp3aki2kUAZaPx0MkpTKpT8xHJwgtlstYFUQTG3H KiICLv90iFWOTY5Se8r9HR9Y8wmlXeq43DPXxKv6Lho/+Ym+D9XredWrq WvfAZ1xz+wQVQAC6C318CHV4WADG6qy3lyssLxL7DTjTT5Jux0Ndfg0uD g==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="335174005" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="335174005" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:21:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="1037487848" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="1037487848" Received: from hextor.igk.intel.com ([10.123.220.6]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:21:40 -0700 From: Michal Wilczynski To: rafael@kernel.org, lenb@kernel.org, dan.j.williams@intel.com, vishal.l.verma@intel.com, dave.jiang@intel.com, ira.weiny@intel.com, rui.zhang@intel.com, jdelvare@suse.com, linux@roeck-us.net, jic23@kernel.org, lars@metafoo.de, bleung@chromium.org, yu.c.chen@intel.com, hdegoede@redhat.com, markgross@kernel.org, luzmaximilian@gmail.com, corentin.chary@gmail.com, jprvita@gmail.com, cascardo@holoscopio.com, don@syst.com.br, pali@kernel.org, jwoithe@just42.net, matan@svgalib.org, kenneth.t.chan@gmail.com, malattia@linux.it, jeremy@system76.com, productdev@system76.com, herton@canonical.com, coproscefalo@gmail.com, tytso@mit.edu, Jason@zx2c4.com, robert.moore@intel.com Cc: linux-acpi@vger.kernel.org, nvdimm@lists.linux.dev, linux-hwmon@vger.kernel.org, linux-iio@vger.kernel.org, chrome-platform@lists.linux.dev, platform-driver-x86@vger.kernel.org, acpi4asus-user@lists.sourceforge.net, Michal Wilczynski , acpica-devel@lists.linuxfoundation.org Subject: [PATCH v4 35/35] acpi/bus: Remove notify callback and flags Date: Thu, 1 Jun 2023 15:21:37 +0200 Message-Id: <20230601132137.301802-1-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 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 and flags variable from struct acpi_driver, as they're 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;