kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Jones <drjones@redhat.com>
To: kvm@vger.kernel.org
Cc: lvivier@redhat.com, thuth@redhat.com, pbonzini@redhat.com
Subject: [kvm-unit-tests PATCH v2 1/4] devicetree: translate with parent node's #address/size-cells
Date: Wed, 11 May 2016 15:25:18 +0200	[thread overview]
Message-ID: <1462973121-14548-2-git-send-email-drjones@redhat.com> (raw)
In-Reply-To: <1462973121-14548-1-git-send-email-drjones@redhat.com>

Don't assume all pbus (cpu physical bus) translations will use the
same number of address and size cells as are defined in the root
node. Use the parent's (which may be the root node), as the spec
tells us to do.

Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 lib/devicetree.c | 13 +++++++++++--
 lib/devicetree.h |  4 ++--
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/lib/devicetree.c b/lib/devicetree.c
index a5c7f7c69ddfd..7859968c7a8d2 100644
--- a/lib/devicetree.c
+++ b/lib/devicetree.c
@@ -82,9 +82,18 @@ int dt_pbus_translate_node(int fdtnode, int regidx,
 			   struct dt_pbus_reg *pbus_reg)
 {
 	struct dt_reg raw_reg;
-	int ret;
+	u32 nac, nsc;
+	int parent, ret;
+
+	parent = fdt_parent_offset(fdt, fdtnode);
+	if (parent < 0)
+		return parent;
 
-	dt_reg_init(&raw_reg, root_nr_address_cells, root_nr_size_cells);
+	ret = dt_get_nr_cells(parent, &nac, &nsc);
+	if (ret != 0)
+		return ret;
+
+	dt_reg_init(&raw_reg, nac, nsc);
 
 	ret = dt_get_reg(fdtnode, regidx, &raw_reg);
 	if (ret < 0)
diff --git a/lib/devicetree.h b/lib/devicetree.h
index c8c86eeae28b6..d40243a603925 100644
--- a/lib/devicetree.h
+++ b/lib/devicetree.h
@@ -92,8 +92,8 @@ static inline dt_pbus_addr_t dt_pbus_read_cells(u32 nr_cells, u32 *cells)
 
 /*
  * dt_pbus_translate translates device node regs for the
- * processor bus using the root node's #address-cells and
- * #size-cells and dt_pbus_read_cells()
+ * processor bus using the parent node's #address-cells
+ * and #size-cells and dt_pbus_read_cells()
  * returns
  *  - zero on success
  *  - a negative FDT_ERR_* value on failure
-- 
2.4.11


  reply	other threads:[~2016-05-11 13:25 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-11 13:25 [kvm-unit-tests PATCH v2 0/4] devicetree: use correct #address/#size cells Andrew Jones
2016-05-11 13:25 ` Andrew Jones [this message]
2016-05-11 15:30   ` [kvm-unit-tests PATCH v2 1/4] devicetree: translate with parent node's #address/size-cells Thomas Huth
2016-05-11 13:25 ` [kvm-unit-tests PATCH v2 2/4] devicetree: don't cache #address/#size-cells Andrew Jones
2016-05-11 15:31   ` Thomas Huth
2016-05-11 13:25 ` [kvm-unit-tests PATCH v2 3/4] devicetree: remove unused globals Andrew Jones
2016-05-11 15:38   ` Thomas Huth
2016-05-11 15:46     ` Paolo Bonzini
2016-05-11 16:10       ` Andrew Jones
2016-05-11 13:25 ` [kvm-unit-tests PATCH v2 4/4] devicetree: dt_get_nr_cells output robustness Andrew Jones
2016-05-11 15:36   ` Thomas Huth

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=1462973121-14548-2-git-send-email-drjones@redhat.com \
    --to=drjones@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=lvivier@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=thuth@redhat.com \
    /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;
as well as URLs for NNTP newsgroup(s).