[PATCH] macintosh: windfarm_smu_sensors: constify wf_sensor_ops structures
Bhumika Goyal
bhumirks at gmail.com
Mon Jan 30 04:26:28 AEDT 2017
Declare wf_sensor_ops structures as const as they are only stored in the
ops field of a wf_sensor structure. This field is of type const, so
wf_sensor_ops structures having this property can be made const too.
Done using Coccinelle:
@r disable optional_qualifier@
identifier x;
position p;
@@
static struct wf_sensor_ops x at p={...};
@ok@
struct smu_ad_sensor ads;
struct smu_cpu_power_sensor pow;
identifier r.x;
position p;
@@
(
ads.sens.ops=&x at p;
|
pow.sens.ops=&x at p;
)
@bad@
position p != {r.p,ok.p};
identifier r.x;
@@
x at p
@depends on !bad disable optional_qualifier@
identifier r.x;
@@
+const
struct wf_sensor_ops x;
Size details after cross compiling the .o file for powerpc architecture.
File size before:
text data bss dec hex filename
3700 408 48 4156 103c macintosh/windfarm_smu_sensors.o
File size after:
text data bss dec hex filename
3832 288 48 4168 1048 macintosh/windfarm_smu_sensors.o
Signed-off-by: Bhumika Goyal <bhumirks at gmail.com>
---
drivers/macintosh/windfarm_smu_sensors.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/macintosh/windfarm_smu_sensors.c b/drivers/macintosh/windfarm_smu_sensors.c
index 1cc4e49..172fd26 100644
--- a/drivers/macintosh/windfarm_smu_sensors.c
+++ b/drivers/macintosh/windfarm_smu_sensors.c
@@ -172,22 +172,22 @@ static int smu_slotspow_get(struct wf_sensor *sr, s32 *value)
}
-static struct wf_sensor_ops smu_cputemp_ops = {
+static const struct wf_sensor_ops smu_cputemp_ops = {
.get_value = smu_cputemp_get,
.release = smu_ads_release,
.owner = THIS_MODULE,
};
-static struct wf_sensor_ops smu_cpuamp_ops = {
+static const struct wf_sensor_ops smu_cpuamp_ops = {
.get_value = smu_cpuamp_get,
.release = smu_ads_release,
.owner = THIS_MODULE,
};
-static struct wf_sensor_ops smu_cpuvolt_ops = {
+static const struct wf_sensor_ops smu_cpuvolt_ops = {
.get_value = smu_cpuvolt_get,
.release = smu_ads_release,
.owner = THIS_MODULE,
};
-static struct wf_sensor_ops smu_slotspow_ops = {
+static const struct wf_sensor_ops smu_slotspow_ops = {
.get_value = smu_slotspow_get,
.release = smu_ads_release,
.owner = THIS_MODULE,
@@ -327,7 +327,7 @@ static int smu_cpu_power_get(struct wf_sensor *sr, s32 *value)
return 0;
}
-static struct wf_sensor_ops smu_cpu_power_ops = {
+static const struct wf_sensor_ops smu_cpu_power_ops = {
.get_value = smu_cpu_power_get,
.release = smu_cpu_power_release,
.owner = THIS_MODULE,
--
2.7.4
More information about the Linuxppc-dev
mailing list