aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAmit Shah <amit.shah@redhat.com>2010-09-02 08:41:48 -0400
committerRusty Russell <rusty@rustcorp.com.au>2010-10-21 03:14:02 -0400
commit8ad37e83c8dc413f92b10c3d9bdeabe9237f521d (patch)
tree1a640ee022950f66b172053667cb21c845ce6471 /drivers
parent7a2853178dfba9553d58f356113f47fd582e9cc6 (diff)
virtio: console: open: Use a common path for error handling
Just re-arrange code for future patches. Signed-off-by: Amit Shah <amit.shah@redhat.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/char/virtio_console.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 21b621343033..2f4f0b23ea00 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -711,6 +711,7 @@ static int port_fops_open(struct inode *inode, struct file *filp)
711{ 711{
712 struct cdev *cdev = inode->i_cdev; 712 struct cdev *cdev = inode->i_cdev;
713 struct port *port; 713 struct port *port;
714 int ret;
714 715
715 port = container_of(cdev, struct port, cdev); 716 port = container_of(cdev, struct port, cdev);
716 filp->private_data = port; 717 filp->private_data = port;
@@ -719,14 +720,17 @@ static int port_fops_open(struct inode *inode, struct file *filp)
719 * Don't allow opening of console port devices -- that's done 720 * Don't allow opening of console port devices -- that's done
720 * via /dev/hvc 721 * via /dev/hvc
721 */ 722 */
722 if (is_console_port(port)) 723 if (is_console_port(port)) {
723 return -ENXIO; 724 ret = -ENXIO;
725 goto out;
726 }
724 727
725 /* Allow only one process to open a particular port at a time */ 728 /* Allow only one process to open a particular port at a time */
726 spin_lock_irq(&port->inbuf_lock); 729 spin_lock_irq(&port->inbuf_lock);
727 if (port->guest_connected) { 730 if (port->guest_connected) {
728 spin_unlock_irq(&port->inbuf_lock); 731 spin_unlock_irq(&port->inbuf_lock);
729 return -EMFILE; 732 ret = -EMFILE;
733 goto out;
730 } 734 }
731 735
732 port->guest_connected = true; 736 port->guest_connected = true;
@@ -745,6 +749,8 @@ static int port_fops_open(struct inode *inode, struct file *filp)
745 send_control_msg(filp->private_data, VIRTIO_CONSOLE_PORT_OPEN, 1); 749 send_control_msg(filp->private_data, VIRTIO_CONSOLE_PORT_OPEN, 1);
746 750
747 return 0; 751 return 0;
752out:
753 return ret;
748} 754}
749 755
750/* 756/*