[PATCH 7/8] mtd: plat_nand: Use devm_*() functions

Brian Norris computersforpeace at gmail.com
Thu Jan 2 20:17:36 EST 2014


On Fri, Dec 20, 2013 at 02:04:29PM +0900, Jingoo Han wrote:
> --- a/drivers/mtd/nand/plat_nand.c
> +++ b/drivers/mtd/nand/plat_nand.c
> @@ -52,25 +52,16 @@ static int plat_nand_probe(struct platform_device *pdev)
>  		return -ENXIO;
>  
>  	/* Allocate memory for the device structure (and zero it) */
> -	data = kzalloc(sizeof(struct plat_nand_data), GFP_KERNEL);
> +	data = devm_kzalloc(&pdev->dev, sizeof(struct plat_nand_data),
> +			    GFP_KERNEL);
>  	if (!data) {
>  		dev_err(&pdev->dev, "failed to allocate device structure.\n");
>  		return -ENOMEM;
>  	}
>  
> -	if (!request_mem_region(res->start, resource_size(res),
> -				dev_name(&pdev->dev))) {
> -		dev_err(&pdev->dev, "request_mem_region failed\n");
> -		err = -EBUSY;
> -		goto out_free;
> -	}
> -
> -	data->io_base = ioremap(res->start, resource_size(res));
> -	if (data->io_base == NULL) {
> -		dev_err(&pdev->dev, "ioremap failed\n");
> -		err = -EIO;
> -		goto out_release_io;
> -	}
> +	data->io_base = devm_ioremap_resource(&pdev->dev, res);
> +	if (IS_ERR(data->io_base))
> +		return PTR_ERR(data->io_base);

This gives me a few errors:

drivers/mtd/nand/plat_nand.c: In function 'plat_nand_probe':
drivers/mtd/nand/plat_nand.c:61:2: error: implicit declaration of function 'IS_ERR' [-Werror=implicit-function-declaration]
drivers/mtd/nand/plat_nand.c:62:3: error: implicit declaration of function 'PTR_ERR' [-Werror=implicit-function-declaration]
make[4]: *** [drivers/mtd/nand/plat_nand.o] Error 1

You probably need to #include <linux/err.h>. I guess you don't
compile-test your changes? It would help if you can catch these mistakes
before they get to the maintainer.

>  
>  	data->chip.priv = &data;
>  	data->mtd.priv = &data->chip;

Brian



More information about the linux-mtd mailing list