From patchwork Sat Feb 8 11:53:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Christophe PLAGNIOL-VILLARD X-Patchwork-Id: 3610051 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 7A0CA9F344 for ; Sat, 8 Feb 2014 11:54:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 91E1320138 for ; Sat, 8 Feb 2014 11:54:39 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8BB7920125 for ; Sat, 8 Feb 2014 11:54:38 +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 1WC6U3-00079T-3Z; Sat, 08 Feb 2014 11:54:07 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WC6Ty-0003G9-IN; Sat, 08 Feb 2014 11:54:02 +0000 Received: from 13.mo6.mail-out.ovh.net ([188.165.56.124] helo=mo6.mail-out.ovh.net) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WC6Tk-0003F8-8Y for linux-arm-kernel@lists.infradead.org; Sat, 08 Feb 2014 11:53:49 +0000 Received: from mail440.ha.ovh.net (gw6.ovh.net [213.251.189.206]) by mo6.mail-out.ovh.net (Postfix) with SMTP id BEAF01000AE4 for ; Sat, 8 Feb 2014 12:58:52 +0100 (CET) Received: from b0.ovh.net (HELO queueout) (213.186.33.50) by b0.ovh.net with SMTP; 8 Feb 2014 13:59:36 +0200 Received: from ns203013.ovh.net (HELO localhost) (plagnioj%jcrosoft.com@91.121.171.124) by ns0.ovh.net with SMTP; 8 Feb 2014 13:59:35 +0200 From: Jean-Christophe PLAGNIOL-VILLARD To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/2] OF: update stdout-path parsing Date: Sat, 8 Feb 2014 12:53:52 +0100 Message-Id: <1391860433-5343-1-git-send-email-plagnioj@jcrosoft.com> X-Mailer: git-send-email 1.8.4.4 X-Ovh-Tracer-Id: 2028590158551034877 X-Ovh-Remote: 91.121.171.124 (ns203013.ovh.net) X-Ovh-Local: 213.186.33.20 (ns0.ovh.net) X-OVH-SPAMSTATE: OK X-OVH-SPAMSCORE: -100 X-OVH-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeejtddrjedvucetufdoteggodetrfcurfhrohhfihhlvgemucfqggfjnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd X-Spam-Check: DONE|U 0.5/N X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeejtddrjeehucetufdoteggodetrfcurfhrohhfihhlvgemucfqggfjnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140208_065348_504630_58D2ED6B X-CRM114-Status: GOOD ( 17.34 ) X-Spam-Score: -1.9 (-) Cc: devicetree@vger.kernel.org, Sascha Hauer , Jean-Christophe PLAGNIOL-VILLARD , linux-serial@vger.kernel.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.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, 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 Today we only check if the linux,stdout-path property is present and retreive the node. But the DT specification allow to pass the serial options too as this linux,stdout-path = &UART0; or with options inux,stdout-path = "/plb@0/serial@84000000:115200"; So update the parsing to support and also the backward compatible stdout-path property. Cc: linux-serial@vger.kernel.org Cc: Sascha Hauer Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD Acked-by: Grant Likely --- drivers/of/base.c | 57 +++++++++++++++++++++++++++++++++++++++++++++--------- include/linux/of.h | 4 ++-- 2 files changed, 50 insertions(+), 11 deletions(-) diff --git a/drivers/of/base.c b/drivers/of/base.c index ff85450..ab9ff2f 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -34,6 +34,7 @@ EXPORT_SYMBOL(of_allnodes); struct device_node *of_chosen; struct device_node *of_aliases; static struct device_node *of_stdout; +static char *of_stdout_option; DEFINE_MUTEX(of_aliases_mutex); @@ -1783,6 +1784,45 @@ static void of_alias_add(struct alias_prop *ap, struct device_node *np, } /** + * of_stdout_path_scan - check if a device node matches the + * linux,stdout-path property and parse it + */ +static void of_stdout_path_scan(void) +{ + const char *name; + const char *tmp; + const char *tmp_option; + + name = of_get_property(of_chosen, "linux,stdout-path", NULL); + if (!name) + name = of_get_property(of_chosen, "stdout-path", NULL); + + if (!name) + return; + + tmp_option = strchr(name, ':'); + + if (!tmp_option) { + of_stdout = of_find_node_by_path(name); + return; + } + + tmp = kstrndup(name, strlen(name) - strlen(tmp_option), GFP_KERNEL); + if (!tmp) + return; + + of_stdout = of_find_node_by_path(tmp); + if (!of_stdout) + goto out; + + tmp_option++; + of_stdout_option = kstrdup(tmp_option, GFP_KERNEL); + +out: + kfree(tmp); +} + +/** * of_alias_scan - Scan all properties of 'aliases' node * * The function scans all the properties of 'aliases' node and populate @@ -1800,13 +1840,8 @@ void of_alias_scan(void * (*dt_alloc)(u64 size, u64 align)) if (of_chosen == NULL) of_chosen = of_find_node_by_path("/chosen@0"); - if (of_chosen) { - const char *name; - - name = of_get_property(of_chosen, "linux,stdout-path", NULL); - if (name) - of_stdout = of_find_node_by_path(name); - } + if (of_chosen) + of_stdout_path_scan(); of_aliases = of_find_node_by_path("/aliases"); if (!of_aliases) @@ -1923,13 +1958,17 @@ EXPORT_SYMBOL_GPL(of_prop_next_string); * linux,stdout-path property * * Check if this device node matches the linux,stdout-path property - * in the chosen node. return true if yes, false otherwise. + * in the chosen node. return true if yes, false otherwise with the option if + * requested. */ -int of_device_is_stdout_path(struct device_node *dn) +int of_device_is_stdout_path(struct device_node *dn, char** option) { if (!of_stdout) return false; + if (option) + *option = of_stdout_option; + return of_stdout == dn; } EXPORT_SYMBOL_GPL(of_device_is_stdout_path); diff --git a/include/linux/of.h b/include/linux/of.h index 70c64ba..a8afe44 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -352,7 +352,7 @@ const __be32 *of_prop_next_u32(struct property *prop, const __be32 *cur, */ const char *of_prop_next_string(struct property *prop, const char *cur); -int of_device_is_stdout_path(struct device_node *dn); +int of_device_is_stdout_path(struct device_node *dn, char** option); #else /* CONFIG_OF */ @@ -542,7 +542,7 @@ static inline int of_machine_is_compatible(const char *compat) return 0; } -static inline int of_device_is_stdout_path(struct device_node *dn) +static inline int of_device_is_stdout_path(struct device_node *dn, char** option) { return 0; }