Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=bf5e5834bffc62b50cd4a201804506eb11ef1af8
Commit:     bf5e5834bffc62b50cd4a201804506eb11ef1af8
Parent:     cf0594625083111ae522496dc1c256f7476939c2
Author:     Alan Cox <[EMAIL PROTECTED]>
AuthorDate: Tue Jan 8 14:55:51 2008 +0000
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Tue Jan 8 16:16:34 2008 -0800

    pl2303: Fix mode switching regression
    
    Cleaning out all the incorrect 'no change made' checks for termios
    settings showed up a problem with the PL2303. The hardware here seems to
    lose sync and bits if you tell it to make no changes. This shows up with
    a real world application.
    
    To fix this the driver check for meaningful hardware changes is restored
    but doing the tests correctly and as a tty layer function so it doesn't
    get duplicated wrongly everywhere if other drivers turn out to need it.
    
    Signed-off-by: Alan Cox <[EMAIL PROTECTED]>
    Tested-by: Mirko Parthey <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
---
 drivers/char/tty_ioctl.c    |   19 +++++++++++++++++++
 drivers/usb/serial/pl2303.c |    7 +++++++
 include/linux/tty.h         |    1 +
 3 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/drivers/char/tty_ioctl.c b/drivers/char/tty_ioctl.c
index e02d592..d4b6d64 100644
--- a/drivers/char/tty_ioctl.c
+++ b/drivers/char/tty_ioctl.c
@@ -365,6 +365,25 @@ void tty_termios_copy_hw(struct ktermios *new, struct 
ktermios *old)
 EXPORT_SYMBOL(tty_termios_copy_hw);
 
 /**
+ *     tty_termios_hw_change   -       check for setting change
+ *     @a: termios
+ *     @b: termios to compare
+ *
+ *     Check if any of the bits that affect a dumb device have changed
+ *     between the two termios structures, or a speed change is needed.
+ */
+
+int tty_termios_hw_change(struct ktermios *a, struct ktermios *b)
+{
+       if (a->c_ispeed != b->c_ispeed || a->c_ospeed != b->c_ospeed)
+               return 1;
+       if ((a->c_cflag ^ b->c_cflag) & ~(HUPCL | CREAD | CLOCAL))
+               return 1;
+       return 0;
+}
+EXPORT_SYMBOL(tty_termios_hw_change);
+
+/**
  *     change_termios          -       update termios values
  *     @tty: tty to update
  *     @new_termios: desired new value
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index cf8add9..0da1df9 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -483,6 +483,13 @@ static void pl2303_set_termios(struct usb_serial_port 
*port,
        }
        spin_unlock_irqrestore(&priv->lock, flags);
 
+       /* The PL2303 is reported to lose bytes if you change
+          serial settings even to the same values as before. Thus
+          we actually need to filter in this specific case */
+
+       if (!tty_termios_hw_change(port->tty->termios, old_termios))
+               return;
+
        cflag = port->tty->termios->c_cflag;
 
        buf = kzalloc(7, GFP_KERNEL);
diff --git a/include/linux/tty.h b/include/linux/tty.h
index c555f54..defd2ab 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -319,6 +319,7 @@ extern speed_t tty_termios_input_baud_rate(struct ktermios 
*termios);
 extern void tty_termios_encode_baud_rate(struct ktermios *termios, speed_t 
ibaud, speed_t obaud);
 extern void tty_encode_baud_rate(struct tty_struct *tty, speed_t ibaud, 
speed_t obaud);
 extern void tty_termios_copy_hw(struct ktermios *new, struct ktermios *old);
+extern int tty_termios_hw_change(struct ktermios *a, struct ktermios *b);
 
 extern struct tty_ldisc *tty_ldisc_ref(struct tty_struct *);
 extern void tty_ldisc_deref(struct tty_ldisc *);
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to