Skip to content

Commit 9c27847

Browse files
mcgrofrustyrussell
authored andcommitted
kernel/params: constify struct kernel_param_ops uses
Most code already uses consts for the struct kernel_param_ops, sweep the kernel for the last offending stragglers. Other than include/linux/moduleparam.h and kernel/params.c all other changes were generated with the following Coccinelle SmPL patch. Merge conflicts between trees can be handled with Coccinelle. In the future git could get Coccinelle merge support to deal with patch --> fail --> grammar --> Coccinelle --> new patch conflicts automatically for us on patches where the grammar is available and the patch is of high confidence. Consider this a feature request. Test compiled on x86_64 against: * allnoconfig * allmodconfig * allyesconfig @ const_found @ identifier ops; @@ const struct kernel_param_ops ops = { }; @ const_not_found depends on !const_found @ identifier ops; @@ -struct kernel_param_ops ops = { +const struct kernel_param_ops ops = { }; Generated-by: Coccinelle SmPL Cc: Rusty Russell <rusty@rustcorp.com.au> Cc: Junio C Hamano <gitster@pobox.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Kees Cook <keescook@chromium.org> Cc: Tejun Heo <tj@kernel.org> Cc: Ingo Molnar <mingo@kernel.org> Cc: cocci@systeme.lip6.fr Cc: linux-kernel@vger.kernel.org Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent 28b8d0c commit 9c27847

27 files changed

Lines changed: 66 additions & 66 deletions

File tree

‎arch/s390/kernel/perf_cpum_sf.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1572,7 +1572,7 @@ static int param_set_sfb_size(const char *val, const struct kernel_param *kp)
15721572
}
15731573

15741574
#define param_check_sfb_size(name, p) __param_check(name, p, void)
1575-
static struct kernel_param_ops param_ops_sfb_size = {
1575+
static const struct kernel_param_ops param_ops_sfb_size = {
15761576
.set = param_set_sfb_size,
15771577
.get = param_get_sfb_size,
15781578
};

‎arch/x86/kvm/mmu_audit.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ static int mmu_audit_set(const char *val, const struct kernel_param *kp)
291291
return 0;
292292
}
293293

294-
static struct kernel_param_ops audit_param_ops = {
294+
static const struct kernel_param_ops audit_param_ops = {
295295
.set = mmu_audit_set,
296296
.get = param_get_bool,
297297
};

‎arch/x86/platform/uv/uv_nmi.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ static int param_set_local64(const char *val, const struct kernel_param *kp)
104104
return 0;
105105
}
106106

107-
static struct kernel_param_ops param_ops_local64 = {
107+
static const struct kernel_param_ops param_ops_local64 = {
108108
.get = param_get_local64,
109109
.set = param_set_local64,
110110
};

‎drivers/block/null_blk.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ static int null_set_queue_mode(const char *str, const struct kernel_param *kp)
9999
return null_param_store_val(str, &queue_mode, NULL_Q_BIO, NULL_Q_MQ);
100100
}
101101

102-
static struct kernel_param_ops null_queue_mode_param_ops = {
102+
static const struct kernel_param_ops null_queue_mode_param_ops = {
103103
.set = null_set_queue_mode,
104104
.get = param_get_int,
105105
};
@@ -127,7 +127,7 @@ static int null_set_irqmode(const char *str, const struct kernel_param *kp)
127127
NULL_IRQ_TIMER);
128128
}
129129

130-
static struct kernel_param_ops null_irqmode_param_ops = {
130+
static const struct kernel_param_ops null_irqmode_param_ops = {
131131
.set = null_set_irqmode,
132132
.get = param_get_int,
133133
};

‎drivers/char/ipmi/ipmi_watchdog.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ static int set_param_timeout(const char *val, const struct kernel_param *kp)
208208
return rv;
209209
}
210210

211-
static struct kernel_param_ops param_ops_timeout = {
211+
static const struct kernel_param_ops param_ops_timeout = {
212212
.set = set_param_timeout,
213213
.get = param_get_int,
214214
};
@@ -270,14 +270,14 @@ static int set_param_wdog_ifnum(const char *val, const struct kernel_param *kp)
270270
return 0;
271271
}
272272

273-
static struct kernel_param_ops param_ops_wdog_ifnum = {
273+
static const struct kernel_param_ops param_ops_wdog_ifnum = {
274274
.set = set_param_wdog_ifnum,
275275
.get = param_get_int,
276276
};
277277

278278
#define param_check_wdog_ifnum param_check_int
279279

280-
static struct kernel_param_ops param_ops_str = {
280+
static const struct kernel_param_ops param_ops_str = {
281281
.set = set_param_str,
282282
.get = get_param_str,
283283
};

‎drivers/dma/dmatest.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ static struct dmatest_info {
120120

121121
static int dmatest_run_set(const char *val, const struct kernel_param *kp);
122122
static int dmatest_run_get(char *val, const struct kernel_param *kp);
123-
static struct kernel_param_ops run_ops = {
123+
static const struct kernel_param_ops run_ops = {
124124
.set = dmatest_run_set,
125125
.get = dmatest_run_get,
126126
};
@@ -195,7 +195,7 @@ static int dmatest_wait_get(char *val, const struct kernel_param *kp)
195195
return param_get_bool(val, kp);
196196
}
197197

198-
static struct kernel_param_ops wait_ops = {
198+
static const struct kernel_param_ops wait_ops = {
199199
.get = dmatest_wait_get,
200200
.set = param_set_bool,
201201
};

‎drivers/ide/ide.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ static int ide_set_dev_param_mask(const char *s, const struct kernel_param *kp)
199199
return 0;
200200
}
201201

202-
static struct kernel_param_ops param_ops_ide_dev_mask = {
202+
static const struct kernel_param_ops param_ops_ide_dev_mask = {
203203
.set = ide_set_dev_param_mask
204204
};
205205

‎drivers/infiniband/ulp/srp/ib_srp.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ module_param(register_always, bool, 0444);
9898
MODULE_PARM_DESC(register_always,
9999
"Use memory registration even for contiguous memory regions");
100100

101-
static struct kernel_param_ops srp_tmo_ops;
101+
static const struct kernel_param_ops srp_tmo_ops;
102102

103103
static int srp_reconnect_delay = 10;
104104
module_param_cb(reconnect_delay, &srp_tmo_ops, &srp_reconnect_delay,
@@ -183,7 +183,7 @@ static int srp_tmo_set(const char *val, const struct kernel_param *kp)
183183
return res;
184184
}
185185

186-
static struct kernel_param_ops srp_tmo_ops = {
186+
static const struct kernel_param_ops srp_tmo_ops = {
187187
.get = srp_tmo_get,
188188
.set = srp_tmo_set,
189189
};

‎drivers/input/misc/ati_remote2.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ static int ati_remote2_get_mode_mask(char *buffer,
9494

9595
static unsigned int channel_mask = ATI_REMOTE2_MAX_CHANNEL_MASK;
9696
#define param_check_channel_mask(name, p) __param_check(name, p, unsigned int)
97-
static struct kernel_param_ops param_ops_channel_mask = {
97+
static const struct kernel_param_ops param_ops_channel_mask = {
9898
.set = ati_remote2_set_channel_mask,
9999
.get = ati_remote2_get_channel_mask,
100100
};
@@ -103,7 +103,7 @@ MODULE_PARM_DESC(channel_mask, "Bitmask of channels to accept <15:Channel16>...<
103103

104104
static unsigned int mode_mask = ATI_REMOTE2_MAX_MODE_MASK;
105105
#define param_check_mode_mask(name, p) __param_check(name, p, unsigned int)
106-
static struct kernel_param_ops param_ops_mode_mask = {
106+
static const struct kernel_param_ops param_ops_mode_mask = {
107107
.set = ati_remote2_set_mode_mask,
108108
.get = ati_remote2_get_mode_mask,
109109
};

‎drivers/input/mouse/psmouse-base.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ MODULE_LICENSE("GPL");
4747
static unsigned int psmouse_max_proto = PSMOUSE_AUTO;
4848
static int psmouse_set_maxproto(const char *val, const struct kernel_param *);
4949
static int psmouse_get_maxproto(char *buffer, const struct kernel_param *kp);
50-
static struct kernel_param_ops param_ops_proto_abbrev = {
50+
static const struct kernel_param_ops param_ops_proto_abbrev = {
5151
.set = psmouse_set_maxproto,
5252
.get = psmouse_get_maxproto,
5353
};

0 commit comments

Comments
 (0)