From: Anton Vorontsov <avorontsov@ru.mvista.com>
To: Grant Likely <grant.likely@secretlab.ca>
Cc: David Brownell <dbrownell@users.sourceforge.net>,
Gary Jennejohn <garyj@denx.de>,
linux-kernel@vger.kernel.org, linuxppc-dev@ozlabs.org,
Guennadi Liakhovetski <g.liakhovetski@gmx.de>,
Pierre Ossman <drzeus-mmc@drzeus.cx>
Subject: Re: [RFC PATCH 2/2] mmc: add OpenFirmware bindings for the mmc_spi driver
Date: Mon, 26 May 2008 15:49:15 +0400 [thread overview]
Message-ID: <20080526114914.GA26288@polina.dev.rtsoft.ru> (raw)
In-Reply-To: <fa686aa40805232219x7e888d80y394958f1c0a0fad0@mail.gmail.com>
On Fri, May 23, 2008 at 11:19:28PM -0600, Grant Likely wrote:
> Yup, I like this approach better. I had been thinking about putting
> this all in the same file (drivers/mmc/host/mmc_spi.c) instead of
> exporting the probe/remove symbols and by using clear comment blocks
> to divide the sections, but I've got no issues with this approach.
>
> This is good work. Some comments below. (I won't repeat Stephen's comments)
Thanks!
> On Fri, May 23, 2008 at 12:28 PM, Anton Vorontsov
> <avorontsov@ru.mvista.com> wrote:
> > This patch depends on the Grant Likely's SPI patches, so this is
> > for RFC only.
> >
> > Also, later we'll able to remove OF_GPIO dependency.
> >
> > Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
> > ---
> > Documentation/powerpc/booting-without-of.txt | 24 ++++
> > drivers/mmc/host/Kconfig | 7 ++
> > drivers/mmc/host/Makefile | 2 +-
> > drivers/mmc/host/of_mmc_spi.c | 151 ++++++++++++++++++++++++++
> > 4 files changed, 183 insertions(+), 1 deletions(-)
> > create mode 100644 drivers/mmc/host/of_mmc_spi.c
> >
> > diff --git a/Documentation/powerpc/booting-without-of.txt b/Documentation/powerpc/booting-without-of.txt
> > index 423cb2b..7d0ef80 100644
> > --- a/Documentation/powerpc/booting-without-of.txt
> > +++ b/Documentation/powerpc/booting-without-of.txt
> > @@ -3151,7 +3151,31 @@ platforms are moved over to use the flattened-device-tree model.
> > };
> > };
> >
> > + ...) MMC-over-SPI
> >
> > + Required properties:
> > + - #address-cells : should be 0.
> > + - #size-cells : should be 0.
>
> Are these properties required at all? Will this node have any children.
Yeah, my weakness for #a/#s, I always insert it where unnecessary. :-)
Will fix.
> > + - compatible : should be "linux,mmc-spi".
> > + - linux,modalias - should be "of_mmc_spi".
>
> I'm not even sure if the whole linux,modalias is even a good idea. I
> had kind of thrown it in there as a convenient way to override
> compatible when needed, but I haven't really thought it out very well
> and I think it is rather a hack.
>
> The real problem is we don't yet have good method (or place) to apply
> a translation table from compatible values to modaliases. Ideally,
> the translations should be part of the drivers themselves, but that
> causes a chicken and egg problem of needing to load the driver to get
> access to the table to know if it is the correct driver... Of course,
> I'm really not very familiar with the whole module autoloading
> mechanism. Regardless; binding should be based on compatible, not on
> a hacky and bogus linux,modalias property.
I fully agree. Though, I just tried to use your spi_of with a belief
that you'll implement compatible->modalias translation in spi_of. :-)
> > + - reg : should specify SPI address (chip-select number).
> > + - max-speed : (optional) maximum frequency for this device (Hz).
> > + - linux,mmc-ocr-mask : (optional) Linux-specific MMC OCR mask
> > + (slot voltage).
>
> Should this property be better defined?
Yes, will do. Was a bit lazy to do this for the RFC.
[...]
> > +static int mmc_get_cd(struct device *dev)
> > +{
> > + struct of_mmc_spi *oms = dev->archdata.of_node->data;
> > +
> > + return gpio_get_value(oms->cd_gpio);
> > +}
> > +
> > +static int of_mmc_spi_probe(struct spi_device *spi)
> > +{
> > + int ret = -EINVAL;
> > + struct device_node *np = spi->dev.archdata.of_node;
> > + struct device *dev = &spi->dev;
> > + struct of_mmc_spi *oms = kzalloc(sizeof(*oms), GFP_KERNEL);
> > + const u32 *ocr_mask;
> > + int size;
> > +
> > + if (!oms)
> > + return -ENOMEM;
> > +
> > + /* Somebody occupied node's data? */
> > + WARN_ON(spi->dev.archdata.of_node->data);
>
> Perhaps bail at this point to avoid corruption? Would it be better to
> use container_of() instead for getting a pointer back to the private
> structure from the pdata pointer?
Using platform_data with container_of isn't always safe (e.g. for
platform bus we can't use it, this is done so that board's platform_data
definitions could be made __initdata).
David, would you [not] suggest us to use platform_data with
container_of, that is, are there any plans to make SPI core copy
the platform_data instead of passing a pointer directly?
> > +
> > + /*
> > + * mmc_spi_probe will use drvdata, so we can't use it. Use node's
> > + * data instead.
> > + */
> > + spi->dev.archdata.of_node->data = oms;
> > +
[...]
--
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2
next prev parent reply other threads:[~2008-05-26 11:49 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-23 18:27 [RFC] OpenFirmware bindings for the MMC-over-SPI driver Anton Vorontsov
2008-05-23 18:28 ` [RFC PATCH 1/2] mmc_spi: export probe and remove functions Anton Vorontsov
[not found] ` <20080526141836.72db0623@mjolnir.drzeus.cx>
2008-05-26 12:25 ` Anton Vorontsov
2008-05-26 13:10 ` Anton Vorontsov
[not found] ` <20080601121841.0392b01c@mjolnir.drzeus.cx>
2008-06-02 12:53 ` Anton Vorontsov
2008-05-23 18:28 ` [RFC PATCH 2/2] mmc: add OpenFirmware bindings for the mmc_spi driver Anton Vorontsov
2008-05-24 2:35 ` Stephen Rothwell
2008-05-26 11:58 ` Anton Vorontsov
2008-05-24 5:19 ` Grant Likely
2008-05-24 14:32 ` Jochen Friedrich
2008-05-24 23:14 ` Segher Boessenkool
2008-05-24 23:06 ` Segher Boessenkool
2008-05-26 11:49 ` Anton Vorontsov [this message]
2008-05-26 22:19 ` David Brownell
2008-05-26 23:15 ` Anton Vorontsov
2008-05-24 19:56 ` [RFC] OpenFirmware bindings for the MMC-over-SPI driver David Brownell
2008-05-25 4:47 ` Grant Likely
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=20080526114914.GA26288@polina.dev.rtsoft.ru \
--to=avorontsov@ru.mvista.com \
--cc=dbrownell@users.sourceforge.net \
--cc=drzeus-mmc@drzeus.cx \
--cc=g.liakhovetski@gmx.de \
--cc=garyj@denx.de \
--cc=grant.likely@secretlab.ca \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@ozlabs.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).