On 10/21/12 16:54, Ohad Ben-Cohen wrote:
> On Fri, Oct 19, 2012 at 7:07 PM, Tony Lindgren <t...@atomide.com> wrote:
> ...
>> We could optimize away a minimal amount of code for many configurations
>> with the ifdef? :)
> 
> Sure, here goes (compile tested only):
> 
>>From 6b82365da2c04986e647d06c285197efece7cb34 Mon Sep 17 00:00:00 2001
> From: Ohad Ben-Cohen <o...@wizery.com>
> Date: Sun, 14 Oct 2012 20:16:01 +0200
> Subject: [PATCH] ARM: OMAP: don't print any error when wl12xx isn't
>  configured
> 
> Stop intimidating users with scary wlan error messages in case wl12xx
> support wasn't even built.
> 
> In addition, when wl12xx_set_platform_data() fails, don't bother
> registering wl12xx's fixed regulator device (on the relevant
> boards).
> 
> While we're at it, extract the wlan init code to a dedicated function to
> make (the relevant boards') init code look a bit nicer.
> 
> Compile tested only.
> 
> Reported-by: Russell King <li...@arm.linux.org.uk>
> Signed-off-by: Ohad Ben-Cohen <o...@wizery.com>

Apart, from the minor comment below,
Acked-by: Igor Grinberg <grinb...@compulab.co.il>

> ---
>  arch/arm/mach-davinci/board-da850-evm.c      |  8 ++-----
>  arch/arm/mach-omap2/board-4430sdp.c          |  7 +++---
>  arch/arm/mach-omap2/board-omap3evm.c         |  6 ++---
>  arch/arm/mach-omap2/board-omap3pandora.c     |  9 +++-----
>  arch/arm/mach-omap2/board-omap4panda.c       | 20 ++++++++++++-----
>  arch/arm/mach-omap2/board-zoom-peripherals.c | 15 ++++++++-----
>  arch/arm/mach-omap2/common-board-devices.c   | 33 
> ++++++++++++++++++++++++++++
>  arch/arm/mach-omap2/common-board-devices.h   |  2 ++
>  8 files changed, 71 insertions(+), 29 deletions(-)

[...]

> diff --git a/arch/arm/mach-omap2/common-board-devices.c
> b/arch/arm/mach-omap2/common-board-devices.c
> index 48daac2..02351e9 100644
> --- a/arch/arm/mach-omap2/common-board-devices.c
> +++ b/arch/arm/mach-omap2/common-board-devices.c
> @@ -23,6 +23,7 @@
>  #include <linux/gpio.h>
>  #include <linux/spi/spi.h>
>  #include <linux/spi/ads7846.h>
> +#include <linux/wl12xx.h>
> 
>  #include <linux/platform_data/spi-omap2-mcspi.h>
>  #include <linux/platform_data/mtd-nand-omap2.h>
> @@ -141,3 +142,35 @@ void __init omap_nand_flash_init(int options,
> struct mtd_partition *parts,
>  {
>  }
>  #endif
> +
> +#ifdef CONFIG_WL12XX_PLATFORM_DATA
> +int __init wl12xx_board_init(struct wl12xx_platform_data *wlan_data, int 
> gpio)
> +{
> +     int ret;
> +
> +     wlan_data->irq = gpio_to_irq(gpio);
> +     if (wlan_data->irq < 0) {
> +             ret = wlan_data->irq;
> +             pr_err("wl12xx: gpio_to_irq(%d) failed: %d\n", gpio, ret);
> +             return ret;
> +     }
> +
> +     ret = wl12xx_set_platform_data(wlan_data);
> +     /* bail out silently in case wl12xx isn't configured */
> +     if (ret == -ENOSYS)
> +             return ret;

Since we have the function ifdef'ed, I don't think we need
the ENOSYS check, do we?

> +
> +     /* bail out verbosely on any other error */
> +     if (ret) {
> +             pr_err("error setting wl12xx data: %d\n", ret);
> +             return ret;
> +     }
> +
> +     return 0;
> +}
> +#else /* !CONFIG_WL12XX_PLATFORM_DATA */
> +int __init wl12xx_board_init(struct wl12xx_platform_data *wlan_data, int 
> gpio)
> +{
> +     return 0;
> +}
> +#endif

[...]


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

Reply via email to