U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] spi: omap3: Fix multiple definition of 'priv'
@ 2016-03-15 18:26 Jagan Teki
  2016-03-15 18:33 ` Jagan Teki
  2016-03-15 18:50 ` Tom Rini
  0 siblings, 2 replies; 3+ messages in thread
From: Jagan Teki @ 2016-03-15 18:26 UTC (permalink / raw)
  To: u-boot

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH] spi: omap3: Fix multiple definition of 'priv'
  2016-03-15 18:26 [U-Boot] [PATCH] spi: omap3: Fix multiple definition of 'priv' Jagan Teki
@ 2016-03-15 18:33 ` Jagan Teki
  2016-03-15 18:50 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Jagan Teki @ 2016-03-15 18:33 UTC (permalink / raw)
  To: u-boot

On 15 March 2016 at 23:56, Jagan Teki <jteki@openedev.com> wrote:
> 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>

Buildman look fine on the respective boards.

$> ./tools/buildman/buildman -b master -c 1 -s
boards.cfg is up to date. Nothing to do.
Summary of 1 commit for 1104 boards (32 threads, 1 job per thread)
01: spi: omap3: Fix multiple definition of 'priv'
      m68k:  +   M5329AFEE M5249EVB M5208EVBE astro_mcf5373l
M54455EVB_intel M5282EVB M54455EVB_i66 M54455EVB_a66 M5253DEMO
M54455EVB_stm33 M54455EVB M5272C3 M5329BFEE cobra5272 M5275EVB
M5253EVBE M5235EVB_Flash32 M5373EVB M5235EVB

-- 
Jagan.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH] spi: omap3: Fix multiple definition of 'priv'
  2016-03-15 18:26 [U-Boot] [PATCH] spi: omap3: Fix multiple definition of 'priv' Jagan Teki
  2016-03-15 18:33 ` Jagan Teki
@ 2016-03-15 18:50 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2016-03-15 18:50 UTC (permalink / raw)
  To: u-boot

On Tue, Mar 15, 2016 at 11:56:33PM +0530, Jagan Teki wrote:

> 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>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160315/b536c7af/attachment.sig>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-03-15 18:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-15 18:26 [U-Boot] [PATCH] spi: omap3: Fix multiple definition of 'priv' Jagan Teki
2016-03-15 18:33 ` Jagan Teki
2016-03-15 18:50 ` Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox