Skip to content

Commit a9090ee

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 <[email protected]>
1 parent 0e34114 commit a9090ee

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
@@ -342,7 +342,7 @@ static const char *ulite_type(struct uart_port *port)
342342

343343
static void ulite_release_port(struct uart_port *port)
344344
{
345-
release_mem_region(port->mapbase, ULITE_REGION);
345+
release_mem_region(port->mapbase, port->mapsize);
346346
iounmap(port->membase);
347347
port->membase = NULL;
348348
}
@@ -356,15 +356,15 @@ static int ulite_request_port(struct uart_port *port)
356356
"ulite console: port=%p; port->mapbase=%llx\n",
357357
port, (unsigned long long) port->mapbase);
358358

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

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

@@ -649,6 +649,7 @@ static int ulite_assign(struct device *dev, int id, u32 base, int irq,
649649
port->iotype = UPIO_MEM;
650650
port->iobase = 1; /* mark port in use */
651651
port->mapbase = base;
652+
port->mapsize = ULITE_REGION;
652653
port->membase = NULL;
653654
port->ops = &ulite_ops;
654655
port->irq = irq;

0 commit comments

Comments
 (0)