Patchwork [v2,1/2] i2c: i2c-bfin-twi: don`t free peripheral before it init successful

login
register
mail settings
Submitter Libo Chen
Date May 9, 2013, 8:27 a.m.
Message ID <1368088044-20408-2-git-send-email-libo.chen@huawei.com>
Download mbox | patch
Permalink /patch/242724/
State Changes Requested
Headers show

Comments

Libo Chen - May 9, 2013, 8:27 a.m.
down out_error_no_irq. When platform_get_irq fail, no need to free peripheral

Signed-off-by: Libo Chen <libo.chen@huawei.com>
---
 drivers/i2c/busses/i2c-bfin-twi.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Zhang, Sonic - May 9, 2013, 8:31 a.m.
Acked-by: Sonic Zhang <sonic.zhang@analog.com>

>-----Original Message-----
>From: Libo Chen [mailto:libo.chen@huawei.com]
>Sent: Thursday, May 09, 2013 4:27 PM
>To: Zhang, Sonic; wsa@the-dreams.de
>Cc: uclinux-dist-devel@blackfin.uclinux.org; linux-kernel@vger.kernel.org; linux-
>i2c@vger.kernel.org; lizefan@huawei.com; Libo Chen
>Subject: [PATCH v2 1/2] i2c: i2c-bfin-twi: don`t free peripheral before it init
>successful
>
>down out_error_no_irq. When platform_get_irq fail, no need to free peripheral
>
>Signed-off-by: Libo Chen <libo.chen@huawei.com>
>---
> drivers/i2c/busses/i2c-bfin-twi.c |    2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
>diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
>index 05080c4..6617645 100644
>--- a/drivers/i2c/busses/i2c-bfin-twi.c
>+++ b/drivers/i2c/busses/i2c-bfin-twi.c
>@@ -709,9 +709,9 @@ static int i2c_bfin_twi_probe(struct platform_device *pdev)
> out_error_add_adapter:
>       free_irq(iface->irq, iface);
> out_error_req_irq:
>-out_error_no_irq:
>       peripheral_free_list((unsigned short *)pdev->dev.platform_data);
> out_error_pin_mux:
>+out_error_no_irq:
>       iounmap(iface->regs_base);
> out_error_ioremap:
> out_error_get_res:
>--
>1.7.1
>
>


--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Zhang, Sonic - May 9, 2013, 8:33 a.m.
Hi Libo,

>-----Original Message-----
>From: Libo Chen [mailto:libo.chen@huawei.com]
>Sent: Thursday, May 09, 2013 4:27 PM
>To: Zhang, Sonic; wsa@the-dreams.de
>Cc: uclinux-dist-devel@blackfin.uclinux.org; linux-kernel@vger.kernel.org; linux-
>i2c@vger.kernel.org; lizefan@huawei.com; Libo Chen
>Subject: [PATCH v2 1/2] i2c: i2c-bfin-twi: don`t free peripheral before it init
>successful
>
>down out_error_no_irq. When platform_get_irq fail, no need to free peripheral
>
>Signed-off-by: Libo Chen <libo.chen@huawei.com>
>---
> drivers/i2c/busses/i2c-bfin-twi.c |    2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
>diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
>index 05080c4..6617645 100644
>--- a/drivers/i2c/busses/i2c-bfin-twi.c
>+++ b/drivers/i2c/busses/i2c-bfin-twi.c
>@@ -709,9 +709,9 @@ static int i2c_bfin_twi_probe(struct platform_device *pdev)
> out_error_add_adapter:
>       free_irq(iface->irq, iface);
> out_error_req_irq:
>-out_error_no_irq:
>       peripheral_free_list((unsigned short *)pdev->dev.platform_data);
> out_error_pin_mux:
>+out_error_no_irq:
>       iounmap(iface->regs_base);
> out_error_ioremap:
> out_error_get_res:
>--

Sorry, but you didn't exchange as I suggested.
Should be

> out_error_req_irq:
>-out_error_no_irq:
>+out_error_pin_mux:
>       peripheral_free_list((unsigned short *)pdev->dev.platform_data);
>-out_error_pin_mux:
>+out_error_no_irq:


Regards,

Sonic

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Zhang, Sonic - May 9, 2013, 8:34 a.m.
Please ignore my Ack.

Sonic

>-----Original Message-----
>From: Zhang, Sonic
>Sent: Thursday, May 09, 2013 4:31 PM
>To: 'Libo Chen'; wsa@the-dreams.de
>Cc: uclinux-dist-devel@blackfin.uclinux.org; linux-kernel@vger.kernel.org; linux-
>i2c@vger.kernel.org; lizefan@huawei.com
>Subject: RE: [PATCH v2 1/2] i2c: i2c-bfin-twi: don`t free peripheral before it init
>successful
>
>Acked-by: Sonic Zhang <sonic.zhang@analog.com>
>
>>-----Original Message-----
>>From: Libo Chen [mailto:libo.chen@huawei.com]
>>Sent: Thursday, May 09, 2013 4:27 PM
>>To: Zhang, Sonic; wsa@the-dreams.de
>>Cc: uclinux-dist-devel@blackfin.uclinux.org;
>>linux-kernel@vger.kernel.org; linux- i2c@vger.kernel.org;
>>lizefan@huawei.com; Libo Chen
>>Subject: [PATCH v2 1/2] i2c: i2c-bfin-twi: don`t free peripheral before
>>it init successful
>>
>>down out_error_no_irq. When platform_get_irq fail, no need to free
>>peripheral
>>
>>Signed-off-by: Libo Chen <libo.chen@huawei.com>
>>---
>> drivers/i2c/busses/i2c-bfin-twi.c |    2 +-
>> 1 files changed, 1 insertions(+), 1 deletions(-)
>>
>>diff --git a/drivers/i2c/busses/i2c-bfin-twi.c
>>b/drivers/i2c/busses/i2c-bfin-twi.c
>>index 05080c4..6617645 100644
>>--- a/drivers/i2c/busses/i2c-bfin-twi.c
>>+++ b/drivers/i2c/busses/i2c-bfin-twi.c
>>@@ -709,9 +709,9 @@ static int i2c_bfin_twi_probe(struct
>>platform_device *pdev)
>> out_error_add_adapter:
>>      free_irq(iface->irq, iface);
>> out_error_req_irq:
>>-out_error_no_irq:
>>      peripheral_free_list((unsigned short *)pdev->dev.platform_data);
>> out_error_pin_mux:
>>+out_error_no_irq:
>>      iounmap(iface->regs_base);
>> out_error_ioremap:
>> out_error_get_res:
>>--
>>1.7.1
>>
>>


--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Libo Chen - May 10, 2013, 1:01 a.m.
On 2013/5/9 16:33, Zhang, Sonic wrote:
> Hi Libo,
> 
>> -----Original Message-----
>> From: Libo Chen [mailto:libo.chen@huawei.com]
>> Sent: Thursday, May 09, 2013 4:27 PM
>> To: Zhang, Sonic; wsa@the-dreams.de
>> Cc: uclinux-dist-devel@blackfin.uclinux.org; linux-kernel@vger.kernel.org; linux-
>> i2c@vger.kernel.org; lizefan@huawei.com; Libo Chen
>> Subject: [PATCH v2 1/2] i2c: i2c-bfin-twi: don`t free peripheral before it init
>> successful
>>
>> down out_error_no_irq. When platform_get_irq fail, no need to free peripheral
>>
>> Signed-off-by: Libo Chen <libo.chen@huawei.com>
>> ---
>> drivers/i2c/busses/i2c-bfin-twi.c |    2 +-
>> 1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
>> index 05080c4..6617645 100644
>> --- a/drivers/i2c/busses/i2c-bfin-twi.c
>> +++ b/drivers/i2c/busses/i2c-bfin-twi.c
>> @@ -709,9 +709,9 @@ static int i2c_bfin_twi_probe(struct platform_device *pdev)
>> out_error_add_adapter:
>>       free_irq(iface->irq, iface);
>> out_error_req_irq:
>> -out_error_no_irq:
>>       peripheral_free_list((unsigned short *)pdev->dev.platform_data);
>> out_error_pin_mux:
>> +out_error_no_irq:
>>       iounmap(iface->regs_base);
>> out_error_ioremap:
>> out_error_get_res:
>> --
> 
> Sorry, but you didn't exchange as I suggested.
> Should be
> 

Hi Sonic,

Look at peripheral_request_list()
{
	u16 cnt;
	int ret;

	for (cnt = 0; per[cnt] != 0; cnt++) {

		ret = peripheral_request(per[cnt], label);

		if (ret < 0) {
			for ( ; cnt > 0; cnt--)
				peripheral_free(per[cnt - 1]);

			return ret;
		}
	}

	return 0;
}


When peripheral_request fail, it had called peripheral_free().
So there is no reason to call peripheral_free_list again.

Did I miss something else?


>> out_error_req_irq:
>> -out_error_no_irq:
>> +out_error_pin_mux:
>>       peripheral_free_list((unsigned short *)pdev->dev.platform_data);
>> -out_error_pin_mux:
>> +out_error_no_irq:
> 
> 
> Regards,
> 
> Sonic
> 
> 
> 


--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Zhang, Sonic - May 13, 2013, 8:52 a.m.
Hi Libo,

>-----Original Message-----
>From: Libo Chen [mailto:clbchenlibo.chen@huawei.com]
>Sent: Friday, May 10, 2013 9:02 AM
>To: Zhang, Sonic
>Cc: Libo Chen; wsa@the-dreams.de; uclinux-dist-devel@blackfin.uclinux.org;
>linux-kernel@vger.kernel.org; linux-i2c@vger.kernel.org; lizefan@huawei.com
>Subject: Re: [PATCH v2 1/2] i2c: i2c-bfin-twi: don`t free peripheral before it init
>successful
>
>On 2013/5/9 16:33, Zhang, Sonic wrote:
>> Hi Libo,
>>
>>> -----Original Message-----
>>> From: Libo Chen [mailto:libo.chen@huawei.com]
>>> Sent: Thursday, May 09, 2013 4:27 PM
>>> To: Zhang, Sonic; wsa@the-dreams.de
>>> Cc: uclinux-dist-devel@blackfin.uclinux.org;
>>> linux-kernel@vger.kernel.org; linux- i2c@vger.kernel.org;
>>> lizefan@huawei.com; Libo Chen
>>> Subject: [PATCH v2 1/2] i2c: i2c-bfin-twi: don`t free peripheral
>>> before it init successful
>>>
>>> down out_error_no_irq. When platform_get_irq fail, no need to free
>>> peripheral
>>>
>>> Signed-off-by: Libo Chen <libo.chen@huawei.com>
>>> ---
>>> drivers/i2c/busses/i2c-bfin-twi.c |    2 +-
>>> 1 files changed, 1 insertions(+), 1 deletions(-)
>>>
>>> diff --git a/drivers/i2c/busses/i2c-bfin-twi.c
>>> b/drivers/i2c/busses/i2c-bfin-twi.c
>>> index 05080c4..6617645 100644
>>> --- a/drivers/i2c/busses/i2c-bfin-twi.c
>>> +++ b/drivers/i2c/busses/i2c-bfin-twi.c
>>> @@ -709,9 +709,9 @@ static int i2c_bfin_twi_probe(struct
>>> platform_device *pdev)
>>> out_error_add_adapter:
>>>       free_irq(iface->irq, iface);
>>> out_error_req_irq:
>>> -out_error_no_irq:
>>>       peripheral_free_list((unsigned short
>>> *)pdev->dev.platform_data);
>>> out_error_pin_mux:
>>> +out_error_no_irq:
>>>       iounmap(iface->regs_base);
>>> out_error_ioremap:
>>> out_error_get_res:
>>> --
>>
>> Sorry, but you didn't exchange as I suggested.
>> Should be
>>
>
>Hi Sonic,
>
>Look at peripheral_request_list()
>{
>       u16 cnt;
>       int ret;
>
>       for (cnt = 0; per[cnt] != 0; cnt++) {
>
>               ret = peripheral_request(per[cnt], label);
>
>               if (ret < 0) {
>                       for ( ; cnt > 0; cnt--)
>                               peripheral_free(per[cnt - 1]);
>
>                       return ret;
>               }
>       }
>
>       return 0;
>}
>
>
>When peripheral_request fail, it had called peripheral_free().
>So there is no reason to call peripheral_free_list again.
>
>Did I miss something else?
>
>
Yes, you are right. They are freed in peripheral_request_list() if any one fails.

You have my ACK on this patch.

Regards,

Sonic


--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
index 05080c4..6617645 100644
--- a/drivers/i2c/busses/i2c-bfin-twi.c
+++ b/drivers/i2c/busses/i2c-bfin-twi.c
@@ -709,9 +709,9 @@  static int i2c_bfin_twi_probe(struct platform_device *pdev)
 out_error_add_adapter:
 	free_irq(iface->irq, iface);
 out_error_req_irq:
-out_error_no_irq:
 	peripheral_free_list((unsigned short *)pdev->dev.platform_data);
 out_error_pin_mux:
+out_error_no_irq:
 	iounmap(iface->regs_base);
 out_error_ioremap:
 out_error_get_res: