Skip to content

Commit f7048b1

Browse files
r-vigneshgregkh
authored andcommitted
tty: serial_core: Add name field to uart_port struct
Introduce a field to store name of uart_port that can be used to easily identify UART port instances on a system that has more than one UART instance. The name is of the form ttyXN(eg. ttyS0, ttyAMA0,..) where N is number that particular UART instance. This field will be useful when printing debug info for a particular port or in register IRQs with unique IRQ name. Port name is populated during uart_add_one_port(). Signed-off-by: Vignesh R <vigneshr@ti.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 7cd3e9d commit f7048b1

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

drivers/tty/serial/serial_core.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2744,6 +2744,12 @@ int uart_add_one_port(struct uart_driver *drv, struct uart_port *uport)
27442744
state->pm_state = UART_PM_STATE_UNDEFINED;
27452745
uport->cons = drv->cons;
27462746
uport->minor = drv->tty_driver->minor_start + uport->line;
2747+
uport->name = kasprintf(GFP_KERNEL, "%s%d", drv->dev_name,
2748+
drv->tty_driver->name_base + uport->line);
2749+
if (!uport->name) {
2750+
ret = -ENOMEM;
2751+
goto out;
2752+
}
27472753

27482754
/*
27492755
* If this port is a console, then the spinlock is already
@@ -2861,6 +2867,7 @@ int uart_remove_one_port(struct uart_driver *drv, struct uart_port *uport)
28612867
if (uport->type != PORT_UNKNOWN && uport->ops->release_port)
28622868
uport->ops->release_port(uport);
28632869
kfree(uport->tty_groups);
2870+
kfree(uport->name);
28642871

28652872
/*
28662873
* Indicate that there isn't a port here anymore.

include/linux/serial_core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ struct uart_port {
247247
unsigned char suspended;
248248
unsigned char irq_wake;
249249
unsigned char unused[2];
250+
char *name; /* port name */
250251
struct attribute_group *attr_group; /* port specific attributes */
251252
const struct attribute_group **tty_groups; /* all attributes (serial core use only) */
252253
struct serial_rs485 rs485;

0 commit comments

Comments
 (0)