Commit 5d0dabed76620b6772999fab0eb18f8566533067
Committed by
Rajendra Nayak
1 parent
e6bf566352
Exists in
ti-linux-3.12.y
and in
3 other branches
bus: omap_l3_noc: support variable mem resource
There are SoC's (like AM43x) that can have less than 3 clockdomains. Modify the driver so that it can handle different number of clockdomains to prepare for AM43x support. While at it use managed device resources and avoid a kfree in error path which should not be done as the memory is not an allocated one. Signed-off-by: Afzal Mohammed <afzal@ti.com>
Showing 1 changed file with 11 additions and 59 deletions Side-by-side Diff
drivers/bus/omap_l3_noc.c
... | ... | @@ -146,58 +146,26 @@ |
146 | 146 | { |
147 | 147 | static struct omap_l3 *l3; |
148 | 148 | struct resource *res; |
149 | - int ret; | |
149 | + int ret, i; | |
150 | 150 | const struct of_device_id *of_id = |
151 | 151 | of_match_device(l3_noc_match, &pdev->dev); |
152 | 152 | |
153 | 153 | l3 = (struct omap_l3 *)of_id->data; |
154 | 154 | |
155 | 155 | if (!l3) |
156 | - return -ENOMEM; | |
156 | + return -EINVAL; | |
157 | 157 | |
158 | 158 | platform_set_drvdata(pdev, l3); |
159 | - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | |
160 | - if (!res) { | |
161 | - dev_err(&pdev->dev, "couldn't find resource 0\n"); | |
162 | - ret = -ENODEV; | |
163 | - goto err0; | |
164 | - } | |
165 | 159 | |
166 | - l3->l3_base[0] = ioremap(res->start, resource_size(res)); | |
167 | - if (!l3->l3_base[0]) { | |
168 | - dev_err(&pdev->dev, "ioremap failed\n"); | |
169 | - ret = -ENOMEM; | |
170 | - goto err0; | |
160 | + for (i = 0; i < l3->num_modules; i++) { | |
161 | + res = platform_get_resource(pdev, IORESOURCE_MEM, i); | |
162 | + if (res == NULL) | |
163 | + return -ENOENT; | |
164 | + l3->l3_base[i] = devm_ioremap_resource(&pdev->dev, res); | |
165 | + if (IS_ERR(l3->l3_base[i])) | |
166 | + return PTR_ERR(l3->l3_base[i]); | |
171 | 167 | } |
172 | 168 | |
173 | - res = platform_get_resource(pdev, IORESOURCE_MEM, 1); | |
174 | - if (!res) { | |
175 | - dev_err(&pdev->dev, "couldn't find resource 1\n"); | |
176 | - ret = -ENODEV; | |
177 | - goto err1; | |
178 | - } | |
179 | - | |
180 | - l3->l3_base[1] = ioremap(res->start, resource_size(res)); | |
181 | - if (!l3->l3_base[1]) { | |
182 | - dev_err(&pdev->dev, "ioremap failed\n"); | |
183 | - ret = -ENOMEM; | |
184 | - goto err1; | |
185 | - } | |
186 | - | |
187 | - res = platform_get_resource(pdev, IORESOURCE_MEM, 2); | |
188 | - if (!res) { | |
189 | - dev_err(&pdev->dev, "couldn't find resource 2\n"); | |
190 | - ret = -ENODEV; | |
191 | - goto err2; | |
192 | - } | |
193 | - | |
194 | - l3->l3_base[2] = ioremap(res->start, resource_size(res)); | |
195 | - if (!l3->l3_base[2]) { | |
196 | - dev_err(&pdev->dev, "ioremap failed\n"); | |
197 | - ret = -ENOMEM; | |
198 | - goto err2; | |
199 | - } | |
200 | - | |
201 | 169 | /* |
202 | 170 | * Setup interrupt Handlers |
203 | 171 | */ |
... | ... | @@ -208,7 +176,7 @@ |
208 | 176 | if (ret) { |
209 | 177 | pr_crit("L3: request_irq failed to register for 0x%x\n", |
210 | 178 | l3->debug_irq); |
211 | - goto err3; | |
179 | + return ret; | |
212 | 180 | } |
213 | 181 | |
214 | 182 | l3->app_irq = platform_get_irq(pdev, 1); |
215 | 183 | |
... | ... | @@ -218,21 +186,9 @@ |
218 | 186 | if (ret) { |
219 | 187 | pr_crit("L3: request_irq failed to register for 0x%x\n", |
220 | 188 | l3->app_irq); |
221 | - goto err4; | |
189 | + free_irq(l3->debug_irq, l3); | |
222 | 190 | } |
223 | 191 | |
224 | - return 0; | |
225 | - | |
226 | -err4: | |
227 | - free_irq(l3->debug_irq, l3); | |
228 | -err3: | |
229 | - iounmap(l3->l3_base[2]); | |
230 | -err2: | |
231 | - iounmap(l3->l3_base[1]); | |
232 | -err1: | |
233 | - iounmap(l3->l3_base[0]); | |
234 | -err0: | |
235 | - kfree(l3); | |
236 | 192 | return ret; |
237 | 193 | } |
238 | 194 | |
... | ... | @@ -242,10 +198,6 @@ |
242 | 198 | |
243 | 199 | free_irq(l3->app_irq, l3); |
244 | 200 | free_irq(l3->debug_irq, l3); |
245 | - iounmap(l3->l3_base[0]); | |
246 | - iounmap(l3->l3_base[1]); | |
247 | - iounmap(l3->l3_base[2]); | |
248 | - kfree(l3); | |
249 | 201 | |
250 | 202 | return 0; |
251 | 203 | } |