Allow for any baud rate within a range rather than having a fixed list of
authorHasso Tepper <hasso@dragonflybsd.org>
Mon, 26 Nov 2007 10:52:33 +0000 (10:52 +0000)
committerHasso Tepper <hasso@dragonflybsd.org>
Mon, 26 Nov 2007 10:52:33 +0000 (10:52 +0000)
rates.

Obtained-from: OpenBSD

sys/dev/usbmisc/uslcom/uslcom.c

index a7066ee..f3ed98a 100644 (file)
@@ -1,5 +1,5 @@
-/*     $DragonFly: src/sys/dev/usbmisc/uslcom/uslcom.c,v 1.9 2007/11/06 20:25:26 hasso Exp $   */
-/*     $OpenBSD: uslcom.c,v 1.12 2007/06/13 06:25:03 mbalmer Exp $     */
+/* $DragonFly: src/sys/dev/usbmisc/uslcom/uslcom.c,v 1.10 2007/11/26 10:52:33 hasso Exp $ */
+/* $OpenBSD: uslcom.c,v 1.17 2007/11/24 10:52:12 jsg Exp $ */
 
 /*
  * Copyright (c) 2006 Jonathan Gray <jsg@openbsd.org>
@@ -361,32 +361,17 @@ uslcom_param(void *vsc, int portno, struct termios *t)
        usb_device_request_t req;
        int data;
 
-       switch (t->c_ospeed) {
-       case 600:
-       case 1200:
-       case 1800:
-       case 2400:
-       case 4800:
-       case 9600:
-       case 19200:
-       case 38400:
-       case 57600:
-       case 115200:
-       case 230400:
-       case 460800:
-       case 921600:
-               req.bmRequestType = USLCOM_WRITE;
-               req.bRequest = USLCOM_BAUD_RATE;
-               USETW(req.wValue, USLCOM_BAUD_REF / t->c_ospeed);
-               USETW(req.wIndex, portno);
-               USETW(req.wLength, 0);
-               err = usbd_do_request(sc->sc_ucom.sc_udev, &req, NULL);
-               if (err)
-                       return (EIO);
-               break;
-       default:
+       if (t->c_ospeed <= 0 || t->c_ospeed > 921600)
                return (EINVAL);
-       }
+
+       req.bmRequestType = USLCOM_WRITE;
+       req.bRequest = USLCOM_BAUD_RATE;
+       USETW(req.wValue, USLCOM_BAUD_REF / t->c_ospeed);
+       USETW(req.wIndex, portno);
+       USETW(req.wLength, 0);
+       err = usbd_do_request(sc->sc_ucom.sc_udev, &req, NULL);
+       if (err)
+               return (EIO);
 
        if (ISSET(t->c_cflag, CSTOPB))
                data = USLCOM_STOP_BITS_2;