From patchwork Wed Oct 23 15:06:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 3089151 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7D72E9F2B8 for ; Wed, 23 Oct 2013 15:09:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D6C47203C4 for ; Wed, 23 Oct 2013 15:09:28 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8E73F20353 for ; Wed, 23 Oct 2013 15:09:27 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VZ03k-0007AC-Ba; Wed, 23 Oct 2013 15:09:20 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VZ03h-0000tM-R3; Wed, 23 Oct 2013 15:09:17 +0000 Received: from mail-bk0-x233.google.com ([2a00:1450:4008:c01::233]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VZ03e-0000sn-L6 for linux-arm-kernel@lists.infradead.org; Wed, 23 Oct 2013 15:09:15 +0000 Received: by mail-bk0-f51.google.com with SMTP id mx10so343973bkb.24 for ; Wed, 23 Oct 2013 08:08:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=Mo+c+4zaOqaBxKK+RVtDE8B19ypQ37+6TrI6CM20ZQo=; b=GpSqpfAUcnJZcYqRG0m0j1ixjHdnN9JTovRPJyLswq3C2b/dyYpNEDEBfEO5VSlF8I sgtmqH/FXhJ6U3NTk+t6YIICmq7pEm3iqauuggBMDyQUYmI2DJcBwCrV39+cvN+Dy6yK EIYqqlupQduMIxIR8j8Dgm1DSdeaM4akZTv+BOMydKbbpbbBlvNlztE0uvwbxHoIT/Dp SmXnQFcWIVCC0yF7LQXrkLmvMKjyWDBRfpTN2KrLEvEuZP3CVWEgTgOpU0bUMtouhr+Q Cm3A3kFQrhF5Tl9snDl+DF+416K8HJlm1cMrqex+VLYiJu+aBrYvLSuKRyIo5uNkrMOZ 7E1g== X-Received: by 10.205.64.68 with SMTP id xh4mr1957544bkb.42.1382540932522; Wed, 23 Oct 2013 08:08:52 -0700 (PDT) Received: from localhost (port-35855.pppoe.wtnet.de. [46.59.190.236]) by mx.google.com with ESMTPSA id ny10sm16533608bkb.17.2013.10.23.08.08.49 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Oct 2013 08:08:50 -0700 (PDT) From: Thierry Reding To: devicetree@vger.kernel.org Subject: [RFC] of: Allow for experimental device tree bindings Date: Wed, 23 Oct 2013 17:06:19 +0200 Message-Id: <1382540779-6334-1-git-send-email-treding@nvidia.com> X-Mailer: git-send-email 1.8.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131023_110914_823560_08583E66 X-CRM114-Status: GOOD ( 18.83 ) X-Spam-Score: -2.0 (--) Cc: ksummit-2013-discuss@lists.linuxfoundation.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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;