* [PATCH] checks: stop allowing nr-gpio, only allow nr-gpios
@ 2021-04-04 23:50 Ilya Lipnitskiy
[not found] ` <20210404235042.630817-1-ilya.lipnitskiy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
0 siblings, 1 reply; 6+ messages in thread
From: Ilya Lipnitskiy @ 2021-04-04 23:50 UTC (permalink / raw)
To: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, David Gibson,
Jon Loeliger
Cc: Ilya Lipnitskiy
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.
Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
checks.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/checks.c b/checks.c
index c4207720ce8c..2800b5786b03 100644
--- a/checks.c
+++ b/checks.c
@@ -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, '-');
--
2.31.1
^ permalink raw reply related [flat|nested] 6+ messages in thread[parent not found: <20210404235042.630817-1-ilya.lipnitskiy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* [PATCH v2] checks: tigthen up nr-gpios prop exception [not found] ` <20210404235042.630817-1-ilya.lipnitskiy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2021-04-05 5:26 ` Ilya Lipnitskiy [not found] ` <20210405052617.2471954-1-ilya.lipnitskiy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 0 siblings, 1 reply; 6+ messages in thread From: Ilya Lipnitskiy @ 2021-04-05 5:26 UTC (permalink / raw) To: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, David Gibson, Jon Loeliger Cc: Ilya Lipnitskiy 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. Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> --- checks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/checks.c b/checks.c index c4207720ce8c..2800b5786b03 100644 --- a/checks.c +++ b/checks.c @@ -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, '-'); -- 2.31.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
[parent not found: <20210405052617.2471954-1-ilya.lipnitskiy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* [PATCH v3] checks: tigthen up nr-gpios prop exception [not found] ` <20210405052617.2471954-1-ilya.lipnitskiy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2021-04-05 23:28 ` Ilya Lipnitskiy [not found] ` <20210405232855.51816-1-ilya.lipnitskiy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 0 siblings, 1 reply; 6+ messages in thread From: Ilya Lipnitskiy @ 2021-04-05 23:28 UTC (permalink / raw) To: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, David Gibson, Jon Loeliger Cc: Ilya Lipnitskiy, Rob Herring 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]: Link: https://github.com/devicetree-org/dt-schema/blob/cb53a16a1eb3e2169ce170c071e47940845ec26e/schemas/gpio/gpio-consumer.yaml#L20 Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> Cc: Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> --- checks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/checks.c b/checks.c index c4207720ce8c..7e9d73af02a3 100644 --- a/checks.c +++ b/checks.c @@ -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, '-'); -- 2.31.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
[parent not found: <20210405232855.51816-1-ilya.lipnitskiy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH v3] checks: tigthen up nr-gpios prop exception [not found] ` <20210405232855.51816-1-ilya.lipnitskiy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2021-04-08 2:50 ` David Gibson [not found] ` <YG5vgwadkwHBoTsQ-l+x2Y8Cxqc4e6aEkudXLsA@public.gmane.org> 0 siblings, 1 reply; 6+ messages in thread From: David Gibson @ 2021-04-08 2:50 UTC (permalink / raw) To: Ilya Lipnitskiy Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, Jon Loeliger, Rob Herring [-- Attachment #1: Type: text/plain, Size: 1740 bytes --] On Mon, Apr 05, 2021 at 04:28:55PM -0700, Ilya Lipnitskiy wrote: > 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]: > Link: https://github.com/devicetree-org/dt-schema/blob/cb53a16a1eb3e2169ce170c071e47940845ec26e/schemas/gpio/gpio-consumer.yaml#L20 > > Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > Cc: Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> 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? > --- > checks.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/checks.c b/checks.c > index c4207720ce8c..7e9d73af02a3 100644 > --- a/checks.c > +++ b/checks.c > @@ -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, '-'); -- 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 #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <YG5vgwadkwHBoTsQ-l+x2Y8Cxqc4e6aEkudXLsA@public.gmane.org>]
* Re: [PATCH v3] checks: tigthen up nr-gpios prop exception [not found] ` <YG5vgwadkwHBoTsQ-l+x2Y8Cxqc4e6aEkudXLsA@public.gmane.org> @ 2021-04-10 18:20 ` Ilya Lipnitskiy [not found] ` <CALCv0x0ra=UYRQi9XPabs=aCCC==Cdt2-NoPMqY6YkbHX+8yCA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 0 siblings, 1 reply; 6+ messages in thread From: Ilya Lipnitskiy @ 2021-04-10 18:20 UTC (permalink / raw) To: David Gibson Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, Jon Loeliger, Rob Herring On Wed, Apr 7, 2021 at 7:59 PM David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org> wrote: > > On Mon, Apr 05, 2021 at 04:28:55PM -0700, Ilya Lipnitskiy wrote: > > 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]: > > Link: https://github.com/devicetree-org/dt-schema/blob/cb53a16a1eb3e2169ce170c071e47940845ec26e/schemas/gpio/gpio-consumer.yaml#L20 > > > > Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > Cc: Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> > > 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 ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <CALCv0x0ra=UYRQi9XPabs=aCCC==Cdt2-NoPMqY6YkbHX+8yCA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: [PATCH v3] checks: tigthen up nr-gpios prop exception [not found] ` <CALCv0x0ra=UYRQi9XPabs=aCCC==Cdt2-NoPMqY6YkbHX+8yCA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2021-04-12 4:30 ` David Gibson 0 siblings, 0 replies; 6+ messages in thread From: David Gibson @ 2021-04-12 4:30 UTC (permalink / raw) To: Ilya Lipnitskiy Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, Jon Loeliger, Rob Herring [-- Attachment #1: Type: text/plain, Size: 2050 bytes --] On Sat, Apr 10, 2021 at 11:20:54AM -0700, Ilya Lipnitskiy wrote: > On Wed, Apr 7, 2021 at 7:59 PM David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org> wrote: > > > > On Mon, Apr 05, 2021 at 04:28:55PM -0700, Ilya Lipnitskiy wrote: > > > 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]: > > > Link: https://github.com/devicetree-org/dt-schema/blob/cb53a16a1eb3e2169ce170c071e47940845ec26e/schemas/gpio/gpio-consumer.yaml#L20 > > > > > > Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > > Cc: Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> > > > > 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); > } 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. -- 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 #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-04-12 4:30 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-04 23:50 [PATCH] checks: stop allowing nr-gpio, only allow nr-gpios Ilya Lipnitskiy
[not found] ` <20210404235042.630817-1-ilya.lipnitskiy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2021-04-05 5:26 ` [PATCH v2] checks: tigthen up nr-gpios prop exception Ilya Lipnitskiy
[not found] ` <20210405052617.2471954-1-ilya.lipnitskiy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2021-04-05 23:28 ` [PATCH v3] " Ilya Lipnitskiy
[not found] ` <20210405232855.51816-1-ilya.lipnitskiy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2021-04-08 2:50 ` David Gibson
[not found] ` <YG5vgwadkwHBoTsQ-l+x2Y8Cxqc4e6aEkudXLsA@public.gmane.org>
2021-04-10 18:20 ` Ilya Lipnitskiy
[not found] ` <CALCv0x0ra=UYRQi9XPabs=aCCC==Cdt2-NoPMqY6YkbHX+8yCA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2021-04-12 4:30 ` David Gibson
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).