mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] u_serial: add setbrg to be able to use loadb & co
@ 2012-01-04 10:35 Eric Bénard
  2012-01-04 11:45 ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 6+ messages in thread
From: Eric Bénard @ 2012-01-04 10:35 UTC (permalink / raw)
  To: barebox

Signed-off-by: Eric Bénard <eric@eukrea.com>
---
 drivers/usb/gadget/u_serial.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
index e310c3a..980b527 100644
--- a/drivers/usb/gadget/u_serial.c
+++ b/drivers/usb/gadget/u_serial.c
@@ -420,6 +420,10 @@ static int serial_getc(struct console_device *cdev)
 static void serial_flush(struct console_device *cdev)
 {
 }
+static int serial_setbaudrate(struct console_device *cdev, int baudrate)
+{
+	return 0;
+}
 
 static struct console_device *mycdev;
 
@@ -469,6 +473,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
 	cdev->putc = serial_putc;
 	cdev->getc = serial_getc;
 	cdev->flush = serial_flush;
+	cdev->setbrg = serial_setbaudrate;
 	console_register(cdev);
 	mycdev = cdev;
 
-- 
1.7.7.5


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] u_serial: add setbrg to be able to use loadb & co
  2012-01-04 10:35 [PATCH] u_serial: add setbrg to be able to use loadb & co Eric Bénard
@ 2012-01-04 11:45 ` Jean-Christophe PLAGNIOL-VILLARD
  2012-01-04 15:01   ` [PATCH] loadb: only try to change the baudrate if the driver has this feature Eric Bénard
  0 siblings, 1 reply; 6+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-01-04 11:45 UTC (permalink / raw)
  To: Eric Bénard; +Cc: barebox

On 11:35 Wed 04 Jan     , Eric Bénard wrote:
> Signed-off-by: Eric Bénard <eric@eukrea.com>
> ---
>  drivers/usb/gadget/u_serial.c |    5 +++++
>  1 files changed, 5 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
> index e310c3a..980b527 100644
> --- a/drivers/usb/gadget/u_serial.c
> +++ b/drivers/usb/gadget/u_serial.c
> @@ -420,6 +420,10 @@ static int serial_getc(struct console_device *cdev)
>  static void serial_flush(struct console_device *cdev)
>  {
>  }
> +static int serial_setbaudrate(struct console_device *cdev, int baudrate)
> +{
> +	return 0;
> +}
>  
>  static struct console_device *mycdev;
>  
> @@ -469,6 +473,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
>  	cdev->putc = serial_putc;
>  	cdev->getc = serial_getc;
>  	cdev->flush = serial_flush;
> +	cdev->setbrg = serial_setbaudrate;
>  	console_register(cdev);
>  	mycdev = cdev;

if no setbrg this need to be manage at framework level

Best Regards,
J.

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] loadb: only try to change the baudrate if the driver has this feature
  2012-01-04 11:45 ` Jean-Christophe PLAGNIOL-VILLARD
@ 2012-01-04 15:01   ` Eric Bénard
  2012-01-04 16:37     ` Sascha Hauer
  0 siblings, 1 reply; 6+ messages in thread
From: Eric Bénard @ 2012-01-04 15:01 UTC (permalink / raw)
  To: barebox

this allows loadb to work over usbserial gadget

Signed-off-by: Eric Bénard <eric@eukrea.com>
---
 commands/loadb.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/commands/loadb.c b/commands/loadb.c
index 439a83a..d60340e 100644
--- a/commands/loadb.c
+++ b/commands/loadb.c
@@ -690,12 +690,13 @@ static int do_load_serial_bin(struct command *cmdtp, int argc, char *argv[])
 {
 	ulong offset = 0;
 	ulong addr;
-	int load_baudrate = 0, current_baudrate;
+	int load_baudrate = 0, current_baudrate = 0;
 	int rcode = 0;
 	int opt;
 	int open_mode = O_WRONLY;
 	char *output_file = NULL;
 	struct console_device *cdev = NULL;
+	unsigned char baudrate[16];
 
 	while ((opt = getopt(argc, argv, "f:b:o:c")) > 0) {
 		switch (opt) {
@@ -722,7 +723,8 @@ static int do_load_serial_bin(struct command *cmdtp, int argc, char *argv[])
 		printf("%s:No console device with STDIN and STDOUT\n", argv[0]);
 		return -ENODEV;
 	}
-	current_baudrate = (int)simple_strtoul(dev_get_param(&cdev->class_dev, "baudrate"), NULL, 10);
+	if (dev_get_param(&cdev->class_dev, "baudrate") != NULL)
+		current_baudrate = (int)simple_strtoul(dev_get_param(&cdev->class_dev, "baudrate"), NULL, 10);
 
 	/* Load Defaults */
 	if (load_baudrate == 0)
-- 
1.7.7.5


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] loadb: only try to change the baudrate if the driver has this feature
  2012-01-04 15:01   ` [PATCH] loadb: only try to change the baudrate if the driver has this feature Eric Bénard
@ 2012-01-04 16:37     ` Sascha Hauer
  2012-01-04 17:04       ` Eric Bénard
  0 siblings, 1 reply; 6+ messages in thread
From: Sascha Hauer @ 2012-01-04 16:37 UTC (permalink / raw)
  To: Eric Bénard; +Cc: barebox

On Wed, Jan 04, 2012 at 04:01:16PM +0100, Eric Bénard wrote:
> this allows loadb to work over usbserial gadget

I like the original approach better. The baudrate setting has no meaning
in hardware for the usb serial gadget. This means that we can happily
support every baudrate requested by adding a fake setbrg function.

If we had some global console_setbrg function I would agree
Jean-Christophe, this function should return cdev->setbrg or
-ENOSYS if the driver does not have a setbrg function. Still the
usb gadget serial driver should have a fake setbrg function for
the reason explained above.

> 
> Signed-off-by: Eric Bénard <eric@eukrea.com>
> ---
>  commands/loadb.c |    6 ++++--
>  1 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/commands/loadb.c b/commands/loadb.c
> index 439a83a..d60340e 100644
> --- a/commands/loadb.c
> +++ b/commands/loadb.c
> @@ -690,12 +690,13 @@ static int do_load_serial_bin(struct command *cmdtp, int argc, char *argv[])
>  {
>  	ulong offset = 0;
>  	ulong addr;
> -	int load_baudrate = 0, current_baudrate;
> +	int load_baudrate = 0, current_baudrate = 0;
>  	int rcode = 0;
>  	int opt;
>  	int open_mode = O_WRONLY;
>  	char *output_file = NULL;
>  	struct console_device *cdev = NULL;
> +	unsigned char baudrate[16];
>  
>  	while ((opt = getopt(argc, argv, "f:b:o:c")) > 0) {
>  		switch (opt) {
> @@ -722,7 +723,8 @@ static int do_load_serial_bin(struct command *cmdtp, int argc, char *argv[])
>  		printf("%s:No console device with STDIN and STDOUT\n", argv[0]);
>  		return -ENODEV;
>  	}
> -	current_baudrate = (int)simple_strtoul(dev_get_param(&cdev->class_dev, "baudrate"), NULL, 10);
> +	if (dev_get_param(&cdev->class_dev, "baudrate") != NULL)
> +		current_baudrate = (int)simple_strtoul(dev_get_param(&cdev->class_dev, "baudrate"), NULL, 10);
>  

This command could be improved by doing all this baudrate stuff only
when the -b option is given. This way we default to the current
baudrate (which seems sane in the cases I can think of)

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 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] loadb: only try to change the baudrate if the driver has this feature
  2012-01-04 16:37     ` Sascha Hauer
@ 2012-01-04 17:04       ` Eric Bénard
  2012-01-05  8:28         ` Sascha Hauer
  0 siblings, 1 reply; 6+ messages in thread
From: Eric Bénard @ 2012-01-04 17:04 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

Hi Sascha,

Le Wed, 4 Jan 2012 17:37:56 +0100,
Sascha Hauer <s.hauer@pengutronix.de> a écrit :

> On Wed, Jan 04, 2012 at 04:01:16PM +0100, Eric Bénard wrote:
> > this allows loadb to work over usbserial gadget
> 
> I like the original approach better. The baudrate setting has no meaning
> in hardware for the usb serial gadget. This means that we can happily
> support every baudrate requested by adding a fake setbrg function.
> 
> If we had some global console_setbrg function I would agree
> Jean-Christophe, this function should return cdev->setbrg or
> -ENOSYS if the driver does not have a setbrg function. Still the
> usb gadget serial driver should have a fake setbrg function for
> the reason explained above.
> 
> This command could be improved by doing all this baudrate stuff only
> when the -b option is given. This way we default to the current
> baudrate (which seems sane in the cases I can think of)
> 
OK so in conclusion, what do you prefer : 
- applying " u_serial: add setbrg to be able to use loadb & co"
- a fix for loadb to only handle baudrate change if -b option is given
- or maybe both options ? ;-)

?
Eric


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] loadb: only try to change the baudrate if the driver has this feature
  2012-01-04 17:04       ` Eric Bénard
@ 2012-01-05  8:28         ` Sascha Hauer
  0 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2012-01-05  8:28 UTC (permalink / raw)
  To: Eric Bénard; +Cc: barebox

On Wed, Jan 04, 2012 at 06:04:23PM +0100, Eric Bénard wrote:
> Hi Sascha,
> 
> Le Wed, 4 Jan 2012 17:37:56 +0100,
> Sascha Hauer <s.hauer@pengutronix.de> a écrit :
> 
> > On Wed, Jan 04, 2012 at 04:01:16PM +0100, Eric Bénard wrote:
> > > this allows loadb to work over usbserial gadget
> > 
> > I like the original approach better. The baudrate setting has no meaning
> > in hardware for the usb serial gadget. This means that we can happily
> > support every baudrate requested by adding a fake setbrg function.
> > 
> > If we had some global console_setbrg function I would agree
> > Jean-Christophe, this function should return cdev->setbrg or
> > -ENOSYS if the driver does not have a setbrg function. Still the
> > usb gadget serial driver should have a fake setbrg function for
> > the reason explained above.
> > 
> > This command could be improved by doing all this baudrate stuff only
> > when the -b option is given. This way we default to the current
> > baudrate (which seems sane in the cases I can think of)
> > 
> OK so in conclusion, what do you prefer : 
> - applying " u_serial: add setbrg to be able to use loadb & co"
> - a fix for loadb to only handle baudrate change if -b option is given
> - or maybe both options ? ;-)

Yes, both. The -b option patch was just something I saw when looking at
your patch.

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 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-01-05  8:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-04 10:35 [PATCH] u_serial: add setbrg to be able to use loadb & co Eric Bénard
2012-01-04 11:45 ` Jean-Christophe PLAGNIOL-VILLARD
2012-01-04 15:01   ` [PATCH] loadb: only try to change the baudrate if the driver has this feature Eric Bénard
2012-01-04 16:37     ` Sascha Hauer
2012-01-04 17:04       ` Eric Bénard
2012-01-05  8:28         ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox