aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/bcm27xx/patches-4.19/950-0323-staging-vc-sm-cma-Use-devm_-allocs-for-sm_state.patch
blob: 70b73dd714b8e71606f32ccffd82abc1880086c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
From 6214831525192a9eb665c67fe8c93006c17acbad Mon Sep 17 00:00:00 2001
From: Dave Stevenson <dave.stevenson@raspberrypi.org>
Date: Fri, 8 Mar 2019 11:06:41 +0000
Subject: [PATCH] staging: vc-sm-cma: Use devm_ allocs for sm_state.

Use managed allocations for sm_state, removing reliance on
manual management.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
---
 drivers/staging/vc04_services/vc-sm-cma/vc_sm.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

--- a/drivers/staging/vc04_services/vc-sm-cma/vc_sm.c
+++ b/drivers/staging/vc04_services/vc-sm-cma/vc_sm.c
@@ -656,7 +656,7 @@ static void vc_sm_connected_init(void)
 		       __func__, ret);
 
 		ret = -EIO;
-		goto err_free_mem;
+		goto err_failed;
 	}
 
 	ret = vchi_connect(NULL, 0, vchi_instance);
@@ -665,7 +665,7 @@ static void vc_sm_connected_init(void)
 		       __func__, ret);
 
 		ret = -EIO;
-		goto err_free_mem;
+		goto err_failed;
 	}
 
 	/* Initialize an instance of the shared memory service. */
@@ -676,7 +676,7 @@ static void vc_sm_connected_init(void)
 		       __func__);
 
 		ret = -EPERM;
-		goto err_free_mem;
+		goto err_failed;
 	}
 
 	/* Create a debug fs directory entry (root). */
@@ -722,8 +722,7 @@ err_remove_shared_memory:
 	debugfs_remove_recursive(sm_state->dir_root);
 err_stop_sm_service:
 	vc_sm_cma_vchi_stop(&sm_state->sm_handle);
-err_free_mem:
-	kfree(sm_state);
+err_failed:
 	pr_info("[%s]: failed, ret %d\n", __func__, ret);
 }
 
@@ -732,7 +731,7 @@ static int bcm2835_vc_sm_cma_probe(struc
 {
 	pr_info("%s: Videocore shared memory driver\n", __func__);
 
-	sm_state = kzalloc(sizeof(*sm_state), GFP_KERNEL);
+	sm_state = devm_kzalloc(&pdev->dev, sizeof(*sm_state), GFP_KERNEL);
 	if (!sm_state)
 		return -ENOMEM;
 	sm_state->pdev = pdev;
@@ -766,7 +765,6 @@ static int bcm2835_vc_sm_cma_remove(stru
 
 		/* Free the memory for the state structure. */
 		mutex_destroy(&sm_state->map_lock);
-		kfree(sm_state);
 	}
 
 	pr_debug("[%s]: end\n", __func__);