Commit f8b2cc29 authored by Russell King's avatar Russell King

[SERIAL] 8250_acpi: Convert to use serial8250_{un,}register_port.

parent 3b19b3ed
......@@ -12,81 +12,71 @@
#include <linux/acpi.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/tty.h>
#include <linux/serial.h>
#include <linux/serial_core.h>
#include <acpi/acpi_bus.h>
#include <asm/io.h>
#include <asm/serial.h>
#include "8250.h"
struct serial_private {
int line;
void *iomem_base;
};
static acpi_status acpi_serial_mmio(struct serial_struct *req,
static acpi_status acpi_serial_mmio(struct uart_port *port,
struct acpi_resource_address64 *addr)
{
unsigned long size;
size = addr->max_address_range - addr->min_address_range + 1;
req->iomap_base = addr->min_address_range;
req->iomem_base = ioremap(req->iomap_base, size);
if (!req->iomem_base) {
printk(KERN_ERR "%s: couldn't ioremap 0x%lx-0x%lx\n",
__FUNCTION__, req->iomap_base, req->iomap_base + size);
return AE_ERROR;
}
req->io_type = SERIAL_IO_MEM;
port->mapbase = addr->min_address_range;
port->iotype = UPIO_MEM;
port->flags |= UPF_IOREMAP;
return AE_OK;
}
static acpi_status acpi_serial_port(struct serial_struct *req,
static acpi_status acpi_serial_port(struct uart_port *port,
struct acpi_resource_io *io)
{
if (io->range_length) {
req->port = io->min_base_address;
req->io_type = SERIAL_IO_PORT;
port->iobase = io->min_base_address;
port->iotype = UPIO_PORT;
} else
printk(KERN_ERR "%s: zero-length IO port range?\n", __FUNCTION__);
return AE_OK;
}
static acpi_status acpi_serial_ext_irq(struct serial_struct *req,
static acpi_status acpi_serial_ext_irq(struct uart_port *port,
struct acpi_resource_ext_irq *ext_irq)
{
if (ext_irq->number_of_interrupts > 0)
req->irq = acpi_register_gsi(ext_irq->interrupts[0],
ext_irq->edge_level, ext_irq->active_high_low);
port->irq = acpi_register_gsi(ext_irq->interrupts[0],
ext_irq->edge_level, ext_irq->active_high_low);
return AE_OK;
}
static acpi_status acpi_serial_irq(struct serial_struct *req,
static acpi_status acpi_serial_irq(struct uart_port *port,
struct acpi_resource_irq *irq)
{
if (irq->number_of_interrupts > 0)
req->irq = acpi_register_gsi(irq->interrupts[0],
irq->edge_level, irq->active_high_low);
port->irq = acpi_register_gsi(irq->interrupts[0],
irq->edge_level, irq->active_high_low);
return AE_OK;
}
static acpi_status acpi_serial_resource(struct acpi_resource *res, void *data)
{
struct serial_struct *serial_req = (struct serial_struct *) data;
struct uart_port *port = (struct uart_port *) data;
struct acpi_resource_address64 addr;
acpi_status status;
status = acpi_resource_to_address64(res, &addr);
if (ACPI_SUCCESS(status))
return acpi_serial_mmio(serial_req, &addr);
return acpi_serial_mmio(port, &addr);
else if (res->id == ACPI_RSTYPE_IO)
return acpi_serial_port(serial_req, &res->data.io);
return acpi_serial_port(port, &res->data.io);
else if (res->id == ACPI_RSTYPE_EXT_IRQ)
return acpi_serial_ext_irq(serial_req, &res->data.extended_irq);
return acpi_serial_ext_irq(port, &res->data.extended_irq);
else if (res->id == ACPI_RSTYPE_IRQ)
return acpi_serial_irq(serial_req, &res->data.irq);
return acpi_serial_irq(port, &res->data.irq);
return AE_OK;
}
......@@ -94,10 +84,13 @@ static int acpi_serial_add(struct acpi_device *device)
{
struct serial_private *priv;
acpi_status status;
struct serial_struct serial_req;
struct uart_port port;
int result;
memset(&serial_req, 0, sizeof(serial_req));
memset(&port, 0, sizeof(struct uart_port));
port.uartclk = 1843200;
port.flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF;
priv = kmalloc(sizeof(struct serial_private), GFP_KERNEL);
if (!priv) {
......@@ -107,25 +100,20 @@ static int acpi_serial_add(struct acpi_device *device)
memset(priv, 0, sizeof(*priv));
status = acpi_walk_resources(device->handle, METHOD_NAME__CRS,
acpi_serial_resource, &serial_req);
acpi_serial_resource, &port);
if (ACPI_FAILURE(status)) {
result = -ENODEV;
goto fail;
}
if (serial_req.iomem_base)
priv->iomem_base = serial_req.iomem_base;
else if (!serial_req.port) {
if (!port.mapbase && !port.iobase) {
printk(KERN_ERR "%s: no iomem or port address in %s _CRS\n",
__FUNCTION__, device->pnp.bus_id);
result = -ENODEV;
goto fail;
}
serial_req.baud_base = BASE_BAUD;
serial_req.flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF;
priv->line = register_serial(&serial_req);
priv->line = serial8250_register_port(&port);
if (priv->line < 0) {
printk(KERN_WARNING "Couldn't register serial port %s: %d\n",
device->pnp.bus_id, priv->line);
......@@ -137,8 +125,6 @@ static int acpi_serial_add(struct acpi_device *device)
return 0;
fail:
if (serial_req.iomem_base)
iounmap(serial_req.iomem_base);
kfree(priv);
return result;
......@@ -152,9 +138,7 @@ static int acpi_serial_remove(struct acpi_device *device, int type)
return -EINVAL;
priv = acpi_driver_data(device);
unregister_serial(priv->line);
if (priv->iomem_base)
iounmap(priv->iomem_base);
serial8250_unregister_port(priv->line);
kfree(priv);
return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment