greybus: uart: Update uart.c to register tty ports
For each new UART connection we need to do a tty_port_init else we'll crash when trying to access the tty mutex later on. Base the TTY major/minor numbers on non-zero values. Supply an empty operations structure for the newly regitered port. Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
parent
f5537d46cb
commit
f95ad78c72
@ -522,6 +522,7 @@ static const struct tty_operations gb_ops = {
|
|||||||
.tiocmset = gb_tty_tiocmset,
|
.tiocmset = gb_tty_tiocmset,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static struct tty_port_operations null_ops = { };
|
||||||
|
|
||||||
static int gb_tty_init(void);
|
static int gb_tty_init(void);
|
||||||
static void gb_tty_exit(void);
|
static void gb_tty_exit(void);
|
||||||
@ -545,6 +546,7 @@ static int gb_uart_connection_init(struct gb_connection *connection)
|
|||||||
gb_tty = kzalloc(sizeof(*gb_tty), GFP_KERNEL);
|
gb_tty = kzalloc(sizeof(*gb_tty), GFP_KERNEL);
|
||||||
if (!gb_tty)
|
if (!gb_tty)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
gb_tty->connection = connection;
|
gb_tty->connection = connection;
|
||||||
connection->private = gb_tty;
|
connection->private = gb_tty;
|
||||||
|
|
||||||
@ -571,6 +573,9 @@ static int gb_uart_connection_init(struct gb_connection *connection)
|
|||||||
init_waitqueue_head(&gb_tty->wioctl);
|
init_waitqueue_head(&gb_tty->wioctl);
|
||||||
mutex_init(&gb_tty->mutex);
|
mutex_init(&gb_tty->mutex);
|
||||||
|
|
||||||
|
tty_port_init(&gb_tty->port);
|
||||||
|
gb_tty->port.ops = &null_ops;
|
||||||
|
|
||||||
send_control(gb_tty, gb_tty->ctrlout);
|
send_control(gb_tty, gb_tty->ctrlout);
|
||||||
|
|
||||||
/* initialize the uart to be 9600n81 */
|
/* initialize the uart to be 9600n81 */
|
||||||
@ -589,6 +594,7 @@ static int gb_uart_connection_init(struct gb_connection *connection)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
error:
|
error:
|
||||||
|
tty_port_destroy(&gb_tty->port);
|
||||||
release_minor(gb_tty);
|
release_minor(gb_tty);
|
||||||
error_version:
|
error_version:
|
||||||
connection->private = NULL;
|
connection->private = NULL;
|
||||||
@ -623,7 +629,7 @@ static void gb_uart_connection_exit(struct gb_connection *connection)
|
|||||||
/* FIXME - free transmit / receive buffers */
|
/* FIXME - free transmit / receive buffers */
|
||||||
|
|
||||||
tty_port_put(&gb_tty->port);
|
tty_port_put(&gb_tty->port);
|
||||||
|
tty_port_destroy(&gb_tty->port);
|
||||||
kfree(gb_tty);
|
kfree(gb_tty);
|
||||||
|
|
||||||
/* If last device is gone, tear down the tty structures */
|
/* If last device is gone, tear down the tty structures */
|
||||||
|
Loading…
Reference in New Issue
Block a user