Skip to content

Commit 8ee3fde

Browse files
robherringgregkh
authored andcommitted
tty_port: register tty ports with serdev bus
Register a serdev controller with the serdev bus when a tty_port is registered. This creates the serdev controller and create's serdev devices for any DT child nodes of the tty_port's parent (i.e. the UART device). Signed-off-by: Rob Herring <robh@kernel.org> Reviewed-By: Sebastian Reichel <sre@kernel.org> Tested-By: Sebastian Reichel <sre@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent bed35c6 commit 8ee3fde

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

drivers/tty/tty_port.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <linux/bitops.h>
1717
#include <linux/delay.h>
1818
#include <linux/module.h>
19+
#include <linux/serdev.h>
1920

2021
static int tty_port_default_receive_buf(struct tty_port *port,
2122
const unsigned char *p,
@@ -128,7 +129,15 @@ struct device *tty_port_register_device_attr(struct tty_port *port,
128129
struct device *device, void *drvdata,
129130
const struct attribute_group **attr_grp)
130131
{
132+
struct device *dev;
133+
131134
tty_port_link_device(port, driver, index);
135+
136+
dev = serdev_tty_port_register(port, device, driver, index);
137+
if (PTR_ERR(dev) != -ENODEV)
138+
/* Skip creating cdev if we registered a serdev device */
139+
return dev;
140+
132141
return tty_register_device_attr(driver, index, device, drvdata,
133142
attr_grp);
134143
}
@@ -180,6 +189,9 @@ static void tty_port_destructor(struct kref *kref)
180189
/* check if last port ref was dropped before tty release */
181190
if (WARN_ON(port->itty))
182191
return;
192+
193+
serdev_tty_port_unregister(port);
194+
183195
if (port->xmit_buf)
184196
free_page((unsigned long)port->xmit_buf);
185197
tty_port_destroy(port);

0 commit comments

Comments
 (0)