Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] jsm: fix for high baud rates problem

Scott Kilau <Scott_Kilau@digi.com>

Digi serial port console doesn't work when baud rates are set higher than
38400. So the lookup table and code in jsm_neo.c has been modified and
tested. Please let me have the feed-back.

Signed-off-by: V.Ananda Krishnan <mansarov@us.ibm.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

V. Ananda Krishnan and committed by
Linus Torvalds
bb3c190e bfaa1dee

+37 -46
+37 -46
drivers/serial/jsm/jsm_neo.c
··· 965 965 baud = ch->ch_custom_speed; 966 966 if (ch->ch_flags & CH_BAUD0) 967 967 ch->ch_flags &= ~(CH_BAUD0); 968 - } else { 969 - int iindex = 0; 970 - int jindex = 0; 968 + } else { 969 + int i; 970 + unsigned int cflag; 971 + static struct { 972 + unsigned int rate; 973 + unsigned int cflag; 974 + } baud_rates[] = { 975 + { 921600, B921600 }, 976 + { 460800, B460800 }, 977 + { 230400, B230400 }, 978 + { 115200, B115200 }, 979 + { 57600, B57600 }, 980 + { 38400, B38400 }, 981 + { 19200, B19200 }, 982 + { 9600, B9600 }, 983 + { 4800, B4800 }, 984 + { 2400, B2400 }, 985 + { 1200, B1200 }, 986 + { 600, B600 }, 987 + { 300, B300 }, 988 + { 200, B200 }, 989 + { 150, B150 }, 990 + { 134, B134 }, 991 + { 110, B110 }, 992 + { 75, B75 }, 993 + { 50, B50 }, 994 + }; 971 995 972 - const u64 bauds[4][16] = { 973 - { 974 - 0, 50, 75, 110, 975 - 134, 150, 200, 300, 976 - 600, 1200, 1800, 2400, 977 - 4800, 9600, 19200, 38400 }, 978 - { 979 - 0, 57600, 115200, 230400, 980 - 460800, 150, 200, 921600, 981 - 600, 1200, 1800, 2400, 982 - 4800, 9600, 19200, 38400 }, 983 - { 984 - 0, 57600, 76800, 115200, 985 - 131657, 153600, 230400, 460800, 986 - 921600, 1200, 1800, 2400, 987 - 4800, 9600, 19200, 38400 }, 988 - { 989 - 0, 57600, 115200, 230400, 990 - 460800, 150, 200, 921600, 991 - 600, 1200, 1800, 2400, 992 - 4800, 9600, 19200, 38400 } 993 - }; 994 - 995 - baud = C_BAUD(ch->uart_port.info->tty) & 0xff; 996 - 997 - if (ch->ch_c_cflag & CBAUDEX) 998 - iindex = 1; 999 - 1000 - jindex = baud; 1001 - 1002 - if ((iindex >= 0) && (iindex < 4) && (jindex >= 0) && (jindex < 16)) 1003 - baud = bauds[iindex][jindex]; 1004 - else { 1005 - jsm_printk(IOCTL, DEBUG, &ch->ch_bd->pci_dev, 1006 - "baud indices were out of range (%d)(%d)", 1007 - iindex, jindex); 1008 - baud = 0; 996 + cflag = C_BAUD(ch->uart_port.info->tty); 997 + baud = 9600; 998 + for (i = 0; i < ARRAY_SIZE(baud_rates); i++) { 999 + if (baud_rates[i].cflag == cflag) { 1000 + baud = baud_rates[i].rate; 1001 + break; 1009 1002 } 1010 - 1011 - if (baud == 0) 1012 - baud = 9600; 1013 - 1014 - if (ch->ch_flags & CH_BAUD0) 1015 - ch->ch_flags &= ~(CH_BAUD0); 1016 1003 } 1004 + 1005 + if (ch->ch_flags & CH_BAUD0) 1006 + ch->ch_flags &= ~(CH_BAUD0); 1007 + } 1017 1008 1018 1009 if (ch->ch_c_cflag & PARENB) 1019 1010 lcr |= UART_LCR_PARITY;