summaryrefslogtreecommitdiffstats
path: root/drivers/char/virtio_console.c
diff options
context:
space:
mode:
authorAmit Shah2010-09-02 14:41:48 +0200
committerRusty Russell2010-10-21 09:14:02 +0200
commit8ad37e83c8dc413f92b10c3d9bdeabe9237f521d (patch)
tree1a640ee022950f66b172053667cb21c845ce6471 /drivers/char/virtio_console.c
parentvirtio: console: remove_port() should return void (diff)
downloadkernel-qcow2-linux-8ad37e83c8dc413f92b10c3d9bdeabe9237f521d.tar.gz
kernel-qcow2-linux-8ad37e83c8dc413f92b10c3d9bdeabe9237f521d.tar.xz
kernel-qcow2-linux-8ad37e83c8dc413f92b10c3d9bdeabe9237f521d.zip
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/char/virtio_console.c')
-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)
{
struct cdev *cdev = inode->i_cdev;
struct port *port;
+ int ret;
port = container_of(cdev, struct port, cdev);
filp->private_data = port;
@@ -719,14 +720,17 @@ static int port_fops_open(struct inode *inode, struct file *filp)
* Don't allow opening of console port devices -- that's done
* via /dev/hvc
*/
- if (is_console_port(port))
- return -ENXIO;
+ if (is_console_port(port)) {
+ ret = -ENXIO;
+ goto out;
+ }
/* Allow only one process to open a particular port at a time */
spin_lock_irq(&port->inbuf_lock);
if (port->guest_connected) {
spin_unlock_irq(&port->inbuf_lock);
- return -EMFILE;
+ ret = -EMFILE;
+ goto out;
}
port->guest_connected = true;
@@ -745,6 +749,8 @@ static int port_fops_open(struct inode *inode, struct file *filp)
send_control_msg(filp->private_data, VIRTIO_CONSOLE_PORT_OPEN, 1);
return 0;
+out:
+ return ret;
}
/*