Skip to content

Commit 8fd9d96

Browse files
committed
drivers: tty: serial: uartlite: fill mapsize and use it
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>
1 parent 1addd1b commit 8fd9d96

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

drivers/tty/serial/uartlite.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ static const char *ulite_type(struct uart_port *port)
339339

340340
static void ulite_release_port(struct uart_port *port)
341341
{
342-
release_mem_region(port->mapbase, ULITE_REGION);
342+
release_mem_region(port->mapbase, port->mapsize);
343343
iounmap(port->membase);
344344
port->membase = NULL;
345345
}
@@ -353,15 +353,15 @@ static int ulite_request_port(struct uart_port *port)
353353
"ulite console: port=%p; port->mapbase=%llx\n",
354354
port, (unsigned long long) port->mapbase);
355355

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

361-
port->membase = ioremap(port->mapbase, ULITE_REGION);
361+
port->membase = ioremap(port->mapbase, port->mapsize);
362362
if (!port->membase) {
363363
dev_err(port->dev, "Unable to map registers\n");
364-
release_mem_region(port->mapbase, ULITE_REGION);
364+
release_mem_region(port->mapbase, port->mapsize);
365365
return -EBUSY;
366366
}
367367

@@ -646,6 +646,7 @@ static int ulite_assign(struct device *dev, int id, u32 base, int irq,
646646
port->iotype = UPIO_MEM;
647647
port->iobase = 1; /* mark port in use */
648648
port->mapbase = base;
649+
port->mapsize = ULITE_REGION;
649650
port->membase = NULL;
650651
port->ops = &ulite_ops;
651652
port->irq = irq;

0 commit comments

Comments
 (0)