aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/gspca/spca561.c
diff options
context:
space:
mode:
authorJean-Francois Moine <moinejf@free.fr>2008-07-04 10:16:16 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-07-20 06:16:53 -0400
commita5ae2062252e697d38e53dbbeb91460252208914 (patch)
tree38706e9f36e2d93cd3dee8eea639bb74a17b3efa /drivers/media/video/gspca/spca561.c
parent54ab92ca05550550bcec2462de2605f35d079b66 (diff)
V4L/DVB (8195): gspca: Input buffer overwritten in spca561 + cleanup code.
spca561: Input buffer may be changed on reg write. (all sd): Cleanup code, 'const' added. Signed-off-by: Jean-Francois Moine <moinejf@free.fr> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/gspca/spca561.c')
-rw-r--r--drivers/media/video/gspca/spca561.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/drivers/media/video/gspca/spca561.c b/drivers/media/video/gspca/spca561.c
index dbd1648a655f..8e39cbdda2a5 100644
--- a/drivers/media/video/gspca/spca561.c
+++ b/drivers/media/video/gspca/spca561.c
@@ -24,8 +24,8 @@
24 24
25#include "gspca.h" 25#include "gspca.h"
26 26
27#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 0) 27#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 4)
28static const char version[] = "2.1.0"; 28static const char version[] = "2.1.4";
29 29
30MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); 30MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
31MODULE_DESCRIPTION("GSPCA/SPCA561 USB Camera Driver"); 31MODULE_DESCRIPTION("GSPCA/SPCA561 USB Camera Driver");
@@ -148,7 +148,8 @@ static void reg_w_val(struct usb_device *dev, __u16 index, __u16 value)
148 PDEBUG(D_ERR, "reg write: error %d", ret); 148 PDEBUG(D_ERR, "reg write: error %d", ret);
149} 149}
150 150
151static void write_vector(struct gspca_dev *gspca_dev, __u16 data[][2]) 151static void write_vector(struct gspca_dev *gspca_dev,
152 const __u16 data[][2])
152{ 153{
153 struct usb_device *dev = gspca_dev->dev; 154 struct usb_device *dev = gspca_dev->dev;
154 int i; 155 int i;
@@ -171,13 +172,16 @@ static void reg_r(struct usb_device *dev,
171} 172}
172 173
173static void reg_w_buf(struct usb_device *dev, 174static void reg_w_buf(struct usb_device *dev,
174 __u16 index, __u8 *buffer, __u16 length) 175 __u16 index, const __u8 *buffer, __u16 len)
175{ 176{
177 __u8 tmpbuf[8];
178
179 memcpy(tmpbuf, buffer, len);
176 usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 180 usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
177 0, /* request */ 181 0, /* request */
178 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 182 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
179 0, /* value */ 183 0, /* value */
180 index, buffer, length, 500); 184 index, tmpbuf, len, 500);
181} 185}
182 186
183static void i2c_init(struct gspca_dev *gspca_dev, __u8 mode) 187static void i2c_init(struct gspca_dev *gspca_dev, __u8 mode)
@@ -227,7 +231,7 @@ static int i2c_read(struct gspca_dev *gspca_dev, __u16 reg, __u8 mode)
227 return ((int) value << 8) | vallsb; 231 return ((int) value << 8) | vallsb;
228} 232}
229 233
230static __u16 spca561_init_data[][2] = { 234static const __u16 spca561_init_data[][2] = {
231 {0x0000, 0x8114}, /* Software GPIO output data */ 235 {0x0000, 0x8114}, /* Software GPIO output data */
232 {0x0001, 0x8114}, /* Software GPIO output data */ 236 {0x0001, 0x8114}, /* Software GPIO output data */
233 {0x0000, 0x8112}, /* Some kind of reset */ 237 {0x0000, 0x8112}, /* Some kind of reset */
@@ -437,7 +441,7 @@ static void sensor_reset(struct gspca_dev *gspca_dev)
437} 441}
438 442
439/******************** QC Express etch2 stuff ********************/ 443/******************** QC Express etch2 stuff ********************/
440static __u16 Pb100_1map8300[][2] = { 444static const __u16 Pb100_1map8300[][2] = {
441 /* reg, value */ 445 /* reg, value */
442 {0x8320, 0x3304}, 446 {0x8320, 0x3304},
443 447
@@ -452,14 +456,14 @@ static __u16 Pb100_1map8300[][2] = {
452 {0x8302, 0x000e}, 456 {0x8302, 0x000e},
453 {} 457 {}
454}; 458};
455static __u16 Pb100_2map8300[][2] = { 459static const __u16 Pb100_2map8300[][2] = {
456 /* reg, value */ 460 /* reg, value */
457 {0x8339, 0x0000}, 461 {0x8339, 0x0000},
458 {0x8307, 0x00aa}, 462 {0x8307, 0x00aa},
459 {} 463 {}
460}; 464};
461 465
462static __u16 spca561_161rev12A_data1[][2] = { 466static const __u16 spca561_161rev12A_data1[][2] = {
463 {0x21, 0x8118}, 467 {0x21, 0x8118},
464 {0x01, 0x8114}, 468 {0x01, 0x8114},
465 {0x00, 0x8112}, 469 {0x00, 0x8112},
@@ -467,7 +471,7 @@ static __u16 spca561_161rev12A_data1[][2] = {
467 {0x04, 0x8802}, /* windows uses 08 */ 471 {0x04, 0x8802}, /* windows uses 08 */
468 {} 472 {}
469}; 473};
470static __u16 spca561_161rev12A_data2[][2] = { 474static const __u16 spca561_161rev12A_data2[][2] = {
471 {0x21, 0x8118}, 475 {0x21, 0x8118},
472 {0x10, 0x8500}, 476 {0x10, 0x8500},
473 {0x07, 0x8601}, 477 {0x07, 0x8601},
@@ -513,7 +517,7 @@ static __u16 spca561_161rev12A_data2[][2] = {
513}; 517};
514 518
515static void sensor_mapwrite(struct gspca_dev *gspca_dev, 519static void sensor_mapwrite(struct gspca_dev *gspca_dev,
516 __u16 sensormap[][2]) 520 const __u16 sensormap[][2])
517{ 521{
518 int i = 0; 522 int i = 0;
519 __u8 usbval[2]; 523 __u8 usbval[2];
@@ -956,7 +960,7 @@ static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val)
956} 960}
957 961
958/* sub-driver description */ 962/* sub-driver description */
959static struct sd_desc sd_desc = { 963static const struct sd_desc sd_desc = {
960 .name = MODULE_NAME, 964 .name = MODULE_NAME,
961 .ctrls = sd_ctrls, 965 .ctrls = sd_ctrls,
962 .nctrls = ARRAY_SIZE(sd_ctrls), 966 .nctrls = ARRAY_SIZE(sd_ctrls),
@@ -971,7 +975,7 @@ static struct sd_desc sd_desc = {
971 975
972/* -- module initialisation -- */ 976/* -- module initialisation -- */
973#define DVNM(name) .driver_info = (kernel_ulong_t) name 977#define DVNM(name) .driver_info = (kernel_ulong_t) name
974static __devinitdata struct usb_device_id device_table[] = { 978static const __devinitdata struct usb_device_id device_table[] = {
975 {USB_DEVICE(0x041e, 0x401a), DVNM("Creative Webcam Vista (PD1100)")}, 979 {USB_DEVICE(0x041e, 0x401a), DVNM("Creative Webcam Vista (PD1100)")},
976 {USB_DEVICE(0x041e, 0x403b), DVNM("Creative Webcam Vista (VF0010)")}, 980 {USB_DEVICE(0x041e, 0x403b), DVNM("Creative Webcam Vista (VF0010)")},
977 {USB_DEVICE(0x0458, 0x7004), DVNM("Genius VideoCAM Express V2")}, 981 {USB_DEVICE(0x0458, 0x7004), DVNM("Genius VideoCAM Express V2")},