From: Paul Burton <paul.burton@mips.com>
To: devicetree-compiler@vger.kernel.org,
David Gibson <david@gibson.dropbear.id.au>,
Jon Loeliger <jdl@jdl.com>
Cc: "Paul Burton" <paul.burton@mips.com>,
"Rob Herring" <robh@kernel.org>,
"Andreas Färber" <afaerber@suse.de>,
linux-mips@linux-mips.org
Subject: [PATCH] checks: Detect cascoda,ca8210 extclock-gpio false-positive
Date: Tue, 24 Jul 2018 11:09:40 -0700 [thread overview]
Message-ID: <20180724180940.20249-1-paul.burton@mips.com> (raw)
In-Reply-To: <20180724000647.okbjmghv4w66bl7u@pburton-laptop>
The binding for the cascoda,ca8210 IEEE 802.15.4 (6LoWPAN) device
includes an extclock-gpio property which does not contain a gpio-list,
but is instead an integer representing a pin of the device itself. This
falls foul of the gpios_property check, for example:
DTC arch/mips/boot/dts/img/pistachio_marduk.dtb
arch/mips/boot/dts/img/pistachio_marduk.dtb: Warning (gpios_property):
/spi@18100f00/sixlowpan@4: Missing property '#gpio-cells' in node
/clk@18144000 or bad phandle (referred from extclock-gpio[0])
Extend the checking for false-positives in prop_is_gpio() to detect this
case in addition to the existing nr-gpio case. The false-positive cases
are described by an array including a compatible string & property name.
A NULL compatible string indicates that the property may be present in
any node, otherwise the property is only allowed in a node compatible
with the given string. This allows us to whitelist the extclock-gpio
property for the cascoda,ca8210 device without allowing it anywhere
else.
Since checks for false-positives now have a little higher cost, they are
moved to after the detection of the gpio(s) substring, which the vast
majority of property names will fail avoiding needless checks against
the false_positives array.
Signed-off-by: Paul Burton <paul.burton@mips.com>
Cc: David Gibson <david@gibson.dropbear.id.au>
Cc: Jon Loeliger <jdl@jdl.com>
Cc: Rob Herring <robh@kernel.org>
Cc: Andreas Färber <afaerber@suse.de>
Cc: devicetree-compiler@vger.kernel.org
Cc: linux-mips@linux-mips.org
---
checks.c | 36 ++++++++++++++++++++++++++----------
1 file changed, 26 insertions(+), 10 deletions(-)
diff --git a/checks.c b/checks.c
index a2cc103..c76e312 100644
--- a/checks.c
+++ b/checks.c
@@ -1254,16 +1254,17 @@ WARNING_PROPERTY_PHANDLE_CELLS(resets, "resets", "#reset-cells");
WARNING_PROPERTY_PHANDLE_CELLS(sound_dai, "sound-dai", "#sound-dai-cells");
WARNING_PROPERTY_PHANDLE_CELLS(thermal_sensors, "thermal-sensors", "#thermal-sensor-cells");
-static bool prop_is_gpio(struct property *prop)
+static bool prop_is_gpio(struct node *node, struct property *prop)
{
+ const struct {
+ char *compat;
+ char *prop;
+ } false_positives[] = {
+ { NULL, "nr-gpio" },
+ { "cascoda,ca8210", "extclock-gpio" },
+ };
char *str;
-
- /*
- * *-gpios and *-gpio can appear in property names,
- * so skip over any false matches (only one known ATM)
- */
- if (strstr(prop->name, "nr-gpio"))
- return false;
+ int i;
str = strrchr(prop->name, '-');
if (str)
@@ -1273,6 +1274,21 @@ static bool prop_is_gpio(struct property *prop)
if (!(streq(str, "gpios") || streq(str, "gpio")))
return false;
+ /*
+ * *-gpios and *-gpio can appear in property names,
+ * so skip over any false matches.
+ */
+ for (i = 0; i < ARRAY_SIZE(false_positives); i++) {
+ if (strstr(prop->name, false_positives[i].prop))
+ return false;
+
+ if (!false_positives[i].compat)
+ return false;
+
+ if (node_is_compatible(node, false_positives[i].compat))
+ return false;
+ }
+
return true;
}
@@ -1289,7 +1305,7 @@ static void check_gpios_property(struct check *c,
for_each_property(node, prop) {
struct provider provider;
- if (!prop_is_gpio(prop))
+ if (!prop_is_gpio(node, prop))
continue;
provider.prop_name = prop->name;
@@ -1310,7 +1326,7 @@ static void check_deprecated_gpio_property(struct check *c,
for_each_property(node, prop) {
char *str;
- if (!prop_is_gpio(prop))
+ if (!prop_is_gpio(node, prop))
continue;
str = strstr(prop->name, "gpio");
--
2.18.0
next prev parent reply other threads:[~2018-07-24 18:10 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-22 21:19 [PATCH 00/15] MIPS: pistachio: Creator Ci40 aka Marduk SPI-UART Andreas Färber
2018-07-22 21:19 ` [PATCH 01/15] MIPS: dts: img: pistachio_marduk: Reorder nodes Andreas Färber
2018-07-22 21:19 ` [PATCH 02/15] MIPS: dts: img: pistachio_marduk: Cleanups Andreas Färber
2018-07-22 21:19 ` [PATCH 03/15] MIPS: dts: img: pistachio: Rename spim0-clk pin node label Andreas Färber
2018-07-22 21:19 ` [PATCH 04/15] MIPS: dts: img: pistachio_marduk: Switch mmc to 1 bit mode Andreas Färber
2018-07-24 22:15 ` Andreas Färber
2018-07-22 21:20 ` [PATCH 05/15] MIPS: dts: img: pistachio_marduk: Enable SPIM0 Andreas Färber
2018-07-22 21:20 ` [PATCH 06/15] MIPS: dts: img: pistachio_marduk: Add 6Lowpan node Andreas Färber
2018-07-24 0:06 ` Paul Burton
2018-07-24 18:09 ` Paul Burton [this message]
2018-07-24 18:16 ` [PATCH] checks: Detect cascoda,ca8210 extclock-gpio false-positive Paul Burton
2018-07-24 19:16 ` Rob Herring
2018-07-24 20:17 ` Paul Burton
2018-07-24 22:12 ` Andreas Färber
2018-07-24 22:33 ` Rob Herring
2018-07-22 21:20 ` [PATCH 07/15] MIPS: dts: img: pistachio_marduk: Add SPI UART node Andreas Färber
2018-07-22 21:20 ` [PATCH 08/15] MIPS: dts: img: pistachio_marduk: Add user LEDs Andreas Färber
2018-07-22 21:20 ` [PATCH 10/15] spi: img-spfi: Implement dual and quad mode Andreas Färber
2018-07-30 15:30 ` Mark Brown
2018-07-22 21:20 ` [PATCH 11/15] spi: img-spfi: Set device select bits for SPFI port state Andreas Färber
2018-07-22 21:20 ` [PATCH 12/15] spi: img-spfi: Use device 0 configuration for all devices Andreas Färber
2018-07-22 21:20 ` [PATCH 13/15] spi: img-spfi: RX maximum burst size for DMA is 8 Andreas Färber
2018-07-30 15:34 ` Mark Brown
2018-07-22 21:20 ` [PATCH 14/15] spi: img-spfi: Finish every transfer cleanly Andreas Färber
2018-07-30 15:35 ` Mark Brown
2018-07-22 21:20 ` [PATCH 15/15] clk: pistachio: Fix wrong SDHost card speed Andreas Färber
2018-07-25 23:43 ` Stephen Boyd
2018-07-25 23:43 ` Stephen Boyd
2018-07-25 23:43 ` Stephen Boyd
2018-07-25 23:43 ` Stephen Boyd
2018-07-31 21:21 ` Rob Herring
-- strict thread matches above, loose matches on Subject: below --
2018-07-22 21:20 [09/15] dmaengine: img-mdc: Handle early status read Andreas Färber
2018-07-22 21:20 ` [PATCH 09/15] " Andreas Färber
2018-07-24 11:36 [09/15] " Vinod Koul
2018-07-24 11:36 ` [PATCH 09/15] " Vinod Koul
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180724180940.20249-1-paul.burton@mips.com \
--to=paul.burton@mips.com \
--cc=afaerber@suse.de \
--cc=david@gibson.dropbear.id.au \
--cc=devicetree-compiler@vger.kernel.org \
--cc=jdl@jdl.com \
--cc=linux-mips@linux-mips.org \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.