Re: [PATCH] drivers/mtd/devices/spear_smi.c: use devm_ functions consistently

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[See here for the original patch:
 http://lists.infradead.org/pipermail/linux-mtd/2012-August/043112.html]

Julia, sorry for long delay,

aiaiai gives says that this patch introduced 3 warnings:

--------------------------------------------------------------------------------

Successfully built configuration "arm-spear6xx_defconfig,arm,arm-unknown-linux-gnueabi-", results:

--- before_patching.log
+++ after_patching.log
@@ @@
-drivers/mtd/devices/spear_smi.c: In function 'spear_smi_remove':
-drivers/mtd/devices/spear_smi.c:1022:30: warning: variable 'pdata' set but not used [-Wunused-but-set-variable]
+drivers/mtd/devices/spear_smi.c: In function 'spear_smi_remove':
+drivers/mtd/devices/spear_smi.c:1026:9: warning: variable 'irq' set but not used [-Wunused-but-set-variable]
+drivers/mtd/devices/spear_smi.c:1022:30: warning: variable 'pdata' set but not used [-Wunused-but-set-variable]
+drivers/mtd/devices/spear_smi.c:1024:19: warning: variable 'smi_base' set but not used [-Wunused-but-set-variable]

--------------------------------------------------------------------------------


On Sat, 2012-08-04 at 22:36 +0200, Julia Lawall wrote:
> From: Julia Lawall <Julia.Lawall@xxxxxxx>
> 
> Use devm_kzalloc for all calls to kzalloc and not just the first.  Use devm
> functions for other allocations as well.
> 
> Move the call to platform_get_resource(pdev, IORESOURCE_MEM, 0) closer to
> where its result is passed to devm_request_and_ioremap to make the lack of
> need for a NULL test more evident.
> 
> The semantic match that finds the inconsistency is as follows:
> (http://coccinelle.lip6.fr/)

...

> @@ -1073,21 +1043,13 @@ static int __devexit spear_smi_remove(struct platform_device *pdev)
>  		ret = mtd_device_unregister(&flash->mtd);
>  		if (ret)
>  			dev_err(&pdev->dev, "error removing mtd\n");
> -
> -		iounmap(flash->base_addr);
> -		kfree(flash);
>  	}
>  
>  	irq = platform_get_irq(pdev, 0);
> -	free_irq(irq, dev);

I guess 'platform_get_irq()' should be killed as well? Stefan, this is
strange code - we get irq, without checking for error, and then free it?
What is the rationale?

>  	clk_disable_unprepare(dev->clk);
> -	clk_put(dev->clk);
> -	iounmap(dev->io_base);
> -	kfree(dev);
>  
>  	smi_base = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	release_mem_region(smi_base->start, resource_size(smi_base));
>  	platform_set_drvdata(pdev, NULL);

Why do we set platform data to NULL, is this needed?


-- 
Best Regards,
Artem Bityutskiy

Attachment: signature.asc
Description: This is a digitally signed message part


[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux