From: Jagan Teki <jteki@openedev.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] spi: omap3: Fix multiple definition of 'priv'
Date: Tue, 15 Mar 2016 23:56:33 +0530 [thread overview]
Message-ID: <1458066393-3606-1-git-send-email-jteki@openedev.com> (raw)
Global definition of priv seems no-sense to use it
for non-dm case and pass the pointer to functions
which are common to both dm and non-dm.
So, fix this by removing omap3_spi_slave from non-dm
and make visible to omap3_spi_priv for both dm and non-dm.
Cc: Christophe Ricard <christophe-h.ricard@st.com>
Reported-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Jagan Teki <jteki@openedev.com>
---
drivers/spi/omap3_spi.c | 40 +++++++++++++++++++++-------------------
1 file changed, 21 insertions(+), 19 deletions(-)
diff --git a/drivers/spi/omap3_spi.c b/drivers/spi/omap3_spi.c
index 98ee6d3..2fe34c9 100644
--- a/drivers/spi/omap3_spi.c
+++ b/drivers/spi/omap3_spi.c
@@ -103,6 +103,9 @@ struct mcspi {
};
struct omap3_spi_priv {
+#ifndef CONFIG_DM_SPI
+ struct spi_slave slave;
+#endif
struct mcspi *regs;
unsigned int cs;
unsigned int freq;
@@ -454,16 +457,9 @@ static void _omap3_spi_claim_bus(struct omap3_spi_priv *priv)
#ifndef CONFIG_DM_SPI
-struct omap3_spi_slave {
- struct spi_slave slave;
- struct omap3_spi_priv spi_priv;
-};
-
-struct omap3_spi_priv *priv;
-
-static inline struct omap3_spi_slave *to_omap3_spi(struct spi_slave *slave)
+static inline struct omap3_spi_priv *to_omap3_spi(struct spi_slave *slave)
{
- return container_of(slave, struct omap3_spi_slave, slave);
+ return container_of(slave, struct omap3_spi_priv, slave);
}
void spi_init(void)
@@ -473,13 +469,15 @@ void spi_init(void)
void spi_free_slave(struct spi_slave *slave)
{
- struct omap3_spi_slave *ds = to_omap3_spi(slave);
+ struct omap3_spi_priv *priv = to_omap3_spi(slave);
- free(ds);
+ free(priv);
}
int spi_claim_bus(struct spi_slave *slave)
{
+ struct omap3_spi_priv *priv = to_omap3_spi(slave);
+
_omap3_spi_claim_bus(priv);
_omap3_spi_set_wordlen(priv);
_omap3_spi_set_mode(priv);
@@ -490,6 +488,8 @@ int spi_claim_bus(struct spi_slave *slave)
void spi_release_bus(struct spi_slave *slave)
{
+ struct omap3_spi_priv *priv = to_omap3_spi(slave);
+
/* Reset the SPI hardware */
spi_reset(priv->regs);
}
@@ -497,7 +497,7 @@ void spi_release_bus(struct spi_slave *slave)
struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
unsigned int max_hz, unsigned int mode)
{
- struct omap3_spi_slave *ds;
+ struct omap3_spi_priv *priv;
struct mcspi *regs;
/*
@@ -551,29 +551,31 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
return NULL;
}
- ds = spi_alloc_slave(struct omap3_spi_slave, bus, cs);
- if (!ds) {
+ priv = spi_alloc_slave(struct omap3_spi_priv, bus, cs);
+ if (!priv) {
printf("SPI error: malloc of SPI structure failed\n");
return NULL;
}
- priv = &ds->spi_priv;
-
priv->regs = regs;
priv->cs = cs;
priv->freq = max_hz;
priv->mode = mode;
- priv->wordlen = ds->slave.wordlen;
+ priv->wordlen = priv->slave.wordlen;
#ifdef CONFIG_OMAP3_SPI_D0_D1_SWAPPED
priv->pin_dir = MCSPI_PINDIR_D0_OUT_D1_IN;
#endif
- return &ds->slave;
+ return &priv->slave;
}
int spi_xfer(struct spi_slave *slave, unsigned int bitlen,
const void *dout, void *din, unsigned long flags)
-{ return _spi_xfer(priv, bitlen, dout, din, flags); }
+{
+ struct omap3_spi_priv *priv = to_omap3_spi(slave);
+
+ return _spi_xfer(priv, bitlen, dout, din, flags);
+}
#else
--
1.9.1
next reply other threads:[~2016-03-15 18:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-15 18:26 Jagan Teki [this message]
2016-03-15 18:33 ` [U-Boot] [PATCH] spi: omap3: Fix multiple definition of 'priv' Jagan Teki
2016-03-15 18:50 ` Tom Rini
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=1458066393-3606-1-git-send-email-jteki@openedev.com \
--to=jteki@openedev.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox