* [PATCH] rtc: add const to rtc_class_ops structures
@ 2017-01-05 17:18 Bhumika Goyal
2017-01-11 0:14 ` Alexandre Belloni
0 siblings, 1 reply; 2+ messages in thread
From: Bhumika Goyal @ 2017-01-05 17:18 UTC (permalink / raw)
To: julia.lawall, a.zummo, alexandre.belloni, rtc-linux,
adi-buildroot-devel, linux-kernel
Cc: Bhumika Goyal
Declare rtc_class_ops structures as const as they are only passed
as an argument to the function devm_rtc_device_register. This argument
is of type const struct rtc_class_ops *, so rtc_class_ops structures
having this property can be declared const.
Done using Coccinelle:
@r1 disable optional_qualifier @
identifier i;
position p;
@@
static struct rtc_class_ops i@p = {...};
@ok1@
identifier r1.i;
position p;
@@
devm_rtc_device_register(...,&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 rtc_class_ops i;
Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
---
Compilation was terminated while compiling the .o files for all the
changed .c files. Therefore file size details of the .o files
could not be obtained.
drivers/rtc/rtc-au1xxx.c | 2 +-
drivers/rtc/rtc-bfin.c | 2 +-
drivers/rtc/rtc-ls1x.c | 2 +-
drivers/rtc/rtc-sh.c | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/rtc/rtc-au1xxx.c b/drivers/rtc/rtc-au1xxx.c
index 84d6e02..2ba44cc 100644
--- a/drivers/rtc/rtc-au1xxx.c
+++ b/drivers/rtc/rtc-au1xxx.c
@@ -56,7 +56,7 @@ static int au1xtoy_rtc_set_time(struct device *dev, struct rtc_time *tm)
return 0;
}
-static struct rtc_class_ops au1xtoy_rtc_ops = {
+static const struct rtc_class_ops au1xtoy_rtc_ops = {
.read_time = au1xtoy_rtc_read_time,
.set_time = au1xtoy_rtc_set_time,
};
diff --git a/drivers/rtc/rtc-bfin.c b/drivers/rtc/rtc-bfin.c
index 535a5f9..15344b7 100644
--- a/drivers/rtc/rtc-bfin.c
+++ b/drivers/rtc/rtc-bfin.c
@@ -333,7 +333,7 @@ static int bfin_rtc_proc(struct device *dev, struct seq_file *seq)
#undef yesno
}
-static struct rtc_class_ops bfin_rtc_ops = {
+static const struct rtc_class_ops bfin_rtc_ops = {
.read_time = bfin_rtc_read_time,
.set_time = bfin_rtc_set_time,
.read_alarm = bfin_rtc_read_alarm,
diff --git a/drivers/rtc/rtc-ls1x.c b/drivers/rtc/rtc-ls1x.c
index 22a9ec4..e04ca54 100644
--- a/drivers/rtc/rtc-ls1x.c
+++ b/drivers/rtc/rtc-ls1x.c
@@ -138,7 +138,7 @@ static int ls1x_rtc_set_time(struct device *dev, struct rtc_time *rtm)
return ret;
}
-static struct rtc_class_ops ls1x_rtc_ops = {
+static const struct rtc_class_ops ls1x_rtc_ops = {
.read_time = ls1x_rtc_read_time,
.set_time = ls1x_rtc_set_time,
};
diff --git a/drivers/rtc/rtc-sh.c b/drivers/rtc/rtc-sh.c
index 17b6235..c626e43 100644
--- a/drivers/rtc/rtc-sh.c
+++ b/drivers/rtc/rtc-sh.c
@@ -535,7 +535,7 @@ static int sh_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *wkalrm)
return 0;
}
-static struct rtc_class_ops sh_rtc_ops = {
+static const struct rtc_class_ops sh_rtc_ops = {
.read_time = sh_rtc_read_time,
.set_time = sh_rtc_set_time,
.read_alarm = sh_rtc_read_alarm,
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] rtc: add const to rtc_class_ops structures
2017-01-05 17:18 [PATCH] rtc: add const to rtc_class_ops structures Bhumika Goyal
@ 2017-01-11 0:14 ` Alexandre Belloni
0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Belloni @ 2017-01-11 0:14 UTC (permalink / raw)
To: Bhumika Goyal
Cc: julia.lawall, a.zummo, rtc-linux, adi-buildroot-devel, linux-kernel
On 05/01/2017 at 22:48:37 +0530, Bhumika Goyal wrote :
> Declare rtc_class_ops structures as const as they are only passed
> as an argument to the function devm_rtc_device_register. This argument
> is of type const struct rtc_class_ops *, so rtc_class_ops structures
> having this property can be declared const.
> Done using Coccinelle:
>
> @r1 disable optional_qualifier @
> identifier i;
> position p;
> @@
> static struct rtc_class_ops i@p = {...};
>
> @ok1@
> identifier r1.i;
> position p;
> @@
> devm_rtc_device_register(...,&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 rtc_class_ops i;
>
> Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
> ---
> Compilation was terminated while compiling the .o files for all the
> changed .c files. Therefore file size details of the .o files
> could not be obtained.
>
> drivers/rtc/rtc-au1xxx.c | 2 +-
> drivers/rtc/rtc-bfin.c | 2 +-
> drivers/rtc/rtc-ls1x.c | 2 +-
> drivers/rtc/rtc-sh.c | 2 +-
> 4 files changed, 4 insertions(+), 4 deletions(-)
>
Applied and squashed in the previous one.
--
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-01-11 0:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-05 17:18 [PATCH] rtc: add const to rtc_class_ops structures Bhumika Goyal
2017-01-11 0:14 ` Alexandre Belloni
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).