All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: linux-arm-kernel@lists.infradead.org
Cc: s.hauer@pengutronix.de, "Wolfram Sang" <w.sang@pengutronix.de>,
	thierry.nolf.barco@gmail.com,
	"Huang Shijie" <b32955@freescale.com>,
	linux-mtd@lists.infradead.org, u.kleine-koenig@pengutronix.de,
	"Linus Walleij" <linus.walleij@linaro.org>,
	"Lothar Waßmann" <LW@karo-electronics.de>
Subject: Re: [PATCH v5 1/3] ARM: mxs: add GPMI-NFC support for imx23/imx28
Date: Fri, 1 Jul 2011 11:25:51 +0200	[thread overview]
Message-ID: <201107011125.51581.arnd@arndb.de> (raw)
In-Reply-To: <4E0D7CE9.2030209@freescale.com>

On Friday 01 July 2011 09:53:13 Huang Shijie wrote:
> >> If you really want to call out obsceneties, how about the fact that this
> >> driver comes with an 805 line patch to add a HAL for a single chip!
> >>
> >> Such abstractions should not be introduced as long as there is only
> >> a single instance of the hardware.
> > If I understood correctly, most if not all upcoming i.MX will have the GPMI
> > (mx50, mx6). Huang, do you already have a draft for the mx50-hal?
> >
> I have finished the code for mx50's GPMI.
> And I am coding for the MX6's GPMI recently.

Ok.

> I need a separate mx50-hal (or mx60-hal) to make the code tidy.
> The MX50 and mx60 support ONFI NAND and TOGGLE nand(which mx23/mx28 do 
> not support),
> they need a long code to initialize the TIMING register. What's more, 
> the READ/WRITE functions
> are different from the mx23/mx28.
> 
> Frankly speaking, I can merge the mxs-hal.c file to the gpmi-nfc.c, but 
> don't you think it too
> messy?

If you already have the code for the other SoCs, it's fine to have an
abstraction. From reading your patches that were specifically targetted
at mxs, that was not clear.

After a very brief look at the driver, my impression is that your layering
is upside-down though:

You have a "main" driver that registers to all devices and then pulls
in hardware specific bits. What you should have instead is a "library"
driver for the common code that provides all the common functionality
as exported functions, and individual drivers for each SoC type that
each register a platform_driver for one device id and use the functions
from the common module.

I don't know how hard it would be to retrofit that model, and I'm not
asking you to do it, unless other people feel strongly about it.
However, I think it would make your life easier when maintaining the
driver in the future. There are multiple advantages to that:

* You would not need a HAL. For your information, that term causes strong
  negative associations with many Linux developers. To us, the kernel
  drivers themselves are the hardware abstraction, you don't need another
  one.

* It's more easy to extend to multiple levels of libraries. E.g. you could
  have one module for stuff that is common between i.MX5 and i.MX6 but
  not i.MX3, and make the later drivers use both libraries.

* It gets rid of the need for #ifdef in the common driver module.

* It becomes very easy to override one function just for a specific
  instance of the hardware, while everything else uses a common version
  from the library.

	Arnd

WARNING: multiple messages have this Message-ID (diff)
From: arnd@arndb.de (Arnd Bergmann)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v5 1/3] ARM: mxs: add GPMI-NFC support for imx23/imx28
Date: Fri, 1 Jul 2011 11:25:51 +0200	[thread overview]
Message-ID: <201107011125.51581.arnd@arndb.de> (raw)
In-Reply-To: <4E0D7CE9.2030209@freescale.com>

On Friday 01 July 2011 09:53:13 Huang Shijie wrote:
> >> If you really want to call out obsceneties, how about the fact that this
> >> driver comes with an 805 line patch to add a HAL for a single chip!
> >>
> >> Such abstractions should not be introduced as long as there is only
> >> a single instance of the hardware.
> > If I understood correctly, most if not all upcoming i.MX will have the GPMI
> > (mx50, mx6). Huang, do you already have a draft for the mx50-hal?
> >
> I have finished the code for mx50's GPMI.
> And I am coding for the MX6's GPMI recently.

Ok.

> I need a separate mx50-hal (or mx60-hal) to make the code tidy.
> The MX50 and mx60 support ONFI NAND and TOGGLE nand(which mx23/mx28 do 
> not support),
> they need a long code to initialize the TIMING register. What's more, 
> the READ/WRITE functions
> are different from the mx23/mx28.
> 
> Frankly speaking, I can merge the mxs-hal.c file to the gpmi-nfc.c, but 
> don't you think it too
> messy?

If you already have the code for the other SoCs, it's fine to have an
abstraction. From reading your patches that were specifically targetted
at mxs, that was not clear.

After a very brief look at the driver, my impression is that your layering
is upside-down though:

You have a "main" driver that registers to all devices and then pulls
in hardware specific bits. What you should have instead is a "library"
driver for the common code that provides all the common functionality
as exported functions, and individual drivers for each SoC type that
each register a platform_driver for one device id and use the functions
from the common module.

I don't know how hard it would be to retrofit that model, and I'm not
asking you to do it, unless other people feel strongly about it.
However, I think it would make your life easier when maintaining the
driver in the future. There are multiple advantages to that:

* You would not need a HAL. For your information, that term causes strong
  negative associations with many Linux developers. To us, the kernel
  drivers themselves are the hardware abstraction, you don't need another
  one.

* It's more easy to extend to multiple levels of libraries. E.g. you could
  have one module for stuff that is common between i.MX5 and i.MX6 but
  not i.MX3, and make the later drivers use both libraries.

* It gets rid of the need for #ifdef in the common driver module.

* It becomes very easy to override one function just for a specific
  instance of the hardware, while everything else uses a common version
  from the library.

	Arnd

  parent reply	other threads:[~2011-07-01  9:25 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-30  3:53 [PATCH v5 0/3] add the GPMI-NFC support for imx23/imx28 Huang Shijie
2011-06-30  3:53 ` Huang Shijie
2011-06-30  3:53 ` [PATCH v5 1/3] ARM: mxs: add " Huang Shijie
2011-06-30  3:53   ` Huang Shijie
2011-06-30 13:55   ` Arnd Bergmann
2011-06-30 13:55     ` Arnd Bergmann
2011-06-30 14:58     ` Lothar Waßmann
2011-06-30 14:58       ` Lothar Waßmann
2011-06-30 22:22       ` Arnd Bergmann
2011-06-30 22:22         ` Arnd Bergmann
2011-07-01  5:59         ` Lothar Waßmann
2011-07-01  5:59           ` Lothar Waßmann
2011-07-01  6:03         ` Wolfram Sang
2011-07-01  6:03           ` Wolfram Sang
2011-07-01  7:53           ` Huang Shijie
2011-07-01  7:53             ` Huang Shijie
2011-07-01  8:01             ` Wolfram Sang
2011-07-01  8:01               ` Wolfram Sang
2011-07-01  8:39               ` Huang Shijie
2011-07-01  8:39                 ` Huang Shijie
2011-07-01  8:45                 ` Huang Shijie
2011-07-01  8:45                   ` Huang Shijie
2011-07-01  9:25             ` Arnd Bergmann [this message]
2011-07-01  9:25               ` Arnd Bergmann
2011-07-08  7:31     ` Uwe Kleine-König
2011-07-08  7:31       ` Uwe Kleine-König
2011-07-08  7:40       ` Huang Shijie
2011-07-08  7:40         ` Huang Shijie
2011-07-08  9:09         ` Uwe Kleine-König
2011-07-08  9:09           ` Uwe Kleine-König
2011-07-08  9:27           ` Huang Shijie
2011-07-08  9:27             ` Huang Shijie
2011-07-08 10:16             ` Uwe Kleine-König
2011-07-08 10:16               ` Uwe Kleine-König
2011-07-08 10:24               ` Lothar Waßmann
2011-07-08 10:24                 ` Lothar Waßmann
2011-07-11  8:00                 ` Uwe Kleine-König
2011-07-11  8:00                   ` Uwe Kleine-König
2011-07-11  8:30                   ` Huang Shijie
2011-07-11  8:30                     ` Huang Shijie
2011-07-11  8:37                   ` Lothar Waßmann
2011-07-11  8:37                     ` Lothar Waßmann
2011-07-08  9:02       ` Arnd Bergmann
2011-07-08  9:02         ` Arnd Bergmann
2011-06-30  3:53 ` [PATCH v5 2/3] ARM: mxs/mx23evk: add GPMI-NFC device Huang Shijie
2011-06-30  3:53   ` Huang Shijie
2011-06-30  7:55   ` Uwe Kleine-König
2011-06-30  7:55     ` Uwe Kleine-König
2011-06-30  8:37     ` Huang Shijie
2011-06-30  8:37       ` Huang Shijie
2011-06-30  3:53 ` [PATCH v5 3/3] ARM: mxs/mx28evk: " Huang Shijie
2011-06-30  3:53   ` Huang Shijie

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=201107011125.51581.arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=LW@karo-electronics.de \
    --cc=b32955@freescale.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=s.hauer@pengutronix.de \
    --cc=thierry.nolf.barco@gmail.com \
    --cc=u.kleine-koenig@pengutronix.de \
    --cc=w.sang@pengutronix.de \
    /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.