hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/drivers/misc/sram.c
....@@ -1,21 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Generic on-chip SRAM allocation driver
34 *
45 * Copyright (C) 2012 Philipp Zabel, Pengutronix
5
- *
6
- * This program is free software; you can redistribute it and/or
7
- * modify it under the terms of the GNU General Public License
8
- * as published by the Free Software Foundation; either version 2
9
- * of the License, or (at your option) any later version.
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU General Public License
16
- * along with this program; if not, write to the Free Software
17
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
- * MA 02110-1301, USA.
196 */
207
218 #include <linux/clk.h>
....@@ -323,10 +310,8 @@
323310 cur_start = block->start + block->size;
324311 }
325312
326
- err_chunks:
327
- if (child)
328
- of_node_put(child);
329
-
313
+err_chunks:
314
+ of_node_put(child);
330315 kfree(rblocks);
331316
332317 return ret;
....@@ -355,8 +340,6 @@
355340 static int sram_probe(struct platform_device *pdev)
356341 {
357342 struct sram_dev *sram;
358
- struct resource *res;
359
- size_t size;
360343 int ret;
361344 int (*init_func)(void);
362345
....@@ -366,25 +349,14 @@
366349
367350 sram->dev = &pdev->dev;
368351
369
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
370
- if (!res) {
371
- dev_err(sram->dev, "found no memory resource\n");
372
- return -EINVAL;
373
- }
374
-
375
- size = resource_size(res);
376
-
377
- if (!devm_request_mem_region(sram->dev, res->start, size, pdev->name)) {
378
- dev_err(sram->dev, "could not request region for resource\n");
379
- return -EBUSY;
380
- }
381
-
382352 if (of_property_read_bool(pdev->dev.of_node, "no-memory-wc"))
383
- sram->virt_base = devm_ioremap(sram->dev, res->start, size);
353
+ sram->virt_base = devm_platform_ioremap_resource(pdev, 0);
384354 else
385
- sram->virt_base = devm_ioremap_wc(sram->dev, res->start, size);
386
- if (!sram->virt_base)
387
- return -ENOMEM;
355
+ sram->virt_base = devm_platform_ioremap_resource_wc(pdev, 0);
356
+ if (IS_ERR(sram->virt_base)) {
357
+ dev_err(&pdev->dev, "could not map SRAM registers\n");
358
+ return PTR_ERR(sram->virt_base);
359
+ }
388360
389361 sram->pool = devm_gen_pool_create(sram->dev, ilog2(SRAM_GRANULARITY),
390362 NUMA_NO_NODE, NULL);
....@@ -397,7 +369,8 @@
397369 else
398370 clk_prepare_enable(sram->clk);
399371
400
- ret = sram_reserve_regions(sram, res);
372
+ ret = sram_reserve_regions(sram,
373
+ platform_get_resource(pdev, IORESOURCE_MEM, 0));
401374 if (ret)
402375 goto err_disable_clk;
403376