From: Peng Fan <Peng.Fan@freescale.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] dm: spi: Correct SPI claim/release_bus() methods
Date: Mon, 20 Apr 2015 12:41:55 +0800 [thread overview]
Message-ID: <55348393.1080206@freescale.com> (raw)
In-Reply-To: <1429455941-14223-1-git-send-email-sjg@chromium.org>
Hi, Simon
On 4/19/2015 11:05 PM, Simon Glass wrote:
> These methods should be passed a slave device, not a bus. This matches the
> old SPI interface. It is important to know which device is claiming the bus
> so passing a bus is not that useful.
>
> Reported-by: Haikun Wang <haikun.wang@freescale.com>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> drivers/spi/exynos_spi.c | 6 ++++--
> drivers/spi/spi-uclass.c | 4 ++--
> drivers/spi/tegra114_spi.c | 3 ++-
> drivers/spi/tegra20_sflash.c | 3 ++-
> drivers/spi/tegra20_slink.c | 3 ++-
> include/spi.h | 10 +++++-----
> 6 files changed, 17 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/spi/exynos_spi.c b/drivers/spi/exynos_spi.c
> index a46d8c1..67f6b2d 100644
> --- a/drivers/spi/exynos_spi.c
> +++ b/drivers/spi/exynos_spi.c
> @@ -296,8 +296,9 @@ static int exynos_spi_probe(struct udevice *bus)
> return 0;
> }
>
> -static int exynos_spi_claim_bus(struct udevice *bus)
> +static int exynos_spi_claim_bus(struct udevice *dev)
> {
> + struct udevice *bus = dev->parent;
> struct exynos_spi_priv *priv = dev_get_priv(bus);
>
> exynos_pinmux_config(priv->periph_id, PINMUX_FLAG_NONE);
> @@ -308,8 +309,9 @@ static int exynos_spi_claim_bus(struct udevice *bus)
> return 0;
> }
>
> -static int exynos_spi_release_bus(struct udevice *bus)
> +static int exynos_spi_release_bus(struct udevice *dev)
> {
> + struct udevice *bus = dev->parent;
> struct exynos_spi_priv *priv = dev_get_priv(bus);
>
> spi_flush_fifo(priv->regs);
> diff --git a/drivers/spi/spi-uclass.c b/drivers/spi/spi-uclass.c
> index 866c48f..83fe8e0 100644
> --- a/drivers/spi/spi-uclass.c
> +++ b/drivers/spi/spi-uclass.c
> @@ -67,7 +67,7 @@ int spi_claim_bus(struct spi_slave *slave)
> if (ret)
> return ret;
>
> - return ops->claim_bus ? ops->claim_bus(bus) : 0;
> + return ops->claim_bus ? ops->claim_bus(dev) : 0;
> }
>
> void spi_release_bus(struct spi_slave *slave)
> @@ -77,7 +77,7 @@ void spi_release_bus(struct spi_slave *slave)
> struct dm_spi_ops *ops = spi_get_ops(bus);
>
> if (ops->release_bus)
> - ops->release_bus(bus);
> + ops->release_bus(dev);
> }
>
> int spi_xfer(struct spi_slave *slave, unsigned int bitlen,
> diff --git a/drivers/spi/tegra114_spi.c b/drivers/spi/tegra114_spi.c
> index 53ff9ea..4bec663 100644
> --- a/drivers/spi/tegra114_spi.c
> +++ b/drivers/spi/tegra114_spi.c
> @@ -153,8 +153,9 @@ static int tegra114_spi_probe(struct udevice *bus)
> return 0;
> }
>
> -static int tegra114_spi_claim_bus(struct udevice *bus)
> +static int tegra114_spi_claim_bus(struct udevice *dev)
> {
> + struct udevice *bus = dev->parent;
> struct tegra114_spi_priv *priv = dev_get_priv(bus);
> struct spi_regs *regs = priv->regs;
>
> diff --git a/drivers/spi/tegra20_sflash.c b/drivers/spi/tegra20_sflash.c
> index 78c74cd..82c1b84 100644
> --- a/drivers/spi/tegra20_sflash.c
> +++ b/drivers/spi/tegra20_sflash.c
> @@ -125,8 +125,9 @@ static int tegra20_sflash_probe(struct udevice *bus)
> return 0;
> }
>
> -static int tegra20_sflash_claim_bus(struct udevice *bus)
> +static int tegra20_sflash_claim_bus(struct udevice *dev)
> {
> + struct udevice *bus = dev->parent;
> struct tegra20_sflash_priv *priv = dev_get_priv(bus);
> struct spi_regs *regs = priv->regs;
> u32 reg;
> diff --git a/drivers/spi/tegra20_slink.c b/drivers/spi/tegra20_slink.c
> index 597d6ad..f6fb89b 100644
> --- a/drivers/spi/tegra20_slink.c
> +++ b/drivers/spi/tegra20_slink.c
> @@ -141,8 +141,9 @@ static int tegra30_spi_probe(struct udevice *bus)
> return 0;
> }
>
> -static int tegra30_spi_claim_bus(struct udevice *bus)
> +static int tegra30_spi_claim_bus(struct udevice *dev)
> {
> + struct udevice *bus = dev->parent;
> struct tegra30_spi_priv *priv = dev_get_priv(bus);
> struct spi_regs *regs = priv->regs;
> u32 reg;
> diff --git a/include/spi.h b/include/spi.h
> index c58e453..863e6db 100644
> --- a/include/spi.h
> +++ b/include/spi.h
> @@ -385,12 +385,12 @@ struct dm_spi_ops {
> * allowed to claim the same bus for several slaves without releasing
> * the bus in between.
> *
> - * @bus: The SPI slave
> + * @dev: The SPI slave
> *
> * Returns: 0 if the bus was claimed successfully, or a negative value
> * if it wasn't.
> */
> - int (*claim_bus)(struct udevice *bus);
> + int (*claim_bus)(struct udevice *dev);
>
> /**
> * Release the SPI bus
> @@ -399,9 +399,9 @@ struct dm_spi_ops {
> * all transfers have finished. It may disable any SPI hardware as
> * appropriate.
> *
> - * @bus: The SPI slave
> + * @dev: The SPI slave
> */
> - int (*release_bus)(struct udevice *bus);
> + int (*release_bus)(struct udevice *dev);
>
> /**
> * Set the word length for SPI transactions
> @@ -413,7 +413,7 @@ struct dm_spi_ops {
> *
> * Returns: 0 on success, -ve on failure.
> */
> - int (*set_wordlen)(struct udevice *bus, unsigned int wordlen);
> + int (*set_wordlen)(struct udevice *dev, unsigned int wordlen);
>
> /**
> * SPI transfer
After applying this patch, qspi flashes can be correctly probed and
read/write on i.MX platform. I original posted a patch
https://patchwork.ozlabs.org/patch/461034/ which seems in wrong way:)
Tested-by: Peng Fan <Peng.Fan@freescale.com>
Regards,
Peng.
next prev parent reply other threads:[~2015-04-20 4:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-19 15:05 [U-Boot] [PATCH] dm: spi: Correct SPI claim/release_bus() methods Simon Glass
2015-04-20 4:41 ` Peng Fan [this message]
2015-04-20 5:27 ` Jagan Teki
2015-04-22 20:42 ` Simon Glass
2015-04-23 9:55 ` Jagan Teki
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=55348393.1080206@freescale.com \
--to=peng.fan@freescale.com \
--cc=u-boot@lists.denx.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.