Constify struct lock_manager_operations for 2.6.32-git-053fe57ac v2
cover Constify struct lock_manager_operations for 2.6.32-git-053fe57ac v2
From: Emese Revfy <[email protected]>
Hello everyone!
The following patch series attempts to constify several structures that hold function pointers. This is only the initial batch, there are about over 150 candidate structures, some of which can be constified as well, I plan to submit them in the future.
The list of constified structures in this series (* marks this thread):acpi_dock_opsaddress_space_operationsbacklight_opsblock_device_operationsdma_map_opsextent_io_opsfile_lock_operationsfile_operationshv_opsintel_dvo_dev_opsitem_operationsiwl_opskgdb_archkgdb_iokset_uevent_ops
* lock_manager_operationsmicrocode_opsmtrr_opsneigh_opsnlmsvc_bindingpci_raw_opsplatform_hibernation_opsplatform_suspend_opssnd_ac97_build_opssysfs_opsusb_mon_operationswd_ops
There are certain exceptions where a given instance of the structure cannot be const, they are marked with a comment in the patch.
The patches compile fine with an allyesconfig kernel on i386 and x86_64.
Please let me know if any of these structures should not be constified and any other issues you see with them.
Changelog:
----------
v1 -> v2
- updated to linus-git-053fe57
- extended comments with a reference to code that prevents constification
- split up patches by subsystem as suggested by Greg KH, Jiri Slaby
- added all Acked-by's received so far
- removed patch for super_operations for now
- removed patch for ptmx_fops
Thanks,
Emese
include/linux/fs.h | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-)
PATCH 1/1 Constify struct microcode_ops for 2.6.32-git-053fe57ac v2
From: Emese Revfy <[email protected]>
--- arch/x86/include/asm/microcode.h | 22 +++++++++++----------- arch/x86/kernel/microcode_amd.c | 4 ++-- arch/x86/kernel/microcode_core.c | 2 +- arch/x86/kernel/microcode_intel.c | 4 ++-- 4 files changed, 16 insertions(+), 16 deletions(-)
arch/x86/include/asm/microcode.h +11 -11
@@ -12,15 +12,15 @@ struct device;enum ucode_state {UCODE_ERROR ,UCODE_OK ,UCODE_NFOUND };struct microcode_ops { -void (*init)(struct device *device); -void (*fini)(void ); -enum ucode_state (*request_microcode_user) (int cpu, +void (*const init)(struct device *device); +void (*const fini)(void ); +enum ucode_state (*const request_microcode_user) (int cpu,const void __user *buf,size_t size); -enum ucode_state (*request_microcode_fw) (int cpu, +enum ucode_state (*const request_microcode_fw) (int cpu,struct device *device); -void (*microcode_fini_cpu) (int cpu); +void (*const microcode_fini_cpu) (int cpu);/* * The generic 'microcode_core' part guarantees that
@@ -28,8 +28,8 @@ struct microcode_ops {* are being called. * See also the "Synchronization" section in microcode_core.c. */ -int (*apply_microcode) (int cpu); -int (*collect_cpu_info) (int cpu,struct cpu_signature *csig); +int (*const apply_microcode) (int cpu); +int (*const collect_cpu_info) (int cpu,struct cpu_signature *csig); };struct ucode_cpu_info {
@@ -40,18 +40,18 @@ struct ucode_cpu_info {extern struct ucode_cpu_info ucode_cpu_info[];#ifdef CONFIG_MICROCODE_INTEL -extern struct microcode_ops *__init init_intel_microcode (void ); +extern const struct microcode_ops *__init init_intel_microcode (void );#else -static inline struct microcode_ops *__init init_intel_microcode (void ) +static inline const struct microcode_ops *__init init_intel_microcode (void ) {return NULL ; }#endif /* CONFIG_MICROCODE_INTEL */ #ifdef CONFIG_MICROCODE_AMD -extern struct microcode_ops *__init init_amd_microcode (void ); +extern const struct microcode_ops *__init init_amd_microcode (void );#else -static inline struct microcode_ops *__init init_amd_microcode (void ) +static inline const struct microcode_ops *__init init_amd_microcode (void ) {return NULL ; }
arch/x86/kernel/microcode_amd.c +2 -2
@@ -347,7 +347,7 @@ void fini_microcode_amd(void)release_firmware (firmware); } -static struct microcode_ops microcode_amd_ops = { +static const struct microcode_ops microcode_amd_ops = { .init = init_microcode_amd, .fini = fini_microcode_amd, .request_microcode_user = request_microcode_user,
@@ -357,7 +357,7 @@ static struct microcode_ops microcode_amd_ops = { .microcode_fini_cpu = microcode_fini_cpu_amd, }; -struct microcode_ops *__init init_amd_microcode (void ) +const struct microcode_ops *__init init_amd_microcode (void ) {return µcode_amd_ops; }
arch/x86/kernel/microcode_core.c +1 -1
@@ -92,7 +92,7 @@ MODULE_LICENSE("GPL");#define MICROCODE_VERSION "2.00" -static struct microcode_ops *microcode_ops; +static const struct microcode_ops *microcode_ops;/* * Synchronization.
arch/x86/kernel/microcode_intel.c +2 -2
@@ -453,7 +453,7 @@ static void microcode_fini_cpu(int cpu) uci->mc =NULL ; } -static struct microcode_ops microcode_intel_ops = { +static const struct microcode_ops microcode_intel_ops = { .request_microcode_user = request_microcode_user, .request_microcode_fw = request_microcode_fw, .collect_cpu_info = collect_cpu_info,
@@ -461,7 +461,7 @@ static struct microcode_ops microcode_intel_ops = { .microcode_fini_cpu = microcode_fini_cpu, }; -struct microcode_ops *__init init_intel_microcode (void ) +const struct microcode_ops *__init init_intel_microcode (void ) {return µcode_intel_ops; }
Signature · 1 line
1.6.5.3
PATCH 1/1 Constify struct mtrr_ops for 2.6.32-git-053fe57ac v2
In reply to [email protected]From: Emese Revfy <[email protected]>
--- arch/x86/kernel/cpu/mtrr/amd.c | 2 +- arch/x86/kernel/cpu/mtrr/centaur.c | 2 +- arch/x86/kernel/cpu/mtrr/cyrix.c | 2 +- arch/x86/kernel/cpu/mtrr/generic.c | 2 +- arch/x86/kernel/cpu/mtrr/main.c | 6 +++--- arch/x86/kernel/cpu/mtrr/mtrr.h | 22 +++++++++++----------- 6 files changed, 18 insertions(+), 18 deletions(-)
arch/x86/kernel/cpu/mtrr/amd.c +1 -1
@@ -108,7 +108,7 @@ amd_validate_add_page(unsigned long base, unsigned long size, unsigned int type)return 0 ; } -static struct mtrr_ops amd_mtrr_ops = { +static const struct mtrr_ops amd_mtrr_ops = { .vendor =X86_VENDOR_AMD , .set = amd_set_mtrr, .get = amd_get_mtrr,
arch/x86/kernel/cpu/mtrr/centaur.c +1 -1
@@ -110,7 +110,7 @@ centaur_validate_add_page(unsigned long base, unsigned long size, unsigned int treturn 0 ; } -static struct mtrr_ops centaur_mtrr_ops = { +static const struct mtrr_ops centaur_mtrr_ops = { .vendor =X86_VENDOR_CENTAUR , .set = centaur_set_mcr, .get = centaur_get_mcr,
arch/x86/kernel/cpu/mtrr/cyrix.c +1 -1
@@ -265,7 +265,7 @@ static void cyrix_set_all(void)post_set (); } -static struct mtrr_ops cyrix_mtrr_ops = { +static const struct mtrr_ops cyrix_mtrr_ops = { .vendor =X86_VENDOR_CYRIX , .set_all = cyrix_set_all, .set = cyrix_set_arr,
arch/x86/kernel/cpu/mtrr/generic.c +1 -1
@@ -752,7 +752,7 @@ int positive_have_wrcomb(void)/* * Generic structure... */ -struct mtrr_ops generic_mtrr_ops = { +const struct mtrr_ops generic_mtrr_ops = { .use_intel_if =1 , .set_all = generic_set_all, .get = generic_get_mtrr,
arch/x86/kernel/cpu/mtrr/main.c +3 -3
@@ -60,14 +60,14 @@ static DEFINE_MUTEX(mtrr_mutex);u64 size_or_mask, size_and_mask;static bool mtrr_aps_delayed_init; -static struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM ]; +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM ]; -struct mtrr_ops *mtrr_if; +const struct mtrr_ops *mtrr_if;static void set_mtrr (unsigned int reg,unsigned long base,unsigned long size,mtrr_type type); -void set_mtrr_ops (struct mtrr_ops *ops) +void set_mtrr_ops (const struct mtrr_ops *ops) {if (ops->vendor && ops->vendor <X86_VENDOR_NUM ) mtrr_ops[ops->vendor] = ops;
arch/x86/kernel/cpu/mtrr/mtrr.h +11 -11
@@ -12,19 +12,19 @@extern unsigned int mtrr_usage_table[MTRR_MAX_VAR_RANGES ];struct mtrr_ops { -u32 vendor; -u32 use_intel_if; -void (*set)(unsigned int reg,unsigned long base, +const u32 vendor; +const u32 use_intel_if; +void (*const set)(unsigned int reg,unsigned long base,unsigned long size,mtrr_type type); -void (*set_all)(void ); +void (*const set_all)(void ); -void (*get)(unsigned int reg,unsigned long *base, +void (*const get)(unsigned int reg,unsigned long *base,unsigned long *size,mtrr_type *type); -int (*get_free_region)(unsigned long base,unsigned long size, +int (*const get_free_region)(unsigned long base,unsigned long size,int replace_reg); -int (*validate_add_page)(unsigned long base,unsigned long size, +int (*const validate_add_page)(unsigned long base,unsigned long size,unsigned int type); -int (*have_wrcomb)(void ); +int (*const have_wrcomb)(void ); }; extern int generic_get_free_region(unsigned long base, unsigned long size,
@@ -32,7 +32,7 @@ extern int generic_get_free_region(unsigned long base, unsigned long size,extern int generic_validate_add_page (unsigned long base,unsigned long size,unsigned int type); -extern struct mtrr_ops generic_mtrr_ops; +extern const struct mtrr_ops generic_mtrr_ops;extern int positive_have_wrcomb (void );
@@ -53,10 +53,10 @@ void fill_mtrr_var_range(unsigned int index, u32 base_lo, u32 base_hi, u32 mask_lo, u32 mask_hi);void get_mtrr_state (void ); -extern void set_mtrr_ops (struct mtrr_ops *ops); +extern void set_mtrr_ops (const struct mtrr_ops *ops);extern u64 size_or_mask, size_and_mask; -extern struct mtrr_ops *mtrr_if; +extern const struct mtrr_ops *mtrr_if;#define is_cpu (vnd) (mtrr_if && mtrr_if->vendor == X86_VENDOR_##vnd)#define use_intel () (mtrr_if && mtrr_if->use_intel_if == 1)
Signature · 1 line
1.6.5.3
PATCH 1/1 Constify struct lock_manager_operations for 2.6.32-git-053fe57ac v2
In reply to [email protected]From: Emese Revfy <[email protected]>
--- include/linux/fs.h | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-)
include/linux/fs.h +8 -8
@@ -1033,14 +1033,14 @@ struct file_lock_operations { };struct lock_manager_operations { -int (*fl_compare_owner)(struct file_lock *,struct file_lock *); -void (*fl_notify)(struct file_lock *);/* unblock callback */ -int (*fl_grant)(struct file_lock *,struct file_lock *,int ); -void (*fl_copy_lock)(struct file_lock *,struct file_lock *); -void (*fl_release_private)(struct file_lock *); -void (*fl_break)(struct file_lock *); -int (*fl_mylease)(struct file_lock *,struct file_lock *); -int (*fl_change)(struct file_lock **,int ); +int (*const fl_compare_owner)(struct file_lock *,struct file_lock *); +void (*const fl_notify)(struct file_lock *);/* unblock callback */ +int (*const fl_grant)(struct file_lock *,struct file_lock *,int ); +void (*const fl_copy_lock)(struct file_lock *,struct file_lock *); +void (*const fl_release_private)(struct file_lock *); +void (*const fl_break)(struct file_lock *); +int (*const fl_mylease)(struct file_lock *,struct file_lock *); +int (*const fl_change)(struct file_lock **,int ); };struct lock_manager {
Signature · 1 line
1.6.5.3