devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] of: Allow for experimental device tree bindings
@ 2013-10-23 15:06 Thierry Reding
  2013-10-23 16:05 ` [Ksummit-2013-discuss] " David Woodhouse
       [not found] ` <1382540779-6334-1-git-send-email-treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
  0 siblings, 2 replies; 25+ messages in thread
From: Thierry Reding @ 2013-10-23 15:06 UTC (permalink / raw)
  To: devicetree-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	ksummit-2013-discuss-cunTk1MwBs98uUxBSJOaYoYkZiVZrdSR2LY78lusg7I

Past and recent discussions have shown that there's some concensus that
device tree bindings should be considered an ABI and therefore need to
remain backwards-compatible once code to implement them is included in
the final release of a Linux kernel.

At the same time there is a desire to keep some manoeuvre while we're
trying to figure things out. The fact is that many of us lack the
experience to design good bindings from the start. At the same time
there is a shortage of people that can review bindings and help design
better ones.

Progress and the addition of new features (and restoration of features
that used to work before the advent of DT for that matter) are blocked
to a large degree because of that.

This patch attempts to restore some degree of freedom by introducing an
easy way to mark device tree bindings as experimental as well as a way
for users to disable the use of experimental bindings if they choose
functionality at the cost of potential device tree incompatibilities.

Bindings are marked experimental by prefixing the compatible value with
an exclamation mark (!). In order to make it clear that experimental
bindings are undesirable in the long run, a warning will be output when
an experimental binding is encountered.

Signed-off-by: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
---
 drivers/of/Kconfig |  7 +++++++
 drivers/of/base.c  | 32 +++++++++++++++++++++++++++++++-
 2 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
index 78cc760..dc482f8 100644
--- a/drivers/of/Kconfig
+++ b/drivers/of/Kconfig
@@ -24,6 +24,13 @@ config OF_SELFTEST
 
 	  If unsure, say N here, but this option is safe to enable.
 
+config OF_EXPERIMENTAL
+	bool "Support experimental device tree bindings"
+	help
+	  This option allows experimental device tree bindings to be used.
+	  Note that experimental bindings are subject to change, possibly
+	  requiring the DTB to be updated.
+
 config OF_FLATTREE
 	bool
 	select DTC
diff --git a/drivers/of/base.c b/drivers/of/base.c
index a96f850..b0b8371 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -342,6 +342,36 @@ struct device_node *of_get_cpu_node(int cpu, unsigned int *thread)
 }
 EXPORT_SYMBOL(of_get_cpu_node);
 
+static int of_compat_match(const char *device, const char *driver,
+			   const struct device_node *np)
+{
+	const char *dev = device;
+	const char *drv = driver;
+
+	if (device[0] == '!')
+		device++;
+
+	if (driver[0] == '!')
+		driver++;
+
+	if (of_compat_cmp(device, driver, strlen(driver)) != 0)
+		return 0;
+
+	/* check if binding is experimental */
+	if (dev != device || drv != driver) {
+		pr_warn("of: device %s (%s) uses an experimental binding\n",
+			np->name, np->full_name);
+
+		/* don't match if we don't want experimental bindings */
+		if (!IS_ENABLED(CONFIG_OF_EXPERIMENTAL)) {
+			pr_err("of: refusing to use binding \"%s\"\n", device);
+			return 0;
+		}
+	}
+
+	return 1;
+}
+
 /** Checks if the given "compat" string matches one of the strings in
  * the device's "compatible" property
  */
@@ -355,7 +385,7 @@ static int __of_device_is_compatible(const struct device_node *device,
 	if (cp == NULL)
 		return 0;
 	while (cplen > 0) {
-		if (of_compat_cmp(cp, compat, strlen(compat)) == 0)
+		if (of_compat_match(cp, compat, device))
 			return 1;
 		l = strlen(cp) + 1;
 		cp += l;
-- 
1.8.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2013-10-25  8:45 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-23 15:06 [RFC] of: Allow for experimental device tree bindings Thierry Reding
2013-10-23 16:05 ` [Ksummit-2013-discuss] " David Woodhouse
     [not found]   ` <1382544332.8522.40.camel-Fexsq3y4057IgHVZqg5X0TlWvGAXklZc@public.gmane.org>
2013-10-23 16:55     ` Guenter Roeck
     [not found]       ` <20131023165512.GB22394-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2013-10-23 17:05         ` David Woodhouse
     [not found]           ` <1382547916.8522.42.camel-Fexsq3y4057IgHVZqg5X0TlWvGAXklZc@public.gmane.org>
2013-10-23 18:56             ` Thierry Reding
2013-10-23 18:51     ` Thierry Reding
     [not found]       ` <20131023185114.GA7863-AwZRO8vwLAwmlAP/+Wk3EA@public.gmane.org>
2013-10-24 22:26         ` Stephen Warren
     [not found]           ` <52699E8B.3000305-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2013-10-25  8:22             ` Thierry Reding
     [not found]               ` <20131025082229.GD19622-AwZRO8vwLAwmlAP/+Wk3EA@public.gmane.org>
2013-10-25  8:45                 ` Stephen Warren
     [not found] ` <1382540779-6334-1-git-send-email-treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-10-23 16:33   ` Stephen Warren
     [not found]     ` <5267FA58.9050002-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2013-10-23 17:20       ` [Ksummit-2013-discuss] " Wolfram Sang
2013-10-23 18:59         ` Thierry Reding
     [not found]           ` <20131023185909.GC7863-AwZRO8vwLAwmlAP/+Wk3EA@public.gmane.org>
2013-10-23 19:34             ` Jason Gunthorpe
     [not found]               ` <20131023193450.GE32563-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2013-10-23 19:58                 ` Thierry Reding
2013-10-23 21:08                   ` Jason Gunthorpe
     [not found]                     ` <20131023210849.GB2912-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2013-10-24  8:04                       ` Thierry Reding
2013-10-24 17:32                         ` Jason Gunthorpe
2013-10-23 21:13                   ` Andy Lutomirski
2013-10-23 19:40             ` Wolfram Sang
2013-10-23 20:05               ` Thierry Reding
2013-10-24  8:34         ` Grant Likely
     [not found]           ` <20131024083459.48FE3C4039D-WNowdnHR2B42iJbIjFUEsiwD8/FfD2ys@public.gmane.org>
2013-10-24  8:50             ` Thierry Reding
2013-10-24 20:26             ` Matt Sealey
2013-10-24 22:29             ` Stephen Warren
2013-10-24 18:39   ` jonsmirl-Re5JQEeQqe8AvxtiuMwx3w

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).