]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/tty/tty_port.c
tty: fix port buffer locking
[karo-tx-linux.git] / drivers / tty / tty_port.c
index 1d21a9c1d33e6e3c5ef007a25e4b4550fb62a51c..88dac3b7936933cc7c6644451c837aa6c6585c9f 100644 (file)
@@ -16,7 +16,6 @@
 #include <linux/bitops.h>
 #include <linux/delay.h>
 #include <linux/module.h>
-#include <linux/serdev.h>
 
 static int tty_port_default_receive_buf(struct tty_port *port,
                                        const unsigned char *p,
@@ -34,7 +33,9 @@ static int tty_port_default_receive_buf(struct tty_port *port,
        if (!disc)
                return 0;
 
+       mutex_lock(&tty->atomic_write_lock);
        ret = tty_ldisc_receive_buf(disc, p, (char *)f, count);
+       mutex_unlock(&tty->atomic_write_lock);
 
        tty_ldisc_deref(disc);
 
@@ -129,15 +130,7 @@ struct device *tty_port_register_device_attr(struct tty_port *port,
                struct device *device, void *drvdata,
                const struct attribute_group **attr_grp)
 {
-       struct device *dev;
-
        tty_port_link_device(port, driver, index);
-
-       dev = serdev_tty_port_register(port, device, driver, index);
-       if (PTR_ERR(dev) != -ENODEV)
-               /* Skip creating cdev if we registered a serdev device */
-               return dev;
-
        return tty_register_device_attr(driver, index, device, drvdata,
                        attr_grp);
 }
@@ -189,9 +182,6 @@ static void tty_port_destructor(struct kref *kref)
        /* check if last port ref was dropped before tty release */
        if (WARN_ON(port->itty))
                return;
-
-       serdev_tty_port_unregister(port);
-
        if (port->xmit_buf)
                free_page((unsigned long)port->xmit_buf);
        tty_port_destroy(port);