[media] drivers: media: i2c: constify v4l2_subdev_* structures
authorBhumika Goyal <bhumirks@gmail.com>
Mon, 12 Dec 2016 07:45:32 +0000 (05:45 -0200)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Fri, 3 Feb 2017 11:23:19 +0000 (09:23 -0200)
v4l2_subdev_{core/pad/video}_ops structures are stored in the
fields of the v4l2_subdev_ops structure which are of type const.
Also, v4l2_subdev_ops structure is passed to a function
having its argument of type const. As these structures are never
modified, so declare them as const.
Done using Coccinelle: (One of the scripts used)

@r1 disable optional_qualifier @
identifier i;
position p;
@@
static struct v4l2_subdev_video_ops i@p = {...};

@ok1@
identifier r1.i;
position p;
struct v4l2_subdev_ops obj;
@@
obj.video=&i@p;

@bad@
position p!={r1.p,ok1.p};
identifier r1.i;
@@
i@p

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
+const
struct v4l2_subdev_video_ops i;

File sizes before:
  text    data     bss     dec     hex filename
   7810     736      16    8562    2172 drivers/media/i2c/mt9p031.o
   9652     736      24   10412    28ac drivers/media/i2c/mt9v032.o
   4613     552      20    5185    1441 drivers/media/i2c/noon010pc30.o
   2615     552       8    3175     c67 drivers/media/i2c/s5k6a3.o

File sizes after:
  text    data     bss     dec     hex filename
   8322     232      16    8570    217a drivers/media/i2c/mt9p031.o
  10164     232      24   10420    28b4 drivers/media/i2c/mt9v032.o
   4933     232      20    5185    1441 drivers/media/i2c/noon010pc30.o
   2935     232       8    3175     c67 drivers/media/i2c/s5k6a3.o

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/media/i2c/mt9p031.c
drivers/media/i2c/mt9v032.c
drivers/media/i2c/noon010pc30.c
drivers/media/i2c/s5k6a3.c

index 237737fec09c15fdc6b3148c10a602860d3b5bff..91d822fc4443a362d3ee8d2b6538deb84b8e2f91 100644 (file)
@@ -972,15 +972,15 @@ static int mt9p031_close(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh)
        return mt9p031_set_power(subdev, 0);
 }
 
-static struct v4l2_subdev_core_ops mt9p031_subdev_core_ops = {
+static const struct v4l2_subdev_core_ops mt9p031_subdev_core_ops = {
        .s_power        = mt9p031_set_power,
 };
 
-static struct v4l2_subdev_video_ops mt9p031_subdev_video_ops = {
+static const struct v4l2_subdev_video_ops mt9p031_subdev_video_ops = {
        .s_stream       = mt9p031_s_stream,
 };
 
-static struct v4l2_subdev_pad_ops mt9p031_subdev_pad_ops = {
+static const struct v4l2_subdev_pad_ops mt9p031_subdev_pad_ops = {
        .enum_mbus_code = mt9p031_enum_mbus_code,
        .enum_frame_size = mt9p031_enum_frame_size,
        .get_fmt = mt9p031_get_format,
@@ -989,7 +989,7 @@ static struct v4l2_subdev_pad_ops mt9p031_subdev_pad_ops = {
        .set_selection = mt9p031_set_selection,
 };
 
-static struct v4l2_subdev_ops mt9p031_subdev_ops = {
+static const struct v4l2_subdev_ops mt9p031_subdev_ops = {
        .core   = &mt9p031_subdev_core_ops,
        .video  = &mt9p031_subdev_video_ops,
        .pad    = &mt9p031_subdev_pad_ops,
index 107eb3baa11f4299e12840c74e0d2df5c6d290c9..2e7a6e62a358ab637342aafebd8ecc3882b942f9 100644 (file)
@@ -935,15 +935,15 @@ static int mt9v032_close(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh)
        return mt9v032_set_power(subdev, 0);
 }
 
-static struct v4l2_subdev_core_ops mt9v032_subdev_core_ops = {
+static const struct v4l2_subdev_core_ops mt9v032_subdev_core_ops = {
        .s_power        = mt9v032_set_power,
 };
 
-static struct v4l2_subdev_video_ops mt9v032_subdev_video_ops = {
+static const struct v4l2_subdev_video_ops mt9v032_subdev_video_ops = {
        .s_stream       = mt9v032_s_stream,
 };
 
-static struct v4l2_subdev_pad_ops mt9v032_subdev_pad_ops = {
+static const struct v4l2_subdev_pad_ops mt9v032_subdev_pad_ops = {
        .enum_mbus_code = mt9v032_enum_mbus_code,
        .enum_frame_size = mt9v032_enum_frame_size,
        .get_fmt = mt9v032_get_format,
@@ -952,7 +952,7 @@ static struct v4l2_subdev_pad_ops mt9v032_subdev_pad_ops = {
        .set_selection = mt9v032_set_selection,
 };
 
-static struct v4l2_subdev_ops mt9v032_subdev_ops = {
+static const struct v4l2_subdev_ops mt9v032_subdev_ops = {
        .core   = &mt9v032_subdev_core_ops,
        .video  = &mt9v032_subdev_video_ops,
        .pad    = &mt9v032_subdev_pad_ops,
index 30cb90b88d7551515abb601dd578216ee60bc204..88c498ad45dfb01aa089090609307ed3ce29673c 100644 (file)
@@ -664,13 +664,13 @@ static const struct v4l2_subdev_core_ops noon010_core_ops = {
        .log_status     = noon010_log_status,
 };
 
-static struct v4l2_subdev_pad_ops noon010_pad_ops = {
+static const struct v4l2_subdev_pad_ops noon010_pad_ops = {
        .enum_mbus_code = noon010_enum_mbus_code,
        .get_fmt        = noon010_get_fmt,
        .set_fmt        = noon010_set_fmt,
 };
 
-static struct v4l2_subdev_video_ops noon010_video_ops = {
+static const struct v4l2_subdev_video_ops noon010_video_ops = {
        .s_stream       = noon010_s_stream,
 };
 
index 769964057881cd1090c47fee5ac33e8b0fc5e818..67dcca76f981cc5a38a23f6a098cc71dc37622e9 100644 (file)
@@ -165,7 +165,7 @@ static int s5k6a3_get_fmt(struct v4l2_subdev *sd,
        return 0;
 }
 
-static struct v4l2_subdev_pad_ops s5k6a3_pad_ops = {
+static const struct v4l2_subdev_pad_ops s5k6a3_pad_ops = {
        .enum_mbus_code = s5k6a3_enum_mbus_code,
        .get_fmt        = s5k6a3_get_fmt,
        .set_fmt        = s5k6a3_set_fmt,
@@ -266,11 +266,11 @@ static int s5k6a3_s_power(struct v4l2_subdev *sd, int on)
        return ret;
 }
 
-static struct v4l2_subdev_core_ops s5k6a3_core_ops = {
+static const struct v4l2_subdev_core_ops s5k6a3_core_ops = {
        .s_power = s5k6a3_s_power,
 };
 
-static struct v4l2_subdev_ops s5k6a3_subdev_ops = {
+static const struct v4l2_subdev_ops s5k6a3_subdev_ops = {
        .core = &s5k6a3_core_ops,
        .pad = &s5k6a3_pad_ops,
 };