Skip to content

Commit

Permalink
core: dt_driver: allow parsing of phandle == 0
Browse files Browse the repository at this point in the history
In Linux, it is allowed to specify a null phandle which means it should
be skipped. Add support for this specific case by simply skipping over
it. This is needed to parse assigned-clock-parents which can use such
syntax. This is specified in the clock bindings [1] which says the
following:

  To skip setting parent or rate of a clock its corresponding entry
  should be set to 0, or can be omitted if it is not followed by any
  non-zero entry

For example this is a valid device-tree description:

assigned-clocks = <foo>, <bar>;
assigned-clock-parents = <0> <bar_parent>;
assigned-clock-rates = <1000>;

Link: [1] https://www.kernel.org/doc/Documentation/devicetree/bindings/clock/clock-bindings.txt
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Clément Léger <clement.leger@bootlin.com>
  • Loading branch information
clementleger authored and jforissier committed Apr 8, 2022
1 parent 84acdda commit f1f7c58
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions core/kernel/dt_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,13 @@ void *dt_driver_device_from_node_idx_prop(const char *prop_name,
while (idx < len) {
idx32 = idx / sizeof(uint32_t);
phandle = fdt32_to_cpu(prop[idx32]);
if (!phandle) {
if (!prop_idx)
break;
idx += sizeof(phandle);
prop_idx--;
continue;
}

prv = dt_driver_get_provider_by_phandle(phandle, type);
if (!prv) {
Expand Down

0 comments on commit f1f7c58

Please sign in to comment.