public inbox for linux-mmc@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Shawn Guo <shawn.guo@freescale.com>
Cc: linux-arm-kernel@lists.infradead.org, s.hauer@pengutronix.de,
	cjb@laptop.org, linux-mmc@vger.kernel.org,
	u.kleine-koenig@pengutronix.de
Subject: Re: [PATCH 1/7] mmc: mxs-mmc: add mmc host driver for i.MX23/28
Date: Sat, 12 Feb 2011 09:59:22 +0100	[thread overview]
Message-ID: <201102120959.22707.arnd@arndb.de> (raw)
In-Reply-To: <20110212140417.GA9821@S2100-06.ap.freescale.net>

On Saturday 12 February 2011 15:04:19 Shawn Guo wrote:
> > and tmio_mmc.c more or less do what I'm suggesting you do instead.
> > 
> > Looking at sh_mmcif:
> > 
> >       host->chan_tx = dma_request_channel(mask, sh_mmcif_filter,
> >                                           &pdata->dma->chan_priv_tx);
> > 
> > 
> > This is the only place where dma engine specific data is used
> > in the driver, and chan_priv_tx is part of the platform data, so the
> > mmc driver can simply pass it down as a void pointer without knowing
> > the type. The platform data as defined in the machine file ties
> > both the dma controller and the mmc device together, but neither
> > of the two drivers needs to know anything about the implementation
> > of the other.
> > 
> Not really.  Though mmc does not need to know anything about dma
> driver, dma knows that mmc driver has to pass .slave_id via
> chan->private.  The snippet below is copied from shdma.
> 
>         struct sh_dmae_slave_config {
>                 unsigned int                    slave_id;
>                 dma_addr_t                      addr;
>                 u32                             chcr;
>                 char                            mid_rid;
>         };
> ---
>         if (chan->private) {
>                 /* The caller is holding dma_list_mutex */
>                 struct sh_dmae_slave *param = chan->private;
>                 clear_bit(param->slave_id, sh_dmae_slave_used);
>         }
> 
> And it only works when slave_id is the first member of
> sh_dmae_slave_config.
>
> For me, it's more natural to define device's dma related things like
> dma channel id and irq as its resources than platform data.  So I
> still maintain the current approach.

I'm not arguing against passing the data as platform data (well, not any
more, but it was never the main objection anyway).

You are right that sh_dmae_slave_config contains all the private data
for the DMA controller, and I have no objection to you doing the
same. However, sh_mmcif.c does not know the defintion of
sh_dmae_slave_config, it just gets it via a void pointer from the
platform data and passes it to the dma_request_channel function via
another void pointer. That function calls into the sh_dmae driver, which
casts it back to struct sh_dmae_slave_config, and that is same that I'm
suggesting you to do.

It should really be a trivial change to move your struct mxs_dma_data
from struct mxs_mmc_host to your platform_data:

struct mxs_mmc_platform_data {
	int wp_gpio;	/* write protect pin */
	void *dma_data;
};

static struct mxs_dma_data mxs_mmc_dma_data = {
	.chan_irq = MMC_DMA_IRQ,
};

static struct mxs_mmc_platform_data mxs_mmc_pdata = {
	.wp_gpio = SOME_CONSTANT,
	.dma_data = &mxs_mmc_dma_data,
}

Now only the platform definition needs to know about both
mxs_mmc_platform_data and mxs_dma_data, while the dma engine driver
and the mmc driver each just need to know about their own data.

Sorry for being too vague in what I asking for before.

	Arnd

  reply	other threads:[~2011-02-12  8:59 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-05  2:18 [PATCH 0/7] Add mmc driver for i.MX23/28 Shawn Guo
2011-02-05  2:18 ` [PATCH 1/7] mmc: mxs-mmc: add mmc host " Shawn Guo
2011-02-04 20:26   ` Arnd Bergmann
2011-02-11  0:35     ` Shawn Guo
2011-02-10 17:17       ` Arnd Bergmann
2011-02-11 23:14         ` Shawn Guo
2011-02-11 15:51           ` Arnd Bergmann
2011-02-12  0:55             ` Shawn Guo
2011-02-11 20:04               ` Arnd Bergmann
2011-02-12 14:04                 ` Shawn Guo
2011-02-12  8:59                   ` Arnd Bergmann [this message]
2011-02-12 17:23                     ` Shawn Guo
2011-02-12 10:07                       ` Arnd Bergmann
2011-02-12 18:37                         ` Shawn Guo
2011-02-12 17:30                           ` Arnd Bergmann
2011-02-13 17:53       ` Shawn Guo
2011-02-13 15:34         ` Arnd Bergmann
2011-02-13 23:52           ` Shawn Guo
2011-02-13 16:10             ` Arnd Bergmann
2011-02-08 11:41   ` Lothar Waßmann
2011-02-11 22:11     ` Shawn Guo
2011-02-11 14:40       ` Lothar Waßmann
2011-02-12  1:08         ` Shawn Guo
2011-02-09  7:46   ` Lothar Waßmann
2011-02-11 22:08     ` Shawn Guo
2011-02-11 14:52       ` Lothar Waßmann
2011-02-11 23:48         ` Shawn Guo
2011-02-05  2:18 ` [PATCH 2/7] ARM: mxs/clock: fix base address missing in name##_set_parent Shawn Guo
2011-02-05  2:18 ` [PATCH 3/7] ARM: mxs: make ssp error irq definition consistent Shawn Guo
2011-02-05  2:18 ` [PATCH 4/7] ARM: mxs: dynamically allocate mmc device Shawn Guo
2011-02-05  2:18 ` [PATCH 5/7] ARM: mxs: fix typo "GPO" in iomux-mx23.h Shawn Guo
2011-02-05  2:18 ` [PATCH 6/7] ARM: mxs/mx23evk: add mmc device Shawn Guo
2011-02-05  2:18 ` [PATCH 7/7] ARM: mxs/mx28evk: " Shawn Guo

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=201102120959.22707.arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=cjb@laptop.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=shawn.guo@freescale.com \
    --cc=u.kleine-koenig@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox