Skip to content

Commit 327b882

Browse files
sthibaulgregkh
authored andcommitted
Staging: speakup: Fix getting port information
Commit f79b0d9 ("staging: speakup: Fixed warning <linux/serial.h> instead of <asm/serial.h>") broke the port information in the speakup driver: SERIAL_PORT_DFNS only gets defined if asm/serial.h is included, and no other header includes asm/serial.h. We here make sure serialio.c does get the arch-specific definition of SERIAL_PORT_DFNS from asm/serial.h, if any. Along the way, this makes sure that we do have information for the requested serial port number (index) Fixes: f79b0d9 ("staging: speakup: Fixed warning <linux/serial.h> instead of <asm/serial.h>") Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Cc: stable <stable@vger.kernel.org> # 3.18 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent b64a1cb commit 327b882

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

drivers/staging/speakup/serialio.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
#include "spk_priv.h"
77
#include "serialio.h"
88

9+
#include <linux/serial_core.h>
10+
/* WARNING: Do not change this to <linux/serial.h> without testing that
11+
* SERIAL_PORT_DFNS does get defined to the appropriate value. */
12+
#include <asm/serial.h>
13+
914
#ifndef SERIAL_PORT_DFNS
1015
#define SERIAL_PORT_DFNS
1116
#endif
@@ -23,9 +28,15 @@ const struct old_serial_port *spk_serial_init(int index)
2328
int baud = 9600, quot = 0;
2429
unsigned int cval = 0;
2530
int cflag = CREAD | HUPCL | CLOCAL | B9600 | CS8;
26-
const struct old_serial_port *ser = rs_table + index;
31+
const struct old_serial_port *ser;
2732
int err;
2833

34+
if (index >= ARRAY_SIZE(rs_table)) {
35+
pr_info("no port info for ttyS%d\n", index);
36+
return NULL;
37+
}
38+
ser = rs_table + index;
39+
2940
/* Divisor, bytesize and parity */
3041
quot = ser->baud_base / baud;
3142
cval = cflag & (CSIZE | CSTOPB);

0 commit comments

Comments
 (0)