提交 97d15089 编写于 作者: J Jiri Slaby 提交者: Greg Kroah-Hartman

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: NJiri Slaby <jslaby@suse.cz>
Acked-by: NAlan Cox <alan@linux.intel.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 bdb498c2
...@@ -1109,11 +1109,10 @@ static struct hvcs_struct *hvcs_get_by_index(int index) ...@@ -1109,11 +1109,10 @@ static struct hvcs_struct *hvcs_get_by_index(int index)
static int hvcs_open(struct tty_struct *tty, struct file *filp) static int hvcs_open(struct tty_struct *tty, struct file *filp)
{ {
struct hvcs_struct *hvcsd; struct hvcs_struct *hvcsd;
int rc, retval = 0;
unsigned long flags;
unsigned int irq;
struct vio_dev *vdev; struct vio_dev *vdev;
unsigned long unit_address; unsigned long unit_address, flags;
unsigned int irq;
int retval;
if (tty->driver_data) if (tty->driver_data)
goto fast_open; goto fast_open;
...@@ -1122,7 +1121,8 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp) ...@@ -1122,7 +1121,8 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
* Is there a vty-server that shares the same index? * Is there a vty-server that shares the same index?
* This function increments the kref index. * This function increments the kref index.
*/ */
if (!(hvcsd = hvcs_get_by_index(tty->index))) { hvcsd = hvcs_get_by_index(tty->index);
if (!hvcsd) {
printk(KERN_WARNING "HVCS: open failed, no device associated" printk(KERN_WARNING "HVCS: open failed, no device associated"
" with tty->index %d.\n", tty->index); " with tty->index %d.\n", tty->index);
return -ENODEV; return -ENODEV;
...@@ -1130,9 +1130,14 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp) ...@@ -1130,9 +1130,14 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
spin_lock_irqsave(&hvcsd->lock, flags); spin_lock_irqsave(&hvcsd->lock, flags);
if (hvcsd->connected == 0) if (hvcsd->connected == 0) {
if ((retval = hvcs_partner_connect(hvcsd))) retval = hvcs_partner_connect(hvcsd);
goto error_release; if (retval) {
spin_unlock_irqrestore(&hvcsd->lock, flags);
printk(KERN_WARNING "HVCS: partner connect failed.\n");
goto err_put;
}
}
hvcsd->port.count = 1; hvcsd->port.count = 1;
hvcsd->port.tty = tty; hvcsd->port.tty = tty;
...@@ -1155,10 +1160,10 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp) ...@@ -1155,10 +1160,10 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
* This must be done outside of the spinlock because it requests irqs * This must be done outside of the spinlock because it requests irqs
* and will grab the spinlock and free the connection if it fails. * and will grab the spinlock and free the connection if it fails.
*/ */
if (((rc = hvcs_enable_device(hvcsd, unit_address, irq, vdev)))) { retval = hvcs_enable_device(hvcsd, unit_address, irq, vdev);
tty_port_put(&hvcsd->port); if (retval) {
printk(KERN_WARNING "HVCS: enable device failed.\n"); printk(KERN_WARNING "HVCS: enable device failed.\n");
return rc; goto err_put;
} }
goto open_success; goto open_success;
...@@ -1179,12 +1184,9 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp) ...@@ -1179,12 +1184,9 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
hvcsd->vdev->unit_address ); hvcsd->vdev->unit_address );
return 0; return 0;
err_put:
error_release:
spin_unlock_irqrestore(&hvcsd->lock, flags);
tty_port_put(&hvcsd->port); tty_port_put(&hvcsd->port);
printk(KERN_WARNING "HVCS: partner connect failed.\n");
return retval; return retval;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册