On Thu, Oct 31, 2013 at 01:09:55PM +0200, Mika Westerberg wrote:
> On Wed, Oct 30, 2013 at 11:14:34PM +0100, Frank Schäfer wrote:
> > Hmm... try to replace the whole pl2303.c from 3.12 with the one from 3.11.
> > If it makes no difference, it's not a pl2303 issue.
> 
> I did that and the 3.11 pl2303.c works (whereas 3.12 doesn't).
> 
> Can you tell me why do we even want to use this "divisor" based calculation
> if we can do the same with direct method?
> 
> I mean why the driver can't do this:
> 
>  1) Try direct method for *all* chips.
>  2) If it succeeds, use that value. Then we don't get any difference
>     between actual and set baud rate.
>  3) If it fails, then and only then use "divisor" based method.
> 
> I would expect that the above cures my problem and possibly others who
> might have affected by this regression.

Something like the patch below.

diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index bedf8e47713b..85f3fa4afc81 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -461,11 +461,11 @@ static void pl2303_encode_baudrate(struct tty_struct *tty,
                                        enum pl2303_type type,
                                        u8 buf[4])
 {
-       int baud;
+       int baud_req, baud;
 
-       baud = tty_get_baud_rate(tty);
-       dev_dbg(&port->dev, "baud requested = %d\n", baud);
-       if (!baud)
+       baud_req = tty_get_baud_rate(tty);
+       dev_dbg(&port->dev, "baud requested = %d\n", baud_req);
+       if (!baud_req)
                return;
        /*
         * There are two methods for setting/encoding the baud rate
@@ -480,10 +480,10 @@ static void pl2303_encode_baudrate(struct tty_struct *tty,
         * the device likely uses the same baud rate generator for both methods
         * so that there is likley no difference.
         */
-       if (type == type_0 || type == type_1 || type == HX_CLONE)
-               baud = pl2303_baudrate_encode_direct(baud, type, buf);
-       else
-               baud = pl2303_baudrate_encode_divisor(baud, type, buf);
+       baud = pl2303_baudrate_encode_direct(baud_req, type, buf);
+       if (baud != baud_req)
+               baud = pl2303_baudrate_encode_divisor(baud_req, type, buf);
+
        /* Save resulting baud rate */
        tty_encode_baud_rate(tty, baud, baud);
        dev_dbg(&port->dev, "baud set = %d\n", baud);
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to