X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fserial%2Fof_serial.c;h=a64d858219969d218c9a973d5b04224a838ea433;hb=444ad82bc3eaa554be40d22dc248e58aeefd54d9;hp=09b0b736a751e6e4bbe9ff5537b1a143b6cbd06a;hpb=9468482bd4c3b89abe04a770848d5eaa1ea830b0;p=linux-2.6 diff --git a/drivers/serial/of_serial.c b/drivers/serial/of_serial.c index 09b0b736a7..a64d858219 100644 --- a/drivers/serial/of_serial.c +++ b/drivers/serial/of_serial.c @@ -17,6 +17,11 @@ #include #include +struct of_serial_info { + int type; + int line; +}; + /* * Fill a struct uart_port for a given device node */ @@ -29,8 +34,8 @@ static int __devinit of_platform_serial_setup(struct of_device *ofdev, int ret; memset(port, 0, sizeof *port); - spd = get_property(np, "current-speed", NULL); - clk = get_property(np, "clock-frequency", NULL); + spd = of_get_property(np, "current-speed", NULL); + clk = of_get_property(np, "clock-frequency", NULL); if (!clk) { dev_warn(&ofdev->dev, "no clock-frequency property set\n"); return -ENODEV; @@ -48,7 +53,8 @@ static int __devinit of_platform_serial_setup(struct of_device *ofdev, port->iotype = UPIO_MEM; port->type = type; port->uartclk = *clk; - port->flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_IOREMAP; + port->flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_IOREMAP + | UPF_FIXED_PORT; port->dev = &ofdev->dev; port->custom_divisor = *clk / (16 * (*spd)); @@ -61,6 +67,7 @@ static int __devinit of_platform_serial_setup(struct of_device *ofdev, static int __devinit of_platform_serial_probe(struct of_device *ofdev, const struct of_device_id *id) { + struct of_serial_info *info; struct uart_port port; int port_type; int ret; @@ -68,30 +75,35 @@ static int __devinit of_platform_serial_probe(struct of_device *ofdev, if (of_find_property(ofdev->node, "used-by-rtas", NULL)) return -EBUSY; + info = kmalloc(sizeof(*info), GFP_KERNEL); + if (info == NULL) + return -ENOMEM; + port_type = (unsigned long)id->data; ret = of_platform_serial_setup(ofdev, port_type, &port); if (ret) goto out; switch (port_type) { - case PORT_UNKNOWN: - dev_info(&ofdev->dev, "Unknown serial port found, " - "attempting to use 8250 driver\n"); - /* fallthrough */ case PORT_8250 ... PORT_MAX_8250: ret = serial8250_register_port(&port); break; default: /* need to add code for these */ + case PORT_UNKNOWN: + dev_info(&ofdev->dev, "Unknown serial port found, ignored\n"); ret = -ENODEV; break; } if (ret < 0) goto out; - ofdev->dev.driver_data = (void *)(unsigned long)ret; + info->type = port_type; + info->line = ret; + ofdev->dev.driver_data = info; return 0; out: + kfree(info); irq_dispose_mapping(port.irq); return ret; } @@ -101,8 +113,16 @@ out: */ static int of_platform_serial_remove(struct of_device *ofdev) { - int line = (unsigned long)ofdev->dev.driver_data; - serial8250_unregister_port(line); + struct of_serial_info *info = ofdev->dev.driver_data; + switch (info->type) { + case PORT_8250 ... PORT_MAX_8250: + serial8250_unregister_port(info->line); + break; + default: + /* need to add code for these */ + break; + } + kfree(info); return 0; }