From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751857AbdA2ReE (ORCPT ); Sun, 29 Jan 2017 12:34:04 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:34249 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751215AbdA2ReB (ORCPT ); Sun, 29 Jan 2017 12:34:01 -0500 From: Bhumika Goyal To: julia.lawall@lip6.fr, benh@kernel.crashing.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Cc: Bhumika Goyal Subject: [PATCH] macintosh: windfarm_smu_sensors: constify wf_sensor_ops structures Date: Sun, 29 Jan 2017 22:56:28 +0530 Message-Id: <1485710788-3662-1-git-send-email-bhumirks@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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@p={...}; @ok@ struct smu_ad_sensor ads; struct smu_cpu_power_sensor pow; identifier r.x; position p; @@ ( ads.sens.ops=&x@p; | pow.sens.ops=&x@p; ) @bad@ position p != {r.p,ok.p}; identifier r.x; @@ x@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 --- 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