소스 검색

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

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>
Heiko Schocher 16 년 전
부모
커밋
98aed37958
2개의 변경된 파일15개의 추가작업 그리고 37개의 파일을 삭제
  1. 6 37
      drivers/i2c/soft_i2c.c
  2. 9 0
      include/i2c.h

+ 6 - 37
drivers/i2c/soft_i2c.c

@@ -82,7 +82,6 @@ static void  send_ack	(int);
 static int   write_byte	(uchar byte);
 static int   write_byte	(uchar byte);
 static uchar read_byte	(int);
 static uchar read_byte	(int);
 
 
-
 /*-----------------------------------------------------------------------
 /*-----------------------------------------------------------------------
  * Send a reset sequence consisting of 9 clocks with the data signal high
  * 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
  * 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)
 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;
 	int j;
 
 
 	I2C_SCL(1);
 	I2C_SCL(1);
@@ -121,12 +115,7 @@ static void send_reset(void)
  */
  */
 static void send_start(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_DELAY;
 	I2C_SDA(1);
 	I2C_SDA(1);
@@ -143,12 +132,7 @@ static void send_start(void)
  */
  */
 static void send_stop(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_SCL(0);
 	I2C_DELAY;
 	I2C_DELAY;
@@ -168,12 +152,7 @@ static void send_stop(void)
  */
  */
 static void send_ack(int ack)
 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_SCL(0);
 	I2C_DELAY;
 	I2C_DELAY;
@@ -193,12 +172,7 @@ static void send_ack(int ack)
  */
  */
 static int write_byte(uchar data)
 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 j;
 	int nack;
 	int nack;
 
 
@@ -273,12 +247,7 @@ int i2c_set_bus_speed(unsigned int speed)
  */
  */
 static uchar read_byte(int ack)
 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  data;
 	int  j;
 	int  j;
 
 

+ 9 - 0
include/i2c.h

@@ -67,6 +67,15 @@
 #define CFG_SPD_BUS_NUM		0
 #define CFG_SPD_BUS_NUM		0
 #endif
 #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
  * Initialization, must be called once on start up, may be called
  * repeatedly to change the speed and slave addresses.
  * repeatedly to change the speed and slave addresses.