8250.c: support specifying DW APB UARTs in device platform_data

Allow the private_data field to be specified in platform_data for the
standard 8250/16550 UART.  This field is used by DW APB type UARTs and
without this patch it's only possible to set this field when registering
the port by hand.  If private_data is not set then the driver will
potentially oops with a NULL pointer dereference.

Signed-off-by: Will Newton <will.newton@gmail.com>
Acked-by: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Russell King <rmk@arm.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Will Newton 2008-02-04 22:27:50 -08:00 committed by Linus Torvalds
parent 02c9b5cf9a
commit 74a1974172
2 changed files with 22 additions and 19 deletions

View file

@ -2671,6 +2671,7 @@ static int __devinit serial8250_probe(struct platform_device *dev)
port.flags = p->flags;
port.mapbase = p->mapbase;
port.hub6 = p->hub6;
port.private_data = p->private_data;
port.dev = &dev->dev;
if (share_irqs)
port.flags |= UPF_SHARE_IRQ;
@ -2821,6 +2822,7 @@ int serial8250_register_port(struct uart_port *port)
uart->port.iotype = port->iotype;
uart->port.flags = port->flags | UPF_BOOT_AUTOCONF;
uart->port.mapbase = port->mapbase;
uart->port.private_data = port->private_data;
if (port->dev)
uart->port.dev = port->dev;

View file

@ -23,6 +23,7 @@ struct plat_serial8250_port {
resource_size_t mapbase; /* resource base */
unsigned int irq; /* interrupt number */
unsigned int uartclk; /* UART clock rate */
void *private_data;
unsigned char regshift; /* register shift */
unsigned char iotype; /* UPIO_* */
unsigned char hub6;