forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 61598093bbdd283a7edc367d900f223070ead8d2
kernel/arch/arm/mach-mmp/sram.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * linux/arch/arm/mach-mmp/sram.c
34 *
....@@ -7,11 +8,6 @@
78 * All Rights Reserved
89 *
910 * Add for mmp sram support - Leo Yan <leoy@marvell.com>
10
- *
11
- * This program is free software; you can redistribute it and/or modify
12
- * it under the terms of the GNU General Public License version 2 as
13
- * published by the Free Software Foundation.
14
- *
1511 */
1612
1713 #include <linux/module.h>
....@@ -76,6 +72,8 @@
7672 if (!info)
7773 return -ENOMEM;
7874
75
+ platform_set_drvdata(pdev, info);
76
+
7977 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
8078 if (res == NULL) {
8179 dev_err(&pdev->dev, "no memory resource defined\n");
....@@ -111,8 +109,6 @@
111109 list_add(&info->node, &sram_bank_list);
112110 mutex_unlock(&sram_lock);
113111
114
- platform_set_drvdata(pdev, info);
115
-
116112 dev_info(&pdev->dev, "initialized\n");
117113 return 0;
118114
....@@ -131,17 +127,19 @@
131127 struct sram_bank_info *info;
132128
133129 info = platform_get_drvdata(pdev);
134
- if (info == NULL)
135
- return -ENODEV;
136130
137
- mutex_lock(&sram_lock);
138
- list_del(&info->node);
139
- mutex_unlock(&sram_lock);
131
+ if (info->sram_size) {
132
+ mutex_lock(&sram_lock);
133
+ list_del(&info->node);
134
+ mutex_unlock(&sram_lock);
140135
141
- gen_pool_destroy(info->gpool);
142
- iounmap(info->sram_virt);
143
- kfree(info->pool_name);
136
+ gen_pool_destroy(info->gpool);
137
+ iounmap(info->sram_virt);
138
+ kfree(info->pool_name);
139
+ }
140
+
144141 kfree(info);
142
+
145143 return 0;
146144 }
147145