Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] mark struct file_operations const 9

Many struct file_operations in the kernel can be "const". Marking them const
moves these to the .rodata section, which avoids false sharing with potential
dirty data. In addition it'll catch accidental writes at compile time to
these shared resources.

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Arjan van de Ven and committed by
Linus Torvalds
9c2e08c5 da7071d7

+55 -55
+1 -1
arch/powerpc/platforms/cell/spufs/spufs.h
··· 149 149 struct spu_context *ctx, u32 *npc, u32 *status); 150 150 long spufs_create(struct nameidata *nd, 151 151 unsigned int flags, mode_t mode); 152 - extern struct file_operations spufs_context_fops; 152 + extern const struct file_operations spufs_context_fops; 153 153 154 154 /* gang management */ 155 155 struct spu_gang *alloc_spu_gang(void);
+1 -1
drivers/s390/char/tape_class.c
··· 36 36 struct tape_class_device *register_tape_dev( 37 37 struct device * device, 38 38 dev_t dev, 39 - struct file_operations *fops, 39 + const struct file_operations *fops, 40 40 char * device_name, 41 41 char * mode_name) 42 42 {
+1 -1
drivers/s390/char/tape_class.h
··· 52 52 struct tape_class_device *register_tape_dev( 53 53 struct device * device, 54 54 dev_t dev, 55 - struct file_operations *fops, 55 + const struct file_operations *fops, 56 56 char * device_name, 57 57 char * node_name 58 58 );
+2 -2
security/inode.c
··· 50 50 return 0; 51 51 } 52 52 53 - static struct file_operations default_file_ops = { 53 + static const struct file_operations default_file_ops = { 54 54 .read = default_read_file, 55 55 .write = default_write_file, 56 56 .open = default_open, ··· 215 215 */ 216 216 struct dentry *securityfs_create_file(const char *name, mode_t mode, 217 217 struct dentry *parent, void *data, 218 - struct file_operations *fops) 218 + const struct file_operations *fops) 219 219 { 220 220 struct dentry *dentry = NULL; 221 221 int error;
+2 -2
security/keys/proc.c
··· 33 33 .show = proc_keys_show, 34 34 }; 35 35 36 - static struct file_operations proc_keys_fops = { 36 + static const struct file_operations proc_keys_fops = { 37 37 .open = proc_keys_open, 38 38 .read = seq_read, 39 39 .llseek = seq_lseek, ··· 54 54 .show = proc_key_users_show, 55 55 }; 56 56 57 - static struct file_operations proc_key_users_fops = { 57 + static const struct file_operations proc_key_users_fops = { 58 58 .open = proc_key_users_open, 59 59 .read = seq_read, 60 60 .llseek = seq_lseek,
+13 -13
security/selinux/selinuxfs.c
··· 161 161 #define sel_write_enforce NULL 162 162 #endif 163 163 164 - static struct file_operations sel_enforce_ops = { 164 + static const struct file_operations sel_enforce_ops = { 165 165 .read = sel_read_enforce, 166 166 .write = sel_write_enforce, 167 167 }; ··· 211 211 #define sel_write_disable NULL 212 212 #endif 213 213 214 - static struct file_operations sel_disable_ops = { 214 + static const struct file_operations sel_disable_ops = { 215 215 .write = sel_write_disable, 216 216 }; 217 217 ··· 225 225 return simple_read_from_buffer(buf, count, ppos, tmpbuf, length); 226 226 } 227 227 228 - static struct file_operations sel_policyvers_ops = { 228 + static const struct file_operations sel_policyvers_ops = { 229 229 .read = sel_read_policyvers, 230 230 }; 231 231 ··· 242 242 return simple_read_from_buffer(buf, count, ppos, tmpbuf, length); 243 243 } 244 244 245 - static struct file_operations sel_mls_ops = { 245 + static const struct file_operations sel_mls_ops = { 246 246 .read = sel_read_mls, 247 247 }; 248 248 ··· 294 294 return length; 295 295 } 296 296 297 - static struct file_operations sel_load_ops = { 297 + static const struct file_operations sel_load_ops = { 298 298 .write = sel_write_load, 299 299 }; 300 300 ··· 374 374 free_page((unsigned long) page); 375 375 return length; 376 376 } 377 - static struct file_operations sel_checkreqprot_ops = { 377 + static const struct file_operations sel_checkreqprot_ops = { 378 378 .read = sel_read_checkreqprot, 379 379 .write = sel_write_checkreqprot, 380 380 }; ··· 423 423 free_page((unsigned long) page); 424 424 return length; 425 425 } 426 - static struct file_operations sel_compat_net_ops = { 426 + static const struct file_operations sel_compat_net_ops = { 427 427 .read = sel_read_compat_net, 428 428 .write = sel_write_compat_net, 429 429 }; ··· 467 467 return rv; 468 468 } 469 469 470 - static struct file_operations transaction_ops = { 470 + static const struct file_operations transaction_ops = { 471 471 .write = selinux_transaction_write, 472 472 .read = simple_transaction_read, 473 473 .release = simple_transaction_release, ··· 875 875 return length; 876 876 } 877 877 878 - static struct file_operations sel_bool_ops = { 878 + static const struct file_operations sel_bool_ops = { 879 879 .read = sel_read_bool, 880 880 .write = sel_write_bool, 881 881 }; ··· 932 932 return length; 933 933 } 934 934 935 - static struct file_operations sel_commit_bools_ops = { 935 + static const struct file_operations sel_commit_bools_ops = { 936 936 .write = sel_commit_bools_write, 937 937 }; 938 938 ··· 1131 1131 return ret; 1132 1132 } 1133 1133 1134 - static struct file_operations sel_avc_cache_threshold_ops = { 1134 + static const struct file_operations sel_avc_cache_threshold_ops = { 1135 1135 .read = sel_read_avc_cache_threshold, 1136 1136 .write = sel_write_avc_cache_threshold, 1137 1137 }; 1138 1138 1139 - static struct file_operations sel_avc_hash_stats_ops = { 1139 + static const struct file_operations sel_avc_hash_stats_ops = { 1140 1140 .read = sel_read_avc_hash_stats, 1141 1141 }; 1142 1142 ··· 1198 1198 return seq_open(file, &sel_avc_cache_stats_seq_ops); 1199 1199 } 1200 1200 1201 - static struct file_operations sel_avc_cache_stats_ops = { 1201 + static const struct file_operations sel_avc_cache_stats_ops = { 1202 1202 .open = sel_open_avc_cache_stats, 1203 1203 .read = seq_read, 1204 1204 .llseek = seq_lseek,
+1 -1
sound/core/control.c
··· 1398 1398 * INIT PART 1399 1399 */ 1400 1400 1401 - static struct file_operations snd_ctl_f_ops = 1401 + static const struct file_operations snd_ctl_f_ops = 1402 1402 { 1403 1403 .owner = THIS_MODULE, 1404 1404 .read = snd_ctl_read,
+1 -1
sound/core/hwdep.c
··· 317 317 318 318 */ 319 319 320 - static struct file_operations snd_hwdep_f_ops = 320 + static const struct file_operations snd_hwdep_f_ops = 321 321 { 322 322 .owner = THIS_MODULE, 323 323 .llseek = snd_hwdep_llseek,
+1 -1
sound/core/info.c
··· 507 507 return -ENXIO; 508 508 } 509 509 510 - static struct file_operations snd_info_entry_operations = 510 + static const struct file_operations snd_info_entry_operations = 511 511 { 512 512 .owner = THIS_MODULE, 513 513 .llseek = snd_info_entry_llseek,
+2 -2
sound/core/init.c
··· 36 36 static DEFINE_SPINLOCK(shutdown_lock); 37 37 static LIST_HEAD(shutdown_files); 38 38 39 - static struct file_operations snd_shutdown_f_ops; 39 + static const struct file_operations snd_shutdown_f_ops; 40 40 41 41 static unsigned int snd_cards_lock; /* locked for registering/using */ 42 42 struct snd_card *snd_cards[SNDRV_CARDS]; ··· 244 244 return -ENODEV; 245 245 } 246 246 247 - static struct file_operations snd_shutdown_f_ops = 247 + static const struct file_operations snd_shutdown_f_ops = 248 248 { 249 249 .owner = THIS_MODULE, 250 250 .llseek = snd_disconnect_llseek,
+1 -1
sound/core/oss/mixer_oss.c
··· 390 390 * REGISTRATION PART 391 391 */ 392 392 393 - static struct file_operations snd_mixer_oss_f_ops = 393 + static const struct file_operations snd_mixer_oss_f_ops = 394 394 { 395 395 .owner = THIS_MODULE, 396 396 .open = snd_mixer_oss_open,
+1 -1
sound/core/oss/pcm_oss.c
··· 2889 2889 * ENTRY functions 2890 2890 */ 2891 2891 2892 - static struct file_operations snd_pcm_oss_f_reg = 2892 + static const struct file_operations snd_pcm_oss_f_reg = 2893 2893 { 2894 2894 .owner = THIS_MODULE, 2895 2895 .read = snd_pcm_oss_read,
+1 -1
sound/core/pcm_native.c
··· 3424 3424 * Register section 3425 3425 */ 3426 3426 3427 - struct file_operations snd_pcm_f_ops[2] = { 3427 + const struct file_operations snd_pcm_f_ops[2] = { 3428 3428 { 3429 3429 .owner = THIS_MODULE, 3430 3430 .write = snd_pcm_write,
+1 -1
sound/core/rawmidi.c
··· 1359 1359 * Register functions 1360 1360 */ 1361 1361 1362 - static struct file_operations snd_rawmidi_f_ops = 1362 + static const struct file_operations snd_rawmidi_f_ops = 1363 1363 { 1364 1364 .owner = THIS_MODULE, 1365 1365 .read = snd_rawmidi_read,
+1 -1
sound/core/seq/oss/seq_oss.c
··· 208 208 * registration of sequencer minor device 209 209 */ 210 210 211 - static struct file_operations seq_oss_f_ops = 211 + static const struct file_operations seq_oss_f_ops = 212 212 { 213 213 .owner = THIS_MODULE, 214 214 .read = odev_read,
+1 -1
sound/core/seq/seq_clientmgr.c
··· 2538 2538 * REGISTRATION PART 2539 2539 */ 2540 2540 2541 - static struct file_operations snd_seq_f_ops = 2541 + static const struct file_operations snd_seq_f_ops = 2542 2542 { 2543 2543 .owner = THIS_MODULE, 2544 2544 .read = snd_seq_read,
+1 -1
sound/core/sound.c
··· 168 168 return err; 169 169 } 170 170 171 - static struct file_operations snd_fops = 171 + static const struct file_operations snd_fops = 172 172 { 173 173 .owner = THIS_MODULE, 174 174 .open = snd_open
+1 -1
sound/core/timer.c
··· 1901 1901 #define snd_timer_user_ioctl_compat NULL 1902 1902 #endif 1903 1903 1904 - static struct file_operations snd_timer_f_ops = 1904 + static const struct file_operations snd_timer_f_ops = 1905 1905 { 1906 1906 .owner = THIS_MODULE, 1907 1907 .read = snd_timer_user_read,
+2 -2
sound/oss/ad1889.c
··· 778 778 return 0; 779 779 } 780 780 781 - static struct file_operations ad1889_fops = { 781 + static const struct file_operations ad1889_fops = { 782 782 .owner = THIS_MODULE, 783 783 .llseek = no_llseek, 784 784 .read = ad1889_read, ··· 812 812 return codec->mixer_ioctl(codec, cmd, arg); 813 813 } 814 814 815 - static struct file_operations ad1889_mixer_fops = { 815 + static const struct file_operations ad1889_mixer_fops = { 816 816 .owner = THIS_MODULE, 817 817 .llseek = no_llseek, 818 818 .ioctl = ad1889_mixer_ioctl,
+3 -3
sound/oss/btaudio.c
··· 429 429 return 0; 430 430 } 431 431 432 - static struct file_operations btaudio_mixer_fops = { 432 + static const struct file_operations btaudio_mixer_fops = { 433 433 .owner = THIS_MODULE, 434 434 .llseek = no_llseek, 435 435 .open = btaudio_mixer_open, ··· 796 796 return mask; 797 797 } 798 798 799 - static struct file_operations btaudio_digital_dsp_fops = { 799 + static const struct file_operations btaudio_digital_dsp_fops = { 800 800 .owner = THIS_MODULE, 801 801 .llseek = no_llseek, 802 802 .open = btaudio_dsp_open_digital, ··· 807 807 .poll = btaudio_dsp_poll, 808 808 }; 809 809 810 - static struct file_operations btaudio_analog_dsp_fops = { 810 + static const struct file_operations btaudio_analog_dsp_fops = { 811 811 .owner = THIS_MODULE, 812 812 .llseek = no_llseek, 813 813 .open = btaudio_dsp_open_analog,
+3 -3
sound/oss/dmasound/dmasound_core.c
··· 371 371 return -EINVAL; 372 372 } 373 373 374 - static struct file_operations mixer_fops = 374 + static const struct file_operations mixer_fops = 375 375 { 376 376 .owner = THIS_MODULE, 377 377 .llseek = no_llseek, ··· 1337 1337 return -EINVAL; 1338 1338 } 1339 1339 1340 - static struct file_operations sq_fops = 1340 + static const struct file_operations sq_fops = 1341 1341 { 1342 1342 .owner = THIS_MODULE, 1343 1343 .llseek = no_llseek, ··· 1561 1561 return n; 1562 1562 } 1563 1563 1564 - static struct file_operations state_fops = { 1564 + static const struct file_operations state_fops = { 1565 1565 .owner = THIS_MODULE, 1566 1566 .llseek = no_llseek, 1567 1567 .read = state_read,
+1 -1
sound/oss/emu10k1/audio.c
··· 1582 1582 return; 1583 1583 } 1584 1584 1585 - struct file_operations emu10k1_audio_fops = { 1585 + const struct file_operations emu10k1_audio_fops = { 1586 1586 .owner = THIS_MODULE, 1587 1587 .llseek = no_llseek, 1588 1588 .read = emu10k1_audio_read,
+1 -1
sound/oss/emu10k1/midi.c
··· 458 458 } 459 459 460 460 /* MIDI file operations */ 461 - struct file_operations emu10k1_midi_fops = { 461 + const struct file_operations emu10k1_midi_fops = { 462 462 .owner = THIS_MODULE, 463 463 .read = emu10k1_midi_read, 464 464 .write = emu10k1_midi_write,
+1 -1
sound/oss/emu10k1/mixer.c
··· 681 681 return 0; 682 682 } 683 683 684 - struct file_operations emu10k1_mixer_fops = { 684 + const struct file_operations emu10k1_mixer_fops = { 685 685 .owner = THIS_MODULE, 686 686 .llseek = no_llseek, 687 687 .ioctl = emu10k1_mixer_ioctl,
+2 -2
sound/oss/hal2.c
··· 1377 1377 return 0; 1378 1378 } 1379 1379 1380 - static struct file_operations hal2_audio_fops = { 1380 + static const struct file_operations hal2_audio_fops = { 1381 1381 .owner = THIS_MODULE, 1382 1382 .llseek = no_llseek, 1383 1383 .read = hal2_read, ··· 1388 1388 .release = hal2_release, 1389 1389 }; 1390 1390 1391 - static struct file_operations hal2_mixer_fops = { 1391 + static const struct file_operations hal2_mixer_fops = { 1392 1392 .owner = THIS_MODULE, 1393 1393 .llseek = no_llseek, 1394 1394 .ioctl = hal2_ioctl_mixdev,
+1 -1
sound/oss/msnd_pinnacle.c
··· 1106 1106 return IRQ_HANDLED; 1107 1107 } 1108 1108 1109 - static struct file_operations dev_fileops = { 1109 + static const struct file_operations dev_fileops = { 1110 1110 .owner = THIS_MODULE, 1111 1111 .read = dev_read, 1112 1112 .write = dev_write,
+1 -1
sound/oss/os.h
··· 43 43 #undef PSEUDO_DMA_AUTOINIT 44 44 #define ALLOW_BUFFER_MAPPING 45 45 46 - extern struct file_operations oss_sound_fops; 46 + extern const struct file_operations oss_sound_fops;
+1 -1
sound/oss/sh_dac_audio.c
··· 255 255 return 0; 256 256 } 257 257 258 - struct file_operations dac_audio_fops = { 258 + const struct file_operations dac_audio_fops = { 259 259 .read = dac_audio_read, 260 260 .write = dac_audio_write, 261 261 .ioctl = dac_audio_ioctl,
+1 -1
sound/oss/soundcard.c
··· 483 483 return 0; 484 484 } 485 485 486 - struct file_operations oss_sound_fops = { 486 + const struct file_operations oss_sound_fops = { 487 487 .owner = THIS_MODULE, 488 488 .llseek = no_llseek, 489 489 .read = sound_read,
+2 -2
sound/oss/via82cxxx_audio.c
··· 1619 1619 } 1620 1620 1621 1621 1622 - static struct file_operations via_mixer_fops = { 1622 + static const struct file_operations via_mixer_fops = { 1623 1623 .owner = THIS_MODULE, 1624 1624 .open = via_mixer_open, 1625 1625 .llseek = no_llseek, ··· 2042 2042 * 2043 2043 */ 2044 2044 2045 - static struct file_operations via_dsp_fops = { 2045 + static const struct file_operations via_dsp_fops = { 2046 2046 .owner = THIS_MODULE, 2047 2047 .open = via_dsp_open, 2048 2048 .release = via_dsp_release,
+2 -2
sound/oss/vwsnd.c
··· 3035 3035 return err; 3036 3036 } 3037 3037 3038 - static struct file_operations vwsnd_audio_fops = { 3038 + static const struct file_operations vwsnd_audio_fops = { 3039 3039 .owner = THIS_MODULE, 3040 3040 .llseek = no_llseek, 3041 3041 .read = vwsnd_audio_read, ··· 3225 3225 return retval; 3226 3226 } 3227 3227 3228 - static struct file_operations vwsnd_mixer_fops = { 3228 + static const struct file_operations vwsnd_mixer_fops = { 3229 3229 .owner = THIS_MODULE, 3230 3230 .llseek = no_llseek, 3231 3231 .ioctl = vwsnd_mixer_ioctl,
+1 -1
sound/sound_core.c
··· 436 436 437 437 static int soundcore_open(struct inode *, struct file *); 438 438 439 - static struct file_operations soundcore_fops= 439 + static const struct file_operations soundcore_fops= 440 440 { 441 441 /* We must have an owner or the module locking fails */ 442 442 .owner = THIS_MODULE,