patch-2.1.37 linux/drivers/sbus/char/vfc_i2c.c

Next file: linux/drivers/scsi/53c7,8xx.c
Previous file: linux/drivers/sbus/char/vfc_dev.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.36/linux/drivers/sbus/char/vfc_i2c.c linux/drivers/sbus/char/vfc_i2c.c
@@ -31,8 +31,8 @@
 #include <asm/system.h>
 #include <asm/sbus.h>
 
-#if 0
-#define VFC_DEBUG
+#if 0 
+#define VFC_I2C_DEBUG
 #endif
 
 #include "vfc.h"
@@ -72,6 +72,8 @@
 
 void vfc_i2c_delay_wakeup(struct vfc_dev *dev) 
 {
+	/* Used to profile code and eliminate too many delays */
+	VFC_I2C_DEBUG_PRINTK(("vfc%d: Delaying\n",dev->instance));
 	wake_up(&dev->poll_wait);
 }
 
@@ -95,14 +97,14 @@
 
 int vfc_init_i2c_bus(struct vfc_dev *dev)
 {
-	dev->regs->i2c_s1= ENABLE_SERIAL | ACK;
+	dev->regs->i2c_s1= ENABLE_SERIAL | SELECT(S0) | ACK;
 	vfc_i2c_reset_bus(dev);
 	return 0;
 }
 
 int vfc_i2c_reset_bus(struct vfc_dev *dev) 
 {
-	VFC_DEBUG_PRINTK((KERN_DEBUG "vfc%d: Resetting the i2c bus\n",
+	VFC_I2C_DEBUG_PRINTK((KERN_DEBUG "vfc%d: Resetting the i2c bus\n",
 			  dev->instance));
 	if(!dev) return -EINVAL;
 	if(!dev->regs) return -EINVAL;
@@ -110,7 +112,7 @@
 	dev->regs->i2c_s1=SEND_I2C_STOP | ACK;
 	vfc_i2c_delay(dev);
 	dev->regs->i2c_s1=CLEAR_I2C_BUS;
-	VFC_DEBUG_PRINTK((KERN_DEBUG "vfc%d: I2C status %x\n",
+	VFC_I2C_DEBUG_PRINTK((KERN_DEBUG "vfc%d: I2C status %x\n",
 			  dev->instance, dev->regs->i2c_s1));
 	return 0;
 }
@@ -146,7 +148,7 @@
 { 
 	int ret,raddr;
 #if 1
-	dev->regs->i2c_s1=SEND_I2C_STOP;
+	dev->regs->i2c_s1=SEND_I2C_STOP | ACK;
 	dev->regs->i2c_s1=SELECT(S0) | ENABLE_SERIAL;
 	vfc_i2c_delay(dev);
 #endif
@@ -154,12 +156,12 @@
 	switch(mode) {
 	case VFC_I2C_READ:
 		dev->regs->i2c_reg=raddr=SHIFT((unsigned int)addr | 0x1);
-		VFC_DEBUG_PRINTK(("vfc%d: recieving from i2c addr 0x%x\n",
+		VFC_I2C_DEBUG_PRINTK(("vfc%d: recieving from i2c addr 0x%x\n",
 				  dev->instance,addr | 0x1));
 		break;
 	case VFC_I2C_WRITE:
 		dev->regs->i2c_reg=raddr=SHIFT((unsigned int)addr & ~0x1);
-		VFC_DEBUG_PRINTK(("vfc%d: sending to i2c addr 0x%x\n",
+		VFC_I2C_DEBUG_PRINTK(("vfc%d: sending to i2c addr 0x%x\n",
 				  dev->instance,addr & ~0x1));
 		break;
 	default:
@@ -215,7 +217,7 @@
 	int ret;
 	if(last) {
 		dev->regs->i2c_reg=NEGATIVE_ACK;
-		VFC_DEBUG_PRINTK((KERN_DEBUG "vfc%d: sending negative ack\n",
+		VFC_I2C_DEBUG_PRINTK(("vfc%d: sending negative ack\n",
 				  dev->instance));
 	} else {
 		dev->regs->i2c_s1=ACK;
@@ -255,6 +257,8 @@
 			printk(KERN_ERR "vfc%d: "
 			       "VFC error while recieving byte\n",
 			       dev->instance);
+			dev->regs->i2c_s1=SEND_I2C_STOP;
+			ret=-EINVAL;
 		}
 		buf++;
 	}
@@ -286,7 +290,7 @@
 		ret=vfc_i2c_xmit_byte(dev,buf);
 		switch(ret) {
 		case XMIT_LAST_BYTE:
-			VFC_DEBUG_PRINTK(("vfc%d: "
+			VFC_I2C_DEBUG_PRINTK(("vfc%d: "
 					  "Reciever ended transmission with "
 					  " %d bytes remaining\n",
 					  dev->instance,count));

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov