From: "Wilczynski, Michal" <michal.wilczynski@intel.com>
To: <linux-acpi@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<nvdimm@lists.linux.dev>,
"Williams, Dan J" <dan.j.williams@intel.com>
Cc: <rafael.j.wysocki@intel.com>, <andriy.shevchenko@intel.com>,
<lenb@kernel.org>, <vishal.l.verma@intel.com>,
<ira.weiny@intel.com>
Subject: Re: [PATCH v2 5/6] ACPI: NFIT: Replace acpi_driver with platform_driver
Date: Tue, 17 Oct 2023 10:51:04 +0200 [thread overview]
Message-ID: <e651d5e5-50a9-4884-8263-ce9d0d705b52@intel.com> (raw)
In-Reply-To: <20231006173055.2938160-6-michal.wilczynski@intel.com>
On 10/6/2023 7:30 PM, Michal Wilczynski wrote:
> NFIT driver uses struct acpi_driver incorrectly to register itself.
> This is wrong as the instances of the ACPI devices are not meant
> to be literal devices, they're supposed to describe ACPI entry of a
> particular device.
>
> Use platform_driver instead of acpi_driver. In relevant places call
> platform devices instances pdev to make a distinction with ACPI
> devices instances.
>
> NFIT driver uses devm_*() family of functions extensively. This change
> has no impact on correct functioning of the whole devm_*() family of
> functions, since the lifecycle of the device stays the same. It is still
> being created during the enumeration, and destroyed on platform device
> removal.
>
> Suggested-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> Signed-off-by: Michal Wilczynski <michal.wilczynski@intel.com>
Hi Dan,
Rafael already reviewed this patch series and merged patches
that he likes. We're waiting on your input regarding two NFIT
commits in this series.
Thanks a lot !
Michał
> ---
> drivers/acpi/nfit/core.c | 34 ++++++++++++++++++----------------
> 1 file changed, 18 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
> index 942b84d94078..fb0bc16fa186 100644
> --- a/drivers/acpi/nfit/core.c
> +++ b/drivers/acpi/nfit/core.c
> @@ -15,6 +15,7 @@
> #include <linux/sort.h>
> #include <linux/io.h>
> #include <linux/nd.h>
> +#include <linux/platform_device.h>
> #include <asm/cacheflush.h>
> #include <acpi/nfit.h>
> #include "intel.h"
> @@ -98,7 +99,7 @@ static struct acpi_device *to_acpi_dev(struct acpi_nfit_desc *acpi_desc)
> || strcmp(nd_desc->provider_name, "ACPI.NFIT") != 0)
> return NULL;
>
> - return to_acpi_device(acpi_desc->dev);
> + return ACPI_COMPANION(acpi_desc->dev);
> }
>
> static int xlat_bus_status(void *buf, unsigned int cmd, u32 status)
> @@ -3284,11 +3285,11 @@ static void acpi_nfit_put_table(void *table)
>
> static void acpi_nfit_notify(acpi_handle handle, u32 event, void *data)
> {
> - struct acpi_device *adev = data;
> + struct device *dev = data;
>
> - device_lock(&adev->dev);
> - __acpi_nfit_notify(&adev->dev, handle, event);
> - device_unlock(&adev->dev);
> + device_lock(dev);
> + __acpi_nfit_notify(dev, handle, event);
> + device_unlock(dev);
> }
>
> static void acpi_nfit_remove_notify_handler(void *data)
> @@ -3329,11 +3330,12 @@ void acpi_nfit_shutdown(void *data)
> }
> EXPORT_SYMBOL_GPL(acpi_nfit_shutdown);
>
> -static int acpi_nfit_add(struct acpi_device *adev)
> +static int acpi_nfit_probe(struct platform_device *pdev)
> {
> struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER, NULL };
> struct acpi_nfit_desc *acpi_desc;
> - struct device *dev = &adev->dev;
> + struct device *dev = &pdev->dev;
> + struct acpi_device *adev = ACPI_COMPANION(dev);
> struct acpi_table_header *tbl;
> acpi_status status = AE_OK;
> acpi_size sz;
> @@ -3360,7 +3362,7 @@ static int acpi_nfit_add(struct acpi_device *adev)
> acpi_desc = devm_kzalloc(dev, sizeof(*acpi_desc), GFP_KERNEL);
> if (!acpi_desc)
> return -ENOMEM;
> - acpi_nfit_desc_init(acpi_desc, &adev->dev);
> + acpi_nfit_desc_init(acpi_desc, dev);
>
> /* Save the acpi header for exporting the revision via sysfs */
> acpi_desc->acpi_header = *tbl;
> @@ -3391,7 +3393,7 @@ static int acpi_nfit_add(struct acpi_device *adev)
> return rc;
>
> rc = acpi_dev_install_notify_handler(adev, ACPI_DEVICE_NOTIFY,
> - acpi_nfit_notify, adev);
> + acpi_nfit_notify, dev);
> if (rc)
> return rc;
>
> @@ -3475,11 +3477,11 @@ static const struct acpi_device_id acpi_nfit_ids[] = {
> };
> MODULE_DEVICE_TABLE(acpi, acpi_nfit_ids);
>
> -static struct acpi_driver acpi_nfit_driver = {
> - .name = KBUILD_MODNAME,
> - .ids = acpi_nfit_ids,
> - .ops = {
> - .add = acpi_nfit_add,
> +static struct platform_driver acpi_nfit_driver = {
> + .probe = acpi_nfit_probe,
> + .driver = {
> + .name = KBUILD_MODNAME,
> + .acpi_match_table = acpi_nfit_ids,
> },
> };
>
> @@ -3517,7 +3519,7 @@ static __init int nfit_init(void)
> return -ENOMEM;
>
> nfit_mce_register();
> - ret = acpi_bus_register_driver(&acpi_nfit_driver);
> + ret = platform_driver_register(&acpi_nfit_driver);
> if (ret) {
> nfit_mce_unregister();
> destroy_workqueue(nfit_wq);
> @@ -3530,7 +3532,7 @@ static __init int nfit_init(void)
> static __exit void nfit_exit(void)
> {
> nfit_mce_unregister();
> - acpi_bus_unregister_driver(&acpi_nfit_driver);
> + platform_driver_unregister(&acpi_nfit_driver);
> destroy_workqueue(nfit_wq);
> WARN_ON(!list_empty(&acpi_descs));
> }
next prev parent reply other threads:[~2023-10-17 8:51 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-06 17:30 [PATCH v2 0/6] Replace acpi_driver with platform_driver Michal Wilczynski
2023-10-06 17:30 ` [PATCH v2 1/6] ACPI: AC: Remove unnecessary checks Michal Wilczynski
2023-10-06 17:30 ` [PATCH v2 2/6] ACPI: AC: Use string_choices API instead of ternary operator Michal Wilczynski
2023-10-06 17:30 ` [PATCH v2 3/6] ACPI: AC: Replace acpi_driver with platform_driver Michal Wilczynski
2023-10-06 17:45 ` Andy Shevchenko
2023-10-06 19:47 ` Rafael J. Wysocki
2023-10-07 7:56 ` Andy Shevchenko
2023-10-07 10:41 ` Rafael J. Wysocki
2023-10-07 10:43 ` Rafael J. Wysocki
2023-10-09 8:40 ` Wilczynski, Michal
2023-10-09 12:27 ` Rafael J. Wysocki
2023-10-09 13:03 ` Wilczynski, Michal
2023-10-09 17:51 ` Rafael J. Wysocki
2023-10-06 17:30 ` [PATCH v2 4/6] ACPI: AC: Rename ACPI device from device to adev Michal Wilczynski
2023-10-06 17:30 ` [PATCH v2 5/6] ACPI: NFIT: Replace acpi_driver with platform_driver Michal Wilczynski
2023-10-17 8:51 ` Wilczynski, Michal [this message]
2023-10-17 10:55 ` Rafael J. Wysocki
2023-10-17 14:06 ` Rafael J. Wysocki
2023-10-17 18:24 ` Dan Williams
2023-10-18 15:38 ` Wilczynski, Michal
2023-10-06 17:30 ` [PATCH v2 6/6] ACPI: NFIT: Remove redundant call to to_acpi_dev() Michal Wilczynski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e651d5e5-50a9-4884-8263-ce9d0d705b52@intel.com \
--to=michal.wilczynski@intel.com \
--cc=andriy.shevchenko@intel.com \
--cc=dan.j.williams@intel.com \
--cc=ira.weiny@intel.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nvdimm@lists.linux.dev \
--cc=rafael.j.wysocki@intel.com \
--cc=vishal.l.verma@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.