Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

serial: 8250_aspeed_vuart: use UPF_IOREMAP to set up register mapping

Previously this driver's use of devm_ioremap_resource() led to
duplicated calls to __release_region() when unbinding it (one from
serial8250_release_std_resource() and one from devres_release_all()),
the second of which resulted in a warning message:

# echo 1e787000.serial > /sys/bus/platform/drivers/aspeed-vuart/unbind
[33091.774200] Trying to free nonexistent resource <000000001e787000-000000001e78703f>

With this change the driver uses the generic serial8250 code's
UPF_IOREMAP to take care of the register mapping automatically instead
of doing its own devm_ioremap_resource(), thus avoiding the duplicate
__release_region() on unbind.

In doing this we eliminate vuart->regs, since it merely duplicates
vuart->port->port.membase, which we now use for our I/O accesses.

Reported-by: Andrew Jeffery <andrew@aj.id.au>
Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
Link: https://lore.kernel.org/r/20210510014231.647-4-zev@bewilderbeest.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Zev Weiss and committed by
Greg Kroah-Hartman
54da3e38 c9805fbf

+3 -8
+3 -8
drivers/tty/serial/8250/8250_aspeed_vuart.c
··· 34 34 35 35 struct aspeed_vuart { 36 36 struct device *dev; 37 - void __iomem *regs; 38 37 struct clk *clk; 39 38 int line; 40 39 struct timer_list unthrottle_timer; ··· 65 66 66 67 static inline u8 aspeed_vuart_readb(struct aspeed_vuart *vuart, u8 reg) 67 68 { 68 - return readb(vuart->regs + reg); 69 + return readb(vuart->port->port.membase + reg); 69 70 } 70 71 71 72 static inline void aspeed_vuart_writeb(struct aspeed_vuart *vuart, u8 val, u8 reg) 72 73 { 73 - writeb(val, vuart->regs + reg); 74 + writeb(val, vuart->port->port.membase + reg); 74 75 } 75 76 76 77 static ssize_t lpc_address_show(struct device *dev, ··· 428 429 timer_setup(&vuart->unthrottle_timer, aspeed_vuart_unthrottle_exp, 0); 429 430 430 431 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 431 - vuart->regs = devm_ioremap_resource(&pdev->dev, res); 432 - if (IS_ERR(vuart->regs)) 433 - return PTR_ERR(vuart->regs); 434 432 435 433 memset(&port, 0, sizeof(port)); 436 434 port.port.private_data = vuart; 437 - port.port.membase = vuart->regs; 438 435 port.port.mapbase = res->start; 439 436 port.port.mapsize = resource_size(res); 440 437 port.port.startup = aspeed_vuart_startup; ··· 487 492 port.port.iotype = UPIO_MEM; 488 493 port.port.type = PORT_16550A; 489 494 port.port.uartclk = clk; 490 - port.port.flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF 495 + port.port.flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_IOREMAP 491 496 | UPF_FIXED_PORT | UPF_FIXED_TYPE | UPF_NO_THRE_TEST; 492 497 493 498 if (of_property_read_bool(np, "no-loopback-test"))