linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: robherring2@gmail.com (Rob Herring)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] serial: pl011: honour serial aliases in device tree
Date: Tue, 21 Aug 2012 08:26:15 -0500	[thread overview]
Message-ID: <50338C77.4060700@gmail.com> (raw)
In-Reply-To: <1345544302-12406-1-git-send-email-matthew.leach@arm.com>

On 08/21/2012 05:18 AM, Matthew Leach wrote:
> If the order of UART nodes is changed in the device tree, then tty dev
> devices are attached to different serial ports causing the console to
> be directed to a different physical serial port. The "serial" aliases
> in the device tree should prevent this.
> 
> This patch ensures that the UART driver creates tty devices that
> honour these aliases if a device tree is present.
> 
> Signed-off-by: Matthew Leach <matthew.leach@arm.com>

One comment/question below, but otherwise:

Acked-by: Rob Herring <rob.herring@calxeda.com>

> ---
>  drivers/tty/serial/amba-pl011.c |   39 +++++++++++++++++++++++++++++++++++++++
>  1 files changed, 39 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
> index c17923e..5919599 100644
> --- a/drivers/tty/serial/amba-pl011.c
> +++ b/drivers/tty/serial/amba-pl011.c
> @@ -52,6 +52,7 @@
>  #include <linux/scatterlist.h>
>  #include <linux/delay.h>
>  #include <linux/types.h>
> +#include <linux/of_device.h>
>  #include <linux/pinctrl/consumer.h>
>  
>  #include <asm/io.h>
> @@ -1869,6 +1870,42 @@ static struct uart_driver amba_reg = {
>  	.cons			= AMBA_CONSOLE,
>  };
>  
> +#ifdef CONFIG_OF

Now that we have IS_ENABLED, perhaps we want to put this inside the
function instead?

if (!IS_ENABLED(CONFIG_OF))
	return index;


> +static int pl011_probe_dt_alias(int index, struct device *dev)
> +{
> +	struct device_node *np;
> +	static bool seen_dev_with_alias = false;
> +	static bool seen_dev_without_alias = false;
> +	int ret = index;
> +
> +	np = dev->of_node;
> +	if (!np)
> +		return ret;
> +
> +	ret = of_alias_get_id(np, "serial");
> +	if (IS_ERR_VALUE(ret)) {
> +		seen_dev_without_alias = true;
> +		ret = index;
> +	} else {
> +		seen_dev_with_alias = true;
> +		if (ret >= ARRAY_SIZE(amba_ports) || amba_ports[ret] != NULL) {
> +			dev_warn(dev, "requested serial port %d  not available.\n", ret);
> +			ret = index;
> +		}
> +	}
> +
> +	if (seen_dev_with_alias && seen_dev_without_alias)
> +		dev_warn(dev, "aliased and non-aliased serial devices found in device tree. Serial port enumeration may be unpredictable.\n");
> +
> +	return ret;
> +}
> +#else
> +static int pl011_probe_dt_alias(int index, struct device *dev)
> +{
> +	return index;
> +}
> +#endif
> +
>  static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
>  {
>  	struct uart_amba_port *uap;
> @@ -1891,6 +1928,8 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
>  		goto out;
>  	}
>  
> +	i = pl011_probe_dt_alias(i, &dev->dev);
> +
>  	base = ioremap(dev->res.start, resource_size(&dev->res));
>  	if (!base) {
>  		ret = -ENOMEM;
> 

      reply	other threads:[~2012-08-21 13:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-21 10:18 [PATCH] serial: pl011: honour serial aliases in device tree Matthew Leach
2012-08-21 13:26 ` Rob Herring [this message]

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=50338C77.4060700@gmail.com \
    --to=robherring2@gmail.com \
    --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).