checks: stop allowing nr-gpio, only allow nr-gpios
PATCH 1/1 checks: stop allowing nr-gpio, only allow nr-gpios
There are no instances of nr-gpio in the Linux kernel tree, only "[<vendor>,]nr-gpios", so make the check stricter to not allow nr-gpio.
--- checks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
checks.c +1 -1
@@ -1494,7 +1494,7 @@ static bool prop_is_gpio(struct property *prop)* *-gpios and *-gpio can appear in property names, * so skip over any false matches (only one known ATM) */ -if (strstr (prop->name,"nr-gpio" )) +if (strstr (prop->name,"nr-gpios" ))return false; str =strrchr (prop->name,'-' );
Signature · 1 line
2.31.1
A message that is not in the archive (sent off-list or not yet received): 20210404235042.630817-1-ilya.lipnitskiy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
PATCH v2 1/1 checks: tigthen up nr-gpios prop exception
There are no instances of nr-gpio in the Linux kernel tree, only "[<vendor>,]nr-gpios", so make the check stricter to not allow nr-gpio.
--- checks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
checks.c +1 -1
@@ -1494,7 +1494,7 @@ static bool prop_is_gpio(struct property *prop)* *-gpios and *-gpio can appear in property names, * so skip over any false matches (only one known ATM) */ -if (strstr (prop->name,"nr-gpio" )) +if (strstr (prop->name,"nr-gpios" ))return false; str =strrchr (prop->name,'-' );
Signature · 1 line
2.31.1
A message that is not in the archive (sent off-list or not yet received): 20210405052617.2471954-1-ilya.lipnitskiy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
PATCH v3 1/1 checks: tigthen up nr-gpios prop exception
There are no instances of nr-gpio in the Linux kernel tree, only "[<vendor>,]nr-gpios", so make the check stricter.
nr-gpios without a "vendor," prefix is also invalid, according to the DT spec[0], and there are no DT files in the Linux kernel tree with non-vendor nr-gpios. There are some drivers, but they are not DT spec compliant, so don't suppress the check for them.
[0]:
--- checks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
checks.c +1 -1
@@ -1494,7 +1494,7 @@ static bool prop_is_gpio(struct property *prop)* *-gpios and *-gpio can appear in property names, * so skip over any false matches (only one known ATM) */ -if (strstr (prop->name,"nr-gpio" )) +if (strstr (prop->name,",nr-gpios" ))return false; str =strrchr (prop->name,'-' );
Signature · 1 line
2.31.1
A message that is not in the archive (sent off-list or not yet received): 20210405232855.51816-1-ilya.lipnitskiy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
David Gibson
AppliedRe: [PATCH v3] checks: tigthen up nr-gpios prop exception
Quoted 8 lines · Ilya Lipnitskiy
There are no instances of nr-gpio in the Linux kernel tree, only "[<vendor>,]nr-gpios", so make the check stricter.
nr-gpios without a "vendor," prefix is also invalid, according to the DT spec[0], and there are no DT files in the Linux kernel tree with non-vendor nr-gpios. There are some drivers, but they are not DT spec compliant, so don't suppress the check for them.
Quoted 5 lines
[0]:
Signed-off-by Ilya Lipnitskiy <[email protected]>Cc Rob Herring <[email protected]>
Applied, since it looks like it definitely improves the current situation.
The use of strstr() at all seems kind of bogus to me. Shouldn't we explicitly be checking that ",nr-gpios" forms the *end* of the property name?
Quoted 17 lines
--- checks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)checks.c +1
-1@@ -1494,7 +1494,7 @@ static bool prop_is_gpio(struct property *prop)* *-gpios and *-gpio can appear in property names, * so skip over any false matches (only one known ATM) */ -if (strstr (prop->name,"nr-gpio" )) +if (strstr (prop->name,",nr-gpios" ))return false; str =strrchr (prop->name,'-' );
Signature · 4 lines
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
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v3] checks: tigthen up nr-gpios prop exception
Quoted 16 lines · David Gibson
Quoted 8 lines · Ilya Lipnitskiy
There are no instances of nr-gpio in the Linux kernel tree, only "[<vendor>,]nr-gpios", so make the check stricter.
nr-gpios without a "vendor," prefix is also invalid, according to the DT spec[0], and there are no DT files in the Linux kernel tree with non-vendor nr-gpios. There are some drivers, but they are not DT spec compliant, so don't suppress the check for them.
Quoted 5 lines
[0]:
Signed-off-by Ilya Lipnitskiy <[email protected]>Cc Rob Herring <[email protected]>
Quoted 6 lines
Applied, since it looks like it definitely improves the current situation.
The use of
strstr()at all seems kind of bogus to me. Shouldn't we explicitly be checking that ",nr-gpios" forms the *end* of the property name?
Yeah, I noticed that too. We could replace strstr with something similar to strcmp_suffix in drivers/of/property.c:
static int strcmp_suffix(const char *str, const char *suffix)
{
unsigned int len, suffix_len;
len = strlen(str);
suffix_len = strlen(suffix);
if (len <= suffix_len)
return -1;
return strcmp(str + len - suffix_len, suffix);
}Ilya
A message that is not in the archive (sent off-list or not yet received): CALCv0x0ra=UYRQi9XPabs=aCCC==Cdt2-NoPMqY6YkbHX+8yCA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH v3] checks: tigthen up nr-gpios prop exception
Quoted 27 lines · Ilya Lipnitskiy
Quoted 16 lines · David Gibson
Quoted 8 lines · Ilya Lipnitskiy
There are no instances of nr-gpio in the Linux kernel tree, only "[<vendor>,]nr-gpios", so make the check stricter.
nr-gpios without a "vendor," prefix is also invalid, according to the DT spec[0], and there are no DT files in the Linux kernel tree with non-vendor nr-gpios. There are some drivers, but they are not DT spec compliant, so don't suppress the check for them.
Quoted 5 lines
[0]:
Signed-off-by Ilya Lipnitskiy <[email protected]>Cc Rob Herring <[email protected]>Quoted 6 lines
Applied, since it looks like it definitely improves the current situation.
The use of
strstr()at all seems kind of bogus to me. Shouldn't we explicitly be checking that ",nr-gpios" forms the *end* of the property name?Yeah, I noticed that too. We could replace strstr with something similar to
strcmp_suffixindrivers/of/property.c:static int
strcmp_suffix(const char *str, const char *suffix)
Quoted 9 lines
{
unsigned int len, suffix_len;
len = strlen(str);
suffix_len = strlen(suffix);
if (len <= suffix_len)
return -1;
return strcmp(str + len - suffix_len, suffix);
}Right. If you add something like this, you should reverse the sense and call it 'strends' to match 'strstarts' which we already define in dtc.h.
Signature · 4 lines
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