Skip to content

Commit

Permalink
drivers: tty: serial: uartlite: fill mapsize and use it
Browse files Browse the repository at this point in the history
Fill the struct uart_port->mapsize field and use it, insteaf of
hardcoded values in many places. This makes the code layout a bit
more consistent and easily allows using generic helpers for the
io memory handling.

Candidates for such helpers could be eg. the request+ioremap and
iounmap+release combinations.

Signed-off-by: Enrico Weigelt <info@metux.net>
  • Loading branch information
metux committed Jan 10, 2020
1 parent 3ccc75a commit eb6134b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions drivers/tty/serial/uartlite.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ static const char *ulite_type(struct uart_port *port)

static void ulite_release_port(struct uart_port *port)
{
release_mem_region(port->mapbase, ULITE_REGION);
release_mem_region(port->mapbase, port->mapsize);
iounmap(port->membase);
port->membase = NULL;
}
Expand All @@ -353,15 +353,15 @@ static int ulite_request_port(struct uart_port *port)
"ulite console: port=%p; port->mapbase=%llx\n",
port, (unsigned long long) port->mapbase);

if (!request_mem_region(port->mapbase, ULITE_REGION, "uartlite")) {
if (!request_mem_region(port->mapbase, port->mapsize, "uartlite")) {
dev_err(port->dev, "Memory region busy\n");
return -EBUSY;
}

port->membase = ioremap(port->mapbase, ULITE_REGION);
port->membase = ioremap(port->mapbase, port->mapsize);
if (!port->membase) {
dev_err(port->dev, "Unable to map registers\n");
release_mem_region(port->mapbase, ULITE_REGION);
release_mem_region(port->mapbase, port->mapsize);
return -EBUSY;
}

Expand Down Expand Up @@ -646,6 +646,7 @@ static int ulite_assign(struct device *dev, int id, u32 base, int irq,
port->iotype = UPIO_MEM;
port->iobase = 1; /* mark port in use */
port->mapbase = base;
port->mapsize = ULITE_REGION;
port->membase = NULL;
port->ops = &ulite_ops;
port->irq = irq;
Expand Down

0 comments on commit eb6134b

Please sign in to comment.