gspca: make control descriptors constant
PATCH 1/1 gspca: make control descriptors constant
From: Márton Németh <[email protected]>
The ctrls field of struct sd_desc is declared as const in gspca.h. It is worth to initialize the content also with constant values.
The semantic match that finds this kind of pattern is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@m@
identifier x;
identifier y;
identifier sd_desc;
@@
static struct x sd_desc = {
...
.ctrls = y,
...
};@c depends on m@
identifier m.y;
identifier ctrl;
@@
static const struct ctrl y[] = ...;
@depends on m && !c@
identifier m.y;
identifier ctrl;
@@
static
+ const
struct ctrl y[] = ...;
// </smpl>
Signed-off-by Márton Németh <[email protected]>
---
linux/drivers/media/video/gspca/benq.c +1 -1
@@ -32,7 +32,7 @@ };/* V4L2 controls supported by the driver */ -static struct ctrl sd_ctrls[] = { +static const struct ctrl sd_ctrls[] = { };static const struct v4l2_pix_format vga_mode[] = {
linux/drivers/media/video/gspca/conex.c +1 -1
@@ -52,7 +52,7 @@static int sd_setcolors (struct gspca_dev *gspca_dev,__s32 val);static int sd_getcolors (struct gspca_dev *gspca_dev,__s32 *val); -static struct ctrl sd_ctrls[] = { +static const struct ctrl sd_ctrls[] = { { { .id =V4L2_CID_BRIGHTNESS ,
linux/drivers/media/video/gspca/etoms.c +1 -1
@@ -52,7 +52,7 @@static int sd_setautogain (struct gspca_dev *gspca_dev,__s32 val);static int sd_getautogain (struct gspca_dev *gspca_dev,__s32 *val); -static struct ctrl sd_ctrls[] = { +static const struct ctrl sd_ctrls[] = { { { .id =V4L2_CID_BRIGHTNESS ,
linux/drivers/media/video/gspca/mars.c +1 -1
@@ -54,7 +54,7 @@static int sd_setsharpness (struct gspca_dev *gspca_dev,__s32 val);static int sd_getsharpness (struct gspca_dev *gspca_dev,__s32 *val); -static struct ctrl sd_ctrls[] = { +static const struct ctrl sd_ctrls[] = { { { .id =V4L2_CID_BRIGHTNESS ,
linux/drivers/media/video/gspca/mr97310a.c +1 -1
@@ -107,7 +107,7 @@static void setgain (struct gspca_dev *gspca_dev);/* V4L2 controls supported by the driver */ -static struct ctrl sd_ctrls[] = { +static const struct ctrl sd_ctrls[] = {/* Separate brightness control description for Argus QuickClix as it has different limits from the other mr97310a cameras */ {
linux/drivers/media/video/gspca/ov534.c +2 -2
@@ -106,7 +106,7 @@static int sd_setfreq (struct gspca_dev *gspca_dev,__s32 val);static int sd_getfreq (struct gspca_dev *gspca_dev,__s32 *val); -static struct ctrl sd_ctrls_ov772x[] = { +static const struct ctrl sd_ctrls_ov772x[] = { {/* 0 */ { .id =V4L2_CID_BRIGHTNESS ,
@@ -277,7 +277,7 @@ .get = sd_getvflip, }, }; -static struct ctrl sd_ctrls_ov965x[] = { +static const struct ctrl sd_ctrls_ov965x[] = { {/* 0 */ { .id =V4L2_CID_BRIGHTNESS ,
linux/drivers/media/video/gspca/pac207.c +1 -1
@@ -77,7 +77,7 @@static int sd_setgain (struct gspca_dev *gspca_dev,__s32 val);static int sd_getgain (struct gspca_dev *gspca_dev,__s32 *val); -static struct ctrl sd_ctrls[] = { +static const struct ctrl sd_ctrls[] = { #define SD_BRIGHTNESS 0 { {
linux/drivers/media/video/gspca/pac7302.c +1 -1
@@ -124,7 +124,7 @@static int sd_setexposure (struct gspca_dev *gspca_dev,__s32 val);static int sd_getexposure (struct gspca_dev *gspca_dev,__s32 *val); -static struct ctrl sd_ctrls[] = { +static const struct ctrl sd_ctrls[] = {/* This control is pac7302 only */ { {
linux/drivers/media/video/gspca/pac7311.c +1 -1
@@ -88,7 +88,7 @@static int sd_setexposure (struct gspca_dev *gspca_dev,__s32 val);static int sd_getexposure (struct gspca_dev *gspca_dev,__s32 *val); -static struct ctrl sd_ctrls[] = { +static const struct ctrl sd_ctrls[] = {/* This control is for both the 7302 and the 7311 */ { {
linux/drivers/media/video/gspca/sn9c20x.c +1 -1
@@ -131,7 +131,7 @@static int sd_setautoexposure (struct gspca_dev *gspca_dev,s32 val);static int sd_getautoexposure (struct gspca_dev *gspca_dev,s32 *val); -static struct ctrl sd_ctrls[] = { +static const struct ctrl sd_ctrls[] = { { #define BRIGHTNESS_IDX 0 {
linux/drivers/media/video/gspca/sonixb.c +1 -1
@@ -145,7 +145,7 @@static int sd_setfreq (struct gspca_dev *gspca_dev,__s32 val);static int sd_getfreq (struct gspca_dev *gspca_dev,__s32 *val); -static struct ctrl sd_ctrls[] = { +static const struct ctrl sd_ctrls[] = { #define BRIGHTNESS_IDX 0 { {
linux/drivers/media/video/gspca/sonixj.c +1 -1
@@ -102,7 +102,7 @@static int sd_setfreq (struct gspca_dev *gspca_dev,__s32 val);static int sd_getfreq (struct gspca_dev *gspca_dev,__s32 *val); -static struct ctrl sd_ctrls[] = { +static const struct ctrl sd_ctrls[] = { #define BRIGHTNESS_IDX 0 { {
linux/drivers/media/video/gspca/spca500.c +1 -1
@@ -68,7 +68,7 @@static int sd_setcolors (struct gspca_dev *gspca_dev,__s32 val);static int sd_getcolors (struct gspca_dev *gspca_dev,__s32 *val); -static struct ctrl sd_ctrls[] = { +static const struct ctrl sd_ctrls[] = { { { .id =V4L2_CID_BRIGHTNESS ,
linux/drivers/media/video/gspca/spca501.c +1 -1
@@ -59,7 +59,7 @@static int sd_setred_balance (struct gspca_dev *gspca_dev,__s32 val);static int sd_getred_balance (struct gspca_dev *gspca_dev,__s32 *val); -static struct ctrl sd_ctrls[] = { +static const struct ctrl sd_ctrls[] = { #define MY_BRIGHTNESS 0 { {
linux/drivers/media/video/gspca/spca505.c +1 -1
@@ -42,7 +42,7 @@static int sd_setbrightness (struct gspca_dev *gspca_dev,__s32 val);static int sd_getbrightness (struct gspca_dev *gspca_dev,__s32 *val); -static struct ctrl sd_ctrls[] = { +static const struct ctrl sd_ctrls[] = { { { .id =V4L2_CID_BRIGHTNESS ,
linux/drivers/media/video/gspca/spca506.c +1 -1
@@ -51,7 +51,7 @@static int sd_sethue (struct gspca_dev *gspca_dev,__s32 val);static int sd_gethue (struct gspca_dev *gspca_dev,__s32 *val); -static struct ctrl sd_ctrls[] = { +static const struct ctrl sd_ctrls[] = { #define SD_BRIGHTNESS 0 { {
linux/drivers/media/video/gspca/spca508.c +1 -1
@@ -45,7 +45,7 @@static int sd_setbrightness (struct gspca_dev *gspca_dev,__s32 val);static int sd_getbrightness (struct gspca_dev *gspca_dev,__s32 *val); -static struct ctrl sd_ctrls[] = { +static const struct ctrl sd_ctrls[] = { { { .id =V4L2_CID_BRIGHTNESS ,
linux/drivers/media/video/gspca/spca561.c +2 -2
@@ -953,7 +953,7 @@ }/* control tables */ -static struct ctrl sd_ctrls_12a[] = { +static const struct ctrl sd_ctrls_12a[] = { { { .id =V4L2_CID_HUE ,
@@ -995,7 +995,7 @@ }, }; -static struct ctrl sd_ctrls_72a[] = { +static const struct ctrl sd_ctrls_72a[] = { { { .id =V4L2_CID_HUE ,
linux/drivers/media/video/gspca/stk014.c +1 -1
@@ -53,7 +53,7 @@static int sd_setfreq (struct gspca_dev *gspca_dev,__s32 val);static int sd_getfreq (struct gspca_dev *gspca_dev,__s32 *val); -static struct ctrl sd_ctrls[] = { +static const struct ctrl sd_ctrls[] = { { { .id =V4L2_CID_BRIGHTNESS ,
linux/drivers/media/video/gspca/stv0680.c +1 -1
@@ -45,7 +45,7 @@ };/* V4L2 controls supported by the driver */ -static struct ctrl sd_ctrls[] = { +static const struct ctrl sd_ctrls[] = { }; static int stv_sndctrl(struct gspca_dev *gspca_dev, int set, u8 req, u16 val,
linux/drivers/media/video/gspca/sunplus.c +1 -1
@@ -67,7 +67,7 @@static int sd_setautogain (struct gspca_dev *gspca_dev,__s32 val);static int sd_getautogain (struct gspca_dev *gspca_dev,__s32 *val); -static struct ctrl sd_ctrls[] = { +static const struct ctrl sd_ctrls[] = { { { .id =V4L2_CID_BRIGHTNESS ,
linux/drivers/media/video/gspca/t613.c +1 -1
@@ -78,7 +78,7 @@static int sd_querymenu (struct gspca_dev *gspca_dev,struct v4l2_querymenu *menu); -static struct ctrl sd_ctrls[] = { +static const struct ctrl sd_ctrls[] = { { { .id =V4L2_CID_BRIGHTNESS ,
linux/drivers/media/video/gspca/tv8532.c +1 -1
@@ -39,7 +39,7 @@static int sd_setbrightness (struct gspca_dev *gspca_dev,__s32 val);static int sd_getbrightness (struct gspca_dev *gspca_dev,__s32 *val); -static struct ctrl sd_ctrls[] = { +static const struct ctrl sd_ctrls[] = { { { .id =V4L2_CID_BRIGHTNESS ,
linux/drivers/media/video/gspca/vc032x.c +1 -1
@@ -78,7 +78,7 @@static int sd_setsharpness (struct gspca_dev *gspca_dev,__s32 val);static int sd_getsharpness (struct gspca_dev *gspca_dev,__s32 *val); -static struct ctrl sd_ctrls[] = { +static const struct ctrl sd_ctrls[] = { #define BRIGHTNESS_IDX 0 { {
linux/drivers/media/video/gspca/zc3xx.c +1 -1
@@ -92,7 +92,7 @@static int sd_setsharpness (struct gspca_dev *gspca_dev,__s32 val);static int sd_getsharpness (struct gspca_dev *gspca_dev,__s32 *val); -static struct ctrl sd_ctrls[] = { +static const struct ctrl sd_ctrls[] = { #define BRIGHTNESS_IDX 0 #define SD_BRIGHTNESS 0 {
Quoted 3 lines · On Tue, 29 Dec 2009 22:45:52 +0100 Németh Márton <[email protected]> wrote:
The ctrls field of struct
sd_descis declared as const ingspca.h. It is worth to initialize the content also with constant values.
Thanks, I got it.
Signature · 2 lines
Ken ar c'hentañ | ** Breizh ha Linux atav! ** Jef | http://moinejf.free.fr/