of: of_path: add of_find_node_by_devpath()
We already have of_find_path_by_node() which finds a device path
for a given device node. This is used by the state framework to
find its backend path. This path has to be translated back to
a device node when Linux is started. The current approach turned
out to be too simple: We assumed that the node path is the same
in the tree Linux is started with. This is not true in several
cases:
- partition nodes should have the name "partition@<offset>", but
  in several trees they have "partition@<num>"
- There are two different partition bindings: The legacy binding
  and the new one with an additional partitions subnode which has
  a compatible = "fixed-partitions" property.
The node path only stays the same when the internal tree uses the
same bindings and node names as the tree Linux is started with.

To overcome this limitation we create of_find_node_by_devpath()
which converts the device path back to a device node. It does
so by finding the device node of the hardware device rather than
the partition node. It then parses over the partitions in this
device node with the known bindings looking for a partition which
matches in offset and size to the barebox partition.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
1 parent 0d0cee1 commit 12960a57841d5e6ea04fd523611e15a9a4170c89
@Sascha Hauer Sascha Hauer authored on 30 Mar 2017
Showing 2 changed files
View
drivers/of/of_path.c
View
include/of.h