diff mbox

[wip] ARM: imx: register "leds-gpio" device using new helper function

Message ID 1305017456-10910-2-git-send-email-u.kleine-koenig@pengutronix.de
State New
Headers show

Commit Message

Uwe Kleine-König May 10, 2011, 8:50 a.m. UTC
This converts eukrea_mbimx27-baseboard to the new helper function.

bloat-o-meter reports for this change:

	add/remove: 1/1 grow/shrink: 0/1 up/down: 128/-220 (-92)
	function                                     old     new   delta
	gpio_led_register_device                       -     128    +128
	platform_devices                              28      24      -4
	leds_gpio                                    216       -    -216

Additionally gpio_led_info (12 bytes) and gpio_leds (32 Bytes) are
initdata now as is gpio_led_register_device.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
This is just an example and probably doesn't apply to the imx tree as
is. I will convert all imx machines when there's an agreement for the
patch providing the helper function.

 arch/arm/mach-imx/Kconfig                    |    1 +
 arch/arm/mach-imx/eukrea_mbimx27-baseboard.c |   18 +++---------------
 2 files changed, 4 insertions(+), 15 deletions(-)

Comments

Hartley Sweeten May 10, 2011, 10:26 p.m. UTC | #1
On Tuesday, May 10, 2011 1:51 AM, Uwe Kleine-König wrote:
> This converts eukrea_mbimx27-baseboard to the new helper function.

>

> bloat-o-meter reports for this change:

>

>	add/remove: 1/1 grow/shrink: 0/1 up/down: 128/-220 (-92)

>	function                                     old     new   delta

>	gpio_led_register_device                       -     128    +128

>	platform_devices                              28      24      -4

>	leds_gpio                                    216       -    -216

>

> Additionally gpio_led_info (12 bytes) and gpio_leds (32 Bytes) are

> initdata now as is gpio_led_register_device.

>

> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

> ---

> This is just an example and probably doesn't apply to the imx tree as

> is. I will convert all imx machines when there's an agreement for the

> patch providing the helper function.

>

>  arch/arm/mach-imx/Kconfig                    |    1 +

>  arch/arm/mach-imx/eukrea_mbimx27-baseboard.c |   18 +++---------------

>  2 files changed, 4 insertions(+), 15 deletions(-)

>

> diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig

> index 56b930a..ef16471 100644

> --- a/arch/arm/mach-imx/Kconfig

> +++ b/arch/arm/mach-imx/Kconfig

> @@ -222,6 +222,7 @@ choice

> 

>  config MACH_EUKREA_MBIMX27_BASEBOARD

>  	bool "Eukrea MBIMX27 development board"

> +	select LEDS_GPIO_REGISTER

>  	select IMX_HAVE_PLATFORM_IMX_FB

>  	select IMX_HAVE_PLATFORM_IMX_KEYPAD

>  	select IMX_HAVE_PLATFORM_IMX_SSI

> diff --git a/arch/arm/mach-imx/eukrea_mbimx27-baseboard.c b/arch/arm/mach-imx/eukrea_mbimx27-baseboard.c

> index fa5288018..3479f66 100644

> --- a/arch/arm/mach-imx/eukrea_mbimx27-baseboard.c

> +++ b/arch/arm/mach-imx/eukrea_mbimx27-baseboard.c

> @@ -113,7 +113,7 @@ eukrea_mbimx27_keymap_data __initconst = {

>  	.keymap_size    = ARRAY_SIZE(eukrea_mbimx27_keymap),

>  };

>  

> -static struct gpio_led gpio_leds[] = {

> +static const struct gpio_led gpio_leds[] __initconst = {

>  	{

>  		.name			= "led1",

>  		.default_trigger	= "heartbeat",

> @@ -128,19 +128,11 @@ static struct gpio_led gpio_leds[] = {

>  	},

>  };

>  

> -static struct gpio_led_platform_data gpio_led_info = {

> +static const struct gpio_led_platform_data gpio_led_info __initconst = {

>  	.leds		= gpio_leds,

>  	.num_leds	= ARRAY_SIZE(gpio_leds),

>  };


Uwe,

Just a note that the 'const' you added to struct gpio_led above will be
discarded in struct gpio_led_platform_data.  You will get something like:

arch/arm/mach-imx/eukrea_mbimx27-baseboard.c:132: warning: initialization discards qualifiers from pointer target type

Regards,
Hartley
Hartley Sweeten May 10, 2011, 11:02 p.m. UTC | #2
On Tuesday, May 10, 2011 1:51 AM, Uwe Kleine-König wrote:
>

> This converts eukrea_mbimx27-baseboard to the new helper function.

>

> bloat-o-meter reports for this change:

>

>	add/remove: 1/1 grow/shrink: 0/1 up/down: 128/-220 (-92)

>	function                                     old     new   delta

>	gpio_led_register_device                       -     128    +128

>	platform_devices                              28      24      -4

>	leds_gpio                                    216       -    -216

>

> Additionally gpio_led_info (12 bytes) and gpio_leds (32 Bytes) are

> initdata now as is gpio_led_register_device.


FWIW, similar results with ep93xx:

add/remove: 1/1 grow/shrink: 2/0 up/down: 137/-240 (-103)
function                                     old     new   delta
gpio_led_register_device                       -     128    +128
kernel_config_data                         10474   10479      +5
ep93xx_init_devices                          116     120      +4
ep93xx_leds                                  240       -    -240

Regards,
Hartley
Uwe Kleine-König May 11, 2011, 6:22 a.m. UTC | #3
Hello Hartley,

On Tue, May 10, 2011 at 05:26:18PM -0500, H Hartley Sweeten wrote:
> On Tuesday, May 10, 2011 1:51 AM, Uwe Kleine-König wrote:
> > diff --git a/arch/arm/mach-imx/eukrea_mbimx27-baseboard.c b/arch/arm/mach-imx/eukrea_mbimx27-baseboard.c
> > index fa5288018..3479f66 100644
> > --- a/arch/arm/mach-imx/eukrea_mbimx27-baseboard.c
> > +++ b/arch/arm/mach-imx/eukrea_mbimx27-baseboard.c
> > @@ -113,7 +113,7 @@ eukrea_mbimx27_keymap_data __initconst = {
> >  	.keymap_size    = ARRAY_SIZE(eukrea_mbimx27_keymap),
> >  };
> >  
> > -static struct gpio_led gpio_leds[] = {
> > +static const struct gpio_led gpio_leds[] __initconst = {
> >  	{
> >  		.name			= "led1",
> >  		.default_trigger	= "heartbeat",
> > @@ -128,19 +128,11 @@ static struct gpio_led gpio_leds[] = {
> >  	},
> >  };
> >  
> > -static struct gpio_led_platform_data gpio_led_info = {
> > +static const struct gpio_led_platform_data gpio_led_info __initconst = {
> >  	.leds		= gpio_leds,
> >  	.num_leds	= ARRAY_SIZE(gpio_leds),
> >  };
> 
> Just a note that the 'const' you added to struct gpio_led above will be
> discarded in struct gpio_led_platform_data.  You will get something like:
> 
> arch/arm/mach-imx/eukrea_mbimx27-baseboard.c:132: warning: initialization discards qualifiers from pointer target type
It seems you don't have

	9517f92 (leds: make *struct gpio_led_platform_data.leds const)

(contained in .39-rc1) in your tree :-)

Best regards
Uwe
diff mbox

Patch

diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index 56b930a..ef16471 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -222,6 +222,7 @@  choice
 
 config MACH_EUKREA_MBIMX27_BASEBOARD
 	bool "Eukrea MBIMX27 development board"
+	select LEDS_GPIO_REGISTER
 	select IMX_HAVE_PLATFORM_IMX_FB
 	select IMX_HAVE_PLATFORM_IMX_KEYPAD
 	select IMX_HAVE_PLATFORM_IMX_SSI
diff --git a/arch/arm/mach-imx/eukrea_mbimx27-baseboard.c b/arch/arm/mach-imx/eukrea_mbimx27-baseboard.c
index fa5288018..3479f66 100644
--- a/arch/arm/mach-imx/eukrea_mbimx27-baseboard.c
+++ b/arch/arm/mach-imx/eukrea_mbimx27-baseboard.c
@@ -113,7 +113,7 @@  eukrea_mbimx27_keymap_data __initconst = {
 	.keymap_size    = ARRAY_SIZE(eukrea_mbimx27_keymap),
 };
 
-static struct gpio_led gpio_leds[] = {
+static const struct gpio_led gpio_leds[] __initconst = {
 	{
 		.name			= "led1",
 		.default_trigger	= "heartbeat",
@@ -128,19 +128,11 @@  static struct gpio_led gpio_leds[] = {
 	},
 };
 
-static struct gpio_led_platform_data gpio_led_info = {
+static const struct gpio_led_platform_data gpio_led_info __initconst = {
 	.leds		= gpio_leds,
 	.num_leds	= ARRAY_SIZE(gpio_leds),
 };
 
-static struct platform_device leds_gpio = {
-	.name	= "leds-gpio",
-	.id	= -1,
-	.dev	= {
-		.platform_data	= &gpio_led_info,
-	},
-};
-
 static struct imx_fb_videomode eukrea_mbimx27_modes[] = {
 	{
 		.mode = {
@@ -294,10 +286,6 @@  static struct i2c_board_info eukrea_mbimx27_i2c_devices[] = {
 	},
 };
 
-static struct platform_device *platform_devices[] __initdata = {
-	&leds_gpio,
-};
-
 static const struct imxmmc_platform_data sdhc_pdata __initconst = {
 	.dat3_card_detect = 1,
 };
@@ -378,5 +366,5 @@  void __init eukrea_mbimx27_baseboard_init(void)
 
 	imx27_add_imx_keypad(&eukrea_mbimx27_keymap_data);
 
-	platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
+	gpio_led_register_device(-1, &gpio_led_info);
 }