Constify struct hv_ops for 2.6.32-git-053fe57ac v2
Subsystems (4)
cover Constify struct hv_ops 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_operations
* hv_opsintel_dvo_dev_opsitem_operationsiwl_opskgdb_archkgdb_iokset_uevent_opslock_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
drivers/char/hvc_beat.c | 2 +- drivers/char/hvc_console.c | 6 +++--- drivers/char/hvc_console.h | 6 +++--- drivers/char/hvc_iseries.c | 2 +- drivers/char/hvc_iucv.c | 2 +- drivers/char/hvc_rtas.c | 2 +- drivers/char/hvc_udbg.c | 2 +- drivers/char/hvc_vio.c | 2 +- drivers/char/hvc_xen.c | 2 +- drivers/char/virtio_console.c | 1 + 10 files changed, 14 insertions(+), 13 deletions(-)
PATCH 1/1 Constify struct intel_dvo_dev_ops for 2.6.32-git-053fe57ac v2
From: Emese Revfy <[email protected]>
--- drivers/gpu/drm/i915/dvo.h | 16 ++++++++-------- drivers/gpu/drm/i915/dvo_ch7017.c | 2 +- drivers/gpu/drm/i915/dvo_ch7xxx.c | 2 +- drivers/gpu/drm/i915/dvo_ivch.c | 2 +- drivers/gpu/drm/i915/dvo_sil164.c | 2 +- drivers/gpu/drm/i915/dvo_tfp410.c | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-)
drivers/gpu/drm/i915/dvo.h +8 -8
@@ -135,23 +135,23 @@ struct intel_dvo_dev_ops {* * \return singly-linked list of modes or NULL if no modes found. */ -struct drm_display_mode *(*get_modes)(struct intel_dvo_device *dvo); +struct drm_display_mode *(*const get_modes)(struct intel_dvo_device *dvo);/** * Clean up driver-specific bits of the output */ -void (*destroy) (struct intel_dvo_device *dvo); +void (*const destroy) (struct intel_dvo_device *dvo);/** * Debugging hook to dump device registers to log file */ - void (*dump_regs)(struct intel_dvo_device *dvo); + void (* const dump_regs)(struct intel_dvo_device *dvo); }; -extern struct intel_dvo_dev_ops sil164_ops; -extern struct intel_dvo_dev_ops ch7xxx_ops; -extern struct intel_dvo_dev_ops ivch_ops; -extern struct intel_dvo_dev_ops tfp410_ops; -extern struct intel_dvo_dev_ops ch7017_ops; +extern const struct intel_dvo_dev_ops sil164_ops; +extern const struct intel_dvo_dev_ops ch7xxx_ops; +extern const struct intel_dvo_dev_ops ivch_ops; +extern const struct intel_dvo_dev_ops tfp410_ops; +extern const struct intel_dvo_dev_ops ch7017_ops;#endif /* _INTEL_DVO_H */
drivers/gpu/drm/i915/dvo_ch7017.c +1 -1
@@ -444,7 +444,7 @@ static void ch7017_destroy(struct intel_dvo_device *dvo) } } -struct intel_dvo_dev_ops ch7017_ops = { +const struct intel_dvo_dev_ops ch7017_ops = { .init = ch7017_init, .detect = ch7017_detect, .mode_valid = ch7017_mode_valid,
drivers/gpu/drm/i915/dvo_ch7xxx.c +1 -1
@@ -358,7 +358,7 @@ static void ch7xxx_destroy(struct intel_dvo_device *dvo) } } -struct intel_dvo_dev_ops ch7xxx_ops = { +const struct intel_dvo_dev_ops ch7xxx_ops = { .init = ch7xxx_init, .detect = ch7xxx_detect, .mode_valid = ch7xxx_mode_valid,
drivers/gpu/drm/i915/dvo_ivch.c +1 -1
@@ -431,7 +431,7 @@ static void ivch_destroy(struct intel_dvo_device *dvo) } } -struct intel_dvo_dev_ops ivch_ops= { +const struct intel_dvo_dev_ops ivch_ops= { .init = ivch_init, .dpms = ivch_dpms, .save = ivch_save,
drivers/gpu/drm/i915/dvo_sil164.c +1 -1
@@ -290,7 +290,7 @@ static void sil164_destroy(struct intel_dvo_device *dvo) } } -struct intel_dvo_dev_ops sil164_ops = { +const struct intel_dvo_dev_ops sil164_ops = { .init = sil164_init, .detect = sil164_detect, .mode_valid = sil164_mode_valid,
drivers/gpu/drm/i915/dvo_tfp410.c +1 -1
@@ -325,7 +325,7 @@ static void tfp410_destroy(struct intel_dvo_device *dvo) } } -struct intel_dvo_dev_ops tfp410_ops = { +const struct intel_dvo_dev_ops tfp410_ops = { .init = tfp410_init, .detect = tfp410_detect, .mode_valid = tfp410_mode_valid,
Signature · 1 line
1.6.5.3
PATCH 1/2 Constify struct item_operations for 2.6.32-git-053fe57ac v2
In reply to [email protected]From: Emese Revfy <[email protected]>
--- fs/reiserfs/item_ops.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-)
fs/reiserfs/item_ops.c +6 -6
@@ -102,7 +102,7 @@ static void sd_print_vi(struct virtual_item *vi) vi->vi_index, vi->vi_type, vi->vi_ih); } -static struct item_operations stat_data_ops = { +static const struct item_operations stat_data_ops = { .bytes_number = sd_bytes_number, .decrement_key = sd_decrement_key, .is_left_mergeable = sd_is_left_mergeable,
@@ -196,7 +196,7 @@ static void direct_print_vi(struct virtual_item *vi) vi->vi_index, vi->vi_type, vi->vi_ih); } -static struct item_operations direct_ops = { +static const struct item_operations direct_ops = { .bytes_number = direct_bytes_number, .decrement_key = direct_decrement_key, .is_left_mergeable = direct_is_left_mergeable,
@@ -341,7 +341,7 @@ static void indirect_print_vi(struct virtual_item *vi) vi->vi_index, vi->vi_type, vi->vi_ih); } -static struct item_operations indirect_ops = { +static const struct item_operations indirect_ops = { .bytes_number = indirect_bytes_number, .decrement_key = indirect_decrement_key, .is_left_mergeable = indirect_is_left_mergeable,
@@ -628,7 +628,7 @@ static void direntry_print_vi(struct virtual_item *vi)printk ("\n" ); } -static struct item_operations direntry_ops = { +static const struct item_operations direntry_ops = { .bytes_number = direntry_bytes_number, .decrement_key = direntry_decrement_key, .is_left_mergeable = direntry_is_left_mergeable,
@@ -724,7 +724,7 @@ static void errcatch_print_vi(struct virtual_item *vi) "Invalid item type observed, run fsck ASAP"); } -static struct item_operations errcatch_ops = { +static const struct item_operations errcatch_ops = { errcatch_bytes_number, errcatch_decrement_key, errcatch_is_left_mergeable,
@@ -746,7 +746,7 @@ static struct item_operations errcatch_ops = {#error Item types must use disk-format assigned values.#endif -struct item_operations *item_ops[TYPE_ANY +1 ] = { +const struct item_operations *const item_ops[TYPE_ANY +1 ] = { &stat_data_ops, &indirect_ops, &direct_ops,
Signature · 1 line
1.6.5.3
PATCH 1/3 Constify struct hv_ops for 2.6.32-git-053fe57ac v2
In reply to [email protected]From: Emese Revfy <[email protected]>
--- drivers/char/hvc_beat.c | 2 +- drivers/char/hvc_console.c | 6 +++--- drivers/char/hvc_console.h | 6 +++--- drivers/char/hvc_iucv.c | 2 +- drivers/char/hvc_rtas.c | 2 +- drivers/char/hvc_udbg.c | 2 +- drivers/char/hvc_xen.c | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-)
drivers/char/hvc_beat.c +1 -1
@@ -84,7 +84,7 @@ static int hvc_beat_put_chars(uint32_t vtermno, const char *buf, int cnt)return cnt; } -static struct hv_ops hvc_beat_get_put_ops = { +static const struct hv_ops hvc_beat_get_put_ops = { .get_chars = hvc_beat_get_chars, .put_chars = hvc_beat_put_chars, };
drivers/char/hvc_console.c +3 -3
@@ -125,7 +125,7 @@ static struct hvc_struct *hvc_get_by_index(int index)* console interfaces but can still be used as a tty device. This has to be * static because kmalloc will not work during early console init. */ -static struct hv_ops *cons_ops[MAX_NR_HVC_CONSOLES ]; +static const struct hv_ops *cons_ops[MAX_NR_HVC_CONSOLES ];static uint32_t vtermnos[MAX_NR_HVC_CONSOLES ] = {[0 ...MAX_NR_HVC_CONSOLES -1 ] =-1 };
@@ -247,7 +247,7 @@ static void destroy_hvc_struct(struct kref *kref)* vty adapters do NOT get an hvc_instantiate() callback since they * appear after early console init. */ -int hvc_instantiate (uint32_t vtermno,int index,struct hv_ops *ops) +int hvc_instantiate (uint32_t vtermno,int index,const struct hv_ops *ops) {struct hvc_struct *hp;
@@ -749,7 +749,7 @@ static const struct tty_operations hvc_ops = { };struct hvc_struct __devinit *hvc_alloc (uint32_t vtermno,int data, -struct hv_ops *ops,int outbuf_size) +const struct hv_ops *ops,int outbuf_size) {struct hvc_struct *hp;int i;
drivers/char/hvc_console.h +3 -3
@@ -55,7 +55,7 @@ struct hvc_struct {int outbuf_size;int n_outbuf;uint32_t vtermno; -struct hv_ops *ops; +const struct hv_ops *ops;int irq_requested;int data;struct winsize ws;
@@ -76,11 +76,11 @@ struct hv_ops { };/* Register a vterm and a slot index for use as a console (console_init) */ -extern int hvc_instantiate (uint32_t vtermno,int index,struct hv_ops *ops); +extern int hvc_instantiate (uint32_t vtermno,int index,const struct hv_ops *ops);/* register a vterm for hvc tty operation (module_init or hotplug add) */ extern struct hvc_struct *__devinit hvc_alloc (uint32_t vtermno,int data, -struct hv_ops *ops,int outbuf_size); +const struct hv_ops *ops,int outbuf_size);/* remove a vterm from hvc tty operation (module_exit or hotplug remove) */ extern int hvc_remove (struct hvc_struct *hp);
drivers/char/hvc_iucv.c +1 -1
@@ -922,7 +922,7 @@ static int hvc_iucv_pm_restore_thaw(struct device *dev)/* HVC operations */ -static struct hv_ops hvc_iucv_ops = { +static const struct hv_ops hvc_iucv_ops = { .get_chars = hvc_iucv_get_chars, .put_chars = hvc_iucv_put_chars, .notifier_add = hvc_iucv_notifier_add,
drivers/char/hvc_rtas.c +1 -1
@@ -71,7 +71,7 @@ static int hvc_rtas_read_console(uint32_t vtermno, char *buf, int count)return i; } -static struct hv_ops hvc_rtas_get_put_ops = { +static const struct hv_ops hvc_rtas_get_put_ops = { .get_chars = hvc_rtas_read_console, .put_chars = hvc_rtas_write_console, };
drivers/char/hvc_udbg.c +1 -1
@@ -58,7 +58,7 @@ static int hvc_udbg_get(uint32_t vtermno, char *buf, int count)return i; } -static struct hv_ops hvc_udbg_ops = { +static const struct hv_ops hvc_udbg_ops = { .get_chars = hvc_udbg_get, .put_chars = hvc_udbg_put, };
drivers/char/hvc_xen.c +1 -1
@@ -122,7 +122,7 @@ static int read_console(uint32_t vtermno, char *buf, int len)return recv; } -static struct hv_ops hvc_ops = { +static const struct hv_ops hvc_ops = { .get_chars = read_console, .put_chars = write_console, .notifier_add = notifier_add_irq,
Signature · 1 line
1.6.5.3
PATCH 2/3 Constify struct hv_ops for 2.6.32-git-053fe57ac v2
In reply to [email protected]From: Emese Revfy <[email protected]>
--- drivers/char/hvc_iseries.c | 2 +- drivers/char/hvc_vio.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/char/hvc_iseries.c +1 -1
@@ -197,7 +197,7 @@ done:return sent; } -static struct hv_ops hvc_get_put_ops = { +static const struct hv_ops hvc_get_put_ops = { .get_chars = get_chars, .put_chars = put_chars, .notifier_add = notifier_add_irq,
drivers/char/hvc_vio.c +1 -1
@@ -77,7 +77,7 @@ static int filtered_get_chars(uint32_t vtermno, char *buf, int count)return got; } -static struct hv_ops hvc_get_put_ops = { +static const struct hv_ops hvc_get_put_ops = { .get_chars = filtered_get_chars, .put_chars = hvc_put_chars, .notifier_add = notifier_add_irq,
Signature · 1 line
1.6.5.3
PATCH 2/2 Constify struct item_operations for 2.6.32-git-053fe57ac v2
In reply to [email protected]From: Emese Revfy <[email protected]>
--- include/linux/reiserfs_fs.h | 24 ++++++++++++------------ 1 files changed, 12 insertions(+), 12 deletions(-)
include/linux/reiserfs_fs.h +12 -12
@@ -1590,24 +1590,24 @@ static inline struct super_block *sb_from_bi(struct buffer_info *bi)*/ struct item_operations { -int (*bytes_number) (struct item_head * ih,int block_size); -void (*decrement_key) (struct cpu_key *); -int (*is_left_mergeable) (struct reiserfs_key * ih, +int (*const bytes_number) (struct item_head * ih,int block_size); +void (*const decrement_key) (struct cpu_key *); +int (*const is_left_mergeable) (struct reiserfs_key * ih,unsigned long bsize); -void (*print_item) (struct item_head *,char *item); -void (*check_item) (struct item_head *,char *item); +void (*const print_item) (struct item_head *,char *item); +void (*const check_item) (struct item_head *,char *item); -int (*create_vi) (struct virtual_node * vn,struct virtual_item * vi, +int (*const create_vi) (struct virtual_node * vn,struct virtual_item * vi,int is_affected,int insert_size); -int (*check_left) (struct virtual_item * vi,int free, +int (*const check_left) (struct virtual_item * vi,int free,int start_skip,int end_skip); -int (*check_right) (struct virtual_item * vi,int free); -int (*part_size) (struct virtual_item * vi,int from,int to); -int (*unit_num) (struct virtual_item * vi); -void (*print_vi) (struct virtual_item * vi); +int (*const check_right) (struct virtual_item * vi,int free); +int (*const part_size) (struct virtual_item * vi,int from,int to); +int (*const unit_num) (struct virtual_item * vi); +void (*const print_vi) (struct virtual_item * vi); }; -extern struct item_operations *item_ops[TYPE_ANY +1 ]; +extern const struct item_operations *const item_ops[TYPE_ANY +1 ];#define op_bytes_number (ih,bsize) item_ops[le_ih_k_type (ih)]->bytes_number (ih, bsize)#define op_is_left_mergeable (key,bsize) item_ops[le_key_k_type (le_key_version (key), key)]->is_left_mergeable (key, bsize)
Signature · 1 line
1.6.5.3
PATCH 3/3 Constify struct hv_ops for 2.6.32-git-053fe57ac v2
In reply to [email protected]From: Emese Revfy <[email protected]>
--- drivers/char/virtio_console.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/char/virtio_console.c +1 -0
@@ -44,6 +44,7 @@ static unsigned int in_len;static char *in, *inbuf;/* The operations for our console. */ +/* cannot be const, see virtcons_probe */ static struct hv_ops virtio_cons;/* The hvc device */
Signature · 1 line
1.6.5.3