All of lore.kernel.org
 help / color / mirror / Atom feed
From: olof@lixom.net (Olof Johansson)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 2/4] ARM: kirkwood: DT board setup for Network Space v2 and parents
Date: Mon, 26 Nov 2012 01:02:53 -0800	[thread overview]
Message-ID: <20121126090253.GI9580@quad.lixom.net> (raw)
In-Reply-To: <1350468546-25901-3-git-send-email-simon.guinot@sequanux.org>

Hi,

This is more directed at Jason and the other maintainers than you, Simon --
it's something I noticed when looking at his pull request.

On Wed, Oct 17, 2012 at 12:09:04PM +0200, Simon Guinot wrote:

> diff --git a/arch/arm/mach-kirkwood/Kconfig b/arch/arm/mach-kirkwood/Kconfig
> index 50bca50..847e0c2 100644
> --- a/arch/arm/mach-kirkwood/Kconfig
> +++ b/arch/arm/mach-kirkwood/Kconfig
> @@ -130,6 +130,27 @@ config MACH_KM_KIRKWOOD_DT
>  	  Say 'Y' here if you want your kernel to support the
>  	  Keymile Kirkwood Reference Desgin, using Flattened Device Tree.
>  
> +config MACH_INETSPACE_V2_DT
> +	bool "LaCie Internet Space v2 NAS (Flattened Device Tree)"
> +	select ARCH_KIRKWOOD_DT
> +	help
> +	  Say 'Y' here if you want your kernel to support the LaCie
> +	  Internet Space v2 NAS, using Flattened Device Tree.
> +
> +config MACH_NETSPACE_V2_DT
> +	bool "LaCie Network Space v2 NAS (Flattened Device Tree)"
> +	select ARCH_KIRKWOOD_DT
> +	help
> +	  Say 'Y' here if you want your kernel to support the LaCie
> +	  Network Space v2 NAS, using Flattened Device Tree.
> +
> +config MACH_NETSPACE_MAX_V2_DT
> +	bool "LaCie Network Space Max v2 NAS (Flattened Device Tree)"
> +	select ARCH_KIRKWOOD_DT
> +	help
> +	  Say 'Y' here if you want your kernel to support the LaCie
> +	  Network Space Max v2 NAS, using Flattened Device Tree.

It would be nice to get away from these config options. The whole point with
device tree is to no longer have to do code changes for new similar boards.

And even then, since they share the same init function, there's no need for
three options, just one.

> diff --git a/arch/arm/mach-kirkwood/Makefile b/arch/arm/mach-kirkwood/Makefile
> index 294779f..1f63d80 100644
> --- a/arch/arm/mach-kirkwood/Makefile
> +++ b/arch/arm/mach-kirkwood/Makefile
> @@ -31,3 +31,6 @@ obj-$(CONFIG_MACH_GOFLEXNET_DT)		+= board-goflexnet.o
>  obj-$(CONFIG_MACH_LSXL_DT)		+= board-lsxl.o
>  obj-$(CONFIG_MACH_IOMEGA_IX2_200_DT)	+= board-iomega_ix2_200.o
>  obj-$(CONFIG_MACH_KM_KIRKWOOD_DT)	+= board-km_kirkwood.o
> +obj-$(CONFIG_MACH_INETSPACE_V2_DT)	+= board-ns2.o
> +obj-$(CONFIG_MACH_NETSPACE_V2_DT)	+= board-ns2.o
> +obj-$(CONFIG_MACH_NETSPACE_MAX_V2_DT)	+= board-ns2.o

Same here.

> diff --git a/arch/arm/mach-kirkwood/board-dt.c b/arch/arm/mach-kirkwood/board-dt.c
> index 70c5a28..b3e0519 100644
> --- a/arch/arm/mach-kirkwood/board-dt.c
> +++ b/arch/arm/mach-kirkwood/board-dt.c
> @@ -96,6 +96,11 @@ static void __init kirkwood_dt_init(void)
>  	if (of_machine_is_compatible("keymile,km_kirkwood"))
>  		km_kirkwood_init();
>  
> +	if (of_machine_is_compatible("lacie,inetspace_v2") ||
> +	    of_machine_is_compatible("lacie,netspace_v2") ||
> +	    of_machine_is_compatible("lacie,netspace_max_v2"))
> +		ns2_init();
> +

This function is now a long sequence of if statments like the ones above. It
would be great if they could be removed by moving most of the functionality
implemented in the board file to the device tree. Looks like it's not a whole
lot left, so that's promising. I'm guessing there's already efforts underway to
take care of the last pieces.

But, until then, I think it'd be nice to make this a table driven lookup
instead of a sequence of open-coded if statements. Tegra had this early on
before the board files were removed too. I.e. just a table of

static struct match_table {
	char *compat;
	void (*fn)(void);
} match_table = {
	{ "lacie,inetspace_v2", ns2_init },
	{ "lacie,netspace_v2", ns2_init },
	....
}

and then an interator over that table.

> @@ -112,6 +117,9 @@ static const char *kirkwood_dt_board_compat[] = {
>  	"buffalo,lsxl",
>  	"iom,ix2-200",
>  	"keymile,km_kirkwood",
> +	"lacie,inetspace_v2",
> +	"lacie,netspace_max_v2",
> +	"lacie,netspace_v2",
>  	NULL
>  };

Same here. I actually think this is a table that is no longer needed -- the
board compat can/should be done on the generic compatible string instead of for
each most-specific board string.

> +static void ns2_power_off(void)
> +{
> +	gpio_set_value(NS2_GPIO_POWER_OFF, 1);
> +}

This kind of thing should be possible to generalize through a generic binding.


-Olof

  reply	other threads:[~2012-11-26  9:02 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-17 10:09 [PATCH v2 0/4] Add DT support for Network Space v2 and parents Simon Guinot
2012-10-17 10:09 ` [PATCH v2 1/4] leds: leds-ns2: add device tree binding Simon Guinot
2012-10-17 10:09 ` [PATCH v3 2/4] ARM: kirkwood: DT board setup for Network Space v2 and parents Simon Guinot
2012-11-26  9:02   ` Olof Johansson [this message]
2012-11-26 10:00     ` Andrew Lunn
2012-11-26 10:03       ` Olof Johansson
2012-11-26 15:18     ` Simon Guinot
2012-11-26 16:04       ` Jason Cooper
2012-11-27 11:14         ` Simon Guinot
2012-11-27 12:50           ` Jason Cooper
2012-11-27 20:57           ` Stefan Peter
2012-11-27 21:02             ` Jason Cooper
2012-10-17 10:09 ` [PATCH v2 3/4] ARM: kirkwood: DT board setup for Network Space Lite v2 Simon Guinot
2012-10-17 10:09 ` [PATCH v2 4/4] ARM: kirkwood: DT board setup for Network Space Mini v2 Simon Guinot
2012-10-20 16:06 ` [PATCH v2 0/4] Add DT support for Network Space v2 and parents Andrew Lunn
2012-10-21  1:05 ` Jason Cooper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121126090253.GI9580@quad.lixom.net \
    --to=olof@lixom.net \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.