From patchwork Fri Nov 2 09:48:52 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sascha Hauer X-Patchwork-Id: 1687701 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 66C083FE20 for ; Fri, 2 Nov 2012 09:51:29 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TUDsi-00030C-Om; Fri, 02 Nov 2012 09:49:40 +0000 Received: from metis.ext.pengutronix.de ([2001:6f8:1178:4:290:27ff:fe1d:cc33]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TUDsX-0002xM-RF for linux-arm-kernel@lists.infradead.org; Fri, 02 Nov 2012 09:49:30 +0000 Received: from dude.hi.pengutronix.de ([2001:6f8:1178:2:21e:67ff:fe11:9c5c]) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1TUDs2-0003Ua-IP; Fri, 02 Nov 2012 10:48:58 +0100 Received: from sha by dude.hi.pengutronix.de with local (Exim 4.80) (envelope-from ) id 1TUDs1-0003d2-Lp; Fri, 02 Nov 2012 10:48:57 +0100 From: Sascha Hauer To: linux-serial@vger.kernel.org Subject: [PATCH 1/3] OF: Add helper for matching against linux,stdout-path Date: Fri, 2 Nov 2012 10:48:52 +0100 Message-Id: <1351849734-9836-2-git-send-email-s.hauer@pengutronix.de> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1351849734-9836-1-git-send-email-s.hauer@pengutronix.de> References: <1351849734-9836-1-git-send-email-s.hauer@pengutronix.de> X-SA-Exim-Connect-IP: 2001:6f8:1178:2:21e:67ff:fe11:9c5c X-SA-Exim-Mail-From: sha@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121102_054930_132042_E106D8C3 X-CRM114-Status: GOOD ( 17.30 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Greg Kroah-Hartman , devicetree-discuss@lists.ozlabs.org, linux-kernel@vger.kernel.org, Grant Likely , kernel@pengutronix.de, Sascha Hauer , linux-arm-kernel@lists.infradead.org, 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 devicetrees may have a linux,stdout-path property in the chosen node describing the console device. This adds a helper function to match a device against this property so a driver can call add_preferred_console for a matching device. Signed-off-by: Sascha Hauer --- drivers/of/Kconfig | 3 +++ drivers/of/Makefile | 1 + drivers/of/of_stdout.c | 27 +++++++++++++++++++++++++++ include/linux/of_stdout.h | 24 ++++++++++++++++++++++++ 4 files changed, 55 insertions(+) create mode 100644 drivers/of/of_stdout.c create mode 100644 include/linux/of_stdout.h diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig index dfba3e6..8574ebb 100644 --- a/drivers/of/Kconfig +++ b/drivers/of/Kconfig @@ -67,6 +67,9 @@ config OF_MDIO help OpenFirmware MDIO bus (Ethernet PHY) accessors +config OF_STDOUT + def_bool y + config OF_PCI def_tristate PCI depends on PCI diff --git a/drivers/of/Makefile b/drivers/of/Makefile index e027f44..c9f3f2f 100644 --- a/drivers/of/Makefile +++ b/drivers/of/Makefile @@ -8,6 +8,7 @@ obj-$(CONFIG_OF_I2C) += of_i2c.o obj-$(CONFIG_OF_NET) += of_net.o obj-$(CONFIG_OF_SELFTEST) += selftest.o obj-$(CONFIG_OF_MDIO) += of_mdio.o +obj-$(CONFIG_OF_STDOUT) += of_stdout.o obj-$(CONFIG_OF_PCI) += of_pci.o obj-$(CONFIG_OF_PCI_IRQ) += of_pci_irq.o obj-$(CONFIG_OF_MTD) += of_mtd.o diff --git a/drivers/of/of_stdout.c b/drivers/of/of_stdout.c new file mode 100644 index 0000000..c9e370e --- /dev/null +++ b/drivers/of/of_stdout.c @@ -0,0 +1,27 @@ +/* + * OF helper for linux,stdoutpath property. + * + * This file is released under the GPLv2 + */ +#include + +/** + * of_device_is_stdout_path - check if a device node matches the + * 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. + */ +int of_device_is_stdout_path(struct device_node *dn) +{ + const char *name; + + name = of_get_property(of_chosen, "linux,stdout-path", NULL); + if (name == NULL) + return 0; + + if (dn == of_find_node_by_path(name)) + return 1; + + return 0; +} diff --git a/include/linux/of_stdout.h b/include/linux/of_stdout.h new file mode 100644 index 0000000..0d80674 --- /dev/null +++ b/include/linux/of_stdout.h @@ -0,0 +1,24 @@ +/* + * OF helper for linux,stdoutpath property. + * + * This file is released under the GPLv2 + */ + +#ifndef __LINUX_OF_STDOUT_H +#define __LINUX_OF_STDOUT_H + +#ifdef CONFIG_OF_STDOUT + +#include +int of_device_is_stdout_path(struct device_node *dn); + +#else + +static inline int of_device_is_stdout_path(struct device_node *dn) +{ + return 0; +} + +#endif + +#endif /* __LINUX_OF_STDOUT_H */