From: s.hauer@pengutronix.de (Sascha Hauer)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/4] OF: Add helper for matching against linux, stdout-path
Date: Wed, 21 Nov 2012 18:26:31 +0100 [thread overview]
Message-ID: <20121121172631.GV10369@pengutronix.de> (raw)
In-Reply-To: <1353513428-25697-1-git-send-email-plagnioj@jcrosoft.com>
On Wed, Nov 21, 2012 at 04:57:05PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> From: Sascha Hauer <s.hauer@pengutronix.de>
>
> 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 <s.hauer@pengutronix.de>
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> Cc: linux-serial at vger.kernel.org
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: kernel at pengutronix.de
> Cc: Alan Cox <alan@linux.intel.com>
> Cc: Grant Likely <grant.likely@secretlab.ca>
> Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
> ---
> 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);
tmp_option may be NULL.
> + 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);
dn_stdout may be NULL aswell.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
next prev parent reply other threads:[~2012-11-21 17:26 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-21 15:53 [PATCH v5] linux,stdout-path helper Jean-Christophe PLAGNIOL-VILLARD
2012-11-21 15:57 ` [PATCH 1/4] OF: Add helper for matching against linux,stdout-path Jean-Christophe PLAGNIOL-VILLARD
2012-11-21 15:57 ` [PATCH 2/4] serial: i.MX: Make console support non optional Jean-Christophe PLAGNIOL-VILLARD
2012-11-21 15:57 ` [PATCH 3/4] serial: i.MX: evaluate linux,stdout-path property Jean-Christophe PLAGNIOL-VILLARD
2012-11-21 15:57 ` [PATCH 4/4] tty: Atmel serial: add linux,stdout-path support Jean-Christophe PLAGNIOL-VILLARD
2012-11-21 17:26 ` Sascha Hauer [this message]
2012-11-22 5:33 ` [PATCH 1/4] OF: Add helper for matching against linux, stdout-path Lothar Waßmann
2012-11-21 18:03 ` Grant Likely
2012-11-22 5:41 ` [PATCH 1/4] OF: Add helper for matching against linux,stdout-path Jean-Christophe PLAGNIOL-VILLARD
2012-11-22 15:31 ` [PATCH 1/4] OF: Add helper for matching against linux, stdout-path Grant Likely
2012-11-22 19:35 ` [PATCH 1/4] OF: Add helper for matching against linux,stdout-path Jean-Christophe PLAGNIOL-VILLARD
2012-11-22 21:21 ` [PATCH 1/4] OF: Add helper for matching against linux, stdout-path Grant Likely
2013-07-23 14:17 ` [PATCH v5] linux,stdout-path helper Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121121172631.GV10369@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).