lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <F3DBB1B3EF102E4994C89758CFCA32412C5AB3@DBDE01.ent.ti.com>
Date:	Fri, 8 Feb 2013 05:37:58 +0000
From:	"Kumar, Anil" <anilkumar.v@...com>
To:	"linux-watchdog@...r.kernel.org" <linux-watchdog@...r.kernel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"davinci-linux-open-source@...ux.davincidsp.com" 
	<davinci-linux-open-source@...ux.davincidsp.com>
CC:	"wim@...ana.be" <wim@...ana.be>, "Nori, Sekhar" <nsekhar@...com>,
	"Kumar, Anil" <anilkumar.v@...com>
Subject: RE: [PATCH] watchdog: davinci_wdt: update to devm_* API

On Thu, Feb 07, 2013 at 09:02:15, Kumar, Anil wrote:
> Update the code to use devm_* API so that driver
> core will manage resources.
> 
> Signed-off-by: Kumar, Anil <anilkumar.v@...com>
> ---
> This patch applies on top of v3.8-rc6.
> 
> Tested on da850 EVM.
> 
> :100644 100644 e8e8724... 6ad76a3... M	drivers/watchdog/davinci_wdt.c
>  drivers/watchdog/davinci_wdt.c |   34 +++++++++-------------------------
>  1 files changed, 9 insertions(+), 25 deletions(-)
> 
> diff --git a/drivers/watchdog/davinci_wdt.c b/drivers/watchdog/davinci_wdt.c
> index e8e8724..6ad76a3 100644
> --- a/drivers/watchdog/davinci_wdt.c
> +++ b/drivers/watchdog/davinci_wdt.c
> @@ -69,7 +69,6 @@ static unsigned long wdt_status;
>  #define WDT_REGION_INITED 2
>  #define WDT_DEVICE_INITED 3
>  
> -static struct resource	*wdt_mem;
>  static void __iomem	*wdt_base;
>  struct clk		*wdt_clk;
>  
> @@ -201,10 +200,10 @@ static struct miscdevice davinci_wdt_miscdev = {
>  
>  static int davinci_wdt_probe(struct platform_device *pdev)
>  {
> -	int ret = 0, size;
> -	struct device *dev = &pdev->dev;
> +	int ret = 0;
> +	static struct resource  *wdt_mem;
>  
> -	wdt_clk = clk_get(dev, NULL);
> +	wdt_clk = clk_get(&pdev->dev, NULL);
>  	if (WARN_ON(IS_ERR(wdt_clk)))
>  		return PTR_ERR(wdt_clk);
>  
> @@ -213,49 +212,34 @@ static int davinci_wdt_probe(struct platform_device *pdev)
>  	if (heartbeat < 1 || heartbeat > MAX_HEARTBEAT)
>  		heartbeat = DEFAULT_HEARTBEAT;
>  
> -	dev_info(dev, "heartbeat %d sec\n", heartbeat);
> +	dev_info(&pdev->dev, "heartbeat %d sec\n", heartbeat);
>  
>  	wdt_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	if (wdt_mem == NULL) {
> -		dev_err(dev, "failed to get memory region resource\n");
> +		dev_err(&pdev->dev, "failed to get memory region resource\n");
>  		return -ENOENT;
>  	}
>  
> -	size = resource_size(wdt_mem);
> -	if (!request_mem_region(wdt_mem->start, size, pdev->name)) {
> -		dev_err(dev, "failed to get memory region\n");
> -		return -ENOENT;
> -	}
> -
> -	wdt_base = ioremap(wdt_mem->start, size);
> +	wdt_base = devm_request_and_ioremap(&pdev->dev, wdt_mem);
>  	if (!wdt_base) {
> -		dev_err(dev, "failed to map memory region\n");
> -		release_mem_region(wdt_mem->start, size);
> -		wdt_mem = NULL;
> +		dev_err(&pdev->dev, "ioremap failed\n");
>  		return -ENOMEM;
>  	}
>  
>  	ret = misc_register(&davinci_wdt_miscdev);
>  	if (ret < 0) {
> -		dev_err(dev, "cannot register misc device\n");
> -		release_mem_region(wdt_mem->start, size);
> -		wdt_mem = NULL;
> +		dev_err(&pdev->dev, "cannot register misc device\n");
>  	} else {
>  		set_bit(WDT_DEVICE_INITED, &wdt_status);
> +		return ret;

No need of return "ret" as it is retuning "ret" just below.
I will fix it in V2.	

>  	}
>  
> -	iounmap(wdt_base);
>  	return ret;
>  }
>  
>  static int davinci_wdt_remove(struct platform_device *pdev)
>  {
>  	misc_deregister(&davinci_wdt_miscdev);
> -	if (wdt_mem) {
> -		release_mem_region(wdt_mem->start, resource_size(wdt_mem));
> -		wdt_mem = NULL;
> -	}
> -
>  	clk_disable_unprepare(wdt_clk);
>  	clk_put(wdt_clk);
>  
> -- 
> 1.7.4.1
> 
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ