From patchwork Wed Jul 22 17:28:19 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Johnson X-Patchwork-Id: 36868 X-Patchwork-Delegate: dougsland@redhat.com Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n6MHSRAl004058 for ; Wed, 22 Jul 2009 17:28:27 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751865AbZGVR2Z (ORCPT ); Wed, 22 Jul 2009 13:28:25 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752388AbZGVR2Z (ORCPT ); Wed, 22 Jul 2009 13:28:25 -0400 Received: from ey-out-2122.google.com ([74.125.78.25]:61151 "EHLO ey-out-2122.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751865AbZGVR2Y (ORCPT ); Wed, 22 Jul 2009 13:28:24 -0400 Received: by ey-out-2122.google.com with SMTP id 9so152590eyd.37 for ; Wed, 22 Jul 2009 10:28:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:received:content-type :mime-version:content-transfer-encoding:subject:x-mercurial-node :message-id:date:from:to:cc; bh=jFRdGzs8deUCprYRKbPMKZ5e/EKhj6I7deYS5dRGuro=; b=PHobI8Rkf8vGVZCwyFBoh55Jmt1zn8/aVBLj5PTfLF0c7hOhLAstLDuUkMiq7VHZ8B 7ujno6fx0X8sEjOtXiwFYmUhNn+9CTeobWlkDyXeZL/AsTczsa8xUIqAxfrshhQhv/H6 ANaRAZ63uBMR27WckTuK9/0Ke1/yb8/SO4gLc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=content-type:mime-version:content-transfer-encoding:subject :x-mercurial-node:message-id:date:from:to:cc; b=GEFoo65zUFFDivLGGNH9/tMNBBoJm38X30NwmMfoTAZRrioh3xRc1jlTjJOt5kcNt9 kPZq1oWm3QqTf2dMDjEaHSgVmEkzZT6Z+qNan2qmjPtcIDBZHlZ5CG96cp6KLmOUUWUM LTBtrpcdAlvIJKajomwk3n0wVHOOr0gog/VQw= Received: by 10.210.130.14 with SMTP id c14mr6411218ebd.93.1248283703121; Wed, 22 Jul 2009 10:28:23 -0700 (PDT) Received: from ubuntu.sys76.lan (c-24-11-127-139.hsd1.mi.comcast.net [24.11.127.139]) by mx.google.com with ESMTPS id 28sm1792815eye.40.2009.07.22.10.28.21 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 22 Jul 2009 10:28:22 -0700 (PDT) Received: from bjohnson by ubuntu.sys76.lan with local (Exim 4.69) (envelope-from ) id 1MTfc3-0005Rf-Hu; Wed, 22 Jul 2009 13:28:19 -0400 MIME-Version: 1.0 Subject: [PATCH] gspca - sn9c20x: Fix up i2c_r functions X-Mercurial-Node: 1de19b8eee9846374757ca3278e8f0df0662363b Message-Id: <1de19b8eee9846374757.1248283699@ubuntu.sys76.lan> Date: Wed, 22 Jul 2009 13:28:19 -0400 From: Brian Johnson To: linux-media@vger.kernel.org Cc: Jean-Francois Moine , Brian Johnson Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Fixes the following issues * use i2c_w instead of reg_w * return error on failure * read the correct number of bytes Signed-off-by: Brian Johnson --- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/linux/drivers/media/video/gspca/sn9c20x.c b/linux/drivers/media/video/gspca/sn9c20x.c --- a/linux/drivers/media/video/gspca/sn9c20x.c +++ b/linux/drivers/media/video/gspca/sn9c20x.c @@ -1099,12 +1099,12 @@ reg_r(gspca_dev, 0x10c0, 1); if (gspca_dev->usb_buf[0] & 0x04) { if (gspca_dev->usb_buf[0] & 0x08) - return -1; + return -EIO; return 0; } msleep(1); } - return -1; + return -EIO; } int i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val) @@ -1155,7 +1155,7 @@ struct sd *sd = (struct sd *) gspca_dev; u8 row[8]; - row[0] = 0x81 | 0x10; + row[0] = 0x81 | (1 << 4); row[1] = sd->i2c_addr; row[2] = reg; row[3] = 0; @@ -1163,14 +1163,15 @@ row[5] = 0; row[6] = 0; row[7] = 0x10; - reg_w(gspca_dev, 0x10c0, row, 8); - msleep(1); - row[0] = 0x81 | (2 << 4) | 0x02; + if (i2c_w(gspca_dev, row) < 0) + return -EIO; + row[0] = 0x81 | (1 << 4) | 0x02; row[2] = 0; - reg_w(gspca_dev, 0x10c0, row, 8); - msleep(1); - reg_r(gspca_dev, 0x10c2, 5); - *val = gspca_dev->usb_buf[3]; + if (i2c_w(gspca_dev, row) < 0) + return -EIO; + if (reg_r(gspca_dev, 0x10c2, 5) < 0) + return -EIO; + *val = gspca_dev->usb_buf[4]; return 0; } @@ -1179,7 +1180,7 @@ struct sd *sd = (struct sd *) gspca_dev; u8 row[8]; - row[0] = 0x81 | 0x10; + row[0] = 0x81 | (1 << 4); row[1] = sd->i2c_addr; row[2] = reg; row[3] = 0; @@ -1187,14 +1188,15 @@ row[5] = 0; row[6] = 0; row[7] = 0x10; - reg_w(gspca_dev, 0x10c0, row, 8); - msleep(1); - row[0] = 0x81 | (3 << 4) | 0x02; + if (i2c_w(gspca_dev, row) < 0) + return -EIO; + row[0] = 0x81 | (2 << 4) | 0x02; row[2] = 0; - reg_w(gspca_dev, 0x10c0, row, 8); - msleep(1); - reg_r(gspca_dev, 0x10c2, 5); - *val = (gspca_dev->usb_buf[2] << 8) | gspca_dev->usb_buf[3]; + if (i2c_w(gspca_dev, row) < 0) + return -EIO; + if (reg_r(gspca_dev, 0x10c2, 5) < 0) + return -EIO; + *val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4]; return 0; }