lkml.org 
[lkml]   [2019]   [Oct]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/3] drm/komeda: Memory manage struct komeda_drv in probe/remove
Date
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@arm.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
\
 
 \ /
  Last update: 2019-10-04 16:37    [W:0.146 / U:13.352 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site