fdt_support: Add multi-serial support for stdout fixup
PATCH 1/7 fdt_support: Add multi-serial support for stdout fixup
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.
--- common/fdt_support.c | 22 +++++++++++++++++++++- 1 files changed, 21 insertions(+), 1 deletions(-)
common/fdt_support.c +21 -1
@@ -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 ) {
Signature · 1 line
1.6.3.3
PATCH 1/7 fdt_support: Add multi-serial support for stdout fixup
Quoted 10 lines · Anton Vorontsov
Currently
fdt_fixup_stdout()is using hard-codedCONFIG_CONS_INDEXconstant. With multi-serial support, theCONS_INDEXmay 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 <[email protected]>---
common/fdt_support.c| 22 +++++++++++++++++++++-1 files changed, 21 insertions(+), 1 deletions(-)
Should get some Ack from Jerry.
- k
PATCH 1/7 fdt_support: Add multi-serial support for stdout fixup
Hi Kumar, Anton,
Quoted 9 lines · Kumar Gala
Quoted 6 lines · Anton Vorontsov
Currently
fdt_fixup_stdout()is using hard-codedCONFIG_CONS_INDEXconstant. With multi-serial support, theCONS_INDEXmay 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.
Quoted 8 lines
Quoted 4 lines
Signed-off-by Anton Vorontsov <[email protected]>---
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
or you can verify and adopt my proposed change (more work :-() and add a
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.
--- common/fdt_support.c | 22 +++++++++++++++++++++- 1 files changed, 21 insertions(+), 1 deletions(-)
common/fdt_support.c +1 -0
@@ -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) {
Signature · 3 lines
1.6.3.3 Original patch:
Quoted 60 lines
Currently
fdt_fixup_stdout()is using hard-codedCONFIG_CONS_INDEXconstant. With multi-serial support, theCONS_INDEXmay 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(-)common/fdt_support.c +21
-1@@ -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 ) {Signature · 1 line
1.6.3.3
PATCH 1/7 fdt_support: Add multi-serial support for stdout fixup
Thanks for review Jerry.
On Wed, Sep 16, 2009 at 08:59:14AM -0400, Jerry Van Baren wrote:
[...]
Quoted 13 lines
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 <[email protected]>or you can verify and adopt my proposed change (more work :-() and add a
Signed-off-by Gerald Van Baren <[email protected]>to Anton's s-o-b.
Thanks,
gvb
------------------------------------------------------------------------
[...]
Review
Quoted 9 lines
#ifdef
CONFIG_OF_STDOUT_VIA_ALIAS(quoted diff) +8
-0+ +#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);
(1)
Review
Quoted 8 lines
(quoted diff) +8
-0+ /* 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);
This case is also needed with multiserial, since 'serial' is what you get by default, and (1) doesn't account 'serial' name.
So, we can either leave the patch as, or duplicate some code for multiserial case, or do this ugly thing (I quite dislike #ifdef like this, i.e. inside the code flow):
static void fdt_fill_sername(char *sername, size_t maxlen) {
#ifdef CONFIG_SERIAL_MULTI 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); #endif if (!sername[0]) sprintf(sername, "serial%d", CONFIG_CONS_INDEX - 1); }
Though, I'll do whatever you prefer.
Thanks,
Signature · 3 lines
Anton Vorontsov email: cbouatmailru at gmail.com irc://irc.freenode.net/bd2
PATCH 1/7 fdt_support: Add multi-serial support for stdout fixup
Quoted 30 lines · Anton Vorontsov
Thanks for review Jerry.
On Wed, Sep 16, 2009 at 08:59:14AM -0400, Jerry Van Baren wrote:
[...]Quoted 13 lines
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 <[email protected]>or you can verify and adopt my proposed change (more work :-() and add a
Signed-off-by Gerald Van Baren <[email protected]>to Anton's s-o-b.
Thanks,
gvb
------------------------------------------------------------------------[...]
Review
Quoted 9 lines
#ifdef
CONFIG_OF_STDOUT_VIA_ALIAS(quoted diff) +8
-0+ +#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);(1)
Quoted 11 lines
Review
Quoted 8 lines
(quoted diff) +8
-0+ /* 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);This case is also needed with multiserial, since 'serial' is what you get by default, and (1) doesn't account 'serial' name.
Ahh, whups, missed that.
Quoted 3 lines
So, we can either leave the patch as, or duplicate some code for multiserial case, or do this ugly thing (I quite dislike #ifdef like this, i.e. inside the code flow):
[snip]
Quoted 1 line
Though, I'll do whatever you prefer.
Lets use the original patch.
Thanks,
gvb