From patchwork Wed Nov 21 15:57:05 2012 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: 1781531 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 74DBBDFF71 for ; Wed, 21 Nov 2012 16:02:07 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TbCiB-0000Nh-1C; Wed, 21 Nov 2012 15:59:39 +0000 Received: from 11.mo5.mail-out.ovh.net ([46.105.47.167] helo=mo5.mail-out.ovh.net) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TbChs-0000I0-Mh for linux-arm-kernel@lists.infradead.org; Wed, 21 Nov 2012 15:59:21 +0000 Received: from mail243.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo5.mail-out.ovh.net (Postfix) with SMTP id CE89710080BD for ; Wed, 21 Nov 2012 17:07:10 +0100 (CET) Received: from b0.ovh.net (HELO queueout) (213.186.33.50) by b0.ovh.net with SMTP; 21 Nov 2012 17:59:18 +0200 Received: from ns32433.ovh.net (HELO localhost) (plagnioj%jcrosoft.com@213.251.161.87) by ns0.ovh.net with SMTP; 21 Nov 2012 17:59:17 +0200 From: Jean-Christophe PLAGNIOL-VILLARD To: linux-arm-kernel@lists.infradead.org X-Ovh-Mailout: 178.32.228.5 (mo5.mail-out.ovh.net) Subject: [PATCH 1/4] OF: Add helper for matching against linux,stdout-path Date: Wed, 21 Nov 2012 16:57:05 +0100 Message-Id: <1353513428-25697-1-git-send-email-plagnioj@jcrosoft.com> X-Mailer: git-send-email 1.7.10 In-Reply-To: <20121121155312.GX4398@game.jcrosoft.org> References: <20121121155312.GX4398@game.jcrosoft.org> X-Ovh-Tracer-Id: 18035509134313761789 X-Ovh-Remote: 213.251.161.87 (ns32433.ovh.net) X-Ovh-Local: 213.186.33.20 (ns0.ovh.net) X-OVH-SPAMSTATE: OK X-OVH-SPAMSCORE: -100 X-OVH-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeehgedrudejucetufdoteggodetrfcurfhrohhfihhlvgemucfqggfjnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfhrhhomheplfgvrghnqdevhhhrihhsthhophhhvgcurffntefipffkqffnqdggkffnnfettfffuceophhlrghgnhhiohhjsehjtghrohhsohhfthdrtghomheqnecujfgurhephffvufffkffojghfsedttdertdertddt X-Spam-Check: DONE|U 0.5/N X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeehgedrudejucetufdoteggodetrfcurfhrohhfihhlvgemucfqggfjnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfhrhhomheplfgvrghnqdevhhhrihhsthhophhhvgcurffntefipffkqffnqdggkffnnfettfffuceophhlrghgnhhiohhjsehjtghrohhsohhfthdrtghomheqnecujfgurhephffvufffkffojghfsedttdertdertddt X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121121_105921_027911_448107FE X-CRM114-Status: GOOD ( 17.95 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [46.105.47.167 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: linux-serial@vger.kernel.org, Greg Kroah-Hartman , devicetree-discuss@lists.ozlabs.org, Nicolas Ferre , Grant Likely , kernel@pengutronix.de, Jean-Christophe PLAGNIOL-VILLARD , Sascha Hauer , Alan Cox X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Sascha Hauer devicetrees may have a linux,stdout-path or stdout-path property in the chosen node describing the console device. This adds a helper function to match a device against this property and retrieve the options so a driver can call add_preferred_console for a matching device. Signed-off-by: Sascha Hauer Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD Cc: linux-serial@vger.kernel.org Cc: Greg Kroah-Hartman Cc: kernel@pengutronix.de Cc: Alan Cox Cc: Grant Likely Cc: Nicolas Ferre --- drivers/of/base.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ include/linux/of.h | 7 +++++++ 2 files changed, 53 insertions(+) diff --git a/drivers/of/base.c b/drivers/of/base.c index f2f63c8..72c49ce 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -1470,3 +1470,49 @@ const char *of_prop_next_string(struct property *prop, const char *cur) return curv; } EXPORT_SYMBOL_GPL(of_prop_next_string); + +/** + * of_device_is_stdout_path - check if a device node matches the + * linux,stdout-path property + * @np: Pointer to the given device_node + * @option: parsed option + * + * Check if this device node matches the linux,stdout-path property + * in the chosen node. return true if yes, false otherwise. + */ +int of_device_is_stdout_path(struct device_node *dn, char **option) +{ + const char *name; + struct device_node *dn_stdout; + bool is_stdout = 0; + const char *tmp; + const char *tmp_option; + + name = of_get_property(of_chosen, "linux,stdout-path", NULL); + if (name == NULL) + name = of_get_property(of_chosen, "stdout-path", NULL); + + if (name == NULL) + return 0; + + tmp_option = strchr(name, ':'); + + tmp = kstrndup(name, strlen(name) - strlen(tmp_option), GFP_KERNEL); + if (!tmp) + return 0; + + dn_stdout = of_find_node_by_path(tmp); + + if (dn_stdout && dn_stdout == dn) { + is_stdout = 1; + tmp_option++; + *option = kstrdup(tmp_option, GFP_KERNEL); + } + + of_node_put(dn_stdout); + + kfree(tmp); + + return is_stdout; +} +EXPORT_SYMBOL_GPL(of_device_is_stdout_path); diff --git a/include/linux/of.h b/include/linux/of.h index 681a6c8..6a82e3f 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -323,6 +323,8 @@ const char *of_prop_next_string(struct property *prop, const char *cur); s; \ s = of_prop_next_string(prop, s)) +int of_device_is_stdout_path(struct device_node *dn, char **option); + #else /* CONFIG_OF */ static inline const char* of_node_full_name(struct device_node *np) @@ -450,6 +452,11 @@ static inline int of_machine_is_compatible(const char *compat) return 0; } +static inline int of_device_is_stdout_path(struct device_node *dn, char **option) +{ + return 0; +} + #define of_match_ptr(_ptr) NULL #define of_match_node(_matches, _node) NULL #define of_property_for_each_u32(np, propname, prop, p, u) \