serial/imx: only parse for iomem resources once
Subsystems (2)
PATCH 1/1 serial/imx: only parse for iomem resources once
Currently, the iomem resources are parsed in serial_imx_probe, then again in imx_request_port and imx_release_port.
This change uses the imx_port data to retrieve the start and size of the memory region, rather than re-parsing the resources through platform_get_resource.
--- drivers/serial/imx.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-)
drivers/serial/imx.c +6 -12
@@ -192,6 +192,7 @@ struct imx_port { unsigned int irda_inv_tx:1;unsigned short trcv_delay;/* transceiver delay */ struct clk *clk; +unsigned long mapsize; };#ifdef CONFIG_IRDA
@@ -945,11 +946,8 @@ static const char *imx_type(struct uart_port *port)*/ static void imx_release_port (struct uart_port *port) { -struct platform_device *pdev =to_platform_device (port->dev); -struct resource *mmres; - - mmres =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); -release_mem_region (mmres->start, mmres->end - mmres->start +1 ); + struct imx_port *imx_port = container_of(port, struct imx_port, port); +release_mem_region (imx_port->port.mapbase, imx_port->mapsize); }/*
@@ -957,15 +955,10 @@ static void imx_release_port(struct uart_port *port)*/ static int imx_request_port (struct uart_port *port) { -struct platform_device *pdev =to_platform_device (port->dev); -struct resource *mmres; + struct imx_port *imx_port = container_of(port, struct imx_port, port);void *ret; - mmres =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); -if (!mmres) -return -ENODEV ; - - ret =request_mem_region (mmres->start, mmres->end - mmres->start +1 , + ret =request_mem_region (imx_port->port.mapbase, imx_port->mapsize,"imx-uart" );return ret ?0 : -EBUSY ;
@@ -1245,6 +1238,7 @@ static int serial_imx_probe(struct platform_device *pdev) sport->port.dev = &pdev->dev; sport->port.mapbase = res->start; sport->port.membase = base; + sport->mapsize = res->end - res->start +1 ; sport->port.type =PORT_IMX , sport->port.iotype =UPIO_MEM ; sport->port.irq =platform_get_irq (pdev,0 );
PATCH 1/1 serial/imx: only parse for iomem resources once
Quoted 8 lines · Jeremy Kerr
Currently, the iomem resources are parsed in
serial_imx_probe, then again inimx_request_portandimx_release_port.This change uses the
imx_portdata to retrieve the start and size of the memory region, rather than re-parsing the resources throughplatform_get_resource.Signed-off-by Jeremy Kerr <[email protected]>
What are the effects for this regarding run time? How often are request_port and release_port called? I wonder if it's worth to save the value. Or what else than run time is your concern?
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH 1/1 serial/imx: only parse for iomem resources once
Hi Uwe,
Quoted 3 lines
What are the effects for this regarding run time? How often are
request_portandrelease_portcalled? I wonder if it's worth to save the value. Or what else than run time is your concern?
I'm not too concerned with the reduction in run time here - I'd like to be able to parse the UART config from the device tree, rather than using platform_get_{irq,resource}.
With this patch, all of the existing parsing is done in serial_imx_probe(). This means we can just abstract the parsing once, rather than having to check what parsing method (platform or devtree) we're using in request_port and release_port as well.
See serial_imx_probe_pdata and serial_imx_probe_dt in:
for my intended (work-in-progress) approach.
Cheers,
Jeremy
PATCH 1/1 serial/imx: only parse for iomem resources once
In reply to Jeremy KerrHello.
Quoted 18 lines · Jeremy Kerr
Currently, the iomem resources are parsed in
serial_imx_probe, then again inimx_request_portandimx_release_port.This change uses the
imx_portdata to retrieve the start and size of the memory region, rather than re-parsing the resources throughplatform_get_resource.Signed-off-by Jeremy Kerr <[email protected]>--- drivers/serial/imx.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-)drivers/serial/imx.c +0
-0
[...]
drivers/serial/imx.c static int serial_imx_probe(struct platform_device *pdev) · line 1242
Quoted 6 lines
drivers/serial/imx.c +1
-0@@ -1245,6 +1238,7 @@ static int serial_imx_probe(struct platform_device *pdev) sport->port.dev = &pdev->dev; sport->port.mapbase = res->start; sport->port.membase = base; + sport->mapsize = res->end - res->start +1 ;
There's resource_size() for this calculation.
WBR, Sergei