lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 25 May 2015 15:17:29 +0300
From:	Vladimir Zapolskiy <vladimir_zapolskiy@...tor.com>
To:	Philipp Zabel <p.zabel@...gutronix.de>,
	Heiko Stübner <heiko@...ech.de>,
	Arnd Bergmann <arnd@...db.de>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>
CC:	<linux-kernel@...r.kernel.org>
Subject: [PATCH v4 3/8] misc: sram: use phys_addr_t instead of u32 for physical address

To avoid any problems on non 32-bit platforms get and store memory
addresses under phys_addr_t type.

Signed-off-by: Vladimir Zapolskiy <vladimir_zapolskiy@...tor.com>
---
Changes from v3 to v4:
- replaced "0x%llx" with "0x%pa" to display phys_addr_t values

Changes from v1 to v2:
- report size of SRAM in decimal format '%zu' instead of '%zx'
- replacement of denominator '1024' to SZ_1K requires explicit
  include of linux/sizes.h on some platforms, keep it as a number

 drivers/misc/sram.c | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/drivers/misc/sram.c b/drivers/misc/sram.c
index 0bfdfac..a35be46f 100644
--- a/drivers/misc/sram.c
+++ b/drivers/misc/sram.c
@@ -41,8 +41,8 @@ struct sram_dev {
 
 struct sram_reserve {
 	struct list_head list;
-	u32 start;
-	u32 size;
+	phys_addr_t start;
+	size_t size;
 };
 
 static int sram_reserve_cmp(void *priv, struct list_head *a,
@@ -60,7 +60,8 @@ static int sram_probe(struct platform_device *pdev)
 	struct sram_dev *sram;
 	struct resource *res;
 	struct device_node *np = pdev->dev.of_node, *child;
-	unsigned long size, cur_start, cur_size;
+	phys_addr_t cur_start;
+	size_t size, cur_size;
 	struct sram_reserve *rblocks, *block;
 	struct list_head reserve_list;
 	unsigned int nblocks;
@@ -106,6 +107,7 @@ static int sram_probe(struct platform_device *pdev)
 	block = &rblocks[0];
 	for_each_available_child_of_node(np, child) {
 		struct resource child_res;
+		phys_addr_t block_end;
 
 		ret = of_address_to_resource(child, 0, &child_res);
 		if (ret < 0) {
@@ -127,11 +129,12 @@ static int sram_probe(struct platform_device *pdev)
 
 		block->start = child_res.start - res->start;
 		block->size = resource_size(&child_res);
+		block_end = block->start + block->size;
+
 		list_add_tail(&block->list, &reserve_list);
 
-		dev_dbg(&pdev->dev, "found reserved block 0x%x-0x%x\n",
-			block->start,
-			block->start + block->size);
+		dev_dbg(&pdev->dev, "found reserved block 0x%pa-0x%pa\n",
+			&block->start, &block_end);
 
 		block++;
 	}
@@ -149,8 +152,8 @@ static int sram_probe(struct platform_device *pdev)
 		/* can only happen if sections overlap */
 		if (block->start < cur_start) {
 			dev_err(&pdev->dev,
-				"block at 0x%x starts after current offset 0x%lx\n",
-				block->start, cur_start);
+				"block at 0x%pa starts after current offset 0x%pa\n",
+				&block->start, &cur_start);
 			ret = -EINVAL;
 			goto err_chunks;
 		}
@@ -168,8 +171,8 @@ static int sram_probe(struct platform_device *pdev)
 		 */
 		cur_size = block->start - cur_start;
 
-		dev_dbg(&pdev->dev, "adding chunk 0x%lx-0x%lx\n",
-			cur_start, cur_start + cur_size);
+		dev_dbg(&pdev->dev, "adding chunk 0x%pa-0x%pa\n",
+			&cur_start, &block->start);
 		ret = gen_pool_add_virt(sram->pool,
 				(unsigned long)virt_base + cur_start,
 				res->start + cur_start, cur_size, -1);
@@ -190,7 +193,8 @@ static int sram_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, sram);
 
-	dev_dbg(&pdev->dev, "SRAM pool: %ld KiB @ 0x%p\n", size / 1024, virt_base);
+	dev_dbg(&pdev->dev, "SRAM pool: %zu KiB @ 0x%p\n",
+		size / 1024, virt_base);
 
 	return 0;
 
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ