[PATCH 5/8] mtd: gpmi: use devm_ioremap_resource

Ezequiel Garcia ezequiel.garcia at free-electrons.com
Thu Nov 14 08:50:34 EST 2013


On Thu, Nov 14, 2013 at 02:25:48PM +0800, Huang Shijie wrote:
> Use the devm_ioremap_resource to simplify the code.
> 
> Signed-off-by: Huang Shijie <b32955 at freescale.com>
> ---
>  drivers/mtd/nand/gpmi-nand/gpmi-nand.c |   26 +++-----------------------
>  1 files changed, 3 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> index 36ef60a..1f99038 100644
> --- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> +++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> @@ -486,16 +486,9 @@ static int acquire_register_block(struct gpmi_nand_data *this,
>  	void __iomem *p;
>  
>  	r = platform_get_resource_byname(pdev, IORESOURCE_MEM, res_name);
> -	if (!r) {
> -		pr_err("Can't get resource for %s\n", res_name);
> -		return -ENODEV;
> -	}
> -
> -	p = ioremap(r->start, resource_size(r));
> -	if (!p) {
> -		pr_err("Can't remap %s\n", res_name);
> -		return -ENOMEM;
> -	}
> +	p = devm_ioremap_resource(&pdev->dev, r);
> +	if (IS_ERR(p))
> +		return PTR_ERR(p);

Hm... devm_ioremap_resource() is not "pin-to-pin" replacement for the
combination of platform_get_resource + ioremap. Instead, you're adding
a request_memory() call.

So, this is an improvement, and it's fine to do so. I'm just warning
about a change in the driver's behavior.
-- 
Ezequiel García, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com



More information about the linux-mtd mailing list