diff mbox

[v2] i2c: change the id to let the i2c-gpio work

Message ID 1350034971-1050-1-git-send-email-voice.shen@atmel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Bo Shen Oct. 12, 2012, 9:42 a.m. UTC
The i2c-gpio driver will turn the platform device ID to busnum.
When using platfrom device ID as -1, it means dynamically assigned
the busnum. When writing code, we need to make sure the busnum,
and call i2c_register_board_info(int busnum, ...) to register device
if using -1, we do not know the value of busnum. 

In order to solve this issue, set the platform device ID as a fix number
Here using 0 to match the busnum used in i2c_regsiter_board_info().

Signed-off-by: Bo Shen <voice.shen@atmel.com>
---
Change since v1
  Make the commit message more clear
---
 arch/arm/mach-at91/at91sam9260_devices.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jean Delvare Oct. 12, 2012, 9:57 a.m. UTC | #1
On Fri, 12 Oct 2012 17:42:51 +0800, Bo Shen wrote:
> The i2c-gpio driver will turn the platform device ID to busnum.
> When using platfrom device ID as -1, it means dynamically assigned
> the busnum. When writing code, we need to make sure the busnum,
> and call i2c_register_board_info(int busnum, ...) to register device
> if using -1, we do not know the value of busnum. 
> 
> In order to solve this issue, set the platform device ID as a fix number
> Here using 0 to match the busnum used in i2c_regsiter_board_info().
> 
> Signed-off-by: Bo Shen <voice.shen@atmel.com>
> ---
> Change since v1
>   Make the commit message more clear
> ---
>  arch/arm/mach-at91/at91sam9260_devices.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm/mach-at91/at91sam9260_devices.c b/arch/arm/mach-at91/at91sam9260_devices.c
> index 0f24cfb..805ef95 100644
> --- a/arch/arm/mach-at91/at91sam9260_devices.c
> +++ b/arch/arm/mach-at91/at91sam9260_devices.c
> @@ -389,7 +389,7 @@ static struct i2c_gpio_platform_data pdata = {
>  
>  static struct platform_device at91sam9260_twi_device = {
>  	.name			= "i2c-gpio",
> -	.id			= -1,
> +	.id			= 0,
>  	.dev.platform_data	= &pdata,
>  };
>  

Acked-by: Jean Delvare <khali@linux-fr.org>
Joachim Eastwood Oct. 12, 2012, 5:42 p.m. UTC | #2
Hi Bo Shen,

On Fri, Oct 12, 2012 at 11:42 AM, Bo Shen <voice.shen@atmel.com> wrote:
> The i2c-gpio driver will turn the platform device ID to busnum.
> When using platfrom device ID as -1, it means dynamically assigned
> the busnum. When writing code, we need to make sure the busnum,
> and call i2c_register_board_info(int busnum, ...) to register device
> if using -1, we do not know the value of busnum.
>
> In order to solve this issue, set the platform device ID as a fix number
> Here using 0 to match the busnum used in i2c_regsiter_board_info().

I have been bitten by this myself on RM9200.

> Signed-off-by: Bo Shen <voice.shen@atmel.com>
> ---
> Change since v1
>   Make the commit message more clear
> ---
>  arch/arm/mach-at91/at91sam9260_devices.c |    2 +-

This pattern exist in at91rm9200_devices.c, at91sam9261_devices.c,
at91sam9263_devices.c and at91sam9rl_devices.c you might want to fix
them as well.

I assume we have the same problem if CONFIG_I2C_AT91 is set?
See further down in at91sam9260_devices.c we have another:  ".id = -1,"

regards
Joachim Eastwood

>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm/mach-at91/at91sam9260_devices.c b/arch/arm/mach-at91/at91sam9260_devices.c
> index 0f24cfb..805ef95 100644
> --- a/arch/arm/mach-at91/at91sam9260_devices.c
> +++ b/arch/arm/mach-at91/at91sam9260_devices.c
> @@ -389,7 +389,7 @@ static struct i2c_gpio_platform_data pdata = {
>
>  static struct platform_device at91sam9260_twi_device = {
>         .name                   = "i2c-gpio",
> -       .id                     = -1,
> +       .id                     = 0,
>         .dev.platform_data      = &pdata,
>  };
>
> --
> 1.7.9.5
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Bo Shen Oct. 15, 2012, 2:09 a.m. UTC | #3
Hi Joachim Eastwood,

On 10/13/2012 1:42, Joachim Eastwood wrote:
> Hi Bo Shen,
>
> On Fri, Oct 12, 2012 at 11:42 AM, Bo Shen <voice.shen@atmel.com> wrote:
>> The i2c-gpio driver will turn the platform device ID to busnum.
>> When using platfrom device ID as -1, it means dynamically assigned
>> the busnum. When writing code, we need to make sure the busnum,
>> and call i2c_register_board_info(int busnum, ...) to register device
>> if using -1, we do not know the value of busnum.
>>
>> In order to solve this issue, set the platform device ID as a fix number
>> Here using 0 to match the busnum used in i2c_regsiter_board_info().
>
> I have been bitten by this myself on RM9200.
>
>> Signed-off-by: Bo Shen <voice.shen@atmel.com>
>> ---
>> Change since v1
>>    Make the commit message more clear
>> ---
>>   arch/arm/mach-at91/at91sam9260_devices.c |    2 +-
>
> This pattern exist in at91rm9200_devices.c, at91sam9261_devices.c,
> at91sam9263_devices.c and at91sam9rl_devices.c you might want to fix
> them as well.

Thanks for your information.
After I test these boards, I will send patches to fix them, while not in 
this patch.

>
> I assume we have the same problem if CONFIG_I2C_AT91 is set?
> See further down in at91sam9260_devices.c we have another:  ".id = -1,"

Maybe Nikolaus Voss will deal with this case.

>
> regards
> Joachim Eastwood
>
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/arm/mach-at91/at91sam9260_devices.c b/arch/arm/mach-at91/at91sam9260_devices.c
>> index 0f24cfb..805ef95 100644
>> --- a/arch/arm/mach-at91/at91sam9260_devices.c
>> +++ b/arch/arm/mach-at91/at91sam9260_devices.c
>> @@ -389,7 +389,7 @@ static struct i2c_gpio_platform_data pdata = {
>>
>>   static struct platform_device at91sam9260_twi_device = {
>>          .name                   = "i2c-gpio",
>> -       .id                     = -1,
>> +       .id                     = 0,
>>          .dev.platform_data      = &pdata,
>>   };
>>
>> --
>> 1.7.9.5
>>
>>
>> _______________________________________________
>> linux-arm-kernel mailing list
>> linux-arm-kernel@lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Ludovic Desroches Oct. 15, 2012, 6:42 a.m. UTC | #4
Le 10/15/2012 04:09 AM, Bo Shen a écrit :
> Hi Joachim Eastwood,
>
> On 10/13/2012 1:42, Joachim Eastwood wrote:
>> Hi Bo Shen,
>>
>> On Fri, Oct 12, 2012 at 11:42 AM, Bo Shen <voice.shen@atmel.com> wrote:
>>> The i2c-gpio driver will turn the platform device ID to busnum.
>>> When using platfrom device ID as -1, it means dynamically assigned
>>> the busnum. When writing code, we need to make sure the busnum,
>>> and call i2c_register_board_info(int busnum, ...) to register device
>>> if using -1, we do not know the value of busnum.
>>>
>>> In order to solve this issue, set the platform device ID as a fix number
>>> Here using 0 to match the busnum used in i2c_regsiter_board_info().
>>
>> I have been bitten by this myself on RM9200.
>>
>>> Signed-off-by: Bo Shen <voice.shen@atmel.com>
>>> ---
>>> Change since v1
>>>    Make the commit message more clear
>>> ---
>>>   arch/arm/mach-at91/at91sam9260_devices.c |    2 +-
>>
>> This pattern exist in at91rm9200_devices.c, at91sam9261_devices.c,
>> at91sam9263_devices.c and at91sam9rl_devices.c you might want to fix
>> them as well.
>
> Thanks for your information.
> After I test these boards, I will send patches to fix them, while not in
> this patch.
>
>>
>> I assume we have the same problem if CONFIG_I2C_AT91 is set?
>> See further down in at91sam9260_devices.c we have another:  ".id = -1,"
>
> Maybe Nikolaus Voss will deal with this case.
>

Yes the problem is the same, I have encountered it and solved it in the 
same way but I was thinking there was a better way to correct it than 
removing dynamic id assignment.
Since setting the id to a fix value is acceptable this change can be 
done also when using i2c-at91.

>>
>> regards
>> Joachim Eastwood
>>
>>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/arch/arm/mach-at91/at91sam9260_devices.c
>>> b/arch/arm/mach-at91/at91sam9260_devices.c
>>> index 0f24cfb..805ef95 100644
>>> --- a/arch/arm/mach-at91/at91sam9260_devices.c
>>> +++ b/arch/arm/mach-at91/at91sam9260_devices.c
>>> @@ -389,7 +389,7 @@ static struct i2c_gpio_platform_data pdata = {
>>>
>>>   static struct platform_device at91sam9260_twi_device = {
>>>          .name                   = "i2c-gpio",
>>> -       .id                     = -1,
>>> +       .id                     = 0,
>>>          .dev.platform_data      = &pdata,
>>>   };
>>>
>>> --
>>> 1.7.9.5
>>>
>>>
>>> _______________________________________________
>>> linux-arm-kernel mailing list
>>> linux-arm-kernel@lists.infradead.org
>>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
> --
> 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
>
>
Nicolas Ferre Oct. 15, 2012, 8:12 a.m. UTC | #5
On 10/15/2012 04:09 AM, Bo Shen :
> Hi Joachim Eastwood,
> 
> On 10/13/2012 1:42, Joachim Eastwood wrote:
>> Hi Bo Shen,
>>
>> On Fri, Oct 12, 2012 at 11:42 AM, Bo Shen <voice.shen@atmel.com> wrote:
>>> The i2c-gpio driver will turn the platform device ID to busnum.
>>> When using platfrom device ID as -1, it means dynamically assigned
>>> the busnum. When writing code, we need to make sure the busnum,
>>> and call i2c_register_board_info(int busnum, ...) to register device
>>> if using -1, we do not know the value of busnum.
>>>
>>> In order to solve this issue, set the platform device ID as a fix number
>>> Here using 0 to match the busnum used in i2c_regsiter_board_info().
>>
>> I have been bitten by this myself on RM9200.
>>
>>> Signed-off-by: Bo Shen <voice.shen@atmel.com>
>>> ---
>>> Change since v1
>>>    Make the commit message more clear
>>> ---
>>>   arch/arm/mach-at91/at91sam9260_devices.c |    2 +-
>>
>> This pattern exist in at91rm9200_devices.c, at91sam9261_devices.c,
>> at91sam9263_devices.c and at91sam9rl_devices.c you might want to fix
>> them as well.
> 
> Thanks for your information.
> After I test these boards, I will send patches to fix them, while not in
> this patch.

I am in favor of doing a comprehensive patch series that covers all
aspects of this issue:
- each boards
- both i2c-gpio and i2c-at91 cases

Bye,
Bo Shen Oct. 15, 2012, 8:26 a.m. UTC | #6
Hi Nicolas,

On 10/15/2012 16:12, Nicolas Ferre wrote:
> On 10/15/2012 04:09 AM, Bo Shen :
>> Hi Joachim Eastwood,
>>
>> On 10/13/2012 1:42, Joachim Eastwood wrote:
>>> Hi Bo Shen,
>>>
>>> On Fri, Oct 12, 2012 at 11:42 AM, Bo Shen <voice.shen@atmel.com> wrote:
>>>> The i2c-gpio driver will turn the platform device ID to busnum.
>>>> When using platfrom device ID as -1, it means dynamically assigned
>>>> the busnum. When writing code, we need to make sure the busnum,
>>>> and call i2c_register_board_info(int busnum, ...) to register device
>>>> if using -1, we do not know the value of busnum.
>>>>
>>>> In order to solve this issue, set the platform device ID as a fix number
>>>> Here using 0 to match the busnum used in i2c_regsiter_board_info().
>>>
>>> I have been bitten by this myself on RM9200.
>>>
>>>> Signed-off-by: Bo Shen <voice.shen@atmel.com>
>>>> ---
>>>> Change since v1
>>>>     Make the commit message more clear
>>>> ---
>>>>    arch/arm/mach-at91/at91sam9260_devices.c |    2 +-
>>>
>>> This pattern exist in at91rm9200_devices.c, at91sam9261_devices.c,
>>> at91sam9263_devices.c and at91sam9rl_devices.c you might want to fix
>>> them as well.
>>
>> Thanks for your information.
>> After I test these boards, I will send patches to fix them, while not in
>> this patch.
>
> I am in favor of doing a comprehensive patch series that covers all
> aspects of this issue:
> - each boards
> - both i2c-gpio and i2c-at91 cases

May I need to submit this patch as a series? One patch for one board, 
and cover i2c-gpio and i2c-at91 cases.
e.g:
[patch 1/x] i2c: change id to let i2c-gpio work on at91rm200ek
[patch 2/x] i2c: change id to let i2c-gpio work on at91sam9261ek
...

or

Just one patch, cover all these boards and i2c-gpio and i2c-at91?

> Bye,
>
Nicolas Ferre Oct. 15, 2012, 8:30 a.m. UTC | #7
On 10/15/2012 10:26 AM, Bo Shen :
> Hi Nicolas,
> 
> On 10/15/2012 16:12, Nicolas Ferre wrote:
>> On 10/15/2012 04:09 AM, Bo Shen :
>>> Hi Joachim Eastwood,
>>>
>>> On 10/13/2012 1:42, Joachim Eastwood wrote:
>>>> Hi Bo Shen,
>>>>
>>>> On Fri, Oct 12, 2012 at 11:42 AM, Bo Shen <voice.shen@atmel.com> wrote:
>>>>> The i2c-gpio driver will turn the platform device ID to busnum.
>>>>> When using platfrom device ID as -1, it means dynamically assigned
>>>>> the busnum. When writing code, we need to make sure the busnum,
>>>>> and call i2c_register_board_info(int busnum, ...) to register device
>>>>> if using -1, we do not know the value of busnum.
>>>>>
>>>>> In order to solve this issue, set the platform device ID as a fix
>>>>> number
>>>>> Here using 0 to match the busnum used in i2c_regsiter_board_info().
>>>>
>>>> I have been bitten by this myself on RM9200.
>>>>
>>>>> Signed-off-by: Bo Shen <voice.shen@atmel.com>
>>>>> ---
>>>>> Change since v1
>>>>>     Make the commit message more clear
>>>>> ---
>>>>>    arch/arm/mach-at91/at91sam9260_devices.c |    2 +-
>>>>
>>>> This pattern exist in at91rm9200_devices.c, at91sam9261_devices.c,
>>>> at91sam9263_devices.c and at91sam9rl_devices.c you might want to fix
>>>> them as well.
>>>
>>> Thanks for your information.
>>> After I test these boards, I will send patches to fix them, while not in
>>> this patch.
>>
>> I am in favor of doing a comprehensive patch series that covers all
>> aspects of this issue:
>> - each boards
>> - both i2c-gpio and i2c-at91 cases
> 
> May I need to submit this patch as a series? One patch for one board,
> and cover i2c-gpio and i2c-at91 cases.
> e.g:
> [patch 1/x] i2c: change id to let i2c-gpio work on at91rm200ek
> [patch 2/x] i2c: change id to let i2c-gpio work on at91sam9261ek
> ...
> 
> or
> 
> Just one patch, cover all these boards and i2c-gpio and i2c-at91?

Neither of the altenatives ;-)
I would have done:
1 for i2c-gpio covering all boards impacted
1 for i2c-at91 covering all boards impacted...

Bye,
diff mbox

Patch

diff --git a/arch/arm/mach-at91/at91sam9260_devices.c b/arch/arm/mach-at91/at91sam9260_devices.c
index 0f24cfb..805ef95 100644
--- a/arch/arm/mach-at91/at91sam9260_devices.c
+++ b/arch/arm/mach-at91/at91sam9260_devices.c
@@ -389,7 +389,7 @@  static struct i2c_gpio_platform_data pdata = {
 
 static struct platform_device at91sam9260_twi_device = {
 	.name			= "i2c-gpio",
-	.id			= -1,
+	.id			= 0,
 	.dev.platform_data	= &pdata,
 };