diff options
author | Jiri Slaby <jslaby@suse.cz> | 2012-03-05 08:52:01 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-03-08 14:42:21 -0500 |
commit | 410235fd4d20b8feaf8930a0575d23acc088aa87 (patch) | |
tree | ad21d071a29ef0ad400393328ca4ab0588d5b2b7 /drivers/tty/serial | |
parent | 44a1bfd95d0a6c0096e79a883197596e1ce83cc3 (diff) |
TTY: remove unneeded tty->index checks
Checking if tty->index is in bounds is not needed. The tty has the
index set in the initial open. This is done in get_tty_driver. And it
can be only in interval <0,driver->num).
So remove the tests which check exactly this interval. Some are
left untouched as they check against the current backing device count.
(Leaving apart that the check is racy in most of the cases.)
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/serial')
-rw-r--r-- | drivers/tty/serial/68328serial.c | 9 | ||||
-rw-r--r-- | drivers/tty/serial/crisv10.c | 15 |
2 files changed, 5 insertions, 19 deletions
diff --git a/drivers/tty/serial/68328serial.c b/drivers/tty/serial/68328serial.c index a88ef9782a4f..7398390e7e65 100644 --- a/drivers/tty/serial/68328serial.c +++ b/drivers/tty/serial/68328serial.c | |||
@@ -1190,14 +1190,9 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp, | |||
1190 | int rs_open(struct tty_struct *tty, struct file * filp) | 1190 | int rs_open(struct tty_struct *tty, struct file * filp) |
1191 | { | 1191 | { |
1192 | struct m68k_serial *info; | 1192 | struct m68k_serial *info; |
1193 | int retval, line; | 1193 | int retval; |
1194 | |||
1195 | line = tty->index; | ||
1196 | |||
1197 | if (line >= NR_PORTS || line < 0) /* we have exactly one */ | ||
1198 | return -ENODEV; | ||
1199 | 1194 | ||
1200 | info = &m68k_soft[line]; | 1195 | info = &m68k_soft[tty->index]; |
1201 | 1196 | ||
1202 | if (serial_paranoia_check(info, tty->name, "rs_open")) | 1197 | if (serial_paranoia_check(info, tty->name, "rs_open")) |
1203 | return -ENODEV; | 1198 | return -ENODEV; |
diff --git a/drivers/tty/serial/crisv10.c b/drivers/tty/serial/crisv10.c index 1dfba7b779c8..23d791696879 100644 --- a/drivers/tty/serial/crisv10.c +++ b/drivers/tty/serial/crisv10.c | |||
@@ -4105,20 +4105,11 @@ static int | |||
4105 | rs_open(struct tty_struct *tty, struct file * filp) | 4105 | rs_open(struct tty_struct *tty, struct file * filp) |
4106 | { | 4106 | { |
4107 | struct e100_serial *info; | 4107 | struct e100_serial *info; |
4108 | int retval, line; | 4108 | int retval; |
4109 | unsigned long page; | 4109 | unsigned long page; |
4110 | int allocated_resources = 0; | 4110 | int allocated_resources = 0; |
4111 | 4111 | ||
4112 | /* find which port we want to open */ | 4112 | info = rs_table + tty->index; |
4113 | line = tty->index; | ||
4114 | |||
4115 | if (line < 0 || line >= NR_PORTS) | ||
4116 | return -ENODEV; | ||
4117 | |||
4118 | /* find the corresponding e100_serial struct in the table */ | ||
4119 | info = rs_table + line; | ||
4120 | |||
4121 | /* don't allow the opening of ports that are not enabled in the HW config */ | ||
4122 | if (!info->enabled) | 4113 | if (!info->enabled) |
4123 | return -ENODEV; | 4114 | return -ENODEV; |
4124 | 4115 | ||
@@ -4131,7 +4122,7 @@ rs_open(struct tty_struct *tty, struct file * filp) | |||
4131 | tty->driver_data = info; | 4122 | tty->driver_data = info; |
4132 | info->port.tty = tty; | 4123 | info->port.tty = tty; |
4133 | 4124 | ||
4134 | info->port.tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0; | 4125 | tty->low_latency = !!(info->flags & ASYNC_LOW_LATENCY); |
4135 | 4126 | ||
4136 | if (!tmp_buf) { | 4127 | if (!tmp_buf) { |
4137 | page = get_zeroed_page(GFP_KERNEL); | 4128 | page = get_zeroed_page(GFP_KERNEL); |