* [PATCH] serial/imx: only parse for iomem resources once
@ 2010-04-21 8:33 Jeremy Kerr
2010-04-22 14:33 ` Uwe Kleine-König
2010-05-05 10:09 ` Sergei Shtylyov
0 siblings, 2 replies; 4+ messages in thread
From: Jeremy Kerr @ 2010-04-21 8:33 UTC (permalink / raw)
To: linux-arm-kernel
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.
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
---
drivers/serial/imx.c | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/drivers/serial/imx.c b/drivers/serial/imx.c
index e579d7a..7de6bf7 100644
--- a/drivers/serial/imx.c
+++ b/drivers/serial/imx.c
@@ -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);
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] serial/imx: only parse for iomem resources once
2010-04-21 8:33 [PATCH] serial/imx: only parse for iomem resources once Jeremy Kerr
@ 2010-04-22 14:33 ` Uwe Kleine-König
2010-04-23 3:02 ` Jeremy Kerr
2010-05-05 10:09 ` Sergei Shtylyov
1 sibling, 1 reply; 4+ messages in thread
From: Uwe Kleine-König @ 2010-04-22 14:33 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Apr 21, 2010 at 04:33:58PM +0800, Jeremy Kerr wrote:
> 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.
>
> Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
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
--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] serial/imx: only parse for iomem resources once
2010-04-22 14:33 ` Uwe Kleine-König
@ 2010-04-23 3:02 ` Jeremy Kerr
0 siblings, 0 replies; 4+ messages in thread
From: Jeremy Kerr @ 2010-04-23 3:02 UTC (permalink / raw)
To: linux-arm-kernel
Hi Uwe,
> 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?
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:
http://kernel.ubuntu.com/git?p=jk/dt/linux-2.6.git;a=blob;f=drivers/serial/imx.c;h=a54f6464d35920a81fdcc9fd93de3283260ab839;hb=2610717ecacfba0db34ad5b28ed6379560108912
for my intended (work-in-progress) approach.
Cheers,
Jeremy
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] serial/imx: only parse for iomem resources once
2010-04-21 8:33 [PATCH] serial/imx: only parse for iomem resources once Jeremy Kerr
2010-04-22 14:33 ` Uwe Kleine-König
@ 2010-05-05 10:09 ` Sergei Shtylyov
1 sibling, 0 replies; 4+ messages in thread
From: Sergei Shtylyov @ 2010-05-05 10:09 UTC (permalink / raw)
To: linux-arm-kernel
Hello.
Jeremy Kerr wrote:
> 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.
>
> Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
>
> ---
> drivers/serial/imx.c | 18 ++++++------------
> 1 file changed, 6 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/serial/imx.c b/drivers/serial/imx.c
> index e579d7a..7de6bf7 100644
> --- a/drivers/serial/imx.c
> +++ b/drivers/serial/imx.c
>
[...]
> @@ -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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-05-05 10:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-21 8:33 [PATCH] serial/imx: only parse for iomem resources once Jeremy Kerr
2010-04-22 14:33 ` Uwe Kleine-König
2010-04-23 3:02 ` Jeremy Kerr
2010-05-05 10:09 ` Sergei Shtylyov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).