]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/i2c/busses/i2c-viapro.c
Merge master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
[linux-2.6-omap-h63xx.git] / drivers / i2c / busses / i2c-viapro.c
index c1c9eb1d714f3a283d5d4e9a3d3c8ceccff2538c..47e52bf2c5ec836f606e3c1a66684b1489771745 100644 (file)
@@ -126,6 +126,8 @@ static void vt596_dump_regs(const char *msg, u8 size)
                printk("%02x\n", inb_p(SMBBLKDAT));
        }
 }
+#else
+static inline void vt596_dump_regs(const char *msg, u8 size) { }
 #endif
 
 /* Return -1 on error, 0 on success */
@@ -135,26 +137,23 @@ static int vt596_transaction(u8 size)
        int result = 0;
        int timeout = 0;
 
-#ifdef DEBUG
        vt596_dump_regs("Transaction (pre)", size);
-#endif
 
        /* Make sure the SMBus host is ready to start transmitting */
        if ((temp = inb_p(SMBHSTSTS)) & 0x1F) {
                dev_dbg(&vt596_adapter.dev, "SMBus busy (0x%02x). "
-                       "Resetting... ", temp);
+                       "Resetting...\n", temp);
 
                outb_p(temp, SMBHSTSTS);
                if ((temp = inb_p(SMBHSTSTS)) & 0x1F) {
-                       printk("Failed! (0x%02x)\n", temp);
+                       dev_err(&vt596_adapter.dev, "SMBus reset failed! "
+                               "(0x%02x)\n", temp);
                        return -1;
-               } else {
-                       printk("Successful!\n");
                }
        }
 
        /* Start the transaction by setting bit 6 */
-       outb_p(0x40 | (size & 0x3C), SMBHSTCNT);
+       outb_p(0x40 | size, SMBHSTCNT);
 
        /* We will always wait for a fraction of a second */
        do {
@@ -171,7 +170,7 @@ static int vt596_transaction(u8 size)
        if (temp & 0x10) {
                result = -1;
                dev_err(&vt596_adapter.dev, "Transaction failed (0x%02x)\n",
-                       inb_p(SMBHSTCNT) & 0x3C);
+                       size);
        }
 
        if (temp & 0x08) {
@@ -180,11 +179,13 @@ static int vt596_transaction(u8 size)
        }
 
        if (temp & 0x04) {
+               int read = inb_p(SMBHSTADD) & 0x01;
                result = -1;
-               /* Quick commands are used to probe for chips, so
-                  errors are expected, and we don't want to frighten the
-                  user. */
-               if ((inb_p(SMBHSTCNT) & 0x3C) != VT596_QUICK)
+               /* The quick and receive byte commands are used to probe
+                  for chips, so errors are expected, and we don't want
+                  to frighten the user. */
+               if (!((size == VT596_QUICK && !read) ||
+                     (size == VT596_BYTE && read)))
                        dev_err(&vt596_adapter.dev, "Transaction error!\n");
        }
 
@@ -192,9 +193,7 @@ static int vt596_transaction(u8 size)
        if (temp & 0x1F)
                outb_p(temp, SMBHSTSTS);
 
-#ifdef DEBUG
        vt596_dump_regs("Transaction (post)", size);
-#endif
 
        return result;
 }
@@ -463,9 +462,9 @@ static void __exit i2c_vt596_exit(void)
        }
 }
 
-MODULE_AUTHOR(
-    "Frodo Looijaard <frodol@dds.nl> and "
-    "Philip Edelbrock <phil@netroedge.com>");
+MODULE_AUTHOR("Kyosti Malkki <kmalkki@cc.hut.fi>, "
+             "Mark D. Studebaker <mdsxyz123@yahoo.com> and "
+             "Jean Delvare <khali@linux-fr.org>");
 MODULE_DESCRIPTION("vt82c596 SMBus driver");
 MODULE_LICENSE("GPL");