Skip to contentSkip to conversation

u_serial: add setbrg to be able to use loadb & co

PATCH In review Eric Bénard 3 participants 6 messages Jan 4, 2012 – Jan 5, 2012 USB

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 u_serial: add setbrg to be able to use loadb & co

---
 drivers/usb/gadget/u_serial.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
drivers/usb/gadget/u_serial.c +5 -0
index e310c3a..980b527 100644
@@ -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;
 
Signature · 7 lines
1.7.7.5


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw
Quoted 21 lines · Eric Bénard
---
 drivers/usb/gadget/u_serial.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
drivers/usb/gadget/u_serial.c +4 -0
index e310c3a..980b527 100644
@@ -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;
 

drivers/usb/gadget/u_serial.c int gserial_connect(struct gserial *gser, u8 port_num) · line 478

Quoted 6 lines
drivers/usb/gadget/u_serial.c +1 -0
@@ -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
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#2 lore raw

PATCH 1/1 loadb: only try to change the baudrate if the driver has this feature

this allows loadb to work over usbserial gadget

---
 commands/loadb.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
commands/loadb.c +4 -2
index 439a83a..d60340e 100644
@@ -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)
Signature · 7 lines
1.7.7.5


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#3 lore raw

Re: [PATCH] loadb: only try to change the baudrate if the driver has this feature

Quoted 1 line · Eric Bénard

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.

Quoted 26 lines
---
 commands/loadb.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
commands/loadb.c +2 -1
index 439a83a..d60340e 100644
@@ -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) {

commands/loadb.c static int do_load_serial_bin(struct command *cmdtp, int argc, char *argv[]) · line 728

Quoted 7 lines
commands/loadb.c +2 -1
@@ -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

Signature · 9 lines
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
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#4 lore raw

Re: [PATCH] loadb: only try to change the baudrate if the driver has this feature

Hi Sascha,

Quoted 13 lines · Sascha Hauer
Quoted 1 line · Eric Bénard

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.

Quoted 4 lines

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
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#5 lore raw

Re: [PATCH] loadb: only try to change the baudrate if the driver has this feature

Quoted 18 lines · Eric Bénard

Hi Sascha,

Quoted 13 lines · Sascha Hauer
Quoted 1 line · Eric Bénard

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.

Quoted 8 lines
Quoted 4 lines

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

Signature · 9 lines
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
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox