* [PATCH] pwm: constify pwm_ops structures
@ 2017-01-10 18:12 Bhumika Goyal
2017-01-18 10:49 ` Thierry Reding
0 siblings, 1 reply; 2+ messages in thread
From: Bhumika Goyal @ 2017-01-10 18:12 UTC (permalink / raw)
To: linux-arm-kernel
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 at 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 at p
|
bwm.chip.ops=&i at p
|
vp.chip.ops=&i at p
|
icp.chip.ops=&i at p
)
@bad@
position p!={r1.p,ok1.p};
identifier r1.i;
@@
i at 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>
---
File: drivers/pwm/pwm-bfin.c is not tested
drivers/pwm/pwm-bfin.c | 2 +-
drivers/pwm/pwm-imx.c | 2 +-
drivers/pwm/pwm-pxa.c | 2 +-
drivers/pwm/pwm-vt8500.c | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/pwm/pwm-bfin.c b/drivers/pwm/pwm-bfin.c
index 7631ef1..d2ed0a2 100644
--- a/drivers/pwm/pwm-bfin.c
+++ b/drivers/pwm/pwm-bfin.c
@@ -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,
diff --git a/drivers/pwm/pwm-imx.c b/drivers/pwm/pwm-imx.c
index d600fd5..177fb81 100644
--- a/drivers/pwm/pwm-imx.c
+++ b/drivers/pwm/pwm-imx.c
@@ -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,
diff --git a/drivers/pwm/pwm-pxa.c b/drivers/pwm/pwm-pxa.c
index 58b709f..4143a46 100644
--- a/drivers/pwm/pwm-pxa.c
+++ b/drivers/pwm/pwm-pxa.c
@@ -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,
diff --git a/drivers/pwm/pwm-vt8500.c b/drivers/pwm/pwm-vt8500.c
index cdb58fd..8141a49 100644
--- a/drivers/pwm/pwm-vt8500.c
+++ b/drivers/pwm/pwm-vt8500.c
@@ -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,
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* [PATCH] pwm: constify pwm_ops structures
2017-01-10 18:12 [PATCH] pwm: constify pwm_ops structures Bhumika Goyal
@ 2017-01-18 10:49 ` Thierry Reding
0 siblings, 0 replies; 2+ messages in thread
From: Thierry Reding @ 2017-01-18 10:49 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, Jan 10, 2017 at 11:42:06PM +0530, Bhumika Goyal wrote:
> 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 at 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 at p
> |
> bwm.chip.ops=&i at p
> |
> vp.chip.ops=&i at p
> |
> icp.chip.ops=&i at p
> )
>
> @bad@
> position p!={r1.p,ok1.p};
> identifier r1.i;
> @@
> i at 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>
> ---
> File: drivers/pwm/pwm-bfin.c is not tested
>
> drivers/pwm/pwm-bfin.c | 2 +-
> drivers/pwm/pwm-imx.c | 2 +-
> drivers/pwm/pwm-pxa.c | 2 +-
> drivers/pwm/pwm-vt8500.c | 2 +-
> 4 files changed, 4 insertions(+), 4 deletions(-)
Applied, thanks.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170118/34466a59/attachment-0001.sig>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-01-18 10:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-10 18:12 [PATCH] pwm: constify pwm_ops structures Bhumika Goyal
2017-01-18 10:49 ` Thierry Reding
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).