summaryrefslogtreecommitdiffstats
path: root/drivers/tty/vcc.c
diff options
context:
space:
mode:
authorJag Raman <jag.raman@oracle.com>2017-08-15 23:03:04 +0200
committerDavid S. Miller <davem@davemloft.net>2017-08-16 06:33:53 +0200
commit63a7174484223f4ba35a3bad8db43234ab56ecea (patch)
treea3e80be1eaf9656c80c86683b7c04aaa6c8328c4 /drivers/tty/vcc.c
parentsparc64: vcc: Enable LDC event processing engine (diff)
downloadlinux-63a7174484223f4ba35a3bad8db43234ab56ecea.tar.xz
linux-63a7174484223f4ba35a3bad8db43234ab56ecea.zip
sparc64: vcc: Add open & close TTY operations
Add handlers to support TTY open & close operations Signed-off-by: Jagannathan Raman <jag.raman@oracle.com> Reviewed-by: Liam Merwick <liam.merwick@oracle.com> Reviewed-by: Shannon Nelson <shannon.nelson@oracle.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/tty/vcc.c')
-rw-r--r--drivers/tty/vcc.c63
1 files changed, 62 insertions, 1 deletions
diff --git a/drivers/tty/vcc.c b/drivers/tty/vcc.c
index 91f663d207b6..f964fb20e4ba 100644
--- a/drivers/tty/vcc.c
+++ b/drivers/tty/vcc.c
@@ -746,7 +746,68 @@ static struct vio_driver vcc_driver = {
.name = "vcc",
};
-static const struct tty_operations vcc_ops;
+static int vcc_open(struct tty_struct *tty, struct file *vcc_file)
+{
+ struct vcc_port *port;
+
+ if (unlikely(!tty)) {
+ pr_err("VCC: open: Invalid TTY handle\n");
+ return -ENXIO;
+ }
+
+ if (tty->count > 1)
+ return -EBUSY;
+
+ port = vcc_get_ne(tty->index);
+ if (unlikely(!port)) {
+ pr_err("VCC: open: Failed to find VCC port\n");
+ return -ENODEV;
+ }
+
+ if (unlikely(!port->vio.lp)) {
+ pr_err("VCC: open: LDC channel not configured\n");
+ vcc_put(port, false);
+ return -EPIPE;
+ }
+ vccdbgl(port->vio.lp);
+
+ vcc_put(port, false);
+
+ if (unlikely(!tty->port)) {
+ pr_err("VCC: open: TTY port not found\n");
+ return -ENXIO;
+ }
+
+ if (unlikely(!tty->port->ops)) {
+ pr_err("VCC: open: TTY ops not defined\n");
+ return -ENXIO;
+ }
+
+ return tty_port_open(tty->port, tty, vcc_file);
+}
+
+static void vcc_close(struct tty_struct *tty, struct file *vcc_file)
+{
+ if (unlikely(!tty)) {
+ pr_err("VCC: close: Invalid TTY handle\n");
+ return;
+ }
+
+ if (unlikely(tty->count > 1))
+ return;
+
+ if (unlikely(!tty->port)) {
+ pr_err("VCC: close: TTY port not found\n");
+ return;
+ }
+
+ tty_port_close(tty->port, tty, vcc_file);
+}
+
+static const struct tty_operations vcc_ops = {
+ .open = vcc_open,
+ .close = vcc_close,
+};
#define VCC_TTY_FLAGS (TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_REAL_RAW)