linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] firmware: coreboot: Let OF core populate platform device
@ 2018-08-06 17:10 Stephen Boyd
  2018-08-06 17:22 ` Sudeep Holla
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Stephen Boyd @ 2018-08-06 17:10 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, Wei-Ning Huang, Julius Werner, Brian Norris,
	Samuel Holland, Thierry Escande

Now that the /firmware/coreboot node in DT is populated by the core DT
platform code with commit 3aa0582fdb82 ("of: platform: populate
/firmware/ node from of_platform_default_populate_init()") we should and
can remove the platform device creation here. Otherwise, the
of_platform_device_create() call will fail, the coreboot of driver won't
be registered, and this driver will never bind. At the same time, we can
move this driver to use platform device APIs instead of DT specific ones
and drop the of_node handling that was presumably placed there to hold a
reference to the DT node created during module init.

Cc: Wei-Ning Huang <wnhuang@chromium.org>
Cc: Julius Werner <jwerner@chromium.org>
Cc: Brian Norris <briannorris@chromium.org>
Cc: Samuel Holland <samuel@sholland.org>
Cc: Thierry Escande <thierry.escande@collabora.com>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
---
 drivers/firmware/google/coreboot_table-of.c | 39 +++++----------------
 1 file changed, 9 insertions(+), 30 deletions(-)

diff --git a/drivers/firmware/google/coreboot_table-of.c b/drivers/firmware/google/coreboot_table-of.c
index f15bf404c579..270f112bdc54 100644
--- a/drivers/firmware/google/coreboot_table-of.c
+++ b/drivers/firmware/google/coreboot_table-of.c
@@ -18,21 +18,20 @@
 #include <linux/device.h>
 #include <linux/io.h>
 #include <linux/module.h>
-#include <linux/of_address.h>
-#include <linux/of_platform.h>
+#include <linux/mod_devicetable.h>
 #include <linux/platform_device.h>
 
 #include "coreboot_table.h"
 
 static int coreboot_table_of_probe(struct platform_device *pdev)
 {
-	struct device_node *fw_dn = pdev->dev.of_node;
 	void __iomem *ptr;
+	struct resource *res;
 
-	ptr = of_iomap(fw_dn, 0);
-	of_node_put(fw_dn);
-	if (!ptr)
-		return -ENOMEM;
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	ptr = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(ptr))
+		return PTR_ERR(ptr);
 
 	return coreboot_table_init(&pdev->dev, ptr);
 }
@@ -44,8 +43,9 @@ static int coreboot_table_of_remove(struct platform_device *pdev)
 
 static const struct of_device_id coreboot_of_match[] = {
 	{ .compatible = "coreboot" },
-	{},
+	{}
 };
+MODULE_DEVICE_TABLE(of, coreboot_of_match);
 
 static struct platform_driver coreboot_table_of_driver = {
 	.probe = coreboot_table_of_probe,
@@ -55,28 +55,7 @@ static struct platform_driver coreboot_table_of_driver = {
 		.of_match_table = coreboot_of_match,
 	},
 };
-
-static int __init platform_coreboot_table_of_init(void)
-{
-	struct platform_device *pdev;
-	struct device_node *of_node;
-
-	/* Limit device creation to the presence of /firmware/coreboot node */
-	of_node = of_find_node_by_path("/firmware/coreboot");
-	if (!of_node)
-		return -ENODEV;
-
-	if (!of_match_node(coreboot_of_match, of_node))
-		return -ENODEV;
-
-	pdev = of_platform_device_create(of_node, "coreboot_table_of", NULL);
-	if (!pdev)
-		return -ENODEV;
-
-	return platform_driver_register(&coreboot_table_of_driver);
-}
-
-module_init(platform_coreboot_table_of_init);
+module_platform_driver(coreboot_table_of_driver);
 
 MODULE_AUTHOR("Google, Inc.");
 MODULE_LICENSE("GPL");
-- 
Sent by a computer through tubes


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-08-09 17:13 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-06 17:10 [PATCH] firmware: coreboot: Let OF core populate platform device Stephen Boyd
2018-08-06 17:22 ` Sudeep Holla
2018-08-06 17:38 ` Brian Norris
2018-08-06 18:05   ` Stephen Boyd
2018-08-06 18:29     ` Julius Werner
2018-08-07 21:41 ` Brian Norris
2018-08-08  6:00   ` Stephen Boyd
2018-08-09 17:13     ` Brian Norris

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).