aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/hvc/hvcs.c
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2012-03-05 08:52:01 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-03-08 14:42:21 -0500
commit410235fd4d20b8feaf8930a0575d23acc088aa87 (patch)
treead21d071a29ef0ad400393328ca4ab0588d5b2b7 /drivers/tty/hvc/hvcs.c
parent44a1bfd95d0a6c0096e79a883197596e1ce83cc3 (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/hvc/hvcs.c')
-rw-r--r--drivers/tty/hvc/hvcs.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
index da0aa476804d..d23759183b47 100644
--- a/drivers/tty/hvc/hvcs.c
+++ b/drivers/tty/hvc/hvcs.c
@@ -1090,27 +1090,23 @@ static int hvcs_enable_device(struct hvcs_struct *hvcsd, uint32_t unit_address,
1090 */ 1090 */
1091static struct hvcs_struct *hvcs_get_by_index(int index) 1091static struct hvcs_struct *hvcs_get_by_index(int index)
1092{ 1092{
1093 struct hvcs_struct *hvcsd = NULL; 1093 struct hvcs_struct *hvcsd;
1094 unsigned long flags; 1094 unsigned long flags;
1095 1095
1096 spin_lock(&hvcs_structs_lock); 1096 spin_lock(&hvcs_structs_lock);
1097 /* We can immediately discard OOB requests */ 1097 list_for_each_entry(hvcsd, &hvcs_structs, next) {
1098 if (index >= 0 && index < HVCS_MAX_SERVER_ADAPTERS) { 1098 spin_lock_irqsave(&hvcsd->lock, flags);
1099 list_for_each_entry(hvcsd, &hvcs_structs, next) { 1099 if (hvcsd->index == index) {
1100 spin_lock_irqsave(&hvcsd->lock, flags); 1100 kref_get(&hvcsd->kref);
1101 if (hvcsd->index == index) {
1102 kref_get(&hvcsd->kref);
1103 spin_unlock_irqrestore(&hvcsd->lock, flags);
1104 spin_unlock(&hvcs_structs_lock);
1105 return hvcsd;
1106 }
1107 spin_unlock_irqrestore(&hvcsd->lock, flags); 1101 spin_unlock_irqrestore(&hvcsd->lock, flags);
1102 spin_unlock(&hvcs_structs_lock);
1103 return hvcsd;
1108 } 1104 }
1109 hvcsd = NULL; 1105 spin_unlock_irqrestore(&hvcsd->lock, flags);
1110 } 1106 }
1111
1112 spin_unlock(&hvcs_structs_lock); 1107 spin_unlock(&hvcs_structs_lock);
1113 return hvcsd; 1108
1109 return NULL;
1114} 1110}
1115 1111
1116/* 1112/*