[media] constify i2c_algorithm structures
authorJulia Lawall <Julia.Lawall@lip6.fr>
Mon, 29 Aug 2016 13:12:01 +0000 (10:12 -0300)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Mon, 19 Sep 2016 19:27:02 +0000 (16:27 -0300)
These i2c_algorithm structures are only stored in the alg field of an
i2c_adapter structure, which is declared as const.  This declare the
structures as const as well.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@r disable optional_qualifier@
identifier i;
position p;
@@
static struct i2c_algorithm i@p = { ... };

@ok@
identifier r.i;
struct i2c_adapter e;
position p;
@@
e.alg = &i@p;

@bad@
position p != {r.p,ok.p};
identifier r.i;
@@
i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
 struct i2c_algorithm i = { ... };
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
12 files changed:
drivers/media/pci/cx23885/cx23885-i2c.c
drivers/media/pci/cx25821/cx25821-i2c.c
drivers/media/pci/ivtv/ivtv-i2c.c
drivers/media/pci/saa7134/saa7134-i2c.c
drivers/media/pci/saa7164/saa7164-i2c.c
drivers/media/radio/si4713/radio-usb-si4713.c
drivers/media/usb/cx231xx/cx231xx-i2c.c
drivers/media/usb/em28xx/em28xx-i2c.c
drivers/media/usb/go7007/go7007-i2c.c
drivers/media/usb/go7007/go7007-usb.c
drivers/media/usb/hdpvr/hdpvr-i2c.c
drivers/media/usb/stk1160/stk1160-i2c.c

index ae061b3585917c4f937a75cbfb4f1f21e770be95..61591225be9a6476bbe809702f7b12f1e14f6a27 100644 (file)
@@ -258,7 +258,7 @@ static u32 cx23885_functionality(struct i2c_adapter *adap)
        return I2C_FUNC_SMBUS_EMUL | I2C_FUNC_I2C;
 }
 
-static struct i2c_algorithm cx23885_i2c_algo_template = {
+static const struct i2c_algorithm cx23885_i2c_algo_template = {
        .master_xfer    = i2c_xfer,
        .functionality  = cx23885_functionality,
 };
index dca37c7dba73a3659131e543ec1b636d8d5d31ca..63ba25b826929ca9b91f7fab99fae849252f47a6 100644 (file)
@@ -281,7 +281,7 @@ static u32 cx25821_functionality(struct i2c_adapter *adap)
                I2C_FUNC_SMBUS_READ_WORD_DATA | I2C_FUNC_SMBUS_WRITE_WORD_DATA;
 }
 
-static struct i2c_algorithm cx25821_i2c_algo_template = {
+static const struct i2c_algorithm cx25821_i2c_algo_template = {
        .master_xfer = i2c_xfer,
        .functionality = cx25821_functionality,
 #ifdef NEED_ALGO_CONTROL
index bccbf2d18e307d5bd37088ffa2576ad4aaf3094d..dd57442cf08612254cf0a9ed7f7eac0ba9d479f5 100644 (file)
@@ -625,7 +625,7 @@ static u32 ivtv_functionality(struct i2c_adapter *adap)
        return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
 }
 
-static struct i2c_algorithm ivtv_algo = {
+static const struct i2c_algorithm ivtv_algo = {
        .master_xfer   = ivtv_xfer,
        .functionality = ivtv_functionality,
 };
index 8ef6399d794f82cb8ac9cb9df049da89f750e18f..2dac48fa1386248fe839fff873034bd582afd05a 100644 (file)
@@ -338,7 +338,7 @@ static u32 functionality(struct i2c_adapter *adap)
        return I2C_FUNC_SMBUS_EMUL;
 }
 
-static struct i2c_algorithm saa7134_algo = {
+static const struct i2c_algorithm saa7134_algo = {
        .master_xfer   = saa7134_i2c_xfer,
        .functionality = functionality,
 };
index 0342d84913b855e4f7e5cac017c87356c1839f89..024f4e29e8400d192b566966b9b291511907e1af 100644 (file)
@@ -75,7 +75,7 @@ static u32 saa7164_functionality(struct i2c_adapter *adap)
        return I2C_FUNC_I2C;
 }
 
-static struct i2c_algorithm saa7164_i2c_algo_template = {
+static const struct i2c_algorithm saa7164_i2c_algo_template = {
        .master_xfer    = i2c_xfer,
        .functionality  = saa7164_functionality,
 };
index 5146be2a1a501a81a6faba23a25d7b17f414d690..e5e5a1672bdbc3128622d99e62943447b8bb8e0f 100644 (file)
@@ -402,7 +402,7 @@ static u32 si4713_functionality(struct i2c_adapter *adapter)
        return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
 }
 
-static struct i2c_algorithm si4713_algo = {
+static const struct i2c_algorithm si4713_algo = {
        .master_xfer   = si4713_transfer,
        .functionality = si4713_functionality,
 };
index 3e7982ef180a83a9f4c08ee0bc5fdf40e91959b2..35e9acfe63d3bff8e9b349740a6ff5bcad95cf24 100644 (file)
@@ -454,7 +454,7 @@ static u32 functionality(struct i2c_adapter *adap)
        return I2C_FUNC_SMBUS_EMUL | I2C_FUNC_I2C;
 }
 
-static struct i2c_algorithm cx231xx_algo = {
+static const struct i2c_algorithm cx231xx_algo = {
        .master_xfer = cx231xx_i2c_xfer,
        .functionality = functionality,
 };
index 1a9e1e556706c46fae02f66be22b7690b0647e8f..8b690ac908a4b5439c467f63df169ee7c7e13e29 100644 (file)
@@ -855,7 +855,7 @@ static u32 functionality(struct i2c_adapter *i2c_adap)
        return 0;
 }
 
-static struct i2c_algorithm em28xx_algo = {
+static const struct i2c_algorithm em28xx_algo = {
        .master_xfer   = em28xx_i2c_xfer,
        .functionality = functionality,
 };
index 55addfa855d4d39e252087b16db850a6cca76cf7..c084bf794b56772fdec9f85b8a3200d8ad963a2d 100644 (file)
@@ -191,7 +191,7 @@ static u32 go7007_functionality(struct i2c_adapter *adapter)
        return I2C_FUNC_SMBUS_BYTE_DATA;
 }
 
-static struct i2c_algorithm go7007_algo = {
+static const struct i2c_algorithm go7007_algo = {
        .smbus_xfer     = go7007_smbus_xfer,
        .master_xfer    = go7007_i2c_master_xfer,
        .functionality  = go7007_functionality,
index 14d3f8c1ce4a4135193dab8b263dac34d2d9fe03..ed9bcaf08d5ec46df4b4b21af8fcaefd460dc47f 100644 (file)
@@ -1032,7 +1032,7 @@ static u32 go7007_usb_functionality(struct i2c_adapter *adapter)
        return (I2C_FUNC_SMBUS_EMUL) & ~I2C_FUNC_SMBUS_QUICK;
 }
 
-static struct i2c_algorithm go7007_usb_algo = {
+static const struct i2c_algorithm go7007_usb_algo = {
        .master_xfer    = go7007_usb_i2c_master_xfer,
        .functionality  = go7007_usb_functionality,
 };
index a38f58c4c6bf5c98201c0d26a3f688a8cfcc5ee6..608ae96dc0e570909f92dd7bd12f2362f7506e34 100644 (file)
@@ -180,7 +180,7 @@ static u32 hdpvr_functionality(struct i2c_adapter *adapter)
        return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
 }
 
-static struct i2c_algorithm hdpvr_algo = {
+static const struct i2c_algorithm hdpvr_algo = {
        .master_xfer   = hdpvr_transfer,
        .functionality = hdpvr_functionality,
 };
index 850cf285ada8d97e2f2348da39f139d041d6404b..3f2517be02bbad835ae826e900be0435f4d61518 100644 (file)
@@ -235,7 +235,7 @@ static u32 functionality(struct i2c_adapter *adap)
        return I2C_FUNC_SMBUS_EMUL;
 }
 
-static struct i2c_algorithm algo = {
+static const struct i2c_algorithm algo = {
        .master_xfer   = stk1160_i2c_xfer,
        .functionality = functionality,
 };