Skip to content
This repository was archived by the owner on May 17, 2022. It is now read-only.

Commit

Permalink
kernel/params: constify struct kernel_param_ops uses
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Junio C Hamano <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Kees Cook <[email protected]>
Cc: Tejun Heo <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Luis R. Rodriguez <[email protected]>
Signed-off-by: Rusty Russell <[email protected]>
Change-Id: I434bcf6b20d9038fb631dfa5fe81c441443360b7
  • Loading branch information
rustyrussell authored and pavlaras committed Aug 7, 2020
1 parent 60a02de commit 1346c66
Show file tree
Hide file tree
Showing 35 changed files with 55 additions and 55 deletions.
2 changes: 1 addition & 1 deletion arch/arm/mach-msm/test-lpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ static int lpm_cpu_update(const char *val, const struct kernel_param *kp)
return ret;
}

static struct kernel_param_ops cpu_debug_events = {
static const struct kernel_param_ops cpu_debug_events = {
.set = lpm_cpu_update,
};

Expand Down
2 changes: 1 addition & 1 deletion arch/x86/kvm/mmu_audit.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ static int mmu_audit_set(const char *val, const struct kernel_param *kp)
return 0;
}

static struct kernel_param_ops audit_param_ops = {
static const struct kernel_param_ops audit_param_ops = {
.set = mmu_audit_set,
.get = param_get_bool,
};
Expand Down
4 changes: 2 additions & 2 deletions drivers/bluetooth/hci_ath.c
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ static int bluesleep_lpm_set(const char *val, const struct kernel_param *kp)

}

static struct kernel_param_ops bluesleep_lpm_ops = {
static const struct kernel_param_ops bluesleep_lpm_ops = {
.set = bluesleep_lpm_set,
.get = param_get_int,
};
Expand Down Expand Up @@ -578,7 +578,7 @@ static int bluesleep_lpm_btwrite(const char *val, const struct kernel_param *kp)
return 0;
}

static struct kernel_param_ops bluesleep_lpm_btwrite_ops = {
static const struct kernel_param_ops bluesleep_lpm_btwrite_ops = {
.set = bluesleep_lpm_btwrite,
.get = param_get_int,
};
Expand Down
6 changes: 3 additions & 3 deletions drivers/char/ipmi/ipmi_watchdog.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ static int set_param_timeout(const char *val, const struct kernel_param *kp)
return rv;
}

static struct kernel_param_ops param_ops_timeout = {
static const struct kernel_param_ops param_ops_timeout = {
.set = set_param_timeout,
.get = param_get_int,
};
Expand Down Expand Up @@ -270,14 +270,14 @@ static int set_param_wdog_ifnum(const char *val, const struct kernel_param *kp)
return 0;
}

static struct kernel_param_ops param_ops_wdog_ifnum = {
static const struct kernel_param_ops param_ops_wdog_ifnum = {
.set = set_param_wdog_ifnum,
.get = param_get_int,
};

#define param_check_wdog_ifnum param_check_int

static struct kernel_param_ops param_ops_str = {
static const struct kernel_param_ops param_ops_str = {
.set = set_param_str,
.get = get_param_str,
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/ide/ide.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ static int ide_set_dev_param_mask(const char *s, const struct kernel_param *kp)
return 0;
}

static struct kernel_param_ops param_ops_ide_dev_mask = {
static const struct kernel_param_ops param_ops_ide_dev_mask = {
.set = ide_set_dev_param_mask
};

Expand Down
4 changes: 2 additions & 2 deletions drivers/input/misc/ati_remote2.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ static int ati_remote2_get_mode_mask(char *buffer,

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

static unsigned int mode_mask = ATI_REMOTE2_MAX_MODE_MASK;
#define param_check_mode_mask(name, p) __param_check(name, p, unsigned int)
static struct kernel_param_ops param_ops_mode_mask = {
static const struct kernel_param_ops param_ops_mode_mask = {
.set = ati_remote2_set_mode_mask,
.get = ati_remote2_get_mode_mask,
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/input/mouse/psmouse-base.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ MODULE_LICENSE("GPL");
static unsigned int psmouse_max_proto = PSMOUSE_AUTO;
static int psmouse_set_maxproto(const char *val, const struct kernel_param *);
static int psmouse_get_maxproto(char *buffer, const struct kernel_param *kp);
static struct kernel_param_ops param_ops_proto_abbrev = {
static const struct kernel_param_ops param_ops_proto_abbrev = {
.set = psmouse_set_maxproto,
.get = psmouse_get_maxproto,
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/misc/lis3lv02d/lis3lv02d.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ static int param_set_axis(const char *val, const struct kernel_param *kp)
return ret;
}

static struct kernel_param_ops param_ops_axis = {
static const struct kernel_param_ops param_ops_axis = {
.set = param_set_axis,
.get = param_get_int,
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/usb/rmnet_usb_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ static int rmnet_init(const char *val, const struct kernel_param *kp)
return ret;
}

static struct kernel_param_ops rmnet_init_ops = {
static const struct kernel_param_ops rmnet_init_ops = {
.set = rmnet_init,
.get = param_get_bool,
};
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/wireless/ath/wil6210/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ static int mtu_max_set(const char *val, const struct kernel_param *kp)
return ret;
}

static struct kernel_param_ops mtu_max_ops = {
static const struct kernel_param_ops mtu_max_ops = {
.set = mtu_max_set,
.get = param_get_uint,
};
Expand Down Expand Up @@ -118,7 +118,7 @@ static int ring_order_set(const char *val, const struct kernel_param *kp)
return 0;
}

static struct kernel_param_ops ring_order_ops = {
static const struct kernel_param_ops ring_order_ops = {
.set = ring_order_set,
.get = param_get_uint,
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/platform/msm/qpnp-power-on.c
Original file line number Diff line number Diff line change
Expand Up @@ -1651,7 +1651,7 @@ static int qpnp_pon_debugfs_uvlo_dload_set(const char *val,
return 0;
}

static struct kernel_param_ops dload_on_uvlo_ops = {
static const struct kernel_param_ops dload_on_uvlo_ops = {
.set = qpnp_pon_debugfs_uvlo_dload_set,
.get = qpnp_pon_debugfs_uvlo_dload_get,
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/power/qpnp-bms.c
Original file line number Diff line number Diff line change
Expand Up @@ -1734,7 +1734,7 @@ static int bms_reset_set(const char *val, const struct kernel_param *kp)
return 0;
}

static struct kernel_param_ops bms_reset_ops = {
static const struct kernel_param_ops bms_reset_ops = {
.set = bms_reset_set,
.get = param_get_bool,
};
Expand Down
4 changes: 2 additions & 2 deletions drivers/power/qpnp-charger.c
Original file line number Diff line number Diff line change
Expand Up @@ -513,12 +513,12 @@ static int ext_ovp_isns_enable(const char *val, const struct kernel_param *kp)
return rc;
}

static struct kernel_param_ops ext_ovp_isns_ops = {
static const struct kernel_param_ops ext_ovp_isns_ops = {
.get = ext_ovp_isns_read,
};
module_param_cb(ext_ovp_isns_ua, &ext_ovp_isns_ops, &ext_ovp_isns_ua, 0644);

static struct kernel_param_ops ext_ovp_en_ops = {
static const struct kernel_param_ops ext_ovp_en_ops = {
.set = ext_ovp_isns_enable,
.get = param_get_bool,
};
Expand Down
4 changes: 2 additions & 2 deletions drivers/power/qpnp-fg.c
Original file line number Diff line number Diff line change
Expand Up @@ -5566,7 +5566,7 @@ static int fg_sense_type_set(const char *val, const struct kernel_param *kp)
return rc;
}

static struct kernel_param_ops fg_sense_type_ops = {
static const struct kernel_param_ops fg_sense_type_ops = {
.set = fg_sense_type_set,
.get = param_get_int,
};
Expand Down Expand Up @@ -5600,7 +5600,7 @@ static int fg_restart_set(const char *val, const struct kernel_param *kp)
return 0;
}

static struct kernel_param_ops fg_restart_ops = {
static const struct kernel_param_ops fg_restart_ops = {
.set = fg_restart_set,
.get = param_get_int,
};
Expand Down
16 changes: 8 additions & 8 deletions drivers/power/test_power.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,42 +422,42 @@ static int param_set_battery_voltage(const char *key,

#define param_get_battery_voltage param_get_int

static struct kernel_param_ops param_ops_ac_online = {
static const struct kernel_param_ops param_ops_ac_online = {
.set = param_set_ac_online,
.get = param_get_ac_online,
};

static struct kernel_param_ops param_ops_usb_online = {
static const struct kernel_param_ops param_ops_usb_online = {
.set = param_set_usb_online,
.get = param_get_usb_online,
};

static struct kernel_param_ops param_ops_battery_status = {
static const struct kernel_param_ops param_ops_battery_status = {
.set = param_set_battery_status,
.get = param_get_battery_status,
};

static struct kernel_param_ops param_ops_battery_present = {
static const struct kernel_param_ops param_ops_battery_present = {
.set = param_set_battery_present,
.get = param_get_battery_present,
};

static struct kernel_param_ops param_ops_battery_technology = {
static const struct kernel_param_ops param_ops_battery_technology = {
.set = param_set_battery_technology,
.get = param_get_battery_technology,
};

static struct kernel_param_ops param_ops_battery_health = {
static const struct kernel_param_ops param_ops_battery_health = {
.set = param_set_battery_health,
.get = param_get_battery_health,
};

static struct kernel_param_ops param_ops_battery_capacity = {
static const struct kernel_param_ops param_ops_battery_capacity = {
.set = param_set_battery_capacity,
.get = param_get_battery_capacity,
};

static struct kernel_param_ops param_ops_battery_voltage = {
static const struct kernel_param_ops param_ops_battery_voltage = {
.set = param_set_battery_voltage,
.get = param_get_battery_voltage,
};
Expand Down
4 changes: 2 additions & 2 deletions drivers/soc/qcom/mct.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,12 +506,12 @@ static int mct_enable_show(char *buf, const struct kernel_param *kp)
return validate_and_show(MCT_ENABLE, buf);
}

static struct kernel_param_ops pmic_notify_ops = {
static const struct kernel_param_ops pmic_notify_ops = {
.set = param_set_bool,
.get = param_get_bool,
};

static struct kernel_param_ops module_ops = {
static const struct kernel_param_ops module_ops = {
.set = mct_enable_store,
.get = mct_enable_show,
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/soc/qcom/scm-mpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static int set_enabled(const char *val, const struct kernel_param *kp)
return ret;
}

static struct kernel_param_ops mpu_ops = {
static const struct kernel_param_ops mpu_ops = {
.set = set_enabled,
.get = param_get_int,
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/android/lowmemorykiller.c
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ static void lowmem_adj_array_free(void *arg)
param_array_ops.free(arg);
}

static struct kernel_param_ops lowmem_adj_array_ops = {
static const struct kernel_param_ops lowmem_adj_array_ops = {
.set = lowmem_adj_array_set,
.get = lowmem_adj_array_get,
.free = lowmem_adj_array_free,
Expand Down
4 changes: 2 additions & 2 deletions drivers/thermal/intel_powerclamp.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ static int duration_set(const char *arg, const struct kernel_param *kp)
return ret;
}

static struct kernel_param_ops duration_ops = {
static const struct kernel_param_ops duration_ops = {
.set = duration_set,
.get = param_get_int,
};
Expand Down Expand Up @@ -167,7 +167,7 @@ static int window_size_set(const char *arg, const struct kernel_param *kp)
return ret;
}

static struct kernel_param_ops window_size_ops = {
static const struct kernel_param_ops window_size_ops = {
.set = window_size_set,
.get = param_get_int,
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/thermal/msm_thermal.c
Original file line number Diff line number Diff line change
Expand Up @@ -4277,7 +4277,7 @@ static int __ref set_enabled(const char *val, const struct kernel_param *kp)
return ret;
}

static struct kernel_param_ops module_ops = {
static const struct kernel_param_ops module_ops = {
.set = set_enabled,
.get = param_get_bool,
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/tty/hvc/hvc_iucv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1203,7 +1203,7 @@ static int param_get_vmidfilter(char *buffer, const struct kernel_param *kp)

#define param_check_vmidfilter(name, p) __param_check(name, p, void)

static struct kernel_param_ops param_ops_vmidfilter = {
static const struct kernel_param_ops param_ops_vmidfilter = {
.set = param_set_vmidfilter,
.get = param_get_vmidfilter,
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/tty/sysrq.c
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ static int sysrq_reset_seq_param_set(const char *buffer,
return 0;
}

static struct kernel_param_ops param_ops_sysrq_reset_seq = {
static const struct kernel_param_ops param_ops_sysrq_reset_seq = {
.get = param_get_ushort,
.set = sysrq_reset_seq_param_set,
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/host/xhci-msm-hsic.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ static int set_host_ready(const char *val, const struct kernel_param *kp)
return ret;
}

static struct kernel_param_ops host_ready_ops = {
static const struct kernel_param_ops host_ready_ops = {
.set = set_host_ready,
.get = param_get_bool,
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/phy/otg-wakelock.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ static int set_enabled(const char *val, const struct kernel_param *kp)
return 0;
}

static struct kernel_param_ops enabled_param_ops = {
static const struct kernel_param_ops enabled_param_ops = {
.set = set_enabled,
.get = param_get_bool,
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/video/msm/mdss/mdss_hdmi_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -4534,7 +4534,7 @@ static int set_hdcp_feature_on(const char *val, const struct kernel_param *kp)
return rc;
}

static struct kernel_param_ops hdcp_feature_on_param_ops = {
static const struct kernel_param_ops hdcp_feature_on_param_ops = {
.set = set_hdcp_feature_on,
.get = param_get_bool,
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/video/uvesafb.c
Original file line number Diff line number Diff line change
Expand Up @@ -2029,7 +2029,7 @@ static int param_set_scroll(const char *val, const struct kernel_param *kp)

return 0;
}
static struct kernel_param_ops param_ops_scroll = {
static const struct kernel_param_ops param_ops_scroll = {
.set = param_set_scroll,
};
#define param_check_scroll(name, p) __param_check(name, p, void)
Expand Down
2 changes: 1 addition & 1 deletion drivers/virtio/virtio_mmio.c
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ static int vm_cmdline_get(char *buffer, const struct kernel_param *kp)
return strlen(buffer) + 1;
}

static struct kernel_param_ops vm_cmdline_param_ops = {
static const struct kernel_param_ops vm_cmdline_param_ops = {
.set = vm_cmdline_set,
.get = vm_cmdline_get,
};
Expand Down
2 changes: 1 addition & 1 deletion fs/nfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -2741,7 +2741,7 @@ static int param_set_portnr(const char *val, const struct kernel_param *kp)
*((unsigned int *)kp->arg) = num;
return 0;
}
static struct kernel_param_ops param_ops_portnr = {
static const struct kernel_param_ops param_ops_portnr = {
.set = param_set_portnr,
.get = param_get_uint,
};
Expand Down
2 changes: 1 addition & 1 deletion include/linux/moduleparam.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ struct kparam_array

/* Obsolete - use module_param_cb() */
#define module_param_call(name, set, get, arg, perm) \
static struct kernel_param_ops __param_ops_##name = \
static const struct kernel_param_ops __param_ops_##name = \
{ (void *)set, (void *)get }; \
__module_param_call(MODULE_PARAM_PREFIX, \
name, &__param_ops_##name, arg, \
Expand Down
2 changes: 1 addition & 1 deletion net/sunrpc/auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ static int param_get_hashtbl_sz(char *buffer, const struct kernel_param *kp)

#define param_check_hashtbl_sz(name, p) __param_check(name, p, unsigned int);

static struct kernel_param_ops param_ops_hashtbl_sz = {
static const struct kernel_param_ops param_ops_hashtbl_sz = {
.set = param_set_hashtbl_sz,
.get = param_get_hashtbl_sz,
};
Expand Down
Loading

0 comments on commit 1346c66

Please sign in to comment.