mpc8xx/i2c.c: CodungStyle cleanup
Make (mostly) checkpatch-clean We don't acctually change the code (like convert to use I/O accessors), so there will be some remaining "Use of volatile" warnings from checkpatch. Signed-off-by: Wolfgang Denk <wd@denx.de> Cc: Heiko Schocher <hs@denx.de>
This commit is contained in:
		
							parent
							
								
									e1196b8005
								
							
						
					
					
						commit
						09e68ffadd
					
				|  | @ -50,12 +50,12 @@ DECLARE_GLOBAL_DATA_PTR; | |||
| #define MAX_TX_SPACE 256 | ||||
| #define I2C_RXTX_LEN 128	/* maximum tx/rx buffer length */ | ||||
| 
 | ||||
| typedef struct I2C_BD | ||||
| { | ||||
| typedef struct I2C_BD { | ||||
| 	unsigned short status; | ||||
| 	unsigned short length; | ||||
| 	unsigned char *addr; | ||||
| } I2C_BD; | ||||
| 
 | ||||
| #define BD_I2C_TX_START 0x0400	/* special status for i2c: Start condition */ | ||||
| 
 | ||||
| #define BD_I2C_TX_CL	0x0001	/* collision error */ | ||||
|  | @ -146,8 +146,7 @@ i2c_roundrate(int hz, int speed, int filter, int modval, | |||
| /*
 | ||||
|  * Sets the I2C clock predivider and divider to meet required clock speed. | ||||
|  */ | ||||
| static int | ||||
| i2c_setrate (int hz, int speed) | ||||
| static int i2c_setrate(int hz, int speed) | ||||
| { | ||||
| 	immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; | ||||
| 	volatile i2c8xx_t *i2c = (i2c8xx_t *) & immap->im_i2c; | ||||
|  | @ -161,7 +160,8 @@ i2c_setrate (int hz, int speed) | |||
| 		filter = 0;	/* Use this fixed value */ | ||||
| 
 | ||||
| 	for (modval = 0; modval < 4; modval++) { | ||||
| 		if (i2c_roundrate(hz,speed,filter,modval,&brgval,&totspeed) == 0) { | ||||
| 		if (i2c_roundrate | ||||
| 		    (hz, speed, filter, modval, &brgval, &totspeed) == 0) { | ||||
| 			int diff = speed - totspeed; | ||||
| 
 | ||||
| 			if ((diff >= 0) && (diff < bestspeed_diff)) { | ||||
|  | @ -182,7 +182,8 @@ i2c_setrate (int hz, int speed) | |||
| 		bestspeed_brgval, | ||||
| 		bestspeed_diff)); | ||||
| 
 | ||||
| 	i2c->i2c_i2mod |= ((bestspeed_modval & 3) << 1) | (bestspeed_filter << 3); | ||||
| 	i2c->i2c_i2mod |= | ||||
| 		((bestspeed_modval & 3) << 1) | (bestspeed_filter << 3); | ||||
| 	i2c->i2c_i2brg = bestspeed_brgval & 0xff; | ||||
| 
 | ||||
| 	PRINTD (("[I2C] i2mod=%08x i2brg=%08x\n", i2c->i2c_i2mod, | ||||
|  | @ -191,8 +192,7 @@ i2c_setrate (int hz, int speed) | |||
| 	return 1; | ||||
| } | ||||
| 
 | ||||
| void | ||||
| i2c_init(int speed, int slaveaddr) | ||||
| void i2c_init(int speed, int slaveaddr) | ||||
| { | ||||
| 	volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; | ||||
| 	volatile cpm8xx_t *cp = (cpm8xx_t *)&immap->im_cpm; | ||||
|  | @ -220,8 +220,8 @@ i2c_init(int speed, int slaveaddr) | |||
| 	dpaddr = iip->iic_rbase; | ||||
| 	if (dpaddr == 0) { | ||||
| 		/* need to allocate dual port ram */ | ||||
| 	    dpaddr = dpram_alloc_align( | ||||
| 		(NUM_RX_BDS * sizeof(I2C_BD)) + (NUM_TX_BDS * sizeof(I2C_BD)) + | ||||
| 		dpaddr = dpram_alloc_align((NUM_RX_BDS * sizeof(I2C_BD)) + | ||||
| 					   (NUM_TX_BDS * sizeof(I2C_BD)) + | ||||
| 					   MAX_TX_SPACE, 8); | ||||
| 	} | ||||
| #else | ||||
|  | @ -302,8 +302,7 @@ i2c_init(int speed, int slaveaddr) | |||
| 	i2c->i2c_i2cmr = 0x00; | ||||
| } | ||||
| 
 | ||||
| static void | ||||
| i2c_newio(i2c_state_t *state) | ||||
| static void i2c_newio(i2c_state_t *state) | ||||
| { | ||||
| 	volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR; | ||||
| 	volatile cpm8xx_t *cp = (cpm8xx_t *)&immap->im_cpm; | ||||
|  | @ -334,9 +333,7 @@ static int | |||
| i2c_send(i2c_state_t *state, | ||||
| 	 unsigned char address, | ||||
| 	 unsigned char secondary_address, | ||||
| 	 unsigned int flags, | ||||
| 	 unsigned short size, | ||||
| 	 unsigned char *dataout) | ||||
| 	 unsigned int flags, unsigned short size, unsigned char *dataout) | ||||
| { | ||||
| 	volatile I2C_BD *txbd; | ||||
| 	int i, j; | ||||
|  | @ -360,13 +357,17 @@ i2c_send(i2c_state_t *state, | |||
| 	if (flags & I2CF_START_COND) { | ||||
| 		PRINTD(("[I2C] Formatting addresses...\n")); | ||||
| 		if (flags & I2CF_ENABLE_SECONDARY) { | ||||
| 			txbd->length = size + 2;  /* Length of msg + dest addr */ | ||||
| 			/* Length of msg + dest addr */ | ||||
| 			txbd->length = size + 2; | ||||
| 
 | ||||
| 			txbd->addr[0] = address << 1; | ||||
| 			txbd->addr[1] = secondary_address; | ||||
| 			i = 2; | ||||
| 		} else { | ||||
| 			txbd->length = size + 1;  /* Length of msg + dest addr */ | ||||
| 			txbd->addr[0] = address << 1;  /* Write dest addr to BD */ | ||||
| 			/* Length of msg + dest addr */ | ||||
| 			txbd->length = size + 1; | ||||
| 			/* Write dest addr to BD */ | ||||
| 			txbd->addr[0] = address << 1; | ||||
| 			i = 1; | ||||
| 		} | ||||
| 	} else { | ||||
|  | @ -406,12 +407,12 @@ i2c_receive(i2c_state_t *state, | |||
| 	    unsigned char address, | ||||
| 	    unsigned char secondary_address, | ||||
| 	    unsigned int flags, | ||||
| 	    unsigned short size_to_expect, | ||||
| 	    unsigned char *datain) | ||||
| 	    unsigned short size_to_expect, unsigned char *datain) | ||||
| { | ||||
| 	volatile I2C_BD *rxbd, *txbd; | ||||
| 
 | ||||
| 	PRINTD(("[I2C] i2c_receive %02d %02d %02d\n", address, secondary_address, flags)); | ||||
| 	PRINTD(("[I2C] i2c_receive %02d %02d %02d\n", | ||||
| 		address, secondary_address, flags)); | ||||
| 
 | ||||
| 	/* Expected to receive too much */ | ||||
| 	if (size_to_expect > I2C_RXTX_LEN) | ||||
|  | @ -513,9 +514,9 @@ static int i2c_doio(i2c_state_t *state) | |||
| 		txbd = ((I2C_BD*)state->txbd) - 1; | ||||
| 		PRINTD(("[I2C] Transmitting...(txbd=0x%08lx)\n", (ulong)txbd)); | ||||
| 		while ((txbd->status & BD_SC_READY) && (j++ < TOUT_LOOP)) { | ||||
| 			if (ctrlc()) { | ||||
| 			if (ctrlc()) | ||||
| 				return (-1); | ||||
| 			} | ||||
| 
 | ||||
| 			__asm__ __volatile__("eieio"); | ||||
| 		} | ||||
| 	} | ||||
|  | @ -524,9 +525,9 @@ static int i2c_doio(i2c_state_t *state) | |||
| 		rxbd = ((I2C_BD*)state->rxbd) - 1; | ||||
| 		PRINTD(("[I2C] Receiving...(rxbd=0x%08lx)\n", (ulong)rxbd)); | ||||
| 		while ((rxbd->status & BD_SC_EMPTY) && (j++ < TOUT_LOOP)) { | ||||
| 			if (ctrlc()) { | ||||
| 			if (ctrlc()) | ||||
| 				return (-1); | ||||
| 			} | ||||
| 
 | ||||
| 			__asm__ __volatile__("eieio"); | ||||
| 		} | ||||
| 	} | ||||
|  | @ -546,7 +547,8 @@ static int i2c_doio(i2c_state_t *state) | |||
| 			for (i = 0; i < n; i++) { | ||||
| 				txbd = ((I2C_BD *) state->txbd) - (n - i); | ||||
| 				if ((b = txbd->status & BD_I2C_TX_ERR) != 0) | ||||
| 					(*state->err_cb)(I2CECB_TX_ERR|b, i); | ||||
| 					(*state->err_cb) (I2CECB_TX_ERR | b, | ||||
| 							  i); | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
|  | @ -554,7 +556,8 @@ static int i2c_doio(i2c_state_t *state) | |||
| 			for (i = 0; i < n; i++) { | ||||
| 				rxbd = ((I2C_BD *) state->rxbd) - (n - i); | ||||
| 				if ((b = rxbd->status & BD_I2C_RX_ERR) != 0) | ||||
| 					(*state->err_cb)(I2CECB_RX_ERR|b, i); | ||||
| 					(*state->err_cb) (I2CECB_RX_ERR | b, | ||||
| 							  i); | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
|  | @ -567,8 +570,7 @@ static int i2c_doio(i2c_state_t *state) | |||
| 
 | ||||
| static int had_tx_nak; | ||||
| 
 | ||||
| static void | ||||
| i2c_test_callback(int flags, int xnum) | ||||
| static void i2c_test_callback(int flags, int xnum) | ||||
| { | ||||
| 	if ((flags & I2CECB_TX_ERR) && (flags & I2CECB_TX_NAK)) | ||||
| 		had_tx_nak = 1; | ||||
|  | @ -587,7 +589,8 @@ int i2c_probe(uchar chip) | |||
| 	state.err_cb = i2c_test_callback; | ||||
| 	had_tx_nak = 0; | ||||
| 
 | ||||
| 	rc = i2c_receive(&state, chip, 0, I2CF_START_COND|I2CF_STOP_COND, 1, buf); | ||||
| 	rc = i2c_receive(&state, chip, 0, I2CF_START_COND | I2CF_STOP_COND, 1, | ||||
| 			 buf); | ||||
| 
 | ||||
| 	if (rc != 0) | ||||
| 		return (rc); | ||||
|  | @ -631,7 +634,8 @@ int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len) | |||
| 
 | ||||
| 	i2c_newio(&state); | ||||
| 
 | ||||
| 	rc = i2c_send(&state, chip, 0, I2CF_START_COND, alen, &xaddr[4-alen]); | ||||
| 	rc = i2c_send(&state, chip, 0, I2CF_START_COND, alen, | ||||
| 		      &xaddr[4 - alen]); | ||||
| 	if (rc != 0) { | ||||
| 		printf("i2c_read: i2c_send failed (%d)\n", rc); | ||||
| 		return 1; | ||||
|  | @ -678,7 +682,8 @@ int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len) | |||
| 
 | ||||
| 	i2c_newio(&state); | ||||
| 
 | ||||
| 	rc = i2c_send(&state, chip, 0, I2CF_START_COND, alen, &xaddr[4-alen]); | ||||
| 	rc = i2c_send(&state, chip, 0, I2CF_START_COND, alen, | ||||
| 		      &xaddr[4 - alen]); | ||||
| 	if (rc != 0) { | ||||
| 		printf("i2c_write: first i2c_send failed (%d)\n", rc); | ||||
| 		return 1; | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue