Skip to content

Commit

Permalink
of/address: Handle #address-cells > 2 specially
Browse files Browse the repository at this point in the history
When a bus specifies #address-cells > 2, of_bus_default_map() now
assumes that the mapping isn't for a physical address but rather an
identifier that needs to match exactly.

This is required by bindings that use multiple cells to translate a
resource to the parent bus (device index, type, ...).

See here for the discussion:

	https://lists.ozlabs.org/pipermail/devicetree-discuss/2012-June/016577.html

Originally-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>
Signed-off-by: Rob Herring <rob.herring@calxeda.com>
  • Loading branch information
Thierry Reding authored and Rob Herring committed Sep 7, 2012
1 parent a4f8bf2 commit e38c0a1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions drivers/of/address.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ static u64 of_bus_default_map(u32 *addr, const __be32 *range,
(unsigned long long)cp, (unsigned long long)s,
(unsigned long long)da);

/*
* If the number of address cells is larger than 2 we assume the
* mapping doesn't specify a physical address. Rather, the address
* specifies an identifier that must match exactly.
*/
if (na > 2 && memcmp(range, addr, na * 4) != 0)
return OF_BAD_ADDR;

if (da < cp || da >= (cp + s))
return OF_BAD_ADDR;
return da - cp;
Expand Down

0 comments on commit e38c0a1

Please sign in to comment.