brcm2708: rename target to bcm27xx
[openwrt/staging/mkresin.git] / target / linux / bcm27xx / patches-4.19 / 950-0323-staging-vc-sm-cma-Use-devm_-allocs-for-sm_state.patch
1 From 6214831525192a9eb665c67fe8c93006c17acbad Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.org>
3 Date: Fri, 8 Mar 2019 11:06:41 +0000
4 Subject: [PATCH] staging: vc-sm-cma: Use devm_ allocs for sm_state.
5
6 Use managed allocations for sm_state, removing reliance on
7 manual management.
8
9 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
10 ---
11 drivers/staging/vc04_services/vc-sm-cma/vc_sm.c | 12 +++++-------
12 1 file changed, 5 insertions(+), 7 deletions(-)
13
14 --- a/drivers/staging/vc04_services/vc-sm-cma/vc_sm.c
15 +++ b/drivers/staging/vc04_services/vc-sm-cma/vc_sm.c
16 @@ -656,7 +656,7 @@ static void vc_sm_connected_init(void)
17 __func__, ret);
18
19 ret = -EIO;
20 - goto err_free_mem;
21 + goto err_failed;
22 }
23
24 ret = vchi_connect(NULL, 0, vchi_instance);
25 @@ -665,7 +665,7 @@ static void vc_sm_connected_init(void)
26 __func__, ret);
27
28 ret = -EIO;
29 - goto err_free_mem;
30 + goto err_failed;
31 }
32
33 /* Initialize an instance of the shared memory service. */
34 @@ -676,7 +676,7 @@ static void vc_sm_connected_init(void)
35 __func__);
36
37 ret = -EPERM;
38 - goto err_free_mem;
39 + goto err_failed;
40 }
41
42 /* Create a debug fs directory entry (root). */
43 @@ -722,8 +722,7 @@ err_remove_shared_memory:
44 debugfs_remove_recursive(sm_state->dir_root);
45 err_stop_sm_service:
46 vc_sm_cma_vchi_stop(&sm_state->sm_handle);
47 -err_free_mem:
48 - kfree(sm_state);
49 +err_failed:
50 pr_info("[%s]: failed, ret %d\n", __func__, ret);
51 }
52
53 @@ -732,7 +731,7 @@ static int bcm2835_vc_sm_cma_probe(struc
54 {
55 pr_info("%s: Videocore shared memory driver\n", __func__);
56
57 - sm_state = kzalloc(sizeof(*sm_state), GFP_KERNEL);
58 + sm_state = devm_kzalloc(&pdev->dev, sizeof(*sm_state), GFP_KERNEL);
59 if (!sm_state)
60 return -ENOMEM;
61 sm_state->pdev = pdev;
62 @@ -766,7 +765,6 @@ static int bcm2835_vc_sm_cma_remove(stru
63
64 /* Free the memory for the state structure. */
65 mutex_destroy(&sm_state->map_lock);
66 - kfree(sm_state);
67 }
68
69 pr_debug("[%s]: end\n", __func__);