.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * linux/arch/arm/mach-mmp/sram.c |
---|
3 | 4 | * |
---|
.. | .. |
---|
7 | 8 | * All Rights Reserved |
---|
8 | 9 | * |
---|
9 | 10 | * 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 | | - * |
---|
15 | 11 | */ |
---|
16 | 12 | |
---|
17 | 13 | #include <linux/module.h> |
---|
.. | .. |
---|
76 | 72 | if (!info) |
---|
77 | 73 | return -ENOMEM; |
---|
78 | 74 | |
---|
| 75 | + platform_set_drvdata(pdev, info); |
---|
| 76 | + |
---|
79 | 77 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
---|
80 | 78 | if (res == NULL) { |
---|
81 | 79 | dev_err(&pdev->dev, "no memory resource defined\n"); |
---|
.. | .. |
---|
111 | 109 | list_add(&info->node, &sram_bank_list); |
---|
112 | 110 | mutex_unlock(&sram_lock); |
---|
113 | 111 | |
---|
114 | | - platform_set_drvdata(pdev, info); |
---|
115 | | - |
---|
116 | 112 | dev_info(&pdev->dev, "initialized\n"); |
---|
117 | 113 | return 0; |
---|
118 | 114 | |
---|
.. | .. |
---|
131 | 127 | struct sram_bank_info *info; |
---|
132 | 128 | |
---|
133 | 129 | info = platform_get_drvdata(pdev); |
---|
134 | | - if (info == NULL) |
---|
135 | | - return -ENODEV; |
---|
136 | 130 | |
---|
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); |
---|
140 | 135 | |
---|
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 | + |
---|
144 | 141 | kfree(info); |
---|
| 142 | + |
---|
145 | 143 | return 0; |
---|
146 | 144 | } |
---|
147 | 145 | |
---|