Patchwork [U-Boot,1/2] serial: Remove the "serial" console device

login
register
mail settings
Submitter Joe Hershberger
Date Nov. 1, 2012, 9:46 p.m.
Message ID <1351806388-27322-1-git-send-email-joe.hershberger@ni.com>
Download mbox | patch
Permalink /patch/196389/
State Under Review
Delegated to: Marek Vasut
Headers show

Comments

Joe Hershberger - Nov. 1, 2012, 9:46 p.m.
Each serial device is added as a console device.  There was also the
"serial" device that points to the most-recently-assigned-to-some-
console-handle device.  This can be confusing.  Instead, only show the
actual serial devices.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
---
 common/console.c | 37 +++++++++++++++++++------------------
 common/stdio.c   | 12 +-----------
 2 files changed, 20 insertions(+), 29 deletions(-)
Marek Vasut - Nov. 3, 2012, 1:35 a.m.
Dear Joe Hershberger,

> Each serial device is added as a console device.  There was also the
> "serial" device that points to the most-recently-assigned-to-some-
> console-handle device.  This can be confusing.  Instead, only show the
> actual serial devices.
> 
> Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
> ---
>  common/console.c | 37 +++++++++++++++++++------------------
>  common/stdio.c   | 12 +-----------
>  2 files changed, 20 insertions(+), 29 deletions(-)
> 
[...]

You also remove the nulldev, shouldn't it go via separate patch? ... but 
otherwise it's good.

Best regards,
Marek Vasut
Joe Hershberger - Nov. 5, 2012, 12:20 a.m.
Hi Marek,

On Fri, Nov 2, 2012 at 8:35 PM, Marek Vasut <marex@denx.de> wrote:
> Dear Joe Hershberger,
>
>> Each serial device is added as a console device.  There was also the
>> "serial" device that points to the most-recently-assigned-to-some-
>> console-handle device.  This can be confusing.  Instead, only show the
>> actual serial devices.
>>
>> Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
>> ---
>>  common/console.c | 37 +++++++++++++++++++------------------
>>  common/stdio.c   | 12 +-----------
>>  2 files changed, 20 insertions(+), 29 deletions(-)
>>
> [...]
>
> You also remove the nulldev, shouldn't it go via separate patch? ... but
> otherwise it's good.

I'm not sure what you mean.  Where in this patch do I remove nulldev?
That's the next patch.
Marek Vasut - Nov. 5, 2012, 11:11 p.m.
Dear Joe Hershberger,

> Hi Marek,
> 
> On Fri, Nov 2, 2012 at 8:35 PM, Marek Vasut <marex@denx.de> wrote:
> > Dear Joe Hershberger,
> > 
> >> Each serial device is added as a console device.  There was also the
> >> "serial" device that points to the most-recently-assigned-to-some-
> >> console-handle device.  This can be confusing.  Instead, only show the
> >> actual serial devices.
> >> 
> >> Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
> >> ---
> >> 
> >>  common/console.c | 37 +++++++++++++++++++------------------
> >>  common/stdio.c   | 12 +-----------
> >>  2 files changed, 20 insertions(+), 29 deletions(-)
> > 
> > [...]
> > 
> > You also remove the nulldev, shouldn't it go via separate patch? ... but
> > otherwise it's good.
> 
> I'm not sure what you mean.  Where in this patch do I remove nulldev?
> That's the next patch.

The adjustment in common/stdio.c

Best regards,
Marek Vasut
Joe Hershberger - Nov. 5, 2012, 11:45 p.m.
Hi Marek,

On Mon, Nov 5, 2012 at 5:11 PM, Marek Vasut <marex@denx.de> wrote:
> Dear Joe Hershberger,
>
>> Hi Marek,
>>
>> On Fri, Nov 2, 2012 at 8:35 PM, Marek Vasut <marex@denx.de> wrote:
>> > Dear Joe Hershberger,
>> >
>> >> Each serial device is added as a console device.  There was also the
>> >> "serial" device that points to the most-recently-assigned-to-some-
>> >> console-handle device.  This can be confusing.  Instead, only show the
>> >> actual serial devices.
>> >>
>> >> Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
>> >> ---
>> >>
>> >>  common/console.c | 37 +++++++++++++++++++------------------
>> >>  common/stdio.c   | 12 +-----------
>> >>  2 files changed, 20 insertions(+), 29 deletions(-)
>> >
>> > [...]
>> >
>> > You also remove the nulldev, shouldn't it go via separate patch? ... but
>> > otherwise it's good.
>>
>> I'm not sure what you mean.  Where in this patch do I remove nulldev?
>> That's the next patch.
>
> The adjustment in common/stdio.c

I think you are reading the diff wrong.  The only nulldev related
"change" is to not get warnings due to a (now) unused variable.  It
simply guards the definition of the variable with the NULLDEV #ifdef.

-Joe
Marek Vasut - Nov. 5, 2012, 11:55 p.m.
Dear Joe Hershberger,

> Hi Marek,
> 
> On Mon, Nov 5, 2012 at 5:11 PM, Marek Vasut <marex@denx.de> wrote:
> > Dear Joe Hershberger,
> > 
> >> Hi Marek,
> >> 
> >> On Fri, Nov 2, 2012 at 8:35 PM, Marek Vasut <marex@denx.de> wrote:
> >> > Dear Joe Hershberger,
> >> > 
> >> >> Each serial device is added as a console device.  There was also the
> >> >> "serial" device that points to the most-recently-assigned-to-some-
> >> >> console-handle device.  This can be confusing.  Instead, only show
> >> >> the actual serial devices.
> >> >> 
> >> >> Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
> >> >> ---
> >> >> 
> >> >>  common/console.c | 37 +++++++++++++++++++------------------
> >> >>  common/stdio.c   | 12 +-----------
> >> >>  2 files changed, 20 insertions(+), 29 deletions(-)
> >> > 
> >> > [...]
> >> > 
> >> > You also remove the nulldev, shouldn't it go via separate patch? ...
> >> > but otherwise it's good.
> >> 
> >> I'm not sure what you mean.  Where in this patch do I remove nulldev?
> >> That's the next patch.
> > 
> > The adjustment in common/stdio.c
> 
> I think you are reading the diff wrong.  The only nulldev related
> "change" is to not get warnings due to a (now) unused variable.  It
> simply guards the definition of the variable with the NULLDEV #ifdef.

Ok

Best regards,
Marek Vasut

Patch

diff --git a/common/console.c b/common/console.c
index 1177f7d..9cc8197 100644
--- a/common/console.c
+++ b/common/console.c
@@ -26,6 +26,7 @@ 
 #include <malloc.h>
 #include <stdio_dev.h>
 #include <exports.h>
+#include <serial.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -550,6 +551,7 @@  int console_assign(int file, const char *devname)
 {
 	int flag;
 	struct stdio_dev *dev;
+	const char *realdevname;
 
 	/* Check for valid file */
 	switch (file) {
@@ -565,8 +567,12 @@  int console_assign(int file, const char *devname)
 	}
 
 	/* Check for valid device name */
+	if (strcmp(devname, "serial") == 0)
+		realdevname = default_serial_console()->name;
+	else
+		realdevname = devname;
 
-	dev = search_device(flag, devname);
+	dev = search_device(flag, realdevname);
 
 	if (dev)
 		return console_setfile(file, dev);
@@ -657,13 +663,16 @@  int console_init_r(void)
 	}
 	/* if the devices are overwritten or not found, use default device */
 	if (inputdev == NULL) {
-		inputdev  = search_device(DEV_FLAGS_INPUT,  "serial");
+		inputdev  = search_device(DEV_FLAGS_INPUT,
+			default_serial_console()->name);
 	}
 	if (outputdev == NULL) {
-		outputdev = search_device(DEV_FLAGS_OUTPUT, "serial");
+		outputdev = search_device(DEV_FLAGS_OUTPUT,
+			default_serial_console()->name);
 	}
 	if (errdev == NULL) {
-		errdev    = search_device(DEV_FLAGS_OUTPUT, "serial");
+		errdev = search_device(DEV_FLAGS_OUTPUT,
+			default_serial_console()->name);
 	}
 	/* Initializes output console first */
 	if (outputdev != NULL) {
@@ -713,18 +722,10 @@  int console_init_r(void)
 	struct list_head *pos;
 	struct stdio_dev *dev;
 
-#ifdef CONFIG_SPLASH_SCREEN
-	/*
-	 * suppress all output if splash screen is enabled and we have
-	 * a bmp to display. We redirect the output from frame buffer
-	 * console to serial console in this case or suppress it if
-	 * "silent" mode was requested.
-	 */
-	if (getenv("splashimage") != NULL) {
-		if (!(gd->flags & GD_FLG_SILENT))
-			outputdev = search_device (DEV_FLAGS_OUTPUT, "serial");
-	}
-#endif
+	outputdev = search_device(DEV_FLAGS_OUTPUT,
+		default_serial_console()->name);
+	inputdev = search_device(DEV_FLAGS_INPUT,
+		default_serial_console()->name);
 
 	/* Scan devices looking for input and output devices */
 	list_for_each(pos, list) {
@@ -760,13 +761,13 @@  int console_init_r(void)
 
 	gd->flags |= GD_FLG_DEVINIT;	/* device initialization completed */
 
-	stdio_print_current_devices();
-
 	/* Setting environment variables */
 	for (i = 0; i < 3; i++) {
 		setenv(stdio_names[i], stdio_devices[i]->name);
 	}
 
+	stdio_print_current_devices();
+
 #if 0
 	/* If nothing usable installed, use only the initial console */
 	if ((stdio_devices[stdin] == NULL) && (stdio_devices[stdout] == NULL))
diff --git a/common/stdio.c b/common/stdio.c
index 605ff3f..e9bdc0e 100644
--- a/common/stdio.c
+++ b/common/stdio.c
@@ -70,21 +70,11 @@  int nulldev_input(void)
 
 static void drv_system_init (void)
 {
+#ifdef CONFIG_SYS_DEVICE_NULLDEV
 	struct stdio_dev dev;
 
 	memset (&dev, 0, sizeof (dev));
 
-	strcpy (dev.name, "serial");
-	dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM;
-	dev.putc = serial_putc;
-	dev.puts = serial_puts;
-	dev.getc = serial_getc;
-	dev.tstc = serial_tstc;
-	stdio_register (&dev);
-
-#ifdef CONFIG_SYS_DEVICE_NULLDEV
-	memset (&dev, 0, sizeof (dev));
-
 	strcpy (dev.name, "nulldev");
 	dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM;
 	dev.putc = nulldev_putc;