All of lore.kernel.org
 help / color / mirror / Atom feed
From: arnd@arndb.de (Arnd Bergmann)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2] USB: Support for LPC32xx SoC
Date: Fri, 24 Feb 2012 15:03:27 +0000	[thread overview]
Message-ID: <201202241503.27406.arnd@arndb.de> (raw)
In-Reply-To: <20120224063521.GA16412@pengutronix.de>

On Friday 24 February 2012, Wolfram Sang wrote:
>   > To get rid of the remaining #ifdefs, I could as well create a new
> > ohci-lpc32xx.c instead of abusing ohci-pnx4008.c. Would this be the way
> > to go or are there any other suggestions?
> 
> If you could tell the difference between pnx4008 and lpc32xx, then you could
> simply do something like:
> 
>         if (machine_is_pnx4008)
>                 pnx4008_configure();
>         else
>                 lpc32xx_configure();
> 
> or
> 
>         if (machine_is_pnx4008)
>                 pnx4008_(un)set_usb_bits

I would recomment telling this from the device itself rather than from the
platform. You can add a platform_device_id list and put information like this
into the driver_data, then do

	switch (pdev->id.driver_data) {
	case OHCI_PNX4008:
                pnx4008_configure();
		break;
	case 
		lpc32xx_configure();
		break;
	};

	if (pdev->id.driver_data == OHCI_PNX4008)
		pnx4008_(un)set_usb_bits()

Alternatively, you can put the common code into one file, and use separate
files for the parts that are different between pnx4008 and lpc32xx.

Unfortunately, the way that ohci handles the abstraction between the
various implementations is backwards, it would be much easier if the
main driver was following that model to start with.

	Arnd

WARNING: multiple messages have this Message-ID (diff)
From: Arnd Bergmann <arnd@arndb.de>
To: linux-arm-kernel@lists.infradead.org
Cc: Wolfram Sang <w.sang@pengutronix.de>,
	Roland Stigge <stigge@antcom.de>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	kevin.wells@nxp.com, Alan Stern <stern@rowland.harvard.edu>
Subject: Re: [PATCH v2] USB: Support for LPC32xx SoC
Date: Fri, 24 Feb 2012 15:03:27 +0000	[thread overview]
Message-ID: <201202241503.27406.arnd@arndb.de> (raw)
In-Reply-To: <20120224063521.GA16412@pengutronix.de>

On Friday 24 February 2012, Wolfram Sang wrote:
>   > To get rid of the remaining #ifdefs, I could as well create a new
> > ohci-lpc32xx.c instead of abusing ohci-pnx4008.c. Would this be the way
> > to go or are there any other suggestions?
> 
> If you could tell the difference between pnx4008 and lpc32xx, then you could
> simply do something like:
> 
>         if (machine_is_pnx4008)
>                 pnx4008_configure();
>         else
>                 lpc32xx_configure();
> 
> or
> 
>         if (machine_is_pnx4008)
>                 pnx4008_(un)set_usb_bits

I would recomment telling this from the device itself rather than from the
platform. You can add a platform_device_id list and put information like this
into the driver_data, then do

	switch (pdev->id.driver_data) {
	case OHCI_PNX4008:
                pnx4008_configure();
		break;
	case 
		lpc32xx_configure();
		break;
	};

	if (pdev->id.driver_data == OHCI_PNX4008)
		pnx4008_(un)set_usb_bits()

Alternatively, you can put the common code into one file, and use separate
files for the parts that are different between pnx4008 and lpc32xx.

Unfortunately, the way that ohci handles the abstraction between the
various implementations is backwards, it would be much easier if the
main driver was following that model to start with.

	Arnd

  reply	other threads:[~2012-02-24 15:03 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-23 20:57 [PATCH v2] USB: Support for LPC32xx SoC Roland Stigge
2012-02-23 20:57 ` Roland Stigge
2012-02-23 21:05 ` Roland Stigge
2012-02-23 21:05   ` Roland Stigge
2012-02-24  6:35   ` Wolfram Sang
2012-02-24  6:35     ` Wolfram Sang
2012-02-24 15:03     ` Arnd Bergmann [this message]
2012-02-24 15:03       ` Arnd Bergmann
2012-02-25  3:51       ` Wolfram Sang
2012-02-25  3:51         ` Wolfram Sang
2012-02-25  8:45         ` Arnd Bergmann
2012-02-25  8:45           ` Arnd Bergmann
2012-02-25 15:46           ` Alan Stern
2012-02-25 15:46             ` Alan Stern
2012-02-26 10:01             ` Arnd Bergmann
2012-02-26 10:01               ` Arnd Bergmann
2012-02-26 15:59               ` Alan Stern
2012-02-26 15:59                 ` Alan Stern
2012-02-27 14:03                 ` Arnd Bergmann
2012-02-27 14:03                   ` Arnd Bergmann
2012-02-27 16:42                   ` Alan Stern
2012-02-27 16:42                     ` Alan Stern
2012-02-27 22:01                     ` Arnd Bergmann
2012-02-27 22:01                       ` Arnd Bergmann
2012-02-28 15:01                       ` Alan Stern
2012-02-28 15:01                         ` Alan Stern
2012-02-28 15:53                         ` Arnd Bergmann
2012-02-28 15:53                           ` Arnd Bergmann
2012-02-28 16:51                           ` Alan Stern
2012-02-28 16:51                             ` Alan Stern
2012-02-25 14:03         ` Roland Stigge
2012-02-25 14:03           ` Roland Stigge

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=201202241503.27406.arnd@arndb.de \
    --to=arnd@arndb.de \
    --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.