pwm: constify pwm_ops structures
authorBhumika Goyal <bhumirks@gmail.com>
Tue, 10 Jan 2017 18:12:06 +0000 (23:42 +0530)
committerThierry Reding <thierry.reding@gmail.com>
Wed, 18 Jan 2017 23:38:17 +0000 (00:38 +0100)
Declare pwm_ops structures as const as they are only stored in the ops
field of a pwm_chip structure. This field is of type const struct pwm_ops
*, so pwm_ops structures having this property can be declared as const.
Done using Coccinelle:

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

@ok1@
identifier r1.i;
position p;
struct pxa_pwm_chip pwm;
struct bfin_pwm_chip bwm;
struct vt8500_chip vp;
struct imx_chip icp;
@@
(
pwm.chip.ops=&i@p
|
bwm.chip.ops=&i@p
|
vp.chip.ops=&i@p
|
icp.chip.ops=&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 pwm_ops i;

File size details:

   text    data     bss     dec     hex filename
   1646     328       0    1974     7b6 drivers/pwm/pwm-imx.o
   1742     224       0    1966     7ae drivers/pwm/pwm-imx.o

   1941     296       0    2237     8bd drivers/pwm/pwm-pxa.o
   2037     192       0    2229     8b5 drivers/pwm/pwm-pxa.o

   1946     296       0    2242     8c2 drivers/pwm/pwm-vt8500.o
   2050     192       0    2242     8c2 drivers/pwm/pwm-vt8500.o

The drivers/pwm/pwm-bfin.o file did not compile.

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
drivers/pwm/pwm-bfin.c
drivers/pwm/pwm-imx.c
drivers/pwm/pwm-pxa.c
drivers/pwm/pwm-vt8500.c

index 7631ef194de7dc80ba28b98da9b340e519ac5095..d2ed0a2a18e886912cdd96393564450750aa0063 100644 (file)
@@ -103,7 +103,7 @@ static void bfin_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
        disable_gptimer(priv->pin);
 }
 
-static struct pwm_ops bfin_pwm_ops = {
+static const struct pwm_ops bfin_pwm_ops = {
        .request = bfin_pwm_request,
        .free = bfin_pwm_free,
        .config = bfin_pwm_config,
index d600fd5cd4bac9a434a20798328d513d89b5452f..177fb81c916da93d1bf22b64cb736460e4900343 100644 (file)
@@ -240,7 +240,7 @@ static void imx_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
        clk_disable_unprepare(imx->clk_per);
 }
 
-static struct pwm_ops imx_pwm_ops = {
+static const struct pwm_ops imx_pwm_ops = {
        .enable = imx_pwm_enable,
        .disable = imx_pwm_disable,
        .config = imx_pwm_config,
index 58b709f291302158bb1643fdd7f3f5d6dcbcea98..4143a46684d2cc587789e154f12989e4e6167ed5 100644 (file)
@@ -118,7 +118,7 @@ static void pxa_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
        clk_disable_unprepare(pc->clk);
 }
 
-static struct pwm_ops pxa_pwm_ops = {
+static const struct pwm_ops pxa_pwm_ops = {
        .config = pxa_pwm_config,
        .enable = pxa_pwm_enable,
        .disable = pxa_pwm_disable,
index cdb58fd4619d21e2225b171ffdad2de55641d653..8141a498412645ac183d50e808e392b49041a0d6 100644 (file)
@@ -184,7 +184,7 @@ static int vt8500_pwm_set_polarity(struct pwm_chip *chip,
        return 0;
 }
 
-static struct pwm_ops vt8500_pwm_ops = {
+static const struct pwm_ops vt8500_pwm_ops = {
        .enable = vt8500_pwm_enable,
        .disable = vt8500_pwm_disable,
        .config = vt8500_pwm_config,