Re: case sensitivity for devicetree node names

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Fri, Jun 10, 2016 at 01:05:24PM -0700, Frank Rowand wrote:
> I had assumed that devicetree node names were case sensitive. But a recent
> email thread asserted that they were not, which made me curious.
> 
> dtc treats node names as case sensitive:
> 
> $ cat test_node_case_1.dts
> 
> /dts-v1/;
> 
> / {
> 	node-x {
> 		prop_a = < 1 >;
> 	};
> };
> 
> / {
> 	node-X {
> 		prop_a = < 2 >;
> 	};
> };
> 
> $ cat test_node_case_2.dts
> 
> /dts-v1/;
> 
> / {
> 	node-x {
> 		prop_a = < 1 >;
> 	};
> };
> 
> / {
> 	node-x {
> 		prop_a = < 2 >;
> 	};
> };
> 
> $ dtc -O dts test_node_case_1.dts
> /dts-v1/;
> 
> / {
> 
> 	node-x {
> 		prop_a = <0x1>;
> 	};
> 
> 	node-X {
> 		prop_a = <0x2>;
> 	};
> };
> 
> $ dtc -O dts test_node_case_2.dts
> /dts-v1/;
> 
> / {
> 
> 	node-x {
> 		prop_a = <0x2>;
> 	};
> };
> 
> 
> But the Linux kernel source code defines of_node_cmp() as:
> 
>   include/linux/of.h:
> 
>   /* Default string compare functions, Allow arch asm/prom.h to override */
>   #if !defined(of_compat_cmp)
>   #define of_node_cmp(s1, s2) strcasecmp((s1), (s2))
> 
> arch/sparc/include/asm/prom.h uses strcmp() instead of strcasecmp().
> 
> Examples of using of_node_cmp() to check for a node name can be found,
> for example, of_find_node_by_name().
> 
> Is case insensitivity for node names a bug in the Linux kernel, or desired
> for some reason?

Hmm.. a bit embarrassingly, I've never really thought about this in
all the years I've been doing dtc - I also pretty much just assumed
it was case-sensitive.

I haven't been able to find something in IEEE 1275 definitively saying
one way or the other - it's not exactly easy to search for since
"case" gives you hundreds or thousands of irrelevant hits of the form
"in the case of blah".

I do recall that there was a semantic difference between vendor
prefixes in uppercase (they were supposed to be stock tickers) and
those in lowercase (those were freeform).  That suggests that property
names at least were expected to be case sensitive.

Here's my inclination for how to treat this in dtc for the time being:
    1) Leave the bulk of dtc case sensitive, as now
    2) Add a new check which will generate an error if there are node
       names which differ only in case.

Any objections to that plan?

-- 
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_!
http://www.ozlabs.org/~dgibson

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Device Tree]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux Audio Users]     [Photos]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]

  Powered by Linux