aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/gspca/sn9c20x.c
diff options
context:
space:
mode:
authorBrian Johnson <brijohn@gmail.com>2009-07-23 04:55:43 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-09-12 11:18:16 -0400
commit00b581ef0d31db9c28215254b64f3890c7c9f939 (patch)
treea90021a4ee341d38a6d573a76abcad7685559f83 /drivers/media/video/gspca/sn9c20x.c
parentf3d6f63302bfcd7462d46bd1fe44146c971634d4 (diff)
V4L/DVB (12351): gspca - sn9c20x: Misc fixes
* use i2c_w instead of reg_w * return error on failure * read the correct number of bytes Signed-off-by: Brian Johnson <brijohn@gmail.com> Signed-off-by: Jean-Francois Moine <moinejf@free.fr> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/gspca/sn9c20x.c')
-rw-r--r--drivers/media/video/gspca/sn9c20x.c38
1 files changed, 20 insertions, 18 deletions
diff --git a/drivers/media/video/gspca/sn9c20x.c b/drivers/media/video/gspca/sn9c20x.c
index fcfbbd329b4c..52a7f8edf7ac 100644
--- a/drivers/media/video/gspca/sn9c20x.c
+++ b/drivers/media/video/gspca/sn9c20x.c
@@ -1096,12 +1096,12 @@ int i2c_w(struct gspca_dev *gspca_dev, const u8 *buffer)
1096 reg_r(gspca_dev, 0x10c0, 1); 1096 reg_r(gspca_dev, 0x10c0, 1);
1097 if (gspca_dev->usb_buf[0] & 0x04) { 1097 if (gspca_dev->usb_buf[0] & 0x04) {
1098 if (gspca_dev->usb_buf[0] & 0x08) 1098 if (gspca_dev->usb_buf[0] & 0x08)
1099 return -1; 1099 return -EIO;
1100 return 0; 1100 return 0;
1101 } 1101 }
1102 msleep(1); 1102 msleep(1);
1103 } 1103 }
1104 return -1; 1104 return -EIO;
1105} 1105}
1106 1106
1107int i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val) 1107int i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val)
@@ -1152,7 +1152,7 @@ int i2c_r1(struct gspca_dev *gspca_dev, u8 reg, u8 *val)
1152 struct sd *sd = (struct sd *) gspca_dev; 1152 struct sd *sd = (struct sd *) gspca_dev;
1153 u8 row[8]; 1153 u8 row[8];
1154 1154
1155 row[0] = 0x81 | 0x10; 1155 row[0] = 0x81 | (1 << 4);
1156 row[1] = sd->i2c_addr; 1156 row[1] = sd->i2c_addr;
1157 row[2] = reg; 1157 row[2] = reg;
1158 row[3] = 0; 1158 row[3] = 0;
@@ -1160,14 +1160,15 @@ int i2c_r1(struct gspca_dev *gspca_dev, u8 reg, u8 *val)
1160 row[5] = 0; 1160 row[5] = 0;
1161 row[6] = 0; 1161 row[6] = 0;
1162 row[7] = 0x10; 1162 row[7] = 0x10;
1163 reg_w(gspca_dev, 0x10c0, row, 8); 1163 if (i2c_w(gspca_dev, row) < 0)
1164 msleep(1); 1164 return -EIO;
1165 row[0] = 0x81 | (2 << 4) | 0x02; 1165 row[0] = 0x81 | (1 << 4) | 0x02;
1166 row[2] = 0; 1166 row[2] = 0;
1167 reg_w(gspca_dev, 0x10c0, row, 8); 1167 if (i2c_w(gspca_dev, row) < 0)
1168 msleep(1); 1168 return -EIO;
1169 reg_r(gspca_dev, 0x10c2, 5); 1169 if (reg_r(gspca_dev, 0x10c2, 5) < 0)
1170 *val = gspca_dev->usb_buf[3]; 1170 return -EIO;
1171 *val = gspca_dev->usb_buf[4];
1171 return 0; 1172 return 0;
1172} 1173}
1173 1174
@@ -1176,7 +1177,7 @@ int i2c_r2(struct gspca_dev *gspca_dev, u8 reg, u16 *val)
1176 struct sd *sd = (struct sd *) gspca_dev; 1177 struct sd *sd = (struct sd *) gspca_dev;
1177 u8 row[8]; 1178 u8 row[8];
1178 1179
1179 row[0] = 0x81 | 0x10; 1180 row[0] = 0x81 | (1 << 4);
1180 row[1] = sd->i2c_addr; 1181 row[1] = sd->i2c_addr;
1181 row[2] = reg; 1182 row[2] = reg;
1182 row[3] = 0; 1183 row[3] = 0;
@@ -1184,14 +1185,15 @@ int i2c_r2(struct gspca_dev *gspca_dev, u8 reg, u16 *val)
1184 row[5] = 0; 1185 row[5] = 0;
1185 row[6] = 0; 1186 row[6] = 0;
1186 row[7] = 0x10; 1187 row[7] = 0x10;
1187 reg_w(gspca_dev, 0x10c0, row, 8); 1188 if (i2c_w(gspca_dev, row) < 0)
1188 msleep(1); 1189 return -EIO;
1189 row[0] = 0x81 | (3 << 4) | 0x02; 1190 row[0] = 0x81 | (2 << 4) | 0x02;
1190 row[2] = 0; 1191 row[2] = 0;
1191 reg_w(gspca_dev, 0x10c0, row, 8); 1192 if (i2c_w(gspca_dev, row) < 0)
1192 msleep(1); 1193 return -EIO;
1193 reg_r(gspca_dev, 0x10c2, 5); 1194 if (reg_r(gspca_dev, 0x10c2, 5) < 0)
1194 *val = (gspca_dev->usb_buf[2] << 8) | gspca_dev->usb_buf[3]; 1195 return -EIO;
1196 *val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1195 return 0; 1197 return 0;
1196} 1198}
1197 1199