aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2012-08-07 15:48:05 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-08-13 19:53:14 -0400
commit97d150898592be8d5381ebc8d435526df38a2791 (patch)
tree4ff19a2cf10d44945b4acd99ae489c4a9da7011b /drivers
parentbdb498c20040616e94b05c31a0ceb3e134b7e829 (diff)
TTY: hvcs, clean hvcs_open a bit
Make the code of hvcs_open a bit more readable by: - moving all assignments out of if's - redoing fail paths so that corresponding pieces are nearby - we need only one of retval and rc Signed-off-by: Jiri Slaby <jslaby@suse.cz> Acked-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/tty/hvc/hvcs.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
index d56788c83974..6f5c3be0f495 100644
--- a/drivers/tty/hvc/hvcs.c
+++ b/drivers/tty/hvc/hvcs.c
@@ -1109,11 +1109,10 @@ static struct hvcs_struct *hvcs_get_by_index(int index)
1109static int hvcs_open(struct tty_struct *tty, struct file *filp) 1109static int hvcs_open(struct tty_struct *tty, struct file *filp)
1110{ 1110{
1111 struct hvcs_struct *hvcsd; 1111 struct hvcs_struct *hvcsd;
1112 int rc, retval = 0;
1113 unsigned long flags;
1114 unsigned int irq;
1115 struct vio_dev *vdev; 1112 struct vio_dev *vdev;
1116 unsigned long unit_address; 1113 unsigned long unit_address, flags;
1114 unsigned int irq;
1115 int retval;
1117 1116
1118 if (tty->driver_data) 1117 if (tty->driver_data)
1119 goto fast_open; 1118 goto fast_open;
@@ -1122,7 +1121,8 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
1122 * Is there a vty-server that shares the same index? 1121 * Is there a vty-server that shares the same index?
1123 * This function increments the kref index. 1122 * This function increments the kref index.
1124 */ 1123 */
1125 if (!(hvcsd = hvcs_get_by_index(tty->index))) { 1124 hvcsd = hvcs_get_by_index(tty->index);
1125 if (!hvcsd) {
1126 printk(KERN_WARNING "HVCS: open failed, no device associated" 1126 printk(KERN_WARNING "HVCS: open failed, no device associated"
1127 " with tty->index %d.\n", tty->index); 1127 " with tty->index %d.\n", tty->index);
1128 return -ENODEV; 1128 return -ENODEV;
@@ -1130,9 +1130,14 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
1130 1130
1131 spin_lock_irqsave(&hvcsd->lock, flags); 1131 spin_lock_irqsave(&hvcsd->lock, flags);
1132 1132
1133 if (hvcsd->connected == 0) 1133 if (hvcsd->connected == 0) {
1134 if ((retval = hvcs_partner_connect(hvcsd))) 1134 retval = hvcs_partner_connect(hvcsd);
1135 goto error_release; 1135 if (retval) {
1136 spin_unlock_irqrestore(&hvcsd->lock, flags);
1137 printk(KERN_WARNING "HVCS: partner connect failed.\n");
1138 goto err_put;
1139 }
1140 }
1136 1141
1137 hvcsd->port.count = 1; 1142 hvcsd->port.count = 1;
1138 hvcsd->port.tty = tty; 1143 hvcsd->port.tty = tty;
@@ -1155,10 +1160,10 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
1155 * This must be done outside of the spinlock because it requests irqs 1160 * This must be done outside of the spinlock because it requests irqs
1156 * and will grab the spinlock and free the connection if it fails. 1161 * and will grab the spinlock and free the connection if it fails.
1157 */ 1162 */
1158 if (((rc = hvcs_enable_device(hvcsd, unit_address, irq, vdev)))) { 1163 retval = hvcs_enable_device(hvcsd, unit_address, irq, vdev);
1159 tty_port_put(&hvcsd->port); 1164 if (retval) {
1160 printk(KERN_WARNING "HVCS: enable device failed.\n"); 1165 printk(KERN_WARNING "HVCS: enable device failed.\n");
1161 return rc; 1166 goto err_put;
1162 } 1167 }
1163 1168
1164 goto open_success; 1169 goto open_success;
@@ -1179,12 +1184,9 @@ open_success:
1179 hvcsd->vdev->unit_address ); 1184 hvcsd->vdev->unit_address );
1180 1185
1181 return 0; 1186 return 0;
1182 1187err_put:
1183error_release:
1184 spin_unlock_irqrestore(&hvcsd->lock, flags);
1185 tty_port_put(&hvcsd->port); 1188 tty_port_put(&hvcsd->port);
1186 1189
1187 printk(KERN_WARNING "HVCS: partner connect failed.\n");
1188 return retval; 1190 return retval;
1189} 1191}
1190 1192