[PATCH v9 8/9] drm/etnaviv: Add a dedicated function to create the virtual master
Sui Jingfeng
15330273260 at 189.cn
Wed Jun 14 02:47:44 UTC 2023
From: Sui Jingfeng <suijingfeng at loongson.cn>
After introducing the etnaviv_of_first_available_node() helper, the
creation of the virtual master platform device can also be simplified.
So, switch to etnaviv_create_virtual_master() function.
Cc: Lucas Stach <l.stach at pengutronix.de>
Cc: Christian Gmeiner <christian.gmeiner at gmail.com>
Cc: Philipp Zabel <p.zabel at pengutronix.de>
Cc: Bjorn Helgaas <bhelgaas at google.com>
Cc: Daniel Vetter <daniel at ffwll.ch>
Signed-off-by: Sui Jingfeng <suijingfeng at loongson.cn>
---
drivers/gpu/drm/etnaviv/etnaviv_drv.c | 43 ++++++++++++++++-----------
1 file changed, 26 insertions(+), 17 deletions(-)
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
index 1c9386e5a1b0..0ee7f641cee3 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
@@ -766,10 +766,32 @@ static void etnaviv_destroy_platform_device(struct platform_device **ppdev)
*ppdev = NULL;
}
+static int etnaviv_create_virtual_master(void)
+{
+ struct platform_device **master = &etnaviv_platform_device;
+ struct device_node *np;
+
+ /*
+ * If the DT contains at least one available GPU device, instantiate
+ * the DRM platform device.
+ */
+ np = etnaviv_of_first_available_node();
+ if (np) {
+ int ret;
+
+ of_node_put(np);
+
+ ret = etnaviv_create_platform_device("etnaviv", master);
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
+
static int __init etnaviv_init(void)
{
int ret;
- struct device_node *np;
etnaviv_validate_init();
@@ -785,22 +807,9 @@ static int __init etnaviv_init(void)
if (ret != 0)
goto unregister_platform_driver;
- /*
- * If the DT contains at least one available GPU device, instantiate
- * the DRM platform device.
- */
- for_each_compatible_node(np, NULL, "vivante,gc") {
- if (!of_device_is_available(np))
- continue;
- of_node_put(np);
-
- ret = etnaviv_create_platform_device("etnaviv",
- &etnaviv_platform_device);
- if (ret)
- goto unregister_platform_driver;
-
- break;
- }
+ ret = etnaviv_create_virtual_master();
+ if (ret)
+ goto unregister_platform_driver;
return ret;
--
2.25.1
More information about the etnaviv
mailing list