[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191004143418.53039-3-mihail.atanassov@arm.com>
Date: Fri, 4 Oct 2019 14:34:39 +0000
From: Mihail Atanassov <Mihail.Atanassov@....com>
To: "dri-devel@...ts.freedesktop.org" <dri-devel@...ts.freedesktop.org>
CC: Mihail Atanassov <Mihail.Atanassov@....com>, nd <nd@....com>,
Maxime Ripard <mripard@...nel.org>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Sean Paul <sean@...rly.run>,
"james qian wang (Arm Technology China)" <james.qian.wang@....com>,
Liviu Dudau <Liviu.Dudau@....com>,
Brian Starkey <Brian.Starkey@....com>,
David Airlie <airlied@...ux.ie>,
Daniel Vetter <daniel@...ll.ch>,
Russell King <linux@...linux.org.uk>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: [PATCH 2/3] drm/komeda: Memory manage struct komeda_drv in
probe/remove
Some fields of komeda_drv members will be useful very early
in probe code, so make sure an instance is available.
Signed-off-by: Mihail Atanassov <mihail.atanassov@....com>
---
.../gpu/drm/arm/display/komeda/komeda_drv.c | 30 +++++++++++--------
1 file changed, 17 insertions(+), 13 deletions(-)
diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_drv.c b/drivers/gpu/drm/arm/display/komeda/komeda_drv.c
index 660181bdc008..9ed25ffe0e22 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_drv.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_drv.c
@@ -32,22 +32,15 @@ static void komeda_unbind(struct device *dev)
if (!mdrv)
return;
- komeda_kms_fini(mdrv->kms);
- komeda_dev_fini(mdrv->mdev);
-
- dev_set_drvdata(dev, NULL);
- devm_kfree(dev, mdrv);
+ komeda_kms_fini(&mdrv->kms);
+ komeda_dev_fini(&mdrv->mdev);
}
static int komeda_bind(struct device *dev)
{
- struct komeda_drv *mdrv;
+ struct komeda_drv *mdrv = dev_get_drvdata(dev);
int err;
- mdrv = devm_kzalloc(dev, sizeof(*mdrv), GFP_KERNEL);
- if (!mdrv)
- return -ENOMEM;
-
err = komeda_dev_init(&mdrv->mdev, dev);
if (err)
goto free_mdrv;
@@ -56,8 +49,6 @@ static int komeda_bind(struct device *dev)
if (err)
goto fini_mdev;
- dev_set_drvdata(dev, mdrv);
-
return 0;
fini_mdev:
@@ -97,10 +88,15 @@ static int komeda_platform_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct component_match *match = NULL;
struct device_node *child;
+ struct komeda_drv *mdrv;
if (!dev->of_node)
return -ENODEV;
+ mdrv = devm_kzalloc(dev, sizeof(*mdrv), GFP_KERNEL);
+ if (!mdrv)
+ return -ENOMEM;
+
for_each_available_child_of_node(dev->of_node, child) {
if (of_node_cmp(child->name, "pipeline") != 0)
continue;
@@ -110,12 +106,20 @@ static int komeda_platform_probe(struct platform_device *pdev)
komeda_add_slave(dev, &match, child, KOMEDA_OF_PORT_OUTPUT, 1);
}
+ dev_set_drvdata(dev, mdrv);
+
return component_master_add_with_match(dev, &komeda_master_ops, match);
}
static int komeda_platform_remove(struct platform_device *pdev)
{
- component_master_del(&pdev->dev, &komeda_master_ops);
+ struct device *dev = &pdev->dev;
+ struct komeda_drv *mdrv = dev_get_drvdata(dev);
+
+ component_master_del(dev, &komeda_master_ops);
+
+ dev_set_drvdata(dev, NULL);
+ devm_kfree(dev, mdrv);
return 0;
}
--
2.23.0
Powered by blists - more mailing lists