[PATCH 2/3] tty: make the ptmx_fops initialized at compile time

From: Arjan van de Ven
Date: Sat Oct 29 2011 - 13:43:57 EST


Now that the tty file operations functions are no longer static,
the pty code can do compile time initialization of the ptmx_fops
struct, which then also allows it to be marked "const".

Signed-off-by: Arjan van de Ven <arjan@xxxxxxxxxxxxxxx>
---
drivers/tty/pty.c | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
index e809e9d..54e0e56 100644
--- a/drivers/tty/pty.c
+++ b/drivers/tty/pty.c
@@ -713,7 +713,18 @@ out:
return retval;
}

-static struct file_operations ptmx_fops;
+static const struct file_operations ptmx_fops =
+{
+ .llseek = no_llseek,
+ .read = tty_read,
+ .write = tty_write,
+ .poll = tty_poll,
+ .unlocked_ioctl = tty_ioctl,
+ .compat_ioctl = tty_compat_ioctl,
+ .open = ptmx_open,
+ .release = tty_release,
+ .fasync = tty_fasync,
+};

static void __init unix98_pty_init(void)
{
@@ -767,9 +778,6 @@ static void __init unix98_pty_init(void)
register_sysctl_table(pty_root_table);

/* Now create the /dev/ptmx special device */
- tty_default_fops(&ptmx_fops);
- ptmx_fops.open = ptmx_open;
-
cdev_init(&ptmx_cdev, &ptmx_fops);
if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
register_chrdev_region(MKDEV(TTYAUX_MAJOR, 2), 1, "/dev/ptmx") < 0)
--
1.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/