Commit 8ad37e83 authored by Amit Shah's avatar Amit Shah Committed by Rusty Russell

virtio: console: open: Use a common path for error handling

Just re-arrange code for future patches.
Signed-off-by: default avatarAmit Shah <amit.shah@redhat.com>
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
parent 7a285317
...@@ -711,6 +711,7 @@ static int port_fops_open(struct inode *inode, struct file *filp) ...@@ -711,6 +711,7 @@ static int port_fops_open(struct inode *inode, struct file *filp)
{ {
struct cdev *cdev = inode->i_cdev; struct cdev *cdev = inode->i_cdev;
struct port *port; struct port *port;
int ret;
port = container_of(cdev, struct port, cdev); port = container_of(cdev, struct port, cdev);
filp->private_data = port; filp->private_data = port;
...@@ -719,14 +720,17 @@ static int port_fops_open(struct inode *inode, struct file *filp) ...@@ -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 * Don't allow opening of console port devices -- that's done
* via /dev/hvc * via /dev/hvc
*/ */
if (is_console_port(port)) if (is_console_port(port)) {
return -ENXIO; ret = -ENXIO;
goto out;
}
/* Allow only one process to open a particular port at a time */ /* Allow only one process to open a particular port at a time */
spin_lock_irq(&port->inbuf_lock); spin_lock_irq(&port->inbuf_lock);
if (port->guest_connected) { if (port->guest_connected) {
spin_unlock_irq(&port->inbuf_lock); spin_unlock_irq(&port->inbuf_lock);
return -EMFILE; ret = -EMFILE;
goto out;
} }
port->guest_connected = true; port->guest_connected = true;
...@@ -745,6 +749,8 @@ static int port_fops_open(struct inode *inode, struct file *filp) ...@@ -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); send_control_msg(filp->private_data, VIRTIO_CONSOLE_PORT_OPEN, 1);
return 0; return 0;
out:
return ret;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment