aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Hurley <peter@hurleysoftware.com>2013-12-02 13:56:03 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-12-08 19:56:05 -0500
commit82f91fe092b6eacd82e976b8955443f9fd97d07e (patch)
tree42b967f676e8054a222e58521024babe250b88c9
parent6c67716d64103e5a8e23c45dcdfc76520033d479 (diff)
tty: Always handle NULL flag ptr
Most line disciplines already handle the undocumented NULL flag ptr in their .receive_buf method; however, several don't. Document the NULL flag ptr, and correct handling in the N_MOUSE, N_GSM0710 and N_R394 line disciplines. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/input/serio/serport.c28
-rw-r--r--drivers/tty/n_gsm.c5
-rw-r--r--drivers/tty/n_r3964.c2
-rw-r--r--include/linux/tty_ldisc.h6
4 files changed, 23 insertions, 18 deletions
diff --git a/drivers/input/serio/serport.c b/drivers/input/serio/serport.c
index 8755f5f3ad37..0cb7ef59071b 100644
--- a/drivers/input/serio/serport.c
+++ b/drivers/input/serio/serport.c
@@ -124,7 +124,7 @@ static void serport_ldisc_receive(struct tty_struct *tty, const unsigned char *c
124{ 124{
125 struct serport *serport = (struct serport*) tty->disc_data; 125 struct serport *serport = (struct serport*) tty->disc_data;
126 unsigned long flags; 126 unsigned long flags;
127 unsigned int ch_flags; 127 unsigned int ch_flags = 0;
128 int i; 128 int i;
129 129
130 spin_lock_irqsave(&serport->lock, flags); 130 spin_lock_irqsave(&serport->lock, flags);
@@ -133,18 +133,20 @@ static void serport_ldisc_receive(struct tty_struct *tty, const unsigned char *c
133 goto out; 133 goto out;
134 134
135 for (i = 0; i < count; i++) { 135 for (i = 0; i < count; i++) {
136 switch (fp[i]) { 136 if (fp) {
137 case TTY_FRAME: 137 switch (fp[i]) {
138 ch_flags = SERIO_FRAME; 138 case TTY_FRAME:
139 break; 139 ch_flags = SERIO_FRAME;
140 140 break;
141 case TTY_PARITY: 141
142 ch_flags = SERIO_PARITY; 142 case TTY_PARITY:
143 break; 143 ch_flags = SERIO_PARITY;
144 144 break;
145 default: 145
146 ch_flags = 0; 146 default:
147 break; 147 ch_flags = 0;
148 break;
149 }
148 } 150 }
149 151
150 serio_interrupt(serport->serio, cp[i], ch_flags); 152 serio_interrupt(serport->serio, cp[i], ch_flags);
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index c0f76da55304..c09db11b8831 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -2269,14 +2269,15 @@ static void gsmld_receive_buf(struct tty_struct *tty, const unsigned char *cp,
2269 char *f; 2269 char *f;
2270 int i; 2270 int i;
2271 char buf[64]; 2271 char buf[64];
2272 char flags; 2272 char flags = TTY_NORMAL;
2273 2273
2274 if (debug & 4) 2274 if (debug & 4)
2275 print_hex_dump_bytes("gsmld_receive: ", DUMP_PREFIX_OFFSET, 2275 print_hex_dump_bytes("gsmld_receive: ", DUMP_PREFIX_OFFSET,
2276 cp, count); 2276 cp, count);
2277 2277
2278 for (i = count, dp = cp, f = fp; i; i--, dp++) { 2278 for (i = count, dp = cp, f = fp; i; i--, dp++) {
2279 flags = *f++; 2279 if (f)
2280 flags = *f++;
2280 switch (flags) { 2281 switch (flags) {
2281 case TTY_NORMAL: 2282 case TTY_NORMAL:
2282 gsm->receive(gsm, *dp); 2283 gsm->receive(gsm, *dp);
diff --git a/drivers/tty/n_r3964.c b/drivers/tty/n_r3964.c
index 1e6405070ce6..8b157d68a03e 100644
--- a/drivers/tty/n_r3964.c
+++ b/drivers/tty/n_r3964.c
@@ -1244,7 +1244,7 @@ static void r3964_receive_buf(struct tty_struct *tty, const unsigned char *cp,
1244{ 1244{
1245 struct r3964_info *pInfo = tty->disc_data; 1245 struct r3964_info *pInfo = tty->disc_data;
1246 const unsigned char *p; 1246 const unsigned char *p;
1247 char *f, flags = 0; 1247 char *f, flags = TTY_NORMAL;
1248 int i; 1248 int i;
1249 1249
1250 for (i = count, p = cp, f = fp; i; i--, p++) { 1250 for (i = count, p = cp, f = fp; i; i--, p++) {
diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
index f15c898ff462..b8347c207cb8 100644
--- a/include/linux/tty_ldisc.h
+++ b/include/linux/tty_ldisc.h
@@ -84,7 +84,8 @@
84 * processing. <cp> is a pointer to the buffer of input 84 * processing. <cp> is a pointer to the buffer of input
85 * character received by the device. <fp> is a pointer to a 85 * character received by the device. <fp> is a pointer to a
86 * pointer of flag bytes which indicate whether a character was 86 * pointer of flag bytes which indicate whether a character was
87 * received with a parity error, etc. 87 * received with a parity error, etc. <fp> may be NULL to indicate
88 * all data received is TTY_NORMAL.
88 * 89 *
89 * void (*write_wakeup)(struct tty_struct *); 90 * void (*write_wakeup)(struct tty_struct *);
90 * 91 *
@@ -118,7 +119,8 @@
118 * processing. <cp> is a pointer to the buffer of input 119 * processing. <cp> is a pointer to the buffer of input
119 * character received by the device. <fp> is a pointer to a 120 * character received by the device. <fp> is a pointer to a
120 * pointer of flag bytes which indicate whether a character was 121 * pointer of flag bytes which indicate whether a character was
121 * received with a parity error, etc. 122 * received with a parity error, etc. <fp> may be NULL to indicate
123 * all data received is TTY_NORMAL.
122 * If assigned, prefer this function for automatic flow control. 124 * If assigned, prefer this function for automatic flow control.
123 */ 125 */
124 126