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: 13263761 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1C54423423; Thu, 1 Jun 2023 13:43:34 +0000 (UTC) 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="421350831" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="421350831" 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 Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: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: 13263760 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C400B23423 for ; Thu, 1 Jun 2023 13:42:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685626955; x=1717162955; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hM51g4LvmO5TXW4gm++QbkwmPKMxxaZZYt1NUl8p1KA=; b=JnXk73K6rKZF3U4PVGqZBA3NFmAFVDafYStdEbLa0JpVwr2EtQ/B1a+d 8E0zWaxIgrFKcqL2fyjjusOi7+98gX86RSDhPOKnUtxPIdDaWQYoKBVp6 zjVLhQ/OiykAx40BxIU0D8xnnTzcVW3Kan2Ps4p9wOUiQfxQEC3qSj4+V gO5SxZMHTZjN4aY2MXUnx3lO3/V3sktVeS71VAuBnSDSUDbHynG0DUjWl U7DnIcNf7HwgpwMEFEEsmEb73C1MGuorZwRiNfOvHbfG9jCtde8u4K/ti dwJy1NSItSS4sWul/cG/qmI+ZFRycNGrAOaRMNghEpkJPmkG1O3hSSyuw g==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="419066882" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="419066882" 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> Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: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: 13263722 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E1AC0E574; Thu, 1 Jun 2023 13:21:16 +0000 (UTC) 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="383826279" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="383826279" 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 Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13263723 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8494FE574; Thu, 1 Jun 2023 13:21:34 +0000 (UTC) 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="441916177" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="441916177" 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 Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13263724 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9BB89FBE8; Thu, 1 Jun 2023 13:21:49 +0000 (UTC) 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="335174006" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="335174006" 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 Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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;