Skip to contentSkip to conversation

PATCH: gspca-mercurial no const buffer for usb_ctrl_msg

PATCH Hans de Goede 1 participant 1 message Jul 3, 2008 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

Hi All,

This patch fixes the usb_control_msg bug fixed in my sonixb patch for all other drivers. The problem was that some drivers pass a constant buffer to usb_control_msg, where it must get passed a variable buffer as the buffer is an in/out parameter in my experience with the pac207 (had the same bug) and sonixb drivers, passing a const buffer can lead to silence failure. I don't know why the failure is silent but it is.

This patch touches allmost all gspca drivers as it makes all const array definitions truely const, in some drivers they were variable, so there the problem of passing a const buffer to usb_control_msg was not present, but there usb_control_msg might have changed the contents of our meant to be const register initialization tables, thus a subsequent use of those tables might yield a different result.

This patch fixes a _real_ const buffer passed to usb_control_msg problems in pac7311, and for the rest is more cosmetical / just to be sure. Note that this also fixes the IMHO ugly use of local static variables for const arrays, why make them static to safe stack space, instead of making them const as they should be?

Regards,

Hans

This patch fixes the usb_control_msg bug fixed in my sonixb patch for all other drivers. The problem was that some drivers pass a constant buffer to usb_control_msg, where it must get passed a variable buffer as the buffer is an in/out parameter in my experience with the pac207 (had the same bug) and sonixb drivers, passing a const buffer can lead to silence failure. I don't know why the failure is silent but it is.

This patch touches allmost all gspca drivers as it makes all const array definitions truely const, in some drivers they were variable, so there the problem of passing a const buffer to usb_control_msg was not present, but there usb_control_msg might have changed the contents of our meant to be const register initialization tables, thus a subsequent use of those tables might yield a different result.

This patch fixes a _real_ const buffer passed to usb_control_msg problems in pac7311, and for the rest is more cosmetical / just to be sure. Note that this also fixes the IMHO ugly use of local static variables for const arrays, why make them static to safe stack space, instead of making them const as they should be?

linux/drivers/media/video/gspca/conex.c renamed from linux/drivers/media/video/gspca/conex.c~ +31 -29
diff -up gspca-2bbb47f61a95/linux/drivers/media/video/gspca/conex.c~ gspca-2bbb47f61a95/linux/drivers/media/video/gspca/conex.c
@@ -121,13 +121,15 @@ static void reg_w(struct usb_device *dev
 		  __u16 index,
 		  const __u8 *buffer, __u16 length)
 {
+	__u8 tmpbuf[8];
 	PDEBUG(D_USBO, "reg write i:%02x = %02x", index, *buffer);
+	memcpy(tmpbuf, buffer, length);
 	usb_control_msg(dev,
 			usb_sndctrlpipe(dev, 0),
 			0,
 			USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
 			0,
-			index, (__u8 *) buffer, length,
+			index, tmpbuf, length,
 			500);
 }
 
@@ -221,7 +223,7 @@ static void cx11646_fw(struct gspca_dev*
 	reg_w(gspca_dev->dev, 0x006a, &val, 1);
 }
 
-static __u8 cxsensor[] = {
+static const __u8 cxsensor[] = {
 	0x88, 0x12, 0x70, 0x01,
 	0x88, 0x0d, 0x02, 0x01,
 	0x88, 0x0f, 0x00, 0x01,
@@ -236,16 +238,16 @@ static __u8 cxsensor[] = {
 	0x00
 };
 
-static __u8 reg20[] = { 0x10, 0x42, 0x81, 0x19, 0xd3, 0xff, 0xa7, 0xff };
-static __u8 reg28[] = { 0x87, 0x00, 0x87, 0x00, 0x8f, 0xff, 0xea, 0xff };
-static __u8 reg10[] = { 0xb1, 0xb1 };
-static __u8 reg71a[] = { 0x08, 0x18, 0x0a, 0x1e };	/* 640 */
-static __u8 reg71b[] = { 0x04, 0x0c, 0x05, 0x0f };
+static const __u8 reg20[] = { 0x10, 0x42, 0x81, 0x19, 0xd3, 0xff, 0xa7, 0xff };
+static const __u8 reg28[] = { 0x87, 0x00, 0x87, 0x00, 0x8f, 0xff, 0xea, 0xff };
+static const __u8 reg10[] = { 0xb1, 0xb1 };
+static const __u8 reg71a[] = { 0x08, 0x18, 0x0a, 0x1e };	/* 640 */
+static const __u8 reg71b[] = { 0x04, 0x0c, 0x05, 0x0f };
 	/* 352{0x04,0x0a,0x06,0x12}; //352{0x05,0x0e,0x06,0x11}; //352 */
-static __u8 reg71c[] = { 0x02, 0x07, 0x03, 0x09 };
+static const __u8 reg71c[] = { 0x02, 0x07, 0x03, 0x09 };
 					/* 320{0x04,0x0c,0x05,0x0f}; //320 */
-static __u8 reg71d[] = { 0x02, 0x07, 0x03, 0x09 };	/* 176 */
-static __u8 reg7b[] = { 0x00, 0xff, 0x00, 0xff, 0x00, 0xff };
+static const __u8 reg71d[] = { 0x02, 0x07, 0x03, 0x09 };	/* 176 */
+static const __u8 reg7b[] = { 0x00, 0xff, 0x00, 0xff, 0x00, 0xff };
 
 static void cx_sensor(struct gspca_dev*gspca_dev)
 {
@@ -253,7 +255,7 @@ static void cx_sensor(struct gspca_dev*g
 	int i = 0;
 	__u8 bufread[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
 	int length = 0;
-	__u8 *ptsensor = cxsensor;
+	const __u8 *ptsensor = cxsensor;
 
 	reg_w(gspca_dev->dev, 0x0020, reg20, 8);
 	reg_w(gspca_dev->dev, 0x0028, reg28, 8);
@@ -297,7 +299,7 @@ static void cx_sensor(struct gspca_dev*g
 	reg_r(gspca_dev->dev, 0x00e7, bufread, 8);
 }
 
-static __u8 cx_inits_176[] = {
+static const __u8 cx_inits_176[] = {
 	0x33, 0x81, 0xB0, 0x00, 0x90, 0x00, 0x0A, 0x03,	/* 176x144 */
 	0x00, 0x03, 0x03, 0x03, 0x1B, 0x05, 0x30, 0x03,
 	0x65, 0x15, 0x18, 0x25, 0x03, 0x25, 0x08, 0x30,
@@ -306,7 +308,7 @@ static __u8 cx_inits_176[] = {
 	0xF7, 0xFF, 0x88, 0xFF, 0x66, 0x02, 0x28, 0x02,
 	0x1E, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
 };
-static __u8 cx_inits_320[] = {
+static const __u8 cx_inits_320[] = {
 	0x7f, 0x7f, 0x40, 0x01, 0xf0, 0x00, 0x02, 0x01,
 	0x00, 0x01, 0x01, 0x01, 0x10, 0x00, 0x02, 0x01,
 	0x65, 0x45, 0xfa, 0x4c, 0x2c, 0xdf, 0xb9, 0x81,
@@ -315,7 +317,7 @@ static __u8 cx_inits_320[] = {
 	0xf5, 0xff, 0x6d, 0xff, 0xf6, 0x01, 0x43, 0x02,
 	0xd3, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
 };
-static __u8 cx_inits_352[] = {
+static const __u8 cx_inits_352[] = {
 	0x2e, 0x7c, 0x60, 0x01, 0x20, 0x01, 0x05, 0x03,
 	0x00, 0x06, 0x03, 0x06, 0x1b, 0x10, 0x05, 0x3b,
 	0x30, 0x25, 0x18, 0x25, 0x08, 0x30, 0x03, 0x25,
@@ -324,7 +326,7 @@ static __u8 cx_inits_352[] = {
 	0xf5, 0xff, 0x6b, 0xff, 0xee, 0x01, 0x43, 0x02,
 	0xe4, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
 };
-static __u8 cx_inits_640[] = {
+static const __u8 cx_inits_640[] = {
 	0x7e, 0x7e, 0x80, 0x02, 0xe0, 0x01, 0x01, 0x01,
 	0x00, 0x02, 0x01, 0x02, 0x10, 0x30, 0x01, 0x01,
 	0x65, 0x45, 0xf7, 0x52, 0x2c, 0xdf, 0xb9, 0x81,
@@ -336,7 +338,7 @@ static __u8 cx_inits_640[] = {
 
 static int cx11646_initsize(struct gspca_dev *gspca_dev)
 {
-	__u8 *cxinit;
+	const __u8 *cxinit;
 	__u8 val;
 	static const __u8 reg12[] = { 0x08, 0x05, 0x07, 0x04, 0x24 };
 	static const __u8 reg17[] =
@@ -388,7 +390,7 @@ static int cx11646_initsize(struct gspca
 	return val;
 }
 
-static __u8 cx_jpeg_init[][8] = {
+static const __u8 cx_jpeg_init[][8] = {
 	{0xff, 0xd8, 0xff, 0xdb, 0x00, 0x84, 0x00, 0x15},	/* 1 */
 	{0x0f, 0x10, 0x12, 0x10, 0x0d, 0x15, 0x12, 0x11},
 	{0x12, 0x18, 0x16, 0x15, 0x19, 0x20, 0x35, 0x22},
@@ -471,7 +473,7 @@ static __u8 cx_jpeg_init[][8] = {
 };
 
 
-static __u8 cxjpeg_640[][8] = {
+static const __u8 cxjpeg_640[][8] = {
 	{0xff, 0xd8, 0xff, 0xdb, 0x00, 0x84, 0x00, 0x10},	/* 1 */
 	{0x0b, 0x0c, 0x0e, 0x0c, 0x0a, 0x10, 0x0e, 0x0d},
 	{0x0e, 0x12, 0x11, 0x10, 0x13, 0x18, 0x28, 0x1a},
@@ -500,7 +502,7 @@ static __u8 cxjpeg_640[][8] = {
 	{0x00, 0x01, 0x11, 0x02, 0x11, 0x00, 0x3F, 0x00},
 	{0xFF, 0xD9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}	/* 27 */
 };
-static __u8 cxjpeg_352[][8] = {
+static const __u8 cxjpeg_352[][8] = {
 	{0xff, 0xd8, 0xff, 0xdb, 0x00, 0x84, 0x00, 0x0d},
 	{0x09, 0x09, 0x0b, 0x09, 0x08, 0x0D, 0x0b, 0x0a},
 	{0x0b, 0x0e, 0x0d, 0x0d, 0x0f, 0x13, 0x1f, 0x14},
@@ -529,7 +531,7 @@ static __u8 cxjpeg_352[][8] = {
 	{0x00, 0x01, 0x11, 0x02, 0x11, 0x00, 0x3F, 0x00},
 	{0xFF, 0xD9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
 };
-static __u8 cxjpeg_320[][8] = {
+static const __u8 cxjpeg_320[][8] = {
 	{0xff, 0xd8, 0xff, 0xdb, 0x00, 0x84, 0x00, 0x05},
 	{0x03, 0x04, 0x04, 0x04, 0x03, 0x05, 0x04, 0x04},
 	{0x04, 0x05, 0x05, 0x05, 0x06, 0x07, 0x0c, 0x08},
@@ -558,7 +560,7 @@ static __u8 cxjpeg_320[][8] = {
 	{0x00, 0x01, 0x11, 0x02, 0x11, 0x00, 0x3F, 0x00},
 	{0xFF, 0xD9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}	/* 27 */
 };
-static __u8 cxjpeg_176[][8] = {
+static const __u8 cxjpeg_176[][8] = {
 	{0xff, 0xd8, 0xff, 0xdb, 0x00, 0x84, 0x00, 0x0d},
 	{0x09, 0x09, 0x0B, 0x09, 0x08, 0x0D, 0x0B, 0x0A},
 	{0x0B, 0x0E, 0x0D, 0x0D, 0x0F, 0x13, 0x1F, 0x14},
@@ -587,7 +589,7 @@ static __u8 cxjpeg_176[][8] = {
 	{0x00, 0x01, 0x11, 0x02, 0x11, 0x00, 0x3F, 0x00},
 	{0xFF, 0xD9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
 };
-static __u8 cxjpeg_qtable[][8] = {	/* 640 take with the zcx30x part */
+static const __u8 cxjpeg_qtable[][8] = {	/* 640 take with the zcx30x part */
 	{0xff, 0xd8, 0xff, 0xdb, 0x00, 0x84, 0x00, 0x08},
 	{0x06, 0x06, 0x07, 0x06, 0x05, 0x08, 0x07, 0x07},
 	{0x07, 0x09, 0x09, 0x08, 0x0a, 0x0c, 0x14, 0x0a},
@@ -633,13 +635,13 @@ static void cx11646_jpegInit(struct gspc
 	reg_w(gspca_dev->dev, 0x0055, &val, 1);
 }
 
-static __u8 reg12[] = { 0x0a, 0x05, 0x07, 0x04, 0x19 };
-static __u8 regE5_8[] = { 0x88, 0x00, 0xd4, 0x01, 0x88, 0x01, 0x01, 0x01 };
-static __u8 regE5a[] = { 0x88, 0x0a, 0x0c, 0x01 };
-static __u8 regE5b[] = { 0x88, 0x0b, 0x12, 0x01 };
-static __u8 regE5c[] = { 0x88, 0x05, 0x01, 0x01 };
-static __u8 reg51[] = { 0x77, 0x03 };
-static __u8 reg70 = 0x03;
+static const __u8 reg12[] = { 0x0a, 0x05, 0x07, 0x04, 0x19 };
+static const __u8 regE5_8[] = { 0x88, 0x00, 0xd4, 0x01, 0x88, 0x01, 0x01, 0x01 };
+static const __u8 regE5a[] = { 0x88, 0x0a, 0x0c, 0x01 };
+static const __u8 regE5b[] = { 0x88, 0x0b, 0x12, 0x01 };
+static const __u8 regE5c[] = { 0x88, 0x05, 0x01, 0x01 };
+static const __u8 reg51[] = { 0x77, 0x03 };
+static const __u8 reg70 = 0x03;
 
 static void cx11646_jpeg(struct gspca_dev*gspca_dev)
 {
linux/drivers/media/video/gspca/etoms.c renamed from linux/drivers/media/video/gspca/etoms.c~ +10 -7
diff -up gspca-2bbb47f61a95/linux/drivers/media/video/gspca/etoms.c~ gspca-2bbb47f61a95/linux/drivers/media/video/gspca/etoms.c
@@ -205,13 +205,13 @@ static struct cam_mode sif_mode[] = {
 #define PAS106_REG0e 0x0e	/* global gain [4..0](default 0x0e) */
 #define PAS106_REG13 0x13	/* end i2c write */
 
-static __u8 GainRGBG[] = { 0x80, 0x80, 0x80, 0x80, 0x00, 0x00 };
+static const __u8 GainRGBG[] = { 0x80, 0x80, 0x80, 0x80, 0x00, 0x00 };
 
-static __u8 I2c2[] = { 0x08, 0x08, 0x08, 0x08, 0x0d };
+static const __u8 I2c2[] = { 0x08, 0x08, 0x08, 0x08, 0x0d };
 
-static __u8 I2c3[] = { 0x12, 0x05 };
+static const __u8 I2c3[] = { 0x12, 0x05 };
 
-static __u8 I2c4[] = { 0x41, 0x08 };
+static const __u8 I2c4[] = { 0x41, 0x08 };
 
 static void Et_RegRead(struct usb_device *dev,
 		       __u16 index, __u8 *buffer, int len)
@@ -233,7 +233,7 @@ static void Et_RegWrite(struct usb_devic
 			0, index, buffer, len, 500);
 }
 
-static int Et_i2cwrite(struct usb_device *dev, __u8 reg, __u8 *buffer,
+static int Et_i2cwrite(struct usb_device *dev, __u8 reg, const __u8 *buffer,
 		       __u16 length, __u8 mode)
 {
 /* buffer should be [D0..D7] */
@@ -250,7 +250,8 @@ static int Et_i2cwrite(struct usb_device
 	Et_RegWrite(dev, ET_I2C_REG, &reg, 1);
 	j = length - 1;
 	for (i = 0; i < length; i++) {
-		Et_RegWrite(dev, (ET_I2C_DATA0 + j), &buffer[j], 1);
+		__u8 value = buffer[j];
+		Et_RegWrite(dev, (ET_I2C_DATA0 + j), &value, 1);
 		j--;
 	}
 	return 0;
@@ -551,6 +552,7 @@ static void Et_init1(struct gspca_dev *g
 						/* try 1/120 0x6d 0xcd 0x40 */
 /*	__u8 I2c0 [] ={0x0a,0x12,0x05,0xfe,0xfe,0xc0,0x01,0x00};
 						 * 1/60000 hmm ?? */
+	__u8 tmpGainRGBG[6];
 
 	PDEBUG(D_STREAM, "Open Init1 ET");
 	value = 7;
@@ -679,7 +681,8 @@ static void Et_init1(struct gspca_dev *g
 	/* magnetude and sign bit for DAC */
 	Et_i2cwrite(dev, PAS106_REG7, I2c4, sizeof I2c4, 1);
 	/* now set by fifo the whole colors setting */
-	Et_RegWrite(dev, ET_G_RED, GainRGBG, 6);
+	memcpy(tmpGainRGBG, GainRGBG, 6);
+	Et_RegWrite(dev, ET_G_RED, tmpGainRGBG, 6);
 	getcolors(gspca_dev);
 	setcolors(gspca_dev);
 }
linux/drivers/media/video/gspca/pac7311.c renamed from linux/drivers/media/video/gspca/pac7311.c~ +5 -3
diff -up gspca-2bbb47f61a95/linux/drivers/media/video/gspca/pac7311.c~ gspca-2bbb47f61a95/linux/drivers/media/video/gspca/pac7311.c
@@ -124,7 +124,7 @@ static struct cam_mode vga_mode[] = {
 
 #define PAC7311_JPEG_HEADER_SIZE (sizeof pac7311_jpeg_header)	/* (594) */
 
-const unsigned char pac7311_jpeg_header[] = {
+static const unsigned char pac7311_jpeg_header[] = {
 	0xff, 0xd8,
 	0xff, 0xe0, 0x00, 0x03, 0x20,
 	0xff, 0xc0, 0x00, 0x11, 0x08,
@@ -198,13 +198,15 @@ static void reg_w(struct usb_device *dev
 			    __u16 req,
 			    __u16 value,
 			    __u16 index,
-			    __u8 *buffer, __u16 length)
+			    const __u8 *buffer, __u16 length)
 {
+	__u8 tmpbuf[8];
+	memcpy(tmpbuf, buffer, length);
 	usb_control_msg(dev,
 			usb_sndctrlpipe(dev, 0),
 			req,
 			USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
-			value, index, buffer, length,
+			value, index, tmpbuf, length,
 			500);
 }
 
linux/drivers/media/video/gspca/sonixj.c renamed from linux/drivers/media/video/gspca/sonixj.c~ +33 -24

193 lines not on this page · raw message

linux/drivers/media/video/gspca/spca500.c renamed from linux/drivers/media/video/gspca/spca500.c~ +8 -8
diff -up gspca-2bbb47f61a95/linux/drivers/media/video/gspca/spca500.c~ gspca-2bbb47f61a95/linux/drivers/media/video/gspca/spca500.c
@@ -139,7 +139,7 @@ static struct cam_mode sif_mode[] = {
 #define SPCA500_OFFSET_DATA      16
 
 #if 0
-static __u16 spca500_read_stats[][3] = {
+static const __u16 spca500_read_stats[][3] = {
 	{0x0c, 0x0000, 0x0000},
 	{0x30, 0x03fd, 0x0001},
 	/* possible values for following call: 0x01b3, 0x01e6, 0x01f7, 0x0218 */
@@ -156,7 +156,7 @@ static __u16 spca500_read_stats[][3] = {
 };
 #endif
 
-static __u16 spca500_visual_defaults[][3] = {
+static const __u16 spca500_visual_defaults[][3] = {
 	{0x00, 0x0003, 0x816b},	/* SSI not active sync with vsync,
 				 * hue (H byte) = 0,
 				 * saturation/hue enable,
@@ -181,7 +181,7 @@ static __u16 spca500_visual_defaults[][3
 
 	{0, 0, 0}
 };
-static __u16 Clicksmart510_defaults[][3] = {
+static const __u16 Clicksmart510_defaults[][3] = {
 	{0x00, 0x00, 0x8211},
 	{0x00, 0x01, 0x82c0},
 	{0x00, 0x10, 0x82cb},
@@ -310,7 +310,7 @@ static __u16 Clicksmart510_defaults[][3]
 	{}
 };
 
-static unsigned char qtable_creative_pccam[2][64] = {
+static const unsigned char qtable_creative_pccam[2][64] = {
 	{				/* Q-table Y-components */
 	 0x05, 0x03, 0x03, 0x05, 0x07, 0x0c, 0x0f, 0x12,
 	 0x04, 0x04, 0x04, 0x06, 0x08, 0x11, 0x12, 0x11,
@@ -331,7 +331,7 @@ static unsigned char qtable_creative_pcc
 	 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e}
 };
 
-static unsigned char qtable_kodak_ez200[2][64] = {
+static const unsigned char qtable_kodak_ez200[2][64] = {
 	{				/* Q-table Y-components */
 	 0x02, 0x01, 0x01, 0x02, 0x02, 0x04, 0x05, 0x06,
 	 0x01, 0x01, 0x01, 0x02, 0x03, 0x06, 0x06, 0x06,
@@ -352,7 +352,7 @@ static unsigned char qtable_kodak_ez200[
 	 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a}
 };
 
-static unsigned char qtable_pocketdv[2][64] = {
+static const unsigned char qtable_pocketdv[2][64] = {
 	{		/* Q-table Y-components start registers 0x8800 */
 	 0x06, 0x04, 0x04, 0x06, 0x0a, 0x10, 0x14, 0x18,
 	 0x05, 0x05, 0x06, 0x08, 0x0a, 0x17, 0x18, 0x16,
@@ -448,7 +448,7 @@ static int reg_readwait(struct usb_devic
 }
 
 static int write_vector(struct gspca_dev *gspca_dev,
-				__u16 data[][3])
+				const __u16 data[][3])
 {
 	struct usb_device *dev = gspca_dev->dev;
 	int ret, i = 0;
@@ -466,7 +466,7 @@ static int spca50x_setup_qtable(struct g
 				unsigned int request,
 				unsigned int ybase,
 				unsigned int cbase,
-				unsigned char qtable[2][64])
+				const unsigned char qtable[][64])
 {
 	struct usb_device *dev = gspca_dev->dev;
 	int i, err;
linux/drivers/media/video/gspca/spca501.c renamed from linux/drivers/media/video/gspca/spca501.c~ +8 -8
diff -up gspca-2bbb47f61a95/linux/drivers/media/video/gspca/spca501.c~ gspca-2bbb47f61a95/linux/drivers/media/video/gspca/spca501.c
@@ -151,7 +151,7 @@ static struct cam_mode vga_mode[] = {
 #define SPCA501_A33 0x10
 
 /* Data for video camera initialization before capturing */
-static __u16 spca501_open_data[][3] = {
+static const __u16 spca501_open_data[][3] = {
 	/* bmRequest,value,index */
 
 	{0x2, 0x50, 0x00},	/* C/S enable soft reset */
@@ -257,7 +257,7 @@ static __u16 spca501_open_data[][3] = {
  */
 
 /* Data for chip initialization (set default values) */
-static __u16 spca501_init_data[][3] = {
+static const __u16 spca501_init_data[][3] = {
 	/* Set all the values to powerup defaults */
 	/* bmRequest,value,index */
 	{0x0, 0xAA, 0x00},
@@ -544,7 +544,7 @@ static __u16 spca501_init_data[][3] = {
  * Capture and decoding by Colin Peart.
  * This is is for the 3com HomeConnect Lite which is spca501a based.
  */
-static __u16 spca501_3com_open_data[][3] = {
+static const __u16 spca501_3com_open_data[][3] = {
 	/* bmRequest,value,index */
 	{0x2, 0x0050, 0x0000},	/* C/S Enable TG soft reset, timing mode=010 */
 	{0x2, 0x0043, 0x0000},	/* C/S Disable TG soft reset, timing mode=010 */
@@ -639,7 +639,7 @@ static __u16 spca501_3com_open_data[][3]
  * 2) Understand why some values seem to appear more than once
  * 3) Write a small comment for each line of the following arrays.
  */
-static __u16 spca501c_arowana_open_data[][3] = {
+static const __u16 spca501c_arowana_open_data[][3] = {
 	/* bmRequest,value,index */
 	{0x02, 0x0007, 0x0005},
 	{0x02, 0xa048, 0x0000},
@@ -661,7 +661,7 @@ static __u16 spca501c_arowana_open_data[
 	{}
 };
 
-static __u16 spca501c_arowana_init_data[][3] = {
+static const __u16 spca501c_arowana_init_data[][3] = {
 	/* bmRequest,value,index */
 	{0x02, 0x0007, 0x0005},
 	{0x02, 0xa048, 0x0000},
@@ -1595,7 +1595,7 @@ static __u16 spca501c_arowana_init_data[
 
 /* Unknow camera from Ori Usbid 0x0000:0x0000 */
 /* Based on snoops from Ori Cohen */
-static __u16 spca501c_mysterious_open_data[][3] = {
+static const __u16 spca501c_mysterious_open_data[][3] = {
 	{0x02, 0x000f, 0x0005},
 	{0x02, 0xa048, 0x0000},
 	{0x05, 0x0022, 0x0004},
@@ -1646,7 +1646,7 @@ static __u16 spca501c_mysterious_open_da
 };
 
 /* Based on snoops from Ori Cohen */
-static __u16 spca501c_mysterious_init_data[][3] = {
+static const __u16 spca501c_mysterious_init_data[][3] = {
 /* Part 3 */
 /* TG registers */
 /*	{0x00, 0x0000, 0x0000}, */
@@ -1839,7 +1839,7 @@ static int reg_read(struct usb_device *d
 }
 
 static int write_vector(struct gspca_dev *gspca_dev,
-				__u16 data[][3])
+				const __u16 data[][3])
 {
 	struct usb_device *dev = gspca_dev->dev;
 	int ret, i = 0;
linux/drivers/media/video/gspca/spca505.c renamed from linux/drivers/media/video/gspca/spca505.c~ +7 -7
diff -up gspca-2bbb47f61a95/linux/drivers/media/video/gspca/spca505.c~ gspca-2bbb47f61a95/linux/drivers/media/video/gspca/spca505.c
@@ -91,7 +91,7 @@ static struct cam_mode vga_mode[] = {
 /*
  * Data to initialize a SPCA505. Common to the CCD and external modes
  */
-static __u16 spca505_init_data[][3] = {
+static const __u16 spca505_init_data[][3] = {
 	/* line	   bmRequest,value,index */
 	/* 1819 */
 	{SPCA50X_REG_GLOBAL, SPCA50X_GMISC3_SAA7113RST, SPCA50X_GLOBAL_MISC3},
@@ -130,7 +130,7 @@ static __u16 spca505_init_data[][3] = {
 /*
  * Data to initialize the camera using the internal CCD
  */
-static __u16 spca505_open_data_ccd[][3] = {
+static const __u16 spca505_open_data_ccd[][3] = {
 	/* line	   bmRequest,value,index */
 	/* Internal CCD data set */
 	/* 1891 */ {0x3, 0x04, 0x01},
@@ -312,7 +312,7 @@ static __u16 spca505_open_data_ccd[][3] 
 /*
  * Data to initialize the camera in external video mode
  */
-static __u16 spca505_open_data_ext[][3] = {
+static const __u16 spca505_open_data_ext[][3] = {
 	/* line	   bmRequest,value,index */
 	/* External video input dataset */
 	/* 0808 */ {0x3, 0x04, 0x01},
@@ -350,7 +350,7 @@ static __u16 spca505_open_data_ext[][3] 
 /*
  * Additional data needed to initialze the camera in external mode
  */
-static __u16 spca505_open_data2[][3] = {
+static const __u16 spca505_open_data2[][3] = {
 	/* line	   bmRequest,value,index */
 	/* 1384 */ {0x3, 0x68, 0x03},
 	/* 1385 */ {0x3, 0x10, 0x01},
@@ -388,7 +388,7 @@ static __u16 spca505_open_data2[][3] = {
 /*
  * Data to initialize a SPCA505. Common to the CCD and external modes
  */
-static __u16 spca505b_init_data[][3] = {
+static const __u16 spca505b_init_data[][3] = {
 /* start */
 	{0x02, 0x00, 0x00},		/* init */
 	{0x02, 0x00, 0x01},
@@ -452,7 +452,7 @@ static __u16 spca505b_init_data[][3] = {
 /*
  * Data to initialize the camera using the internal CCD
  */
-static __u16 spca505b_open_data_ccd[][3] = {
+static const __u16 spca505b_open_data_ccd[][3] = {
 
 /* {0x02,0x00,0x00}, */
 	{0x03, 0x04, 0x01},		/* rst */
@@ -668,7 +668,7 @@ static int reg_read(struct usb_device *d
 }
 
 static int write_vector(struct gspca_dev *gspca_dev,
-				__u16 data[][3])
+				const __u16 data[][3])
 {
 	struct usb_device *dev = gspca_dev->dev;
 	int ret, i = 0;
linux/drivers/media/video/gspca/spca508.c renamed from linux/drivers/media/video/gspca/spca508.c~ +7 -7
diff -up gspca-2bbb47f61a95/linux/drivers/media/video/gspca/spca508.c~ gspca-2bbb47f61a95/linux/drivers/media/video/gspca/spca508.c
@@ -92,7 +92,7 @@ static struct cam_mode sif_mode[] = {
  * Initialization data: this is the first set-up data written to the
  * device (before the open data).
  */
-static __u16 spca508_init_data[][3] =
+static const __u16 spca508_init_data[][3] =
 #define IGN(x)			/* nothing */
 {
 	/*  line   URB      value, index */
@@ -611,7 +611,7 @@ static __u16 spca508_init_data[][3] =
 /*
  * Data to initialize the camera using the internal CCD
  */
-static __u16 spca508_open_data[][3] = {
+static const __u16 spca508_open_data[][3] = {
 	/* line	bmRequest,value,index */
 	{0, 0}
 };
@@ -620,7 +620,7 @@ static __u16 spca508_open_data[][3] = {
 /*
  * Initialization data for Intel EasyPC Camera CS110
  */
-static __u16 spca508cs110_init_data[][3] = {
+static const __u16 spca508cs110_init_data[][3] = {
 	{0x0000, 0x870b}, /* Reset CTL3 */
 	{0x0003, 0x8111}, /* Soft Reset compression, memory, TG & CDSP */
 	{0x0000, 0x8111}, /* Normal operation on reset */
@@ -704,7 +704,7 @@ static __u16 spca508cs110_init_data[][3]
 	{}
 };
 
-static __u16 spca508_sightcam_init_data[][3] = {
+static const __u16 spca508_sightcam_init_data[][3] = {
 /* This line seems to setup the frame/canvas */
 	/*368  */ {0x000f, 0x8402},
 
@@ -788,7 +788,7 @@ static __u16 spca508_sightcam_init_data[
 	{0, 0}
 };
 
-static __u16 spca508_sightcam2_init_data[][3] = {
+static const __u16 spca508_sightcam2_init_data[][3] = {
 #if 1
 /* 35 */ {0x0020, 0x8112},
 
@@ -1137,7 +1137,7 @@ static __u16 spca508_sightcam2_init_data
 /*
  * Initialization data for Creative Webcam Vista
  */
-static __u16 spca508_vista_init_data[][3] = {
+static const __u16 spca508_vista_init_data[][3] = {
 	{0x0008, 0x8200},	/* Clear register */
 	{0x0000, 0x870b},	/* Reset CTL3 */
 	{0x0020, 0x8112},	/* Video Drop packet enable */
@@ -1479,7 +1479,7 @@ static int reg_read(struct usb_device *d
 }
 
 static int write_vector(struct gspca_dev *gspca_dev,
-				__u16 data[][3])
+				const __u16 data[][3])
 {
 	struct usb_device *dev = gspca_dev->dev;
 	int ret, i = 0;
linux/drivers/media/video/gspca/spca561.c renamed from linux/drivers/media/video/gspca/spca561.c~ +7 -7
diff -up gspca-2bbb47f61a95/linux/drivers/media/video/gspca/spca561.c~ gspca-2bbb47f61a95/linux/drivers/media/video/gspca/spca561.c
@@ -148,7 +148,7 @@ static void reg_w_val(struct usb_device 
 		PDEBUG(D_ERR, "reg write: error %d", ret);
 }
 
-static void write_vector(struct gspca_dev *gspca_dev, __u16 data[][2])
+static void write_vector(struct gspca_dev *gspca_dev, const __u16 data[][2])
 {
 	struct usb_device *dev = gspca_dev->dev;
 	int i;
@@ -227,7 +227,7 @@ static int i2c_read(struct gspca_dev *gs
 	return ((int) value << 8) | vallsb;
 }
 
-static __u16 spca561_init_data[][2] = {
+static const __u16 spca561_init_data[][2] = {
 	{0x0000, 0x8114},	/* Software GPIO output data */
 	{0x0001, 0x8114},	/* Software GPIO output data */
 	{0x0000, 0x8112},	/* Some kind of reset */
@@ -437,7 +437,7 @@ static void sensor_reset(struct gspca_de
 }
 
 /******************** QC Express etch2 stuff ********************/
-static __u16 Pb100_1map8300[][2] = {
+static const __u16 Pb100_1map8300[][2] = {
 	/* reg, value */
 	{0x8320, 0x3304},
 
@@ -452,14 +452,14 @@ static __u16 Pb100_1map8300[][2] = {
 	{0x8302, 0x000e},
 	{}
 };
-static __u16 Pb100_2map8300[][2] = {
+static const __u16 Pb100_2map8300[][2] = {
 	/* reg, value */
 	{0x8339, 0x0000},
 	{0x8307, 0x00aa},
 	{}
 };
 
-static __u16 spca561_161rev12A_data1[][2] = {
+static const __u16 spca561_161rev12A_data1[][2] = {
 	{0x21, 0x8118},
 	{0x01, 0x8114},
 	{0x00, 0x8112},
@@ -467,7 +467,7 @@ static __u16 spca561_161rev12A_data1[][2
 	{0x04, 0x8802},		/* windows uses 08 */
 	{}
 };
-static __u16 spca561_161rev12A_data2[][2] = {
+static const __u16 spca561_161rev12A_data2[][2] = {
 	{0x21, 0x8118},
 	{0x10, 0x8500},
 	{0x07, 0x8601},
@@ -513,7 +513,7 @@ static __u16 spca561_161rev12A_data2[][2
 };
 
 static void sensor_mapwrite(struct gspca_dev *gspca_dev,
-			    __u16 sensormap[][2])
+			    const __u16 sensormap[][2])
 {
 	int i = 0;
 	__u8 usbval[2];
linux/drivers/media/video/gspca/sunplus.c renamed from linux/drivers/media/video/gspca/sunplus.c~ +8 -8
diff -up gspca-2bbb47f61a95/linux/drivers/media/video/gspca/sunplus.c~ gspca-2bbb47f61a95/linux/drivers/media/video/gspca/sunplus.c
@@ -156,7 +156,7 @@ static struct cam_mode vga_mode2[] = {
 #define SPCA536_OFFSET_FRAMSEQ	 1
 
 /* Initialisation data for the Creative PC-CAM 600 */
-static __u16 spca504_pccam600_init_data[][3] = {
+static const __u16 spca504_pccam600_init_data[][3] = {
 /*	{0xa0, 0x0000, 0x0503},  * capture mode */
 	{0x00, 0x0000, 0x2000},
 	{0x00, 0x0013, 0x2301},
@@ -193,7 +193,7 @@ static __u16 spca504_pccam600_init_data[
 /* Creative PC-CAM 600 specific open data, sent before using the
  * generic initialisation data from spca504_open_data.
  */
-static __u16 spca504_pccam600_open_data[][3] = {
+static const __u16 spca504_pccam600_open_data[][3] = {
 	{0x00, 0x0001, 0x2501},
 	{0x20, 0x0500, 0x0001},	/* snapshot mode */
 	{0x00, 0x0003, 0x2880},
@@ -202,7 +202,7 @@ static __u16 spca504_pccam600_open_data[
 };
 
 /* Initialisation data for the logitech clicksmart 420 */
-static __u16 spca504A_clicksmart420_init_data[][3] = {
+static const __u16 spca504A_clicksmart420_init_data[][3] = {
 /*	{0xa0, 0x0000, 0x0503},  * capture mode */
 	{0x00, 0x0000, 0x2000},
 	{0x00, 0x0013, 0x2301},
@@ -257,7 +257,7 @@ static __u16 spca504A_clicksmart420_init
 };
 
 /* clicksmart 420 open data ? */
-static __u16 spca504A_clicksmart420_open_data[][3] = {
+static const __u16 spca504A_clicksmart420_open_data[][3] = {
 	{0x00, 0x0001, 0x2501},
 	{0x20, 0x0502, 0x0000},
 	{0x06, 0x0000, 0x0000},
@@ -404,7 +404,7 @@ static __u16 spca504A_clicksmart420_open
 	{}
 };
 
-static unsigned char qtable_creative_pccam[2][64] = {
+static const unsigned char qtable_creative_pccam[2][64] = {
 	{				/* Q-table Y-components */
 	 0x05, 0x03, 0x03, 0x05, 0x07, 0x0c, 0x0f, 0x12,
 	 0x04, 0x04, 0x04, 0x06, 0x08, 0x11, 0x12, 0x11,
@@ -429,7 +429,7 @@ static unsigned char qtable_creative_pcc
  *		except for one byte. Possibly a typo?
  *		NWG: 18/05/2003.
  */
-static unsigned char qtable_spca504_default[2][64] = {
+static const unsigned char qtable_spca504_default[2][64] = {
 	{				/* Q-table Y-components */
 	 0x05, 0x03, 0x03, 0x05, 0x07, 0x0c, 0x0f, 0x12,
 	 0x04, 0x04, 0x04, 0x06, 0x08, 0x11, 0x12, 0x11,
@@ -543,7 +543,7 @@ static int reg_read(struct usb_device *d
 }
 
 static int write_vector(struct gspca_dev *gspca_dev,
-				__u16 data[][3])
+				const __u16 data[][3])
 {
 	struct usb_device *dev = gspca_dev->dev;
 	int ret, i = 0;
@@ -565,7 +565,7 @@ static int spca50x_setup_qtable(struct g
 				unsigned int request,
 				unsigned int ybase,
 				unsigned int cbase,
-				unsigned char qtable[2][64])
+				const unsigned char qtable[][64])
 {
 	struct usb_device *dev = gspca_dev->dev;
 	int i, err;
linux/drivers/media/video/gspca/t613.c renamed from linux/drivers/media/video/gspca/t613.c~ +31 -22

130 lines not on this page · raw message

linux/drivers/media/video/gspca/vc032x.c renamed from linux/drivers/media/video/gspca/vc032x.c~ +35 -35

241 lines not on this page · raw message

linux/drivers/media/video/gspca/zc3xx.c renamed from linux/drivers/media/video/gspca/zc3xx.c~ +116 -116

838 lines not on this page · raw message

--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list