linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
To: Tomoya MORINAGA <tomoya-linux-ECg8zkTtlr0C6LszWs/t0g@public.gmane.org>
Cc: 'David Brownell'
	<dbrownell-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>,
	"'Wang, Qi'" <qi.wang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	"'linux-kernel-u79uwXL29TaiAVqoAR/hOA49XUYAGyU/@public.gmane.org@intel.com'"@angua.secretlab.ca,
	yong.y.wang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org,
	'Milton Miller' <miltonm-ogEGBHC/i9Y@public.gmane.org>,
	Toshiharu Okada
	<toshiharu-linux-ECg8zkTtlr0C6LszWs/t0g@public.gmane.org>,
	kok.howg.ewe-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org,
	spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
	joel.clark-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
Subject: Re: [PATCH 1/3] spi_topcliff_pch: support new device ML7213
Date: Fri, 21 Jan 2011 11:48:52 -0700	[thread overview]
Message-ID: <20110121184852.GA18603@angua.secretlab.ca> (raw)
In-Reply-To: <84FF3503839A46E0B9919DF000DDE5C5-c0cKtqp5df7I9507bXv2FdBPR1lH4CV8@public.gmane.org>

On Tue, Jan 11, 2011 at 06:38:35PM +0900, Tomoya MORINAGA wrote:
> Hi Grant,
> 
> On Friday, January 07, 2011 6:22 PM, Milton Miller wrote:
> > follow mfd_add_devices into drivers/mfd/mfd-core.c
> I have also seen mfd-core.c.
> However, I couldn't clear my question.
> 
> Q1. It seems platform_device is not used in your example. Does need "platform_device" ?
> Q2. How detect pch_spi channel dynamically ?
> 
> I want to catch your saying correctly.
> Could you give me more information ?

Let me try a different explanation.  The pch_spi driver implements a
pci_driver, and currently that pci_driver implements a single
spi_master child device as a child of the pci_bus.  The structure in
/sys/devices is probably something like this:

/sys/devices/.../0000:00:1a.0 (pci_dev bound to driver 'pch_spi_pcidev')
  |
  +--spi0.0  (spi_device 0 on spi_master 0)
  |
  \--spi0.1  (spi_device 1 on spi_master 0)

You want to modify the driver so that it can have more than one
spi_master attached to the device.  Your patch attempts to do so by
maintaining an array of spi_master devices that are children of the
pci_dev, so that the structure looks like this:


/sys/devices/.../0000:00:1a.0 (pci_dev bound to driver 'pch_spi_pcidev')
  |
  +--spi0.0  (spi_device 0 on spi_master 0)
  |
  +--spi0.1  (spi_device 1 on spi_master 0)
  |
  \--spi1.0  (spi_device 0 on spi_master 1)

Am I correct so far?

What I'm suggesting is that the code used to implement this structure
adds unnecessary complexity to the driver since each of the spi_master
instances are essentially completely independent, yet the driver has
to do extra work to know about the multiple instances.

Instead what you can do is to treat each spi bus as a child
platform_device of the pci_dev, and move the guts of the current
pch_spi_pcidev driver into a new platform_driver.  Then, instead of
driving the spi_master directly, the pch_spi_pcidev registers one or
more child platform_devices, one for each spi bus, so that the device
model looks something like this:

/sys/devices/.../0000:00:1a.0 (pci_dev bound to driver 'pch_spi_pcidev')
  |
  +--pch_spi.0
  |   |
  |   +--spi0.0  (spi_device 0 on spi_master 0)
  |   |
  |   \--spi0.1  (spi_device 1 on spi_master 0)
  |
  \--pch_spi.1
      |
      \--spi1.0  (spi_device 0 on spi_master 1)

where pch_spi.0 and pch_spi.1 are platform devices.  The
pch_spi_pcidev driver would allocated and register one or more
pch_spi.* platform_device children, each of which gets bound to a
pch_spi_platform_driver independently.  Doing it this way lets the
Linux driver model manage multiple instances instead of implementing
it by hand in your driver.

Make sense?

To do this, you need to move most of the driver code into a
platform_driver, and then modify your pci_driver so that it only
allocates and registers one or more platform_devices that will bind to
the driver.  It means you now have *two* driver structures.  One for
the pci_dev, and one for the platform_device children, and the pci_dev
acts as a container for the platform_devices.

The files in drivers/misc are an example of drivers that work in this
way.

g.


------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d

  parent reply	other threads:[~2011-01-21 18:48 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-27 11:23 [PATCH 1/3] spi_topcliff_pch: support new device ML7213 Tomoya MORINAGA
2010-12-27 11:23 ` [PATCH 2/3] spi_topcliff_pch: change calling function order correctly in remove Tomoya MORINAGA
2010-12-27 11:23   ` [PATCH 3/3] spi_topcliff_pch: fix resource leak issue Tomoya MORINAGA
2010-12-29  6:51     ` Grant Likely
2010-12-29  6:51   ` [PATCH 2/3] spi_topcliff_pch: change calling function order correctly in remove Grant Likely
2010-12-29  6:49 ` [PATCH 1/3] spi_topcliff_pch: support new device ML7213 Grant Likely
2011-01-05  2:34   ` Tomoya MORINAGA
2011-01-05 16:38     ` Grant Likely
2011-01-07  6:40       ` Tomoya MORINAGA
     [not found]         ` <46862922F48B45F781832619CF3F4B79-c0cKtqp5df7I9507bXv2FdBPR1lH4CV8@public.gmane.org>
2011-01-07  9:21           ` Milton Miller
     [not found]             ` <topcliff-split-kM9DGJe42AJBDgjK7y7TUQ@public.gmane.org>
2011-01-07  9:45               ` Tomoya MORINAGA
2011-01-11  9:38               ` Tomoya MORINAGA
     [not found]                 ` <84FF3503839A46E0B9919DF000DDE5C5-c0cKtqp5df7I9507bXv2FdBPR1lH4CV8@public.gmane.org>
2011-01-21 18:48                   ` Grant Likely [this message]
     [not found]                     ` <20110121184852.GA18603-MrY2KI0G/OVr83L8+7iqerDks+cytr/Z@public.gmane.org>
2011-01-24  3:14                       ` Tomoya MORINAGA
2011-01-11  9:42             ` Tomoya MORINAGA
2011-01-12  5:27               ` Tomoya MORINAGA
2011-01-18 12:36                 ` Tomoya MORINAGA
2011-01-19  6:25                   ` Grant Likely
2011-01-07  9:45           ` Milton Miller
2011-01-07  9:57         ` Milton Miller
2011-01-07  6:47       ` Tomoya MORINAGA

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=20110121184852.GA18603@angua.secretlab.ca \
    --to=grant.likely-s3s/wqlpoipyb63q8fvjnq@public.gmane.org \
    --cc="'linux-kernel-u79uwXL29TaiAVqoAR/hOA49XUYAGyU/@public.gmane.org@intel.com'"@angua.secretlab.ca \
    --cc=dbrownell-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=joel.clark-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=kok.howg.ewe-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=miltonm-ogEGBHC/i9Y@public.gmane.org \
    --cc=qi.wang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=tomoya-linux-ECg8zkTtlr0C6LszWs/t0g@public.gmane.org \
    --cc=toshiharu-linux-ECg8zkTtlr0C6LszWs/t0g@public.gmane.org \
    --cc=yong.y.wang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).