From: Márton Németh
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/)
//
@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[] = ...;
//
Signed-off-by: Márton Németh
Cc: co...@diku.dk
---
diff -r 563555b04382 linux/drivers/media/video/gspca/benq.c
--- a/linux/drivers/media/video/gspca/benq.cSun Dec 27 17:18:24 2009 +0100
+++ b/linux/drivers/media/video/gspca/benq.cTue Dec 29 21:03:28 2009 +0100
@@ -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[] = {
diff -r 563555b04382 linux/drivers/media/video/gspca/conex.c
--- a/linux/drivers/media/video/gspca/conex.c Sun Dec 27 17:18:24 2009 +0100
+++ b/linux/drivers/media/video/gspca/conex.c Tue Dec 29 21:03:28 2009 +0100
@@ -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,
diff -r 563555b04382 linux/drivers/media/video/gspca/etoms.c
--- a/linux/drivers/media/video/gspca/etoms.c Sun Dec 27 17:18:24 2009 +0100
+++ b/linux/drivers/media/video/gspca/etoms.c Tue Dec 29 21:03:28 2009 +0100
@@ -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,
diff -r 563555b04382 linux/drivers/media/video/gspca/mars.c
--- a/linux/drivers/media/video/gspca/mars.cSun Dec 27 17:18:24 2009 +0100
+++ b/linux/drivers/media/video/gspca/mars.cTue Dec 29 21:03:28 2009 +0100
@@ -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,
diff -r 563555b04382 linux/drivers/media/video/gspca/mr97310a.c
--- a/linux/drivers/media/video/gspca/mr97310a.cSun Dec 27 17:18:24
2009 +0100
+++ b/linux/drivers/media/video/gspca/mr97310a.cTue Dec 29 21:03:28
2009 +0100
@@ -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 */
{
diff -r 563555b04382 linux/drivers/media/video/gspca/ov534.c
--- a/linux/drivers/media/video/gspca/ov534.c Sun Dec 27 17:18:24 2009 +0100
+++ b/linux/drivers/media/video/gspca/ov534.c Tue Dec 29 21:03:28 2009 +0100
@@ -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,
diff -r 563555b04382 linux/drivers/media/video/gspca/pac207.c
--- a/linux/drivers/media/video/gspca/pac207.c Sun Dec 27 17:18:24 2009 +0100
+++ b/linux/drivers/media/video/gspca/pac207.c Tue Dec 29 21:03:28 2009 +0100
@@ -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
{
{
diff -r 563555b04382 linux/drivers/media/video/gspca/pac7302.c
--- a/linux/drivers/media/video/gspca/pac7302.c Sun Dec 27 17:18:24 2009 +0100
+++ b/linux/drivers/media/video/gspca/pac7302.c Tue Dec 29 21:03:28 2009 +0100
@@ -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[] = {