[PATCH] dtc: add ability to make nodes conditional on them being referenced

David Gibson david at gibson.dropbear.id.au
Wed Apr 16 00:30:53 PDT 2014

On Sun, Mar 16, 2014 at 10:22:02PM +0100, Heiko Stübner wrote:
> From: Heiko Stuebner <heiko.stuebner at bq.com>
> On i.MX, which carries a lot of pin-groups of which most are unused on
> individual boards, they noticed that this plethora of nodes also results
> in the runtime-lookup-performance also degrading [0].
> A i.MX-specific solution defining the pingroups in the board files but
> using macros to reference the pingroup-data was not well received.
> This patch is trying to solve this issue in a more general way, by
> adding the ability to mark nodes as needing to be referenced somewhere
> in the tree.
> To mark a node a needing to be referenced it must be prefixed with
> /delete-unreferenced/. This makes dtc check the nodes reference-status
> when creating the flattened tree, dropping it if unreferenced.
> For example, the i.MX6SL pingroup
> 	/delete-unreferenced/ pinctrl_ecspi1_1: ecspi1grp-1 {
> 		fsl,pins = <
> 		>;
> 	};
> would only be included in the dtb if it got referenced somewhere
> as pingroup via
> 	node {
> 		pinctrl-0 <&pinctrl_ecscpi1_1>;
> 	};

Sorry for the delay - I'm pretty busy with non-dtc things.

Concept looks fine to me.  It's perhaps a bit special use case, but
the syntax is well isolated (that is, unlikely to mix badly with other
possible syntax changes), so I'm happy enough to include it for those
who want it.

Maybe change the keyword to /delete-if-unreferenced/, it's a little
bit more accurate.  It's a bit long-winded, but I can't think of a
more succinct term, so it will do.

It needs testcases.

There are a few minor problems in the implementation.

With those things fixed, I'd be happy to apply.

Some detailed comments on the implementation below:

> @@ -472,6 +472,8 @@ static void fixup_phandle_references(struct check *c, struct node *dt,
>  		phandle = get_node_phandle(dt, refnode);
>  		*((cell_t *)(prop->val.val + m->offset)) = cpu_to_fdt32(phandle);
> +
> +		reference_node(refnode);

This may have some slightly unexpected behaviour when combined with
/delete-node/ and or /delete-prop/.  At worst it should include the
unnecessary node though, so I don't think it's a big problem.

> +struct node *check_node_referenced(struct node *node)

This function needs a different name, since it doesn't actually check
anything (it just triggers a later check).  Maybe

David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140416/3608e549/attachment.sig>

More information about the linux-arm-kernel mailing list