Patchwork [11/16,v2] ARM: ux500: Do not attempt to register non-existent i2c devices on Snowball

login
register
mail settings
Submitter Lee Jones
Date April 17, 2012, 3:44 p.m.
Message ID <4F8D8FD6.1070508@linaro.org>
Download mbox | patch
Permalink /patch/153238/
State New
Headers show

Comments

Lee Jones - April 17, 2012, 3:44 p.m.
From: Lee Jones <lee.jones@linaro.org>
Date: Mon, 16 Apr 2012 15:26:55 +0100
Subject: [PATCH 11/16] ARM: ux500: Do not attempt to register non-existent
 i2c devices on Snowball

This patch prevents i2c devices which are not present on the Snowball
low-cost development board from being registered. Devices such as;
tc3589x, bu1780 and lp5521 are present on other supported boards,
but are not located on Snowball.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
 arch/arm/mach-ux500/board-mop500.c |   24 +++++++++++++-----------
 1 files changed, 13 insertions(+), 11 deletions(-)
Arnd Bergmann - April 17, 2012, 4:02 p.m.
On Tuesday 17 April 2012, Lee Jones wrote:
> From: Lee Jones <lee.jones@linaro.org>
> Date: Mon, 16 Apr 2012 15:26:55 +0100
> Subject: [PATCH 11/16] ARM: ux500: Do not attempt to register non-existent
>  i2c devices on Snowball
> 
> This patch prevents i2c devices which are not present on the Snowball
> low-cost development board from being registered. Devices such as;
> tc3589x, bu1780 and lp5521 are present on other supported boards,
> but are not located on Snowball.
> 
> Signed-off-by: Lee Jones <lee.jones@linaro.org>

Reviewed-by: Arnd Bergmann <arnd@arndb.de>

> @@ -831,13 +830,16 @@ static void __init u8500_init_machine(void)
>                                 ARRAY_SIZE(mop500_platform_devs));
>  
>                 hrefv60_sdi_init(parent);
> +
> +               i2c0_devs = ARRAY_SIZE(mop500_i2c0_devices);
> +               i2c0_devs -= NUM_PRE_V60_I2C0_DEVICES;
> +
> +               i2c_register_board_info(0, mop500_i2c0_devices, i2c0_devs);
> +               i2c_register_board_info(2, mop500_i2c2_devices,
> +                                       ARRAY_SIZE(mop500_i2c2_devices));
>         }
>         mop500_i2c_init(parent);

You could still simplify this and get rid of the i2c0_devs variable, but
this version is fine too, since it does match the hrefv60_init_machine()
function that has the same code in it.

	Arnd

Patch

diff --git a/arch/arm/mach-ux500/board-mop500.c b/arch/arm/mach-ux500/board-mop500.c
index a46345e..ed92456 100644
--- a/arch/arm/mach-ux500/board-mop500.c
+++ b/arch/arm/mach-ux500/board-mop500.c
@@ -652,7 +652,6 @@  static void __init mop500_init_machine(void)
 static void __init snowball_init_machine(void)
 {
 	struct device *parent = NULL;
-	int i2c0_devs;
 	int i;
 
 	parent = u8500_init_devices();
@@ -670,11 +669,6 @@  static void __init snowball_init_machine(void)
 	mop500_spi_init(parent);
 	mop500_uart_init(parent);
 
-	i2c0_devs = ARRAY_SIZE(mop500_i2c0_devices);
-	i2c_register_board_info(0, mop500_i2c0_devices, i2c0_devs);
-	i2c_register_board_info(2, mop500_i2c2_devices,
-				ARRAY_SIZE(mop500_i2c2_devices));
-
 	/* This board has full regulator constraints */
 	regulator_has_full_constraints();
 }
@@ -787,7 +781,6 @@  static void __init u8500_init_machine(void)
 	int i;
 
 	parent = u8500_of_init_devices();
-	i2c0_devs = ARRAY_SIZE(mop500_i2c0_devices);
 
 	for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++)
 		mop500_platform_devs[i]->dev.parent = parent;
@@ -805,6 +798,12 @@  static void __init u8500_init_machine(void)
 				ARRAY_SIZE(mop500_platform_devs));
 
 		mop500_sdi_init(parent);
+
+		i2c0_devs = ARRAY_SIZE(mop500_i2c0_devices);
+		i2c_register_board_info(0, mop500_i2c0_devices, i2c0_devs);
+		i2c_register_board_info(2, mop500_i2c2_devices,
+					ARRAY_SIZE(mop500_i2c2_devices));
+
 	} else if (of_machine_is_compatible("calaosystems,snowball-a9500")) {
 		snowball_pins_init();
 
@@ -831,13 +830,16 @@  static void __init u8500_init_machine(void)
 				ARRAY_SIZE(mop500_platform_devs));
 
 		hrefv60_sdi_init(parent);
+
+		i2c0_devs = ARRAY_SIZE(mop500_i2c0_devices);
+		i2c0_devs -= NUM_PRE_V60_I2C0_DEVICES;
+
+		i2c_register_board_info(0, mop500_i2c0_devices, i2c0_devs);
+		i2c_register_board_info(2, mop500_i2c2_devices,
+					ARRAY_SIZE(mop500_i2c2_devices));
 	}
 	mop500_i2c_init(parent);
 
-	i2c_register_board_info(0, mop500_i2c0_devices, i2c0_devs);
-	i2c_register_board_info(2, mop500_i2c2_devices,
-				ARRAY_SIZE(mop500_i2c2_devices));
-
 	/* This board has full regulator constraints */
 	regulator_has_full_constraints();
 }