Skip to content

Commit

Permalink
drivers: tty: serial: sb1250-duart: 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 Feb 7, 2021
1 parent d806df4 commit 49b1946
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions drivers/tty/serial/sb1250-duart.c
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ static void sbd_release_port(struct uart_port *uport)

if(refcount_dec_and_test(&duart->map_guard))
release_mem_region(duart->mapctrl, DUART_CHANREG_SPACING);
release_mem_region(uport->mapbase, DUART_CHANREG_SPACING);
release_mem_region(uport->mapbase, uport->mapsize);
}

static int sbd_map_port(struct uart_port *uport)
Expand All @@ -663,7 +663,7 @@ static int sbd_map_port(struct uart_port *uport)

if (!uport->membase)
uport->membase = ioremap(uport->mapbase,
DUART_CHANREG_SPACING);
uport->mapsize);
if (!uport->membase) {
dev_err(uport->dev, "Cannot map MMIO (base)\n");
return -ENOMEM;
Expand All @@ -688,7 +688,7 @@ static int sbd_request_port(struct uart_port *uport)
struct sbd_duart *duart = to_sport(uport)->duart;
int ret = 0;

if (!request_mem_region(uport->mapbase, DUART_CHANREG_SPACING,
if (!request_mem_region(uport->mapbase, uport->mapsize,
"sb1250-duart")) {
pr_err(err);
return -EBUSY;
Expand All @@ -711,7 +711,7 @@ static int sbd_request_port(struct uart_port *uport)
}
}
if (ret) {
release_mem_region(uport->mapbase, DUART_CHANREG_SPACING);
release_mem_region(uport->mapbase, uport->mapsize);
return ret;
}
return 0;
Expand Down Expand Up @@ -808,6 +808,7 @@ static void __init sbd_probe_duarts(void)
uport->line = line;
uport->mapbase = SBD_CHANREGS(line);
uport->has_sysrq = IS_ENABLED(CONFIG_SERIAL_SB1250_DUART_CONSOLE);
uport->mapsize = DUART_CHANREG_SPACING;
}
}
}
Expand Down

0 comments on commit 49b1946

Please sign in to comment.