* [PATCH 1/2] cpuidle: mvebu: clean up multiple platform drivers
@ 2015-10-02 23:24 Russell King
2015-10-05 9:40 ` Daniel Lezcano
0 siblings, 1 reply; 3+ messages in thread
From: Russell King @ 2015-10-02 23:24 UTC (permalink / raw)
To: Gregory CLEMENT; +Cc: Rafael J. Wysocki, Daniel Lezcano, linux-pm
There's no need to use multiple platform drivers, especially when we
want to do something different in the probe, but we still use a common
probe function.
We can use the platform ID system to only register one platform driver,
but have it match several devices, and give us the CPU idle driver via
the ID's driver_data.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
drivers/cpuidle/cpuidle-mvebu-v7.c | 45 +++++++++++++++++---------------------
1 file changed, 20 insertions(+), 25 deletions(-)
diff --git a/drivers/cpuidle/cpuidle-mvebu-v7.c b/drivers/cpuidle/cpuidle-mvebu-v7.c
index 980151f34707..facd7d3e57dc 100644
--- a/drivers/cpuidle/cpuidle-mvebu-v7.c
+++ b/drivers/cpuidle/cpuidle-mvebu-v7.c
@@ -99,44 +99,39 @@ static struct cpuidle_driver armada38x_idle_driver = {
static int mvebu_v7_cpuidle_probe(struct platform_device *pdev)
{
- mvebu_v7_cpu_suspend = pdev->dev.platform_data;
+ const struct platform_device_id *id = pdev->id_entry;
- if (!strcmp(pdev->dev.driver->name, "cpuidle-armada-xp"))
- return cpuidle_register(&armadaxp_idle_driver, NULL);
- else if (!strcmp(pdev->dev.driver->name, "cpuidle-armada-370"))
- return cpuidle_register(&armada370_idle_driver, NULL);
- else if (!strcmp(pdev->dev.driver->name, "cpuidle-armada-38x"))
- return cpuidle_register(&armada38x_idle_driver, NULL);
- else
+ if (!id)
return -EINVAL;
-}
-static struct platform_driver armadaxp_cpuidle_plat_driver = {
- .driver = {
- .name = "cpuidle-armada-xp",
- },
- .probe = mvebu_v7_cpuidle_probe,
-};
+ mvebu_v7_cpu_suspend = pdev->dev.platform_data;
-module_platform_driver(armadaxp_cpuidle_plat_driver);
+ return cpuidle_register((struct cpuidle_driver *)id->driver_data, NULL);
+}
-static struct platform_driver armada370_cpuidle_plat_driver = {
- .driver = {
+static const struct platform_device_id mvebu_cpuidle_ids[] = {
+ {
+ .name = "cpuidle-armada-xp",
+ .driver_data = (unsigned long)&armadaxp_idle_driver,
+ }, {
.name = "cpuidle-armada-370",
+ .driver_data = (unsigned long)&armada370_idle_driver,
+ }, {
+ .name = "cpuidle-armada-38x",
+ .driver_data = (unsigned long)&armada38x_idle_driver,
},
- .probe = mvebu_v7_cpuidle_probe,
+ {}
};
-module_platform_driver(armada370_cpuidle_plat_driver);
-
-static struct platform_driver armada38x_cpuidle_plat_driver = {
+static struct platform_driver mvebu_cpuidle_driver = {
+ .probe = mvebu_v7_cpuidle_probe,
.driver = {
- .name = "cpuidle-armada-38x",
+ .name = "cpuidle-mbevu",
},
- .probe = mvebu_v7_cpuidle_probe,
+ .id_table = mvebu_cpuidle_ids,
};
-module_platform_driver(armada38x_cpuidle_plat_driver);
+module_platform_driver(mvebu_cpuidle_driver);
MODULE_AUTHOR("Gregory CLEMENT <gregory.clement@free-electrons.com>");
MODULE_DESCRIPTION("Marvell EBU v7 cpuidle driver");
--
2.1.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] cpuidle: mvebu: clean up multiple platform drivers
2015-10-02 23:24 [PATCH 1/2] cpuidle: mvebu: clean up multiple platform drivers Russell King
@ 2015-10-05 9:40 ` Daniel Lezcano
0 siblings, 0 replies; 3+ messages in thread
From: Daniel Lezcano @ 2015-10-05 9:40 UTC (permalink / raw)
To: Russell King, Gregory CLEMENT; +Cc: Rafael J. Wysocki, linux-pm
On 10/03/2015 01:24 AM, Russell King wrote:
> There's no need to use multiple platform drivers, especially when we
> want to do something different in the probe, but we still use a common
> probe function.
>
> We can use the platform ID system to only register one platform driver,
> but have it match several devices, and give us the CPU idle driver via
> the ID's driver_data.
>
> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
> ---
Hi Russell,
I applied the two patches for 4.4.
Thanks !
-- Daniel
--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] cpuidle: mvebu: clean up multiple platform drivers
2015-10-23 11:54 [PULL] cpuidle for 4.4 Daniel Lezcano
@ 2015-10-23 11:54 ` Daniel Lezcano
0 siblings, 0 replies; 3+ messages in thread
From: Daniel Lezcano @ 2015-10-23 11:54 UTC (permalink / raw)
To: rjw; +Cc: Russell King, open list:CPUIDLE DRIVERS, open list
From: Russell King <rmk+kernel@arm.linux.org.uk>
There's no need to use multiple platform drivers, especially when we
want to do something different in the probe, but we still use a common
probe function.
We can use the platform ID system to only register one platform driver,
but have it match several devices, and give us the CPU idle driver via
the ID's driver_data.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
drivers/cpuidle/cpuidle-mvebu-v7.c | 45 +++++++++++++++++---------------------
1 file changed, 20 insertions(+), 25 deletions(-)
diff --git a/drivers/cpuidle/cpuidle-mvebu-v7.c b/drivers/cpuidle/cpuidle-mvebu-v7.c
index 980151f..facd7d3 100644
--- a/drivers/cpuidle/cpuidle-mvebu-v7.c
+++ b/drivers/cpuidle/cpuidle-mvebu-v7.c
@@ -99,44 +99,39 @@ static struct cpuidle_driver armada38x_idle_driver = {
static int mvebu_v7_cpuidle_probe(struct platform_device *pdev)
{
- mvebu_v7_cpu_suspend = pdev->dev.platform_data;
+ const struct platform_device_id *id = pdev->id_entry;
- if (!strcmp(pdev->dev.driver->name, "cpuidle-armada-xp"))
- return cpuidle_register(&armadaxp_idle_driver, NULL);
- else if (!strcmp(pdev->dev.driver->name, "cpuidle-armada-370"))
- return cpuidle_register(&armada370_idle_driver, NULL);
- else if (!strcmp(pdev->dev.driver->name, "cpuidle-armada-38x"))
- return cpuidle_register(&armada38x_idle_driver, NULL);
- else
+ if (!id)
return -EINVAL;
-}
-static struct platform_driver armadaxp_cpuidle_plat_driver = {
- .driver = {
- .name = "cpuidle-armada-xp",
- },
- .probe = mvebu_v7_cpuidle_probe,
-};
+ mvebu_v7_cpu_suspend = pdev->dev.platform_data;
-module_platform_driver(armadaxp_cpuidle_plat_driver);
+ return cpuidle_register((struct cpuidle_driver *)id->driver_data, NULL);
+}
-static struct platform_driver armada370_cpuidle_plat_driver = {
- .driver = {
+static const struct platform_device_id mvebu_cpuidle_ids[] = {
+ {
+ .name = "cpuidle-armada-xp",
+ .driver_data = (unsigned long)&armadaxp_idle_driver,
+ }, {
.name = "cpuidle-armada-370",
+ .driver_data = (unsigned long)&armada370_idle_driver,
+ }, {
+ .name = "cpuidle-armada-38x",
+ .driver_data = (unsigned long)&armada38x_idle_driver,
},
- .probe = mvebu_v7_cpuidle_probe,
+ {}
};
-module_platform_driver(armada370_cpuidle_plat_driver);
-
-static struct platform_driver armada38x_cpuidle_plat_driver = {
+static struct platform_driver mvebu_cpuidle_driver = {
+ .probe = mvebu_v7_cpuidle_probe,
.driver = {
- .name = "cpuidle-armada-38x",
+ .name = "cpuidle-mbevu",
},
- .probe = mvebu_v7_cpuidle_probe,
+ .id_table = mvebu_cpuidle_ids,
};
-module_platform_driver(armada38x_cpuidle_plat_driver);
+module_platform_driver(mvebu_cpuidle_driver);
MODULE_AUTHOR("Gregory CLEMENT <gregory.clement@free-electrons.com>");
MODULE_DESCRIPTION("Marvell EBU v7 cpuidle driver");
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-10-23 11:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-02 23:24 [PATCH 1/2] cpuidle: mvebu: clean up multiple platform drivers Russell King
2015-10-05 9:40 ` Daniel Lezcano
-- strict thread matches above, loose matches on Subject: below --
2015-10-23 11:54 [PULL] cpuidle for 4.4 Daniel Lezcano
2015-10-23 11:54 ` [PATCH 1/2] cpuidle: mvebu: clean up multiple platform drivers Daniel Lezcano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).