Fix for i2c-ibm_iic.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Attached diff against 2.4 kernel fixes "new" (for i2c-ibm_iic) i2c
initalization path.
This i2c adapter can't understand commands with zero length so it
doesn't recognize SMBUS_QUICK command and none chip can be attached to
this. Patch fixes this cruft.
Tested on ppc32 with max663x chip attached.

Please review and commit.


-- 
	Evgeniy Polaykov ( s0mbre )

Crash is better than data corruption. -- Art Grabowski
-------------- next part --------------
===== drivers/i2c/i2c-ibm_iic.c 1.4 vs 1.5 =====
--- 1.4/drivers/i2c/i2c-ibm_iic.c	Fri Jun 27 15:19:03 2003
+++ 1.5/drivers/i2c/i2c-ibm_iic.c	Fri Apr  9 20:48:20 2004
@@ -61,14 +61,14 @@
 #define DBG_LEVEL 0
 
 #if DBG_LEVEL > 0
-#  define DBG(x...)	printk(KERN_DEBUG "ibm-iic" ##x)
+#  define DBG(f, x...)	printk("ibm-iic" f, ##x)
 #else
-#  define DBG(x...)	((void)0)
+#  define DBG(f, x...)	((void)0)
 #endif
 #if DBG_LEVEL > 1
-#  define DBG2(x...) 	DBG( ##x )
+#  define DBG2(f, x...) 	DBG( f, x )
 #else
-#  define DBG2(x...) 	((void)0)
+#  define DBG2(f, x...) 	((void)0)
 #endif
 #if DBG_LEVEL > 2
 static void dump_iic_regs(const char* header, struct ibm_iic_private* dev)
@@ -328,6 +328,24 @@
 	return ret;
 }
 
+static int iic_write_empty(struct ibm_iic_private* dev)
+{
+	volatile struct iic_regs *iic = dev->vaddr;
+	int ret = 0;
+
+	u8 cntl = (in_8(&iic->cntl) & CNTL_AMD) | CNTL_PT;
+	
+	DBG2("%d: xfer_bytes, %d, CNTL = 0x%02x\n", dev->idx, 0, cntl);
+	
+	/* Start transfer */
+	out_8(&iic->cntl, cntl);
+	
+	/* Wait for completion */
+	ret = iic_wait_for_tc(dev);
+
+	return ret > 0 ? 0 : ret;
+}
+
 /*
  * Low level master transfer routine
  */
@@ -338,6 +356,11 @@
 	char* buf = pm->buf;
 	int i, j, loops, ret = 0;
 	int len = pm->len;
+	
+	if (len == 0)
+	{
+		return iic_write_empty(dev);
+	}
 
 	u8 cntl = (in_8(&iic->cntl) & CNTL_AMD) | CNTL_PT;
 	if (pm->flags & I2C_M_RD)
@@ -445,11 +468,6 @@
 		return -EINVAL;
 	}		
 	for (i = 0; i < num; ++i){
-		if (unlikely(msgs[i].len <= 0)){
-			DBG("%d: invalid len %d in msg[%d]\n", dev->idx, 
-				msgs[i].len, i);
-			return -EINVAL;
-		}
 		if (unlikely(iic_address_neq(&msgs[0], &msgs[i]))){
 			DBG("%d: invalid addr in msg[%d]\n", dev->idx, i);
 			return -EINVAL;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20040412/ecc04dfa/attachment.bin 


[Index of Archives]     [Linux Kernel]     [Linux Hardware Monitoring]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux