public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Jerry Van Baren <gerald.vanbaren@ge.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/7] fdt_support: Add multi-serial support for stdout fixup
Date: Wed, 16 Sep 2009 08:59:14 -0400	[thread overview]
Message-ID: <4AB0E122.4010502@ge.com> (raw)
In-Reply-To: <C5D0EB96-46D5-489E-AFC7-ABDF0CB5F692@kernel.crashing.org>

Hi Kumar, Anton,

Kumar Gala wrote:
> 
> On Aug 19, 2009, at 1:37 PM, Anton Vorontsov wrote:
> 
>> Currently fdt_fixup_stdout() is using hard-coded CONFIG_CONS_INDEX
>> constant. With multi-serial support, the CONS_INDEX may no longer
>> represent actual console, so we should try to extract port number
>> from the current stdio device name instead of always hard-coding the
>> constant value.
>>
>> Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
>> ---
>> common/fdt_support.c |   22 +++++++++++++++++++++-
>> 1 files changed, 21 insertions(+), 1 deletions(-)
> 
> Should get some Ack from Jerry.
> 
> - k

Sorry, I was asleep at the wheel.

I'm OK with the patch as is, but it could be tightened up slightly by 
having the new function fill in the serial name in the non-multi 
situation.  I renamed the function as well to be fdt_fill_sername() to 
remove the "multi" connotation.

Below is a *HAND MODIFIED* (i.e. probably broken) edit of Anton's patch 
reflecting my thoughts.

I'll leave it up to Anton and Kumar... I'm OK with Anton's original 
patch and you have my
   Acked-by: Gerald Van Baren <vanbaren@cideas.com>
or you can verify and adopt my proposed change (more work :-() and add a
   Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
to Anton's s-o-b.

Thanks,
gvb
------------------------------------------------------------------------

Currently fdt_fixup_stdout() is using hard-coded CONFIG_CONS_INDEX
constant. With multi-serial support, the CONS_INDEX may no longer
represent actual console, so we should try to extract port number
from the current stdio device name instead of always hard-coding the
constant value.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
---
  common/fdt_support.c |   22 +++++++++++++++++++++-
  1 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/common/fdt_support.c b/common/fdt_support.c
index 89164a1..e01303a 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -22,6 +22,7 @@
   */

  #include <common.h>
+#include <stdio_dev.h>
  #include <linux/ctype.h>
  #include <linux/types.h>
  #include <asm/global_data.h>
@@ -90,6 +91,26 @@ int fdt_find_and_setprop(void *fdt, const char *node, 
const char *prop,
  }

  #ifdef CONFIG_OF_STDOUT_VIA_ALIAS
+
+#ifdef CONFIG_SERIAL_MULTI
+static void fdt_fill_sername(char *sername, size_t maxlen)
+{
+	const char *outname = stdio_devices[stdout]->name;
+
+	if (strcmp(outname, "serial") > 0)
+		strncpy(sername, outname, maxlen);
+
+	/* eserial? */
+	if (strcmp(outname + 1, "serial") > 0)
+		strncpy(sername, outname + 1, maxlen);
+}
+#else
+static inline void fdt_fill_sername(char *sername, size_t maxlen)
+{
+	sprintf(sername, "serial%d", CONFIG_CONS_INDEX - 1);
+}
+#endif /* CONFIG_SERIAL_MULTI */
+
  static int fdt_fixup_stdout(void *fdt, int chosenoff)
  {
  	int err = 0;
@@ -98,7 +116,7 @@ static int fdt_fixup_stdout(void *fdt, int chosenoff)
  	char sername[9] = { 0 };
  	const char *path;

-	sprintf(sername, "serial%d", CONFIG_CONS_INDEX - 1);
+	fdt_fill_sername(sername, sizeof(sername) - 1);

  	err = node = fdt_path_offset(fdt, "/aliases");
  	if (node >= 0) {
-- 
1.6.3.3

Original patch:

> Currently fdt_fixup_stdout() is using hard-coded CONFIG_CONS_INDEX
> constant. With multi-serial support, the CONS_INDEX may no longer
> represent actual console, so we should try to extract port number
> from the current stdio device name instead of always hard-coding the
> constant value.
> 
> Signed-off-by: Anton Vorontsov <avorontsov <at> ru.mvista.com>
> ---
>  common/fdt_support.c |   22 +++++++++++++++++++++-
>  1 files changed, 21 insertions(+), 1 deletions(-)
> 
> diff --git a/common/fdt_support.c b/common/fdt_support.c
> index 89164a1..e01303a 100644
> --- a/common/fdt_support.c
> +++ b/common/fdt_support.c
> @@ -22,6 +22,7 @@
>   */
> 
>  #include <common.h>
> +#include <stdio_dev.h>
>  #include <linux/ctype.h>
>  #include <linux/types.h>
>  #include <asm/global_data.h>
> @@ -90,6 +91,23 @@ int fdt_find_and_setprop(void *fdt, const char *node, const char *prop,
>  }
> 
>  #ifdef CONFIG_OF_STDOUT_VIA_ALIAS
> +
> +#ifdef CONFIG_SERIAL_MULTI
> +static void fdt_fill_multisername(char *sername, size_t maxlen)
> +{
> +	const char *outname = stdio_devices[stdout]->name;
> +
> +	if (strcmp(outname, "serial") > 0)
> +		strncpy(sername, outname, maxlen);
> +
> +	/* eserial? */
> +	if (strcmp(outname + 1, "serial") > 0)
> +		strncpy(sername, outname + 1, maxlen);
> +}
> +#else
> +static inline void fdt_fill_multisername(char *sername, size_t maxlen) {}
> +#endif /* CONFIG_SERIAL_MULTI */
> +
>  static int fdt_fixup_stdout(void *fdt, int chosenoff)
>  {
>  	int err = 0;
> @@ -98,7 +116,9 @@ static int fdt_fixup_stdout(void *fdt, int chosenoff)
>  	char sername[9] = { 0 };
>  	const char *path;
> 
> -	sprintf(sername, "serial%d", CONFIG_CONS_INDEX - 1);
> +	fdt_fill_multisername(sername, sizeof(sername) - 1);
> +	if (!sername[0])
> +		sprintf(sername, "serial%d", CONFIG_CONS_INDEX - 1);
> 
>  	err = node = fdt_path_offset(fdt, "/aliases");
>  	if (node >= 0) {
> -- 
> 1.6.3.3

  reply	other threads:[~2009-09-16 12:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-19 18:37 [U-Boot] [PATCH 1/7] fdt_support: Add multi-serial support for stdout fixup Anton Vorontsov
2009-09-16  4:18 ` Kumar Gala
2009-09-16 12:59   ` Jerry Van Baren [this message]
2009-09-16 15:17     ` Anton Vorontsov
2009-09-16 15:27       ` Jerry Van Baren
  -- strict thread matches above, loose matches on Subject: below --
2009-10-15 13:46 [U-Boot] [PATCH 0/7] Some patches for MPC8569E-MDS Anton Vorontsov
2009-10-15 13:47 ` [U-Boot] [PATCH 1/7] fdt_support: Add multi-serial support for stdout fixup Anton Vorontsov
2009-10-22 14:24   ` Kumar Gala
2009-10-22 14:47     ` Jerry Van Baren
2009-10-27  2:39   ` Kumar Gala

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=4AB0E122.4010502@ge.com \
    --to=gerald.vanbaren@ge.com \
    --cc=u-boot@lists.denx.de \
    /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