aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJean-Francois Moine <moinejf@free.fr>2009-05-13 13:25:29 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-06-16 17:21:15 -0400
commit7880f6613814e737de829911b204d7bc1f2ccb49 (patch)
treee429fcfcf37e87bcdd4f3b79461cc25271898007 /drivers
parent1af63b3d1dfd38175c145f1435bab865ebdd8951 (diff)
V4L/DVB (11868): gspca - spca508: Optimize code.
Signed-off-by: Jean-Francois Moine <moinejf@free.fr> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/video/gspca/spca508.c46
1 files changed, 16 insertions, 30 deletions
diff --git a/drivers/media/video/gspca/spca508.c b/drivers/media/video/gspca/spca508.c
index 5896bfe2ffd1..2ed2669bac3e 100644
--- a/drivers/media/video/gspca/spca508.c
+++ b/drivers/media/video/gspca/spca508.c
@@ -1305,16 +1305,16 @@ static int reg_read(struct gspca_dev *gspca_dev,
1305} 1305}
1306 1306
1307static int write_vector(struct gspca_dev *gspca_dev, 1307static int write_vector(struct gspca_dev *gspca_dev,
1308 const u16 data[][2]) 1308 const u16 (*data)[2])
1309{ 1309{
1310 struct usb_device *dev = gspca_dev->dev; 1310 struct usb_device *dev = gspca_dev->dev;
1311 int ret, i = 0; 1311 int ret;
1312 1312
1313 while (data[i][1] != 0) { 1313 while ((*data)[1] != 0) {
1314 ret = reg_write(dev, data[i][1], data[i][0]); 1314 ret = reg_write(dev, (*data)[1], (*data)[0]);
1315 if (ret < 0) 1315 if (ret < 0)
1316 return ret; 1316 return ret;
1317 i++; 1317 data++;
1318 } 1318 }
1319 return 0; 1319 return 0;
1320} 1320}
@@ -1326,6 +1326,15 @@ static int sd_config(struct gspca_dev *gspca_dev,
1326 struct sd *sd = (struct sd *) gspca_dev; 1326 struct sd *sd = (struct sd *) gspca_dev;
1327 struct cam *cam; 1327 struct cam *cam;
1328 int data1, data2; 1328 int data1, data2;
1329 const u16 (*init_data)[2];
1330 static const u16 (*(init_data_tb[]))[2] = {
1331 spca508_vista_init_data, /* CreativeVista 0 */
1332 spca508_sightcam_init_data, /* HamaUSBSightcam 1 */
1333 spca508_sightcam2_init_data, /* HamaUSBSightcam2 2 */
1334 spca508cs110_init_data, /* IntelEasyPCCamera 3 */
1335 spca508cs110_init_data, /* MicroInnovationIC200 4 */
1336 spca508_init_data, /* ViewQuestVQ110 5 */
1337 };
1329 1338
1330 /* Read from global register the USB product and vendor IDs, just to 1339 /* Read from global register the USB product and vendor IDs, just to
1331 * prove that we can communicate with the device. This works, which 1340 * prove that we can communicate with the device. This works, which
@@ -1349,31 +1358,8 @@ static int sd_config(struct gspca_dev *gspca_dev,
1349 sd->subtype = id->driver_info; 1358 sd->subtype = id->driver_info;
1350 sd->brightness = BRIGHTNESS_DEF; 1359 sd->brightness = BRIGHTNESS_DEF;
1351 1360
1352 switch (sd->subtype) { 1361 init_data = init_data_tb[sd->subtype];
1353 case ViewQuestVQ110: 1362 return write_vector(gspca_dev, init_data);
1354 if (write_vector(gspca_dev, spca508_init_data))
1355 return -1;
1356 break;
1357 default:
1358/* case MicroInnovationIC200: */
1359/* case IntelEasyPCCamera: */
1360 if (write_vector(gspca_dev, spca508cs110_init_data))
1361 return -1;
1362 break;
1363 case HamaUSBSightcam:
1364 if (write_vector(gspca_dev, spca508_sightcam_init_data))
1365 return -1;
1366 break;
1367 case HamaUSBSightcam2:
1368 if (write_vector(gspca_dev, spca508_sightcam2_init_data))
1369 return -1;
1370 break;
1371 case CreativeVista:
1372 if (write_vector(gspca_dev, spca508_vista_init_data))
1373 return -1;
1374 break;
1375 }
1376 return 0; /* success */
1377} 1363}
1378 1364
1379/* this function is called at probe and resume time */ 1365/* this function is called at probe and resume time */