diff mbox

pinctrl: pinctrl-single: Convert to devm_ioremap_resource()

Message ID 1377587134-8967-1-git-send-email-manishv.b@ti.com (mailing list archive)
State New, archived
Headers show

Commit Message

Vishwanathrao Badarkhe, Manish Aug. 27, 2013, 7:05 a.m. UTC
From: "Vishwanathrao Badarkhe, Manish" <manishv.b@ti.com>

Convert devm_request_mem_region() and devm_ioremap() to
devm_ioremap_resource() which provides more consistent
error handling to manage resource.

Signed-off-by: Vishwanathrao Badarkhe, Manish <manishv.b@ti.com>
---
:100644 100644 7323cca... b0fef18... M	drivers/pinctrl/pinctrl-single.c
 drivers/pinctrl/pinctrl-single.c |   21 +++------------------
 1 file changed, 3 insertions(+), 18 deletions(-)

Comments

Sergei Shtylyov Aug. 27, 2013, 12:19 p.m. UTC | #1
Hello.

On 27-08-2013 11:05, Vishwanathrao Badarkhe, Manish wrote:

> From: "Vishwanathrao Badarkhe, Manish" <manishv.b@ti.com>

> Convert devm_request_mem_region() and devm_ioremap() to
> devm_ioremap_resource() which provides more consistent
> error handling to manage resource.

> Signed-off-by: Vishwanathrao Badarkhe, Manish <manishv.b@ti.com>
> ---
> :100644 100644 7323cca... b0fef18... M	drivers/pinctrl/pinctrl-single.c
>   drivers/pinctrl/pinctrl-single.c |   21 +++------------------
>   1 file changed, 3 insertions(+), 18 deletions(-)

> diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
> index 7323cca..b0fef18 100644
> --- a/drivers/pinctrl/pinctrl-single.c
> +++ b/drivers/pinctrl/pinctrl-single.c
> @@ -1556,24 +1556,9 @@ static int pcs_probe(struct platform_device *pdev)
>   						  "pinctrl-single,bit-per-mux");
>
>   	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	if (!res) {
> -		dev_err(pcs->dev, "could not get resource\n");
> -		return -ENODEV;
> -	}
> -
> -	pcs->res = devm_request_mem_region(pcs->dev, res->start,
> -			resource_size(res), DRIVER_NAME);
> -	if (!pcs->res) {

    Is pcs->res used anywhere else?

> -		dev_err(pcs->dev, "could not get mem_region\n");
> -		return -EBUSY;
> -	}
> -
> -	pcs->size = resource_size(pcs->res);

    Is pcs->size used anywhere else?

> -	pcs->base = devm_ioremap(pcs->dev, pcs->res->start, pcs->size);
> -	if (!pcs->base) {
> -		dev_err(pcs->dev, "could not ioremap\n");
> -		return -ENODEV;
> -	}
> +	pcs->base = devm_ioremap_resource(pcs->dev, res);
> +	if (IS_ERR(pcs->base))
> +		return PTR_ERR(pcs->base);

WBR, Sergei
Vishwanathrao Badarkhe, Manish Aug. 27, 2013, 12:59 p.m. UTC | #2
Hi

On Tuesday 27 August 2013 05:49 PM, Sergei Shtylyov wrote:
> Hello.
>
> On 27-08-2013 11:05, Vishwanathrao Badarkhe, Manish wrote:
>
>> From: "Vishwanathrao Badarkhe, Manish" <manishv.b@ti.com>
>
>> Convert devm_request_mem_region() and devm_ioremap() to
>> devm_ioremap_resource() which provides more consistent
>> error handling to manage resource.
>
>> Signed-off-by: Vishwanathrao Badarkhe, Manish <manishv.b@ti.com>
>> ---
>> :100644 100644 7323cca... b0fef18... M drivers/pinctrl/pinctrl-single.c
>>   drivers/pinctrl/pinctrl-single.c |   21 +++------------------
>>   1 file changed, 3 insertions(+), 18 deletions(-)
>
>> diff --git a/drivers/pinctrl/pinctrl-single.c 
>> b/drivers/pinctrl/pinctrl-single.c
>> index 7323cca..b0fef18 100644
>> --- a/drivers/pinctrl/pinctrl-single.c
>> +++ b/drivers/pinctrl/pinctrl-single.c
>> @@ -1556,24 +1556,9 @@ static int pcs_probe(struct platform_device 
>> *pdev)
>>                             "pinctrl-single,bit-per-mux");
>>
>>       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> -    if (!res) {
>> -        dev_err(pcs->dev, "could not get resource\n");
>> -        return -ENODEV;
>> -    }
>> -
>> -    pcs->res = devm_request_mem_region(pcs->dev, res->start,
>> -            resource_size(res), DRIVER_NAME);
>> -    if (!pcs->res) {
>
>    Is pcs->res used anywhere else?

My bad, I have not seen this variable is used in another functions too.
>
>> -        dev_err(pcs->dev, "could not get mem_region\n");
>> -        return -EBUSY;
>> -    }
>> -
>> -    pcs->size = resource_size(pcs->res);
>
>    Is pcs->size used anywhere else?
My bad, I have not seen this variable is used in another functions too.
>
>> -    pcs->base = devm_ioremap(pcs->dev, pcs->res->start, pcs->size);
>> -    if (!pcs->base) {
>> -        dev_err(pcs->dev, "could not ioremap\n");
>> -        return -ENODEV;
>> -    }
>> +    pcs->base = devm_ioremap_resource(pcs->dev, res);
>> +    if (IS_ERR(pcs->base))
>> +        return PTR_ERR(pcs->base);
>
I will go through code again and update it accordingly.
>
Regards
Manish Badarkhe
diff mbox

Patch

diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index 7323cca..b0fef18 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -1556,24 +1556,9 @@  static int pcs_probe(struct platform_device *pdev)
 						  "pinctrl-single,bit-per-mux");
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(pcs->dev, "could not get resource\n");
-		return -ENODEV;
-	}
-
-	pcs->res = devm_request_mem_region(pcs->dev, res->start,
-			resource_size(res), DRIVER_NAME);
-	if (!pcs->res) {
-		dev_err(pcs->dev, "could not get mem_region\n");
-		return -EBUSY;
-	}
-
-	pcs->size = resource_size(pcs->res);
-	pcs->base = devm_ioremap(pcs->dev, pcs->res->start, pcs->size);
-	if (!pcs->base) {
-		dev_err(pcs->dev, "could not ioremap\n");
-		return -ENODEV;
-	}
+	pcs->base = devm_ioremap_resource(pcs->dev, res);
+	if (IS_ERR(pcs->base))
+		return PTR_ERR(pcs->base);
 
 	INIT_RADIX_TREE(&pcs->pgtree, GFP_KERNEL);
 	INIT_RADIX_TREE(&pcs->ftree, GFP_KERNEL);