USB: cypress_m8: allow unstable baud rates
[firefly-linux-kernel-4.4.55.git] / drivers / usb / serial / cypress_m8.c
index a591ebec0f89c0af5d0ece8c3e9685fbe3d80d4f..60c200230bc8955d2da36835d969e0c119486d67 100644 (file)
 #include "cypress_m8.h"
 
 
-#ifdef CONFIG_USB_SERIAL_DEBUG
-       static int debug = 1;
-#else
-       static int debug;
-#endif
+static int debug;
 static int stats;
 static int interval;
+static int unstable_bauds;
 
 /*
  * Version Information
@@ -295,6 +292,9 @@ static int analyze_baud_rate(struct usb_serial_port *port, speed_t new_rate)
        struct cypress_private *priv;
        priv = usb_get_serial_port_data(port);
 
+       if (unstable_bauds)
+               return new_rate;
+
        /*
         * The general purpose firmware for the Cypress M8 allows for
         * a maximum speed of 57600bps (I have no idea whether DeLorme
@@ -356,15 +356,12 @@ static int cypress_serial_control(struct tty_struct *tty,
 
        switch (cypress_request_type) {
        case CYPRESS_SET_CONFIG:
-               new_baudrate = priv->baud_rate;
                /* 0 means 'Hang up' so doesn't change the true bit rate */
-               if (baud_rate == 0)
-                       new_baudrate = priv->baud_rate;
-               /* Change of speed ? */
-               else if (baud_rate != priv->baud_rate) {
+               new_baudrate = priv->baud_rate;
+               if (baud_rate && baud_rate != priv->baud_rate) {
                        dbg("%s - baud rate is changing", __func__);
                        retval = analyze_baud_rate(port, baud_rate);
-                       if (retval >=  0) {
+                       if (retval >= 0) {
                                new_baudrate = retval;
                                dbg("%s - New baud rate set to %d",
                                    __func__, new_baudrate);
@@ -1650,3 +1647,5 @@ module_param(stats, bool, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(stats, "Enable statistics or not");
 module_param(interval, int, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(interval, "Overrides interrupt interval");
+module_param(unstable_bauds, bool, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(unstable_bauds, "Allow unstable baud rates");