From: "Grant Likely" <grant.likely@secretlab.ca>
To: "Anton Vorontsov" <avorontsov@ru.mvista.com>
Cc: linuxppc-dev@ozlabs.org, Gary Jennejohn <garyj@denx.de>,
Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Subject: Re: [PATCH 1/4] [SPI] spi_mpc83xx: convert to the OF platform driver
Date: Wed, 21 May 2008 10:50:02 -0600 [thread overview]
Message-ID: <fa686aa40805210950i2df67158p139770f675ef2032@mail.gmail.com> (raw)
In-Reply-To: <20080521154137.GA4566@polina.dev.rtsoft.ru>
On Wed, May 21, 2008 at 9:41 AM, Anton Vorontsov
<avorontsov@ru.mvista.com> wrote:
> This patch converts the driver to speak OF directly. FSL SPI controllers
> do not use internal chip-select machines, so boards must use GPIOs for
> these purposes.
>
Mostly this looks good to me, but I didn't look
> Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
> ---
> Documentation/powerpc/booting-without-of.txt | 1 +
> drivers/spi/Kconfig | 3 +-
> drivers/spi/spi_mpc83xx.c | 279 +++++++++++++++++---------
> 3 files changed, 184 insertions(+), 99 deletions(-)
>
> @@ -536,92 +539,152 @@ static void mpc83xx_spi_cleanup(struct spi_device *spi)
> kfree(spi->controller_state);
> }
>
> -static int __init mpc83xx_spi_probe(struct platform_device *dev)
> +static unsigned int of_num_children(struct device_node *parent)
> +{
> + unsigned int count = 0;
> + struct device_node *child = NULL;
> +
> + for_each_child_of_node(parent, child)
> + count++;
> +
> + return count;
> +}
This smells like it should be in common of code; but I don't think
this routine is needed at all (see below)
[...]
> - if (master == NULL) {
> + bus_num = of_get_property(np, "reg", &size);
> + if (!bus_num || size < sizeof(*bus_num)) {
> + dev_err(dev, "unable to get reg property from OF\n");
> + ret = -EINVAL;
> + goto err_bus_num;
> + }
> + master->bus_num = *bus_num;
Does the driver really need to define its own bus num? I know your
using it for binding with a board info structure, but I think there
are better ways to do it (I'll elaborate in my reply to your patch
that adds support for boardinfo structures). It's better to let the
SPI infrastructure assign an SPI bus number. and use other methods to
ensure that extra data is provided to the driver. Besides, there is
no guarantee that 'reg' will be unique.
> +
> + master->num_chipselect = of_num_children(np);
This assumes that there are no gaps in the assigned CS numbers of
child nodes, or that the child nodes are an exhaustive list of
attached devices, neither of which may be true. num_chipselect should
be calculated from the number of GPIOs specified instead.
Cheers,
g.
--
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
next prev parent reply other threads:[~2008-05-21 16:50 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-21 15:41 [RFC/DRAFT] SPI OF bindings, MMC-over-SPI, chip-selects and so on Anton Vorontsov
2008-05-21 15:41 ` [PATCH 1/4] [SPI] spi_mpc83xx: convert to the OF platform driver Anton Vorontsov
2008-05-21 16:50 ` Grant Likely [this message]
2008-05-21 17:05 ` Anton Vorontsov
2008-05-21 17:17 ` Grant Likely
2008-05-21 15:41 ` [PATCH 2/4] [OF] spi_of: add support for dedicated SPI constructors Anton Vorontsov
2008-05-21 15:56 ` Guennadi Liakhovetski
2008-05-21 16:10 ` Anton Vorontsov
2008-05-21 16:24 ` Guennadi Liakhovetski
2008-05-21 16:48 ` Anton Vorontsov
2008-05-21 17:05 ` Grant Likely
2008-05-21 17:51 ` Guennadi Liakhovetski
2008-05-21 19:06 ` Grant Likely
2008-05-21 19:20 ` Guennadi Liakhovetski
2008-05-21 19:53 ` Grant Likely
2008-05-21 20:00 ` Guennadi Liakhovetski
2008-05-21 20:07 ` Grant Likely
2008-05-21 17:30 ` Grant Likely
2008-05-21 15:41 ` [PATCH 3/4] [OF] MMC-over-SPI OF constructor Anton Vorontsov
2008-05-21 15:41 ` [PATCH 4/4] [POWERPC] 86xx: mpc8610_hpcd: support for MMC-over-SPI and PIXIS' GPIOs Anton Vorontsov
2008-05-21 15:54 ` [RFC/DRAFT] SPI OF bindings, MMC-over-SPI, chip-selects and so on Guennadi Liakhovetski
2008-05-21 16:01 ` Anton Vorontsov
2008-05-21 16:51 ` Grant Likely
2008-05-21 17:32 ` 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=fa686aa40805210950i2df67158p139770f675ef2032@mail.gmail.com \
--to=grant.likely@secretlab.ca \
--cc=avorontsov@ru.mvista.com \
--cc=g.liakhovetski@gmx.de \
--cc=garyj@denx.de \
--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).