public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2 05/16] soft_i2c: prevent compilerwarnings if driver not uses CPU Pins.
@ 2008-10-15  7:35 Heiko Schocher
  2008-10-15 16:35 ` Ben Warren
  0 siblings, 1 reply; 3+ messages in thread
From: Heiko Schocher @ 2008-10-15  7:35 UTC (permalink / raw)
  To: u-boot

This patch fixes the following warnings, when using
the soft_i2c driver using no CPU pins on MPC82xx or MPC8xx
systems:

soft_i2c.c: In function 'send_reset':
soft_i2c.c:93: warning: unused variable 'immr'
soft_i2c.c: In function 'send_start':
soft_i2c.c:124: warning: unused variable 'immr'
soft_i2c.c: In function 'send_stop':
soft_i2c.c:146: warning: unused variable 'immr'
soft_i2c.c: In function 'send_ack':
soft_i2c.c:171: warning: unused variable 'immr'
soft_i2c.c: In function 'write_byte':
soft_i2c.c:196: warning: unused variable 'immr'
soft_i2c.c: In function 'read_byte':
soft_i2c.c:244: warning: unused variable 'immr'

Signed-off-by: Heiko Schocher <hs@denx.de>
---
 drivers/i2c/soft_i2c.c |   43 ++++++-------------------------------------
 include/i2c.h          |    9 +++++++++
 2 files changed, 15 insertions(+), 37 deletions(-)

diff --git a/drivers/i2c/soft_i2c.c b/drivers/i2c/soft_i2c.c
index 57736da..19c364b 100644
--- a/drivers/i2c/soft_i2c.c
+++ b/drivers/i2c/soft_i2c.c
@@ -82,7 +82,6 @@ static void  send_ack	(int);
 static int   write_byte	(uchar byte);
 static uchar read_byte	(int);

-
 /*-----------------------------------------------------------------------
  * Send a reset sequence consisting of 9 clocks with the data signal high
  * to clock any confused device back into an idle state.  Also send a
@@ -90,12 +89,7 @@ static uchar read_byte	(int);
  */
 static void send_reset(void)
 {
-#ifdef	CONFIG_MPC8260
-	volatile ioport_t *iop = ioport_addr((immap_t *)CFG_IMMR, I2C_PORT);
-#endif
-#ifdef	CONFIG_8xx
-	volatile immap_t *immr = (immap_t *)CFG_IMMR;
-#endif
+	I2C_SOFT_DECLARATIONS	/* intentional without ';' */
 	int j;

 	I2C_SCL(1);
@@ -121,12 +115,7 @@ static void send_reset(void)
  */
 static void send_start(void)
 {
-#ifdef	CONFIG_MPC8260
-	volatile ioport_t *iop = ioport_addr((immap_t *)CFG_IMMR, I2C_PORT);
-#endif
-#ifdef	CONFIG_8xx
-	volatile immap_t *immr = (immap_t *)CFG_IMMR;
-#endif
+	I2C_SOFT_DECLARATIONS	/* intentional without ';' */

 	I2C_DELAY;
 	I2C_SDA(1);
@@ -143,12 +132,7 @@ static void send_start(void)
  */
 static void send_stop(void)
 {
-#ifdef	CONFIG_MPC8260
-	volatile ioport_t *iop = ioport_addr((immap_t *)CFG_IMMR, I2C_PORT);
-#endif
-#ifdef	CONFIG_8xx
-	volatile immap_t *immr = (immap_t *)CFG_IMMR;
-#endif
+	I2C_SOFT_DECLARATIONS	/* intentional without ';' */

 	I2C_SCL(0);
 	I2C_DELAY;
@@ -168,12 +152,7 @@ static void send_stop(void)
  */
 static void send_ack(int ack)
 {
-#ifdef	CONFIG_MPC8260
-	volatile ioport_t *iop = ioport_addr((immap_t *)CFG_IMMR, I2C_PORT);
-#endif
-#ifdef	CONFIG_8xx
-	volatile immap_t *immr = (immap_t *)CFG_IMMR;
-#endif
+	I2C_SOFT_DECLARATIONS	/* intentional without ';' */

 	I2C_SCL(0);
 	I2C_DELAY;
@@ -193,12 +172,7 @@ static void send_ack(int ack)
  */
 static int write_byte(uchar data)
 {
-#ifdef	CONFIG_MPC8260
-	volatile ioport_t *iop = ioport_addr((immap_t *)CFG_IMMR, I2C_PORT);
-#endif
-#ifdef	CONFIG_8xx
-	volatile immap_t *immr = (immap_t *)CFG_IMMR;
-#endif
+	I2C_SOFT_DECLARATIONS	/* intentional without ';' */
 	int j;
 	int nack;

@@ -273,12 +247,7 @@ int i2c_set_bus_speed(unsigned int speed)
  */
 static uchar read_byte(int ack)
 {
-#ifdef	CONFIG_MPC8260
-	volatile ioport_t *iop = ioport_addr((immap_t *)CFG_IMMR, I2C_PORT);
-#endif
-#ifdef	CONFIG_8xx
-	volatile immap_t *immr = (immap_t *)CFG_IMMR;
-#endif
+	I2C_SOFT_DECLARATIONS	/* intentional without ';' */
 	int  data;
 	int  j;

diff --git a/include/i2c.h b/include/i2c.h
index a51c164..a6e797a 100644
--- a/include/i2c.h
+++ b/include/i2c.h
@@ -67,6 +67,15 @@
 #define CFG_SPD_BUS_NUM		0
 #endif

+#ifndef I2C_SOFT_DECLARATIONS
+# if defined(CONFIG_MPC8260)
+#  define I2C_SOFT_DECLARATIONS volatile ioport_t *iop = ioport_addr((immap_t *)CFG_IMMR, I2C_PORT);
+# elif defined(CONFIG_8xx)
+#  define I2C_SOFT_DECLARATIONS	volatile immap_t *immr = (immap_t *)CFG_IMMR;
+# else
+#  define I2C_SOFT_DECLARATIONS
+# endif
+#endif
 /*
  * Initialization, must be called once on start up, may be called
  * repeatedly to change the speed and slave addresses.
-- 
1.5.6.1

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

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

* [U-Boot] [PATCH v2 05/16] soft_i2c: prevent compilerwarnings if driver not uses CPU Pins.
  2008-10-15  7:35 [U-Boot] [PATCH v2 05/16] soft_i2c: prevent compilerwarnings if driver not uses CPU Pins Heiko Schocher
@ 2008-10-15 16:35 ` Ben Warren
  2008-10-15 18:42   ` Wolfgang Denk
  0 siblings, 1 reply; 3+ messages in thread
From: Ben Warren @ 2008-10-15 16:35 UTC (permalink / raw)
  To: u-boot

Heiko Schocher wrote:
> This patch fixes the following warnings, when using
> the soft_i2c driver using no CPU pins on MPC82xx or MPC8xx
> systems:
>   
Trivial nit, but 'compilerwarnings' is not a word.  In fact, in 
Thunderbird there's a little red line under it.

regards,
Ben

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

* [U-Boot] [PATCH v2 05/16] soft_i2c: prevent compilerwarnings if driver not uses CPU Pins.
  2008-10-15 16:35 ` Ben Warren
@ 2008-10-15 18:42   ` Wolfgang Denk
  0 siblings, 0 replies; 3+ messages in thread
From: Wolfgang Denk @ 2008-10-15 18:42 UTC (permalink / raw)
  To: u-boot

Dear Ben Warren,

In message <48F61BEF.8050902@gmail.com> you wrote:
> Heiko Schocher wrote:
> > This patch fixes the following warnings, when using
> > the soft_i2c driver using no CPU pins on MPC82xx or MPC8xx
> > systems:
> >   
> Trivial nit, but 'compilerwarnings' is not a word.  In fact, in 
> Thunderbird there's a little red line under it.

And the commit in the "next" branch reads:

commit 8d44a21c4b5a2c2d3279414070d9ef683fe5a7a7
Author: Heiko Schocher <hs@denx.de>
Date:   Wed Oct 15 09:35:26 2008 +0200

    soft_i2c: prevent compiler warnings if driver does not use CPU Pins.

:-)

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Operating-system software is the program that  orchestrates  all  the
basic functions of a computer.
- The Wall Street Journal, Tuesday, September 15, 1987, page 40

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

end of thread, other threads:[~2008-10-15 18:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-15  7:35 [U-Boot] [PATCH v2 05/16] soft_i2c: prevent compilerwarnings if driver not uses CPU Pins Heiko Schocher
2008-10-15 16:35 ` Ben Warren
2008-10-15 18:42   ` Wolfgang Denk

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