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] [thread-next>] [day] [month] [year] [list]
Message-ID: <20111024115649.GM8708@ponder.secretlab.ca>
Date:	Mon, 24 Oct 2011 13:56:49 +0200
From:	Grant Likely <grant.likely@...retlab.ca>
To:	Wolfram Sang <w.sang@...gutronix.de>
Cc:	linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
	Greg KH <gregkh@...e.de>, Tejun Heo <tj@...nel.org>
Subject: Re: [RFC 4/4] watchdog: imx2: simplify resource allocation

On Mon, Oct 24, 2011 at 10:42:09AM +0200, Wolfram Sang wrote:
> Use the new devm_resource_to_mapped_ptr function to simplify the code
> and standardize the error-handling. Silently fixes a wrong type for the
> resource_size variable as well.
> 
> Signed-off-by: Wolfram Sang <w.sang@...gutronix.de>
> ---
>  drivers/watchdog/imx2_wdt.c |   22 +++-------------------
>  1 files changed, 3 insertions(+), 19 deletions(-)

w00t!  I can see a lot of drivers simplified by using this.

g.

> 
> diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c
> index b8ef2c6..1fc6714 100644
> --- a/drivers/watchdog/imx2_wdt.c
> +++ b/drivers/watchdog/imx2_wdt.c
> @@ -247,28 +247,12 @@ static struct miscdevice imx2_wdt_miscdev = {
>  static int __init imx2_wdt_probe(struct platform_device *pdev)
>  {
>  	int ret;
> -	int res_size;
>  	struct resource *res;
>  
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	if (!res) {
> -		dev_err(&pdev->dev, "can't get device resources\n");
> -		return -ENODEV;
> -	}
> -
> -	res_size = resource_size(res);
> -	if (!devm_request_mem_region(&pdev->dev, res->start, res_size,
> -		res->name)) {
> -		dev_err(&pdev->dev, "can't allocate %d bytes at %d address\n",
> -			res_size, res->start);
> -		return -ENOMEM;
> -	}
> -
> -	imx2_wdt.base = devm_ioremap_nocache(&pdev->dev, res->start, res_size);
> -	if (!imx2_wdt.base) {
> -		dev_err(&pdev->dev, "ioremap failed\n");
> -		return -ENOMEM;
> -	}
> +	ret = devm_resource_to_mapped_ptr(&pdev->dev, res, &imx2_wdt.base);
> +	if (ret)
> +		return ret;
>  
>  	imx2_wdt.clk = clk_get(&pdev->dev, NULL);
>  	if (IS_ERR(imx2_wdt.clk)) {
> -- 
> 1.7.6.3
> 
--
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