* [PATCH v2 0/3] Replace acpi_driver with platform_driver
@ 2023-10-18 19:09 Michal Wilczynski
2023-10-18 19:09 ` [PATCH v2 1/3] ACPI: acpi_pad: " Michal Wilczynski
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Michal Wilczynski @ 2023-10-18 19:09 UTC (permalink / raw)
To: linux-acpi, linux-kernel
Cc: rafael.j.wysocki, andriy.shevchenko, lenb, Michal Wilczynski
This patchset is a continuation of efforts from [1] aiming to replace
acpi_driver with platform_driver. To ease up review effort I'm sending
miniseries per driver, with a replacement patch + various improvements
that were noticed by me, or during internal review.
This mini-series takes care of acpi_pad driver.
v2:
- removed all the unnecessary whitespace changes from first commit
- removed changes to acpi_pad_notify(), and installer/removal handlers
[1] - https://lore.kernel.org/linux-acpi/20231011083334.3987477-1-michal.wilczynski@intel.com/T/#t
Michal Wilczynski (3):
ACPI: acpi_pad: Replace acpi_driver with platform_driver
ACPI: acpi_pad: Use dev groups for sysfs
ACPI: acpi_pad: Rename ACPI device from device to adev
drivers/acpi/acpi_pad.c | 82 ++++++++++++++++-------------------------
1 file changed, 31 insertions(+), 51 deletions(-)
--
2.41.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 1/3] ACPI: acpi_pad: Replace acpi_driver with platform_driver
2023-10-18 19:09 [PATCH v2 0/3] Replace acpi_driver with platform_driver Michal Wilczynski
@ 2023-10-18 19:09 ` Michal Wilczynski
2023-10-24 19:10 ` Rafael J. Wysocki
2023-10-18 19:09 ` [PATCH v2 2/3] ACPI: acpi_pad: Use dev groups for sysfs Michal Wilczynski
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Michal Wilczynski @ 2023-10-18 19:09 UTC (permalink / raw)
To: linux-acpi, linux-kernel
Cc: rafael.j.wysocki, andriy.shevchenko, lenb, Michal Wilczynski
The acpi_pad driver uses struct acpi_driver to register itself while it
would be more logically consistent to use struct platform_driver for this
purpose, because the corresponding platform device is present and the
role of struct acpi_device is to amend the other bus types. ACPI devices
are not meant to be used as proper representation of hardware entities,
but to collect information on those hardware entities provided by the
platform firmware.
Use struct platform_driver for registering the acpi_pad driver.
Suggested-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Michal Wilczynski <michal.wilczynski@intel.com>
---
drivers/acpi/acpi_pad.c | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c
index 7a453c5ff303..25068f2c5b4d 100644
--- a/drivers/acpi/acpi_pad.c
+++ b/drivers/acpi/acpi_pad.c
@@ -18,6 +18,7 @@
#include <linux/slab.h>
#include <linux/acpi.h>
#include <linux/perf_event.h>
+#include <linux/platform_device.h>
#include <asm/mwait.h>
#include <xen/xen.h>
@@ -430,8 +431,9 @@ static void acpi_pad_notify(acpi_handle handle, u32 event,
}
}
-static int acpi_pad_add(struct acpi_device *device)
+static int acpi_pad_probe(struct platform_device *pdev)
{
+ struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
acpi_status status;
strcpy(acpi_device_name(device), ACPI_PROCESSOR_AGGREGATOR_DEVICE_NAME);
@@ -450,8 +452,10 @@ static int acpi_pad_add(struct acpi_device *device)
return 0;
}
-static void acpi_pad_remove(struct acpi_device *device)
+static void acpi_pad_remove(struct platform_device *pdev)
{
+ struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
+
mutex_lock(&isolated_cpus_lock);
acpi_pad_idle_cpus(0);
mutex_unlock(&isolated_cpus_lock);
@@ -467,13 +471,12 @@ static const struct acpi_device_id pad_device_ids[] = {
};
MODULE_DEVICE_TABLE(acpi, pad_device_ids);
-static struct acpi_driver acpi_pad_driver = {
- .name = "processor_aggregator",
- .class = ACPI_PROCESSOR_AGGREGATOR_CLASS,
- .ids = pad_device_ids,
- .ops = {
- .add = acpi_pad_add,
- .remove = acpi_pad_remove,
+static struct platform_driver acpi_pad_driver = {
+ .probe = acpi_pad_probe,
+ .remove_new = acpi_pad_remove,
+ .driver = {
+ .name = "processor_aggregator",
+ .acpi_match_table = pad_device_ids,
},
};
@@ -487,12 +490,12 @@ static int __init acpi_pad_init(void)
if (power_saving_mwait_eax == 0)
return -EINVAL;
- return acpi_bus_register_driver(&acpi_pad_driver);
+ return platform_driver_register(&acpi_pad_driver);
}
static void __exit acpi_pad_exit(void)
{
- acpi_bus_unregister_driver(&acpi_pad_driver);
+ platform_driver_unregister(&acpi_pad_driver);
}
module_init(acpi_pad_init);
--
2.41.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 2/3] ACPI: acpi_pad: Use dev groups for sysfs
2023-10-18 19:09 [PATCH v2 0/3] Replace acpi_driver with platform_driver Michal Wilczynski
2023-10-18 19:09 ` [PATCH v2 1/3] ACPI: acpi_pad: " Michal Wilczynski
@ 2023-10-18 19:09 ` Michal Wilczynski
2023-10-18 19:09 ` [PATCH v2 3/3] ACPI: acpi_pad: Rename ACPI device from device to adev Michal Wilczynski
2023-10-19 12:17 ` [PATCH v2 0/3] Replace acpi_driver with platform_driver Andy Shevchenko
3 siblings, 0 replies; 6+ messages in thread
From: Michal Wilczynski @ 2023-10-18 19:09 UTC (permalink / raw)
To: linux-acpi, linux-kernel
Cc: rafael.j.wysocki, andriy.shevchenko, lenb, Michal Wilczynski,
Andy Shevchenko
Change the way sysfs files are created. Use dev_groups, as it's a
better approach - it allows to declare attributes, and the core code
would take care of the lifecycle of those objects.
Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Michal Wilczynski <michal.wilczynski@intel.com>
---
drivers/acpi/acpi_pad.c | 42 +++++++++--------------------------------
1 file changed, 9 insertions(+), 33 deletions(-)
diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c
index 25068f2c5b4d..3ede3019d898 100644
--- a/drivers/acpi/acpi_pad.c
+++ b/drivers/acpi/acpi_pad.c
@@ -337,33 +337,14 @@ static ssize_t idlecpus_show(struct device *dev,
static DEVICE_ATTR_RW(idlecpus);
-static int acpi_pad_add_sysfs(struct acpi_device *device)
-{
- int result;
-
- result = device_create_file(&device->dev, &dev_attr_idlecpus);
- if (result)
- return -ENODEV;
- result = device_create_file(&device->dev, &dev_attr_idlepct);
- if (result) {
- device_remove_file(&device->dev, &dev_attr_idlecpus);
- return -ENODEV;
- }
- result = device_create_file(&device->dev, &dev_attr_rrtime);
- if (result) {
- device_remove_file(&device->dev, &dev_attr_idlecpus);
- device_remove_file(&device->dev, &dev_attr_idlepct);
- return -ENODEV;
- }
- return 0;
-}
+static struct attribute *acpi_pad_attrs[] = {
+ &dev_attr_idlecpus.attr,
+ &dev_attr_idlepct.attr,
+ &dev_attr_rrtime.attr,
+ NULL
+};
-static void acpi_pad_remove_sysfs(struct acpi_device *device)
-{
- device_remove_file(&device->dev, &dev_attr_idlecpus);
- device_remove_file(&device->dev, &dev_attr_idlepct);
- device_remove_file(&device->dev, &dev_attr_rrtime);
-}
+ATTRIBUTE_GROUPS(acpi_pad);
/*
* Query firmware how many CPUs should be idle
@@ -439,15 +420,10 @@ static int acpi_pad_probe(struct platform_device *pdev)
strcpy(acpi_device_name(device), ACPI_PROCESSOR_AGGREGATOR_DEVICE_NAME);
strcpy(acpi_device_class(device), ACPI_PROCESSOR_AGGREGATOR_CLASS);
- if (acpi_pad_add_sysfs(device))
- return -ENODEV;
-
status = acpi_install_notify_handler(device->handle,
ACPI_DEVICE_NOTIFY, acpi_pad_notify, device);
- if (ACPI_FAILURE(status)) {
- acpi_pad_remove_sysfs(device);
+ if (ACPI_FAILURE(status))
return -ENODEV;
- }
return 0;
}
@@ -462,7 +438,6 @@ static void acpi_pad_remove(struct platform_device *pdev)
acpi_remove_notify_handler(device->handle,
ACPI_DEVICE_NOTIFY, acpi_pad_notify);
- acpi_pad_remove_sysfs(device);
}
static const struct acpi_device_id pad_device_ids[] = {
@@ -475,6 +450,7 @@ static struct platform_driver acpi_pad_driver = {
.probe = acpi_pad_probe,
.remove_new = acpi_pad_remove,
.driver = {
+ .dev_groups = acpi_pad_groups,
.name = "processor_aggregator",
.acpi_match_table = pad_device_ids,
},
--
2.41.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 3/3] ACPI: acpi_pad: Rename ACPI device from device to adev
2023-10-18 19:09 [PATCH v2 0/3] Replace acpi_driver with platform_driver Michal Wilczynski
2023-10-18 19:09 ` [PATCH v2 1/3] ACPI: acpi_pad: " Michal Wilczynski
2023-10-18 19:09 ` [PATCH v2 2/3] ACPI: acpi_pad: Use dev groups for sysfs Michal Wilczynski
@ 2023-10-18 19:09 ` Michal Wilczynski
2023-10-19 12:17 ` [PATCH v2 0/3] Replace acpi_driver with platform_driver Andy Shevchenko
3 siblings, 0 replies; 6+ messages in thread
From: Michal Wilczynski @ 2023-10-18 19:09 UTC (permalink / raw)
To: linux-acpi, linux-kernel
Cc: rafael.j.wysocki, andriy.shevchenko, lenb, Michal Wilczynski
Since transformation from ACPI driver to platform driver there are two
devices on which the driver operates - ACPI device and platform device.
For the sake of reader this calls for the distinction in their naming,
to avoid confusion. Rename device to adev, as corresponding
platform device is called pdev.
Signed-off-by: Michal Wilczynski <michal.wilczynski@intel.com>
---
drivers/acpi/acpi_pad.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c
index 3ede3019d898..32a2c006908b 100644
--- a/drivers/acpi/acpi_pad.c
+++ b/drivers/acpi/acpi_pad.c
@@ -398,13 +398,13 @@ static void acpi_pad_handle_notify(acpi_handle handle)
static void acpi_pad_notify(acpi_handle handle, u32 event,
void *data)
{
- struct acpi_device *device = data;
+ struct acpi_device *adev = data;
switch (event) {
case ACPI_PROCESSOR_AGGREGATOR_NOTIFY:
acpi_pad_handle_notify(handle);
- acpi_bus_generate_netlink_event(device->pnp.device_class,
- dev_name(&device->dev), event, 0);
+ acpi_bus_generate_netlink_event(adev->pnp.device_class,
+ dev_name(&adev->dev), event, 0);
break;
default:
pr_warn("Unsupported event [0x%x]\n", event);
@@ -414,14 +414,15 @@ static void acpi_pad_notify(acpi_handle handle, u32 event,
static int acpi_pad_probe(struct platform_device *pdev)
{
- struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
+ struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
acpi_status status;
- strcpy(acpi_device_name(device), ACPI_PROCESSOR_AGGREGATOR_DEVICE_NAME);
- strcpy(acpi_device_class(device), ACPI_PROCESSOR_AGGREGATOR_CLASS);
+ strcpy(acpi_device_name(adev), ACPI_PROCESSOR_AGGREGATOR_DEVICE_NAME);
+ strcpy(acpi_device_class(adev), ACPI_PROCESSOR_AGGREGATOR_CLASS);
+
+ status = acpi_install_notify_handler(adev->handle,
+ ACPI_DEVICE_NOTIFY, acpi_pad_notify, adev);
- status = acpi_install_notify_handler(device->handle,
- ACPI_DEVICE_NOTIFY, acpi_pad_notify, device);
if (ACPI_FAILURE(status))
return -ENODEV;
@@ -430,13 +431,13 @@ static int acpi_pad_probe(struct platform_device *pdev)
static void acpi_pad_remove(struct platform_device *pdev)
{
- struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
+ struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
mutex_lock(&isolated_cpus_lock);
acpi_pad_idle_cpus(0);
mutex_unlock(&isolated_cpus_lock);
- acpi_remove_notify_handler(device->handle,
+ acpi_remove_notify_handler(adev->handle,
ACPI_DEVICE_NOTIFY, acpi_pad_notify);
}
--
2.41.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 0/3] Replace acpi_driver with platform_driver
2023-10-18 19:09 [PATCH v2 0/3] Replace acpi_driver with platform_driver Michal Wilczynski
` (2 preceding siblings ...)
2023-10-18 19:09 ` [PATCH v2 3/3] ACPI: acpi_pad: Rename ACPI device from device to adev Michal Wilczynski
@ 2023-10-19 12:17 ` Andy Shevchenko
3 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2023-10-19 12:17 UTC (permalink / raw)
To: Michal Wilczynski; +Cc: linux-acpi, linux-kernel, rafael.j.wysocki, lenb
On Wed, Oct 18, 2023 at 10:09:42PM +0300, Michal Wilczynski wrote:
> This patchset is a continuation of efforts from [1] aiming to replace
> acpi_driver with platform_driver. To ease up review effort I'm sending
> miniseries per driver, with a replacement patch + various improvements
> that were noticed by me, or during internal review.
>
> This mini-series takes care of acpi_pad driver.
All three LGTM, FWIW,
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/3] ACPI: acpi_pad: Replace acpi_driver with platform_driver
2023-10-18 19:09 ` [PATCH v2 1/3] ACPI: acpi_pad: " Michal Wilczynski
@ 2023-10-24 19:10 ` Rafael J. Wysocki
0 siblings, 0 replies; 6+ messages in thread
From: Rafael J. Wysocki @ 2023-10-24 19:10 UTC (permalink / raw)
To: Michal Wilczynski
Cc: linux-acpi, linux-kernel, rafael.j.wysocki, andriy.shevchenko, lenb
On Wed, Oct 18, 2023 at 10:37 PM Michal Wilczynski
<michal.wilczynski@intel.com> wrote:
>
> The acpi_pad driver uses struct acpi_driver to register itself while it
> would be more logically consistent to use struct platform_driver for this
> purpose, because the corresponding platform device is present and the
> role of struct acpi_device is to amend the other bus types. ACPI devices
> are not meant to be used as proper representation of hardware entities,
> but to collect information on those hardware entities provided by the
> platform firmware.
>
> Use struct platform_driver for registering the acpi_pad driver.
>
> Suggested-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> Signed-off-by: Michal Wilczynski <michal.wilczynski@intel.com>
> ---
> drivers/acpi/acpi_pad.c | 25 ++++++++++++++-----------
> 1 file changed, 14 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c
> index 7a453c5ff303..25068f2c5b4d 100644
> --- a/drivers/acpi/acpi_pad.c
> +++ b/drivers/acpi/acpi_pad.c
> @@ -18,6 +18,7 @@
> #include <linux/slab.h>
> #include <linux/acpi.h>
> #include <linux/perf_event.h>
> +#include <linux/platform_device.h>
> #include <asm/mwait.h>
> #include <xen/xen.h>
>
> @@ -430,8 +431,9 @@ static void acpi_pad_notify(acpi_handle handle, u32 event,
> }
> }
>
> -static int acpi_pad_add(struct acpi_device *device)
> +static int acpi_pad_probe(struct platform_device *pdev)
> {
> + struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
> acpi_status status;
>
> strcpy(acpi_device_name(device), ACPI_PROCESSOR_AGGREGATOR_DEVICE_NAME);
> @@ -450,8 +452,10 @@ static int acpi_pad_add(struct acpi_device *device)
> return 0;
> }
>
> -static void acpi_pad_remove(struct acpi_device *device)
> +static void acpi_pad_remove(struct platform_device *pdev)
> {
> + struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
> +
> mutex_lock(&isolated_cpus_lock);
> acpi_pad_idle_cpus(0);
> mutex_unlock(&isolated_cpus_lock);
> @@ -467,13 +471,12 @@ static const struct acpi_device_id pad_device_ids[] = {
> };
> MODULE_DEVICE_TABLE(acpi, pad_device_ids);
>
> -static struct acpi_driver acpi_pad_driver = {
> - .name = "processor_aggregator",
> - .class = ACPI_PROCESSOR_AGGREGATOR_CLASS,
> - .ids = pad_device_ids,
> - .ops = {
> - .add = acpi_pad_add,
> - .remove = acpi_pad_remove,
> +static struct platform_driver acpi_pad_driver = {
> + .probe = acpi_pad_probe,
> + .remove_new = acpi_pad_remove,
> + .driver = {
> + .name = "processor_aggregator",
> + .acpi_match_table = pad_device_ids,
> },
> };
>
> @@ -487,12 +490,12 @@ static int __init acpi_pad_init(void)
> if (power_saving_mwait_eax == 0)
> return -EINVAL;
>
> - return acpi_bus_register_driver(&acpi_pad_driver);
> + return platform_driver_register(&acpi_pad_driver);
> }
>
> static void __exit acpi_pad_exit(void)
> {
> - acpi_bus_unregister_driver(&acpi_pad_driver);
> + platform_driver_unregister(&acpi_pad_driver);
> }
>
> module_init(acpi_pad_init);
> --
Applied as 6.7 material along with the rest of the series, thanks!
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-10-24 19:11 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-18 19:09 [PATCH v2 0/3] Replace acpi_driver with platform_driver Michal Wilczynski
2023-10-18 19:09 ` [PATCH v2 1/3] ACPI: acpi_pad: " Michal Wilczynski
2023-10-24 19:10 ` Rafael J. Wysocki
2023-10-18 19:09 ` [PATCH v2 2/3] ACPI: acpi_pad: Use dev groups for sysfs Michal Wilczynski
2023-10-18 19:09 ` [PATCH v2 3/3] ACPI: acpi_pad: Rename ACPI device from device to adev Michal Wilczynski
2023-10-19 12:17 ` [PATCH v2 0/3] Replace acpi_driver with platform_driver Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®