mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 05/14] of: partition: support 64bit partition sizes
Date: Fri, 31 Mar 2017 07:33:14 +0200	[thread overview]
Message-ID: <20170331053323.17821-6-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20170331053323.17821-1-s.hauer@pengutronix.de>

Do not assume that #address-cells and #size-cells are
both 1. Parse them appropriately to support devices
> 4GuB.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/of/partition.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/of/partition.c b/drivers/of/partition.c
index f4d6c3322c..30df6b32d1 100644
--- a/drivers/of/partition.c
+++ b/drivers/of/partition.c
@@ -40,10 +40,11 @@ struct cdev *of_parse_partition(struct cdev *cdev, struct device_node *node)
 	char *filename;
 	struct cdev *new;
 	const __be32 *reg;
-	unsigned long offset, size;
+	u64 offset, size;
 	const char *name;
 	int len;
 	unsigned long flags = 0;
+	int na, ns;
 
 	if (!node)
 		return NULL;
@@ -52,8 +53,16 @@ struct cdev *of_parse_partition(struct cdev *cdev, struct device_node *node)
 	if (!reg)
 		return NULL;
 
-	offset = be32_to_cpu(reg[0]);
-	size = be32_to_cpu(reg[1]);
+	na = of_n_addr_cells(node);
+	ns = of_n_size_cells(node);
+
+	if (len < (na + ns) * sizeof(__be32)) {
+		pr_err("reg property too small in %s\n", node->full_name);
+		return NULL;
+	}
+
+	offset = of_read_number(reg, na);
+	size = of_read_number(reg + na, ns);
 
 	partname = of_get_property(node, "label", &len);
 	if (!partname)
@@ -63,7 +72,7 @@ struct cdev *of_parse_partition(struct cdev *cdev, struct device_node *node)
 
 	name = (char *)partname;
 
-	debug("add partition: %s.%s 0x%08lx 0x%08lx\n", cdev->name, partname, offset, size);
+	debug("add partition: %s.%s 0x%08llx 0x%08llx\n", cdev->name, partname, offset, size);
 
 	if (of_get_property(node, "read-only", &len))
 		flags = DEVFS_PARTITION_READONLY;
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2017-03-31  5:34 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-31  5:33 OF partitions rework Sascha Hauer
2017-03-31  5:33 ` [PATCH 01/14] of: Add of_property_write_string() Sascha Hauer
2017-03-31  5:33 ` [PATCH 02/14] treewide: Use of_property_write_string() where appropriate Sascha Hauer
2017-03-31  5:33 ` [PATCH 03/14] of: partition: Move of_mtd_fixup to drivers/of/ Sascha Hauer
2017-03-31  5:33 ` [PATCH 04/14] mtd: of: Make used partition binding configurable Sascha Hauer
2017-03-31  5:33 ` Sascha Hauer [this message]
2017-03-31  5:33 ` [PATCH 06/14] mtd: partition: set cdev->offset to the actual offset Sascha Hauer
2017-03-31  8:46   ` Sascha Hauer
2017-03-31  5:33 ` [PATCH 07/14] cdev: Collect partitions on list Sascha Hauer
2017-03-31  5:33 ` [PATCH 08/14] of: partition: Make partition fixup independent from mtd devices Sascha Hauer
2017-03-31  5:33 ` [PATCH 09/14] fs: devfs-core: remove unused code Sascha Hauer
2017-03-31  5:33 ` [PATCH 10/14] fs: devfs-core: replace DEVFS_PARTITION_FIXED flag with pointer to the master cdev Sascha Hauer
2017-03-31  5:33 ` [PATCH 11/14] of: partition: only create partition node when partitions exist Sascha Hauer
2017-03-31  5:33 ` [PATCH 12/14] of: partitions: flag partitions from a partition table Sascha Hauer
2017-03-31  5:33 ` [PATCH 13/14] of: partition: Register the of partition fixup for of partition users Sascha Hauer
2017-03-31  5:33 ` [PATCH 14/14] of: of_path: add of_find_node_by_devpath() Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170331053323.17821-6-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox