linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [ARM] spitz/pxa: Refactor i2c init code in spitz.c
@ 2012-12-11 20:27 dromede at gmail.com
  2013-01-23  9:00 ` Haojian Zhuang
  0 siblings, 1 reply; 3+ messages in thread
From: dromede at gmail.com @ 2012-12-11 20:27 UTC (permalink / raw)
  To: linux-arm-kernel

From: Marko Katic <dromede.gmail.com>

This patch changes the way i2c devices are defined
and registered.

I2c devices that are present in all spitz
variants are always defined and registered while the max7310
gpio expander specific to the akita variant is defined
and registered only when building the kernel for akita variants.

spitz_i2c_init() is simplified and is now more readable.

Signed-off-by: Marko Katic <dromede@gmail.com>
---
 arch/arm/mach-pxa/spitz.c |   38 ++++++++++++++++++--------------------
 1 file changed, 18 insertions(+), 20 deletions(-)

diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c
index 0cc9dc7..1c7dc2b 100644
--- a/arch/arm/mach-pxa/spitz.c
+++ b/arch/arm/mach-pxa/spitz.c
@@ -865,17 +865,6 @@ static struct pca953x_platform_data akita_pca953x_pdata = {
 	.gpio_base		= AKITA_IOEXP_GPIO_BASE,
 };
 
-static struct i2c_board_info spitz_i2c_devs[] = {
-	{
-		.type		= "wm8750",
-		.addr		= 0x1b,
-	}, {
-		.type		= "max7310",
-		.addr		= 0x18,
-		.platform_data	= &akita_pca953x_pdata,
-	},
-};
-
 static struct regulator_consumer_supply isl6271a_consumers[] = {
 	REGULATOR_SUPPLY("vcc_core", NULL),
 };
@@ -894,26 +883,35 @@ static struct regulator_init_data isl6271a_info[] = {
 	}
 };
 
-static struct i2c_board_info spitz_pi2c_devs[] = {
+static struct i2c_board_info spitz_i2c_devs[2] = {
 	{
+		.type		= "wm8750",
+		.addr		= 0x1b,
+	}, {
 		.type		= "isl6271a",
 		.addr		= 0x0c,
 		.platform_data	= &isl6271a_info,
 	},
 };
 
+#ifdef CONFIG_MACH_AKITA
+static struct i2c_board_info akita_i2c_max7310 = {
+		.type		= "max7310",
+		.addr           = 0x18,
+		.platform_data  = &akita_pca953x_pdata,
+};
+#endif
+
 static void __init spitz_i2c_init(void)
 {
-	int size = ARRAY_SIZE(spitz_i2c_devs);
-
-	/* Only Akita has the max7310 chip */
-	if (!machine_is_akita())
-		size--;
-
 	pxa_set_i2c_info(NULL);
 	pxa27x_set_i2c_power_info(NULL);
-	i2c_register_board_info(0, spitz_i2c_devs, size);
-	i2c_register_board_info(1, ARRAY_AND_SIZE(spitz_pi2c_devs));
+
+	i2c_register_board_info(0, &spitz_i2c_devs[0], 1);
+	i2c_register_board_info(1, &spitz_i2c_devs[1], 1);
+
+	if (machine_is_akita())
+		i2c_register_board_info(0, &akita_i2c_max7310, 1);
 }
 #else
 static inline void spitz_i2c_init(void) {}
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH] [ARM] spitz/pxa: Refactor i2c init code in spitz.c
  2012-12-11 20:27 [PATCH] [ARM] spitz/pxa: Refactor i2c init code in spitz.c dromede at gmail.com
@ 2013-01-23  9:00 ` Haojian Zhuang
  2013-01-23 11:28   ` Marko Katić
  0 siblings, 1 reply; 3+ messages in thread
From: Haojian Zhuang @ 2013-01-23  9:00 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Dec 12, 2012 at 4:27 AM,  <dromede@gmail.com> wrote:
> From: Marko Katic <dromede.gmail.com>
>
> This patch changes the way i2c devices are defined
> and registered.
>
> I2c devices that are present in all spitz
> variants are always defined and registered while the max7310
> gpio expander specific to the akita variant is defined
> and registered only when building the kernel for akita variants.
>
> spitz_i2c_init() is simplified and is now more readable.
>
> Signed-off-by: Marko Katic <dromede@gmail.com>
> ---
>  arch/arm/mach-pxa/spitz.c |   38 ++++++++++++++++++--------------------
>  1 file changed, 18 insertions(+), 20 deletions(-)
>
> diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c
> index 0cc9dc7..1c7dc2b 100644
> --- a/arch/arm/mach-pxa/spitz.c
> +++ b/arch/arm/mach-pxa/spitz.c
> @@ -865,17 +865,6 @@ static struct pca953x_platform_data akita_pca953x_pdata = {
>         .gpio_base              = AKITA_IOEXP_GPIO_BASE,
>  };
>
> -static struct i2c_board_info spitz_i2c_devs[] = {
> -       {
> -               .type           = "wm8750",
> -               .addr           = 0x1b,
> -       }, {
> -               .type           = "max7310",
> -               .addr           = 0x18,
> -               .platform_data  = &akita_pca953x_pdata,
> -       },
> -};
> -
>  static struct regulator_consumer_supply isl6271a_consumers[] = {
>         REGULATOR_SUPPLY("vcc_core", NULL),
>  };
> @@ -894,26 +883,35 @@ static struct regulator_init_data isl6271a_info[] = {
>         }
>  };
>
> -static struct i2c_board_info spitz_pi2c_devs[] = {
> +static struct i2c_board_info spitz_i2c_devs[2] = {
>         {
> +               .type           = "wm8750",
> +               .addr           = 0x1b,
> +       }, {
>                 .type           = "isl6271a",
>                 .addr           = 0x0c,
>                 .platform_data  = &isl6271a_info,
>         },
>  };
>
spitz_i2c_devs[] are in i2c0 bus. spitz_pi2c_devs[] are in i2c1 bus.
Why do you move wm8750 from i2c0 bus to i2c1 bus?

> +#ifdef CONFIG_MACH_AKITA
> +static struct i2c_board_info akita_i2c_max7310 = {
> +               .type           = "max7310",
> +               .addr           = 0x18,
> +               .platform_data  = &akita_pca953x_pdata,
> +};
> +#endif
> +
>  static void __init spitz_i2c_init(void)
>  {
> -       int size = ARRAY_SIZE(spitz_i2c_devs);
> -
> -       /* Only Akita has the max7310 chip */
> -       if (!machine_is_akita())
> -               size--;
> -
>         pxa_set_i2c_info(NULL);
>         pxa27x_set_i2c_power_info(NULL);
> -       i2c_register_board_info(0, spitz_i2c_devs, size);
> -       i2c_register_board_info(1, ARRAY_AND_SIZE(spitz_pi2c_devs));
> +
> +       i2c_register_board_info(0, &spitz_i2c_devs[0], 1);
> +       i2c_register_board_info(1, &spitz_i2c_devs[1], 1);
> +
> +       if (machine_is_akita())
> +               i2c_register_board_info(0, &akita_i2c_max7310, 1);
>  }
>  #else
>  static inline void spitz_i2c_init(void) {}
> --
> 1.7.10.4
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] [ARM] spitz/pxa: Refactor i2c init code in spitz.c
  2013-01-23  9:00 ` Haojian Zhuang
@ 2013-01-23 11:28   ` Marko Katić
  0 siblings, 0 replies; 3+ messages in thread
From: Marko Katić @ 2013-01-23 11:28 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Jan 23, 2013 at 10:00 AM, Haojian Zhuang
<haojian.zhuang@gmail.com> wrote:
> On Wed, Dec 12, 2012 at 4:27 AM,  <dromede@gmail.com> wrote:
>> From: Marko Katic <dromede.gmail.com>
>>
>> This patch changes the way i2c devices are defined
>> and registered.
>>
>> I2c devices that are present in all spitz
>> variants are always defined and registered while the max7310
>> gpio expander specific to the akita variant is defined
>> and registered only when building the kernel for akita variants.
>>
>> spitz_i2c_init() is simplified and is now more readable.
>>
>> Signed-off-by: Marko Katic <dromede@gmail.com>
>> ---
>>  arch/arm/mach-pxa/spitz.c |   38 ++++++++++++++++++--------------------
>>  1 file changed, 18 insertions(+), 20 deletions(-)
>>
>> diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c
>> index 0cc9dc7..1c7dc2b 100644
>> --- a/arch/arm/mach-pxa/spitz.c
>> +++ b/arch/arm/mach-pxa/spitz.c
>> @@ -865,17 +865,6 @@ static struct pca953x_platform_data akita_pca953x_pdata = {
>>         .gpio_base              = AKITA_IOEXP_GPIO_BASE,
>>  };
>>
>> -static struct i2c_board_info spitz_i2c_devs[] = {
>> -       {
>> -               .type           = "wm8750",
>> -               .addr           = 0x1b,
>> -       }, {
>> -               .type           = "max7310",
>> -               .addr           = 0x18,
>> -               .platform_data  = &akita_pca953x_pdata,
>> -       },
>> -};
>> -
>>  static struct regulator_consumer_supply isl6271a_consumers[] = {
>>         REGULATOR_SUPPLY("vcc_core", NULL),
>>  };
>> @@ -894,26 +883,35 @@ static struct regulator_init_data isl6271a_info[] = {
>>         }
>>  };
>>
>> -static struct i2c_board_info spitz_pi2c_devs[] = {
>> +static struct i2c_board_info spitz_i2c_devs[2] = {
>>         {
>> +               .type           = "wm8750",
>> +               .addr           = 0x1b,
>> +       }, {
>>                 .type           = "isl6271a",
>>                 .addr           = 0x0c,
>>                 .platform_data  = &isl6271a_info,
>>         },
>>  };
>>
> spitz_i2c_devs[] are in i2c0 bus. spitz_pi2c_devs[] are in i2c1 bus.
> Why do you move wm8750 from i2c0 bus to i2c1 bus?

Only the isl6271a is located on the i2c1 bus. WM8750 and MAX7310 are
on i2c0 bus.
Please examine my patch again. You will find that WM8750 is correctly
registered on
i2c0 bus with this line:

 i2c_register_board_info(0, &spitz_i2c_devs[0], 1);

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-01-23 11:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-11 20:27 [PATCH] [ARM] spitz/pxa: Refactor i2c init code in spitz.c dromede at gmail.com
2013-01-23  9:00 ` Haojian Zhuang
2013-01-23 11:28   ` Marko Katić

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).