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: <5084EF0E.20300@metafoo.de>
Date:	Mon, 22 Oct 2012 09:00:30 +0200
From:	Lars-Peter Clausen <lars@...afoo.de>
To:	Marcos Paulo de Souza <marcos.souza.org@...il.com>
CC:	cbou@...l.ru, dwmw2@...radead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/2 v2] drivers: power: jz4740_battery: Use devm_request_and_ioremap

On 10/22/2012 03:13 AM, Marcos Paulo de Souza wrote:
> And remove all checks abvout request_mem_region and ioremap.
> This is just a cleanup. Not functional changes here.
> 
> Signed-off-by: Marcos Paulo de Souza <marcos.souza.org@...il.com>

Thanks, looks almost good. But you could also have removed the check and error
message after platform_get_resource since devm_request_and_ioremap also does
this internally. Also you can remove the mem field from jz_battery struct since
it now only is used in the probe function.

> ---
>  drivers/power/jz4740-battery.c |   23 +++++------------------
>  1 file changed, 5 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/power/jz4740-battery.c b/drivers/power/jz4740-battery.c
> index 59900c6..1df7be8 100644
> --- a/drivers/power/jz4740-battery.c
> +++ b/drivers/power/jz4740-battery.c
> @@ -272,19 +272,12 @@ static int __devinit jz_battery_probe(struct platform_device *pdev)
>  		return -ENOENT;
>  	}
>  
> -	jz_battery->mem = request_mem_region(jz_battery->mem->start,
> -				resource_size(jz_battery->mem),	pdev->name);
> -	if (!jz_battery->mem) {
> -		dev_err(&pdev->dev, "Failed to request mmio memory region\n");
> -		return -EBUSY;
> -	}
> +	jz_battery->base = devm_request_and_ioremap(&pdev->dev
> +							, jz_battery->mem);

The comma should go on the previous line, after the dev.

>  
> -	jz_battery->base = ioremap_nocache(jz_battery->mem->start,
> -				resource_size(jz_battery->mem));
>  	if (!jz_battery->base) {
> -		ret = -EBUSY;
>  		dev_err(&pdev->dev, "Failed to ioremap mmio memory\n");
> -		goto err_release_mem_region;
> +		return -EBUSY;
>  	}
>  
>  	battery = &jz_battery->battery;
> @@ -308,7 +301,7 @@ static int __devinit jz_battery_probe(struct platform_device *pdev)
>  			jz_battery);
>  	if (ret) {
>  		dev_err(&pdev->dev, "Failed to request irq %d\n", ret);
> -		goto err_iounmap;
> +		goto err_irq;
>  	}
>  	disable_irq(jz_battery->irq);
>  
> @@ -365,11 +358,8 @@ err_free_gpio:
>  		gpio_free(jz_battery->pdata->gpio_charge);
>  err_free_irq:
>  	free_irq(jz_battery->irq, jz_battery);
> -err_iounmap:
> +err_irq:
>  	platform_set_drvdata(pdev, NULL);
> -	iounmap(jz_battery->base);
> -err_release_mem_region:
> -	release_mem_region(jz_battery->mem->start, resource_size(jz_battery->mem));
>  	return ret;
>  }
>  
> @@ -389,9 +379,6 @@ static int __devexit jz_battery_remove(struct platform_device *pdev)
>  
>  	free_irq(jz_battery->irq, jz_battery);
>  
> -	iounmap(jz_battery->base);
> -	release_mem_region(jz_battery->mem->start, resource_size(jz_battery->mem));
> -
>  	return 0;
>  }
>  

--
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