linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
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 2/4] [OF] spi_of: add support for dedicated SPI constructors
Date: Wed, 21 May 2008 11:30:55 -0600	[thread overview]
Message-ID: <fa686aa40805211030p1ada86b5gf3e2f4b1b5aca754@mail.gmail.com> (raw)
In-Reply-To: <20080521154139.GB4566@polina.dev.rtsoft.ru>

On Wed, May 21, 2008 at 9:41 AM, Anton Vorontsov
<avorontsov@ru.mvista.com> wrote:
> Dedicated (usually the ones that need to fill platform data) constructors
> will create board info, so SPI core will probe them as normal SPI devices.
>
> Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
> ---
>  drivers/spi/spi_of.c       |   67 ++++++++++++++++++++++++++++++++++++++++++++
>  include/linux/spi/spi_of.h |    5 +++
>  2 files changed, 72 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/spi/spi_of.c b/drivers/spi/spi_of.c
> index b5ae434..2e1a11f 100644
> --- a/drivers/spi/spi_of.c
> +++ b/drivers/spi/spi_of.c
> @@ -11,6 +11,66 @@
>  #include <linux/spi/spi.h>
>  #include <linux/spi/spi_of.h>
>
> +/*
> + * Caller have no idea who is master, i.e. this function does not
> + * accept pointer to the master, instead we use board infos.
> + */
> +int of_spi_device_probe_common(struct device_node *np,
> +                              struct spi_board_info *spi_binfo,
> +                              const char *modalias)
> +{
> +       struct device_node *parent;
> +       const u32 *bus_num;
> +       const u32 *chip_select;
> +       const u32 *max_speed;
> +       int size;
> +
> +       parent = of_get_parent(np);
> +       if (!parent) {
> +               pr_err("%s: no parent\n", np->full_name);
> +               return -EINVAL;
> +       }
> +
> +       bus_num = of_get_property(parent, "reg", &size);
> +       if (!bus_num || size < sizeof(*bus_num)) {
> +               pr_err("%s: no reg specified for parent\n", np->full_name);
> +               of_node_put(parent);
> +               return -EINVAL;
> +       }
> +       spi_binfo->bus_num = *bus_num;
> +       of_node_put(parent);
> +
> +       chip_select = of_get_property(np, "reg", &size);
> +       if (!chip_select || size < sizeof(*chip_select)) {
> +               pr_err("%s: no reg (chip-select) specified\n", np->full_name);
> +               return -EINVAL;
> +       }
> +       spi_binfo->chip_select = *chip_select;
> +
> +       max_speed = of_get_property(np, "max-speed", &size);
> +       if (!max_speed || size < sizeof(*max_speed))
> +               spi_binfo->max_speed_hz = 100000;
> +       else
> +               spi_binfo->max_speed_hz = *max_speed;
> +
> +       strcpy(spi_binfo->modalias, modalias);
> +
> +       /*
> +        * spi_of_register_devices() should not probe this device, it will
> +        * be managed by the dedicated driver.
> +        */
> +       np->data = spi_binfo;
> +
> +       return 0;
> +}
> +EXPORT_SYMBOL(of_spi_device_probe_common);

This is mostly a duplication of stuff in spi_of_register_devices() and
it short circuits that path.  While I'm not hugely fond of boardinfo
in general, I'd much rather see it passed via spi_of_register_devices
instead of using a different path.  I know we've discussed this before
and I resisted settling on a solution (like adding a specific
platform_data pointer instead of using device_node->data) mostly
because I'm being cautious.  I still don't know if it would be better
to use a device_node value or to have some form of callback into the
boards platform code.  But, either method would be better than having
multiple paths for registering SPI devices which are described in the
device tree.

Cheers,
g.

-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

  parent reply	other threads:[~2008-05-21 17:30 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
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 [this message]
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=fa686aa40805211030p1ada86b5gf3e2f4b1b5aca754@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).