[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20220402154358.1708299-1-15330273260@189.cn>
Date: Sat, 2 Apr 2022 23:43:58 +0800
From: Sui Jingfeng <15330273260@....cn>
To: Lucas Stach <l.stach@...gutronix.de>,
Russell King <linux+etnaviv@...linux.org.uk>,
Christian Gmeiner <christian.gmeiner@...il.com>,
David Airlie <airlied@...ux.ie>,
Daniel Vetter <daniel@...ll.ch>
Cc: etnaviv@...ts.freedesktop.org, dri-devel@...ts.freedesktop.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] drm/etnaviv: introduce a function to create etnaviv platform device
This patch make the code more clear, call of_node_put(np) only once
in for_each_compatible_node(np, NULL, "vivante,gc") loop instead of
three.
Signed-off-by: Sui Jingfeng <15330273260@....cn>
---
drivers/gpu/drm/etnaviv/etnaviv_drv.c | 36 +++++++++++++++++----------
1 file changed, 23 insertions(+), 13 deletions(-)
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
index 0b756ecb1bc2..42cb624cf1ae 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
@@ -659,6 +659,26 @@ static struct platform_driver etnaviv_platform_driver = {
static struct platform_device *etnaviv_drm;
+static int etnaviv_create_platform_device(const char *name)
+{
+ struct platform_device *pdev;
+ int ret;
+
+ pdev = platform_device_alloc(name, PLATFORM_DEVID_NONE);
+ if (!pdev)
+ return -ENOMEM;
+
+ ret = platform_device_add(pdev);
+ if (ret) {
+ platform_device_put(pdev);
+ return ret;
+ }
+
+ etnaviv_drm = pdev;
+
+ return 0;
+}
+
static int __init etnaviv_init(void)
{
struct platform_device *pdev;
@@ -683,22 +703,12 @@ static int __init etnaviv_init(void)
if (!of_device_is_available(np))
continue;
- pdev = platform_device_alloc("etnaviv", PLATFORM_DEVID_NONE);
- if (!pdev) {
- ret = -ENOMEM;
- of_node_put(np);
- goto unregister_platform_driver;
- }
+ of_node_put(np);
- ret = platform_device_add(pdev);
- if (ret) {
- platform_device_put(pdev);
- of_node_put(np);
+ ret = etnaviv_create_platform_device("etnaviv");
+ if (ret)
goto unregister_platform_driver;
- }
- etnaviv_drm = pdev;
- of_node_put(np);
break;
}
--
2.25.1
Powered by blists - more mailing lists