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

USB: Make file operations structs in drivers/usb const.

Making structs const prevents accidental bugs and with the proper debug
options they're protected against corruption.

Signed-off-by: Luiz Fernando N. Capitulino <lcapitulino@mandriva.com.br>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Luiz Fernando N. Capitulino and committed by
Greg Kroah-Hartman
066202dd f2ebf92c

+33 -33
+1 -1
drivers/usb/class/usblp.c
··· 813 813 return 0; 814 814 } 815 815 816 - static struct file_operations usblp_fops = { 816 + static const struct file_operations usblp_fops = { 817 817 .owner = THIS_MODULE, 818 818 .read = usblp_read, 819 819 .write = usblp_write,
+1 -1
drivers/usb/core/devices.c
··· 667 667 return ret; 668 668 } 669 669 670 - struct file_operations usbfs_devices_fops = { 670 + const struct file_operations usbfs_devices_fops = { 671 671 .llseek = usb_device_lseek, 672 672 .read = usb_device_read, 673 673 .poll = usb_device_poll,
+1 -1
drivers/usb/core/devio.c
··· 1572 1572 return mask; 1573 1573 } 1574 1574 1575 - struct file_operations usbfs_device_file_operations = { 1575 + const struct file_operations usbfs_device_file_operations = { 1576 1576 .llseek = usbdev_lseek, 1577 1577 .read = usbdev_read, 1578 1578 .poll = usbdev_poll,
+1 -1
drivers/usb/core/file.c
··· 55 55 return err; 56 56 } 57 57 58 - static struct file_operations usb_fops = { 58 + static const struct file_operations usb_fops = { 59 59 .owner = THIS_MODULE, 60 60 .open = usb_open, 61 61 };
+3 -3
drivers/usb/core/inode.c
··· 44 44 #include "hcd.h" 45 45 46 46 static struct super_operations usbfs_ops; 47 - static struct file_operations default_file_operations; 47 + static const struct file_operations default_file_operations; 48 48 static struct vfsmount *usbfs_mount; 49 49 static int usbfs_mount_count; /* = 0 */ 50 50 static int ignore_mount = 0; ··· 407 407 return 0; 408 408 } 409 409 410 - static struct file_operations default_file_operations = { 410 + static const struct file_operations default_file_operations = { 411 411 .read = default_read_file, 412 412 .write = default_write_file, 413 413 .open = default_open, ··· 494 494 495 495 static struct dentry *fs_create_file (const char *name, mode_t mode, 496 496 struct dentry *parent, void *data, 497 - struct file_operations *fops, 497 + const struct file_operations *fops, 498 498 uid_t uid, gid_t gid) 499 499 { 500 500 struct dentry *dentry;
+2 -2
drivers/usb/core/usb.h
··· 90 90 /* usbfs stuff */ 91 91 extern struct mutex usbfs_mutex; 92 92 extern struct usb_driver usbfs_driver; 93 - extern struct file_operations usbfs_devices_fops; 94 - extern struct file_operations usbfs_device_file_operations; 93 + extern const struct file_operations usbfs_devices_fops; 94 + extern const struct file_operations usbfs_device_file_operations; 95 95 extern void usbfs_conn_disc_event(void); 96 96 97 97 extern int usbdev_init(void);
+1 -1
drivers/usb/gadget/at91_udc.c
··· 247 247 return single_open(file, proc_udc_show, PDE(inode)->data); 248 248 } 249 249 250 - static struct file_operations proc_ops = { 250 + static const struct file_operations proc_ops = { 251 251 .open = proc_udc_open, 252 252 .read = seq_read, 253 253 .llseek = seq_lseek,
+4 -4
drivers/usb/gadget/inode.c
··· 714 714 /*----------------------------------------------------------------------*/ 715 715 716 716 /* used after endpoint configuration */ 717 - static struct file_operations ep_io_operations = { 717 + static const struct file_operations ep_io_operations = { 718 718 .owner = THIS_MODULE, 719 719 .llseek = no_llseek, 720 720 ··· 873 873 } 874 874 875 875 /* used before endpoint configuration */ 876 - static struct file_operations ep_config_operations = { 876 + static const struct file_operations ep_config_operations = { 877 877 .owner = THIS_MODULE, 878 878 .llseek = no_llseek, 879 879 ··· 1247 1247 } 1248 1248 1249 1249 /* used after device configuration */ 1250 - static struct file_operations ep0_io_operations = { 1250 + static const struct file_operations ep0_io_operations = { 1251 1251 .owner = THIS_MODULE, 1252 1252 .llseek = no_llseek, 1253 1253 ··· 1929 1929 return value; 1930 1930 } 1931 1931 1932 - static struct file_operations dev_init_operations = { 1932 + static const struct file_operations dev_init_operations = { 1933 1933 .owner = THIS_MODULE, 1934 1934 .llseek = no_llseek, 1935 1935
+1 -1
drivers/usb/gadget/omap_udc.c
··· 2437 2437 return single_open(file, proc_udc_show, NULL); 2438 2438 } 2439 2439 2440 - static struct file_operations proc_ops = { 2440 + static const struct file_operations proc_ops = { 2441 2441 .open = proc_udc_open, 2442 2442 .read = seq_read, 2443 2443 .llseek = seq_lseek,
+1 -1
drivers/usb/host/isp116x-hcd.c
··· 1207 1207 return single_open(file, isp116x_show_dbg, inode->i_private); 1208 1208 } 1209 1209 1210 - static struct file_operations isp116x_debug_fops = { 1210 + static const struct file_operations isp116x_debug_fops = { 1211 1211 .open = isp116x_open_seq, 1212 1212 .read = seq_read, 1213 1213 .llseek = seq_lseek,
+1 -1
drivers/usb/host/sl811-hcd.c
··· 1517 1517 return single_open(file, proc_sl811h_show, PDE(inode)->data); 1518 1518 } 1519 1519 1520 - static struct file_operations proc_ops = { 1520 + static const struct file_operations proc_ops = { 1521 1521 .open = proc_sl811h_open, 1522 1522 .read = seq_read, 1523 1523 .llseek = seq_lseek,
+2 -2
drivers/usb/host/uhci-debug.c
··· 16 16 17 17 #include "uhci-hcd.h" 18 18 19 - #define uhci_debug_operations (* (struct file_operations *) NULL) 19 + #define uhci_debug_operations (* (const struct file_operations *) NULL) 20 20 static struct dentry *uhci_debugfs_root; 21 21 22 22 #ifdef DEBUG ··· 500 500 } 501 501 502 502 #undef uhci_debug_operations 503 - static struct file_operations uhci_debug_operations = { 503 + static const struct file_operations uhci_debug_operations = { 504 504 .owner = THIS_MODULE, 505 505 .open = uhci_debug_open, 506 506 .llseek = uhci_debug_lseek,
+2 -2
drivers/usb/image/mdc800.c
··· 424 424 ***************************************************************************/ 425 425 426 426 static struct usb_driver mdc800_usb_driver; 427 - static struct file_operations mdc800_device_ops; 427 + static const struct file_operations mdc800_device_ops; 428 428 static struct usb_class_driver mdc800_class = { 429 429 .name = "mdc800%d", 430 430 .fops = &mdc800_device_ops, ··· 941 941 ****************************************************************************/ 942 942 943 943 /* File Operations of this drivers */ 944 - static struct file_operations mdc800_device_ops = 944 + static const struct file_operations mdc800_device_ops = 945 945 { 946 946 .owner = THIS_MODULE, 947 947 .read = mdc800_device_read,
+1 -1
drivers/usb/input/hiddev.c
··· 722 722 return -EINVAL; 723 723 } 724 724 725 - static struct file_operations hiddev_fops = { 725 + static const struct file_operations hiddev_fops = { 726 726 .owner = THIS_MODULE, 727 727 .read = hiddev_read, 728 728 .write = hiddev_write,
+1 -1
drivers/usb/misc/auerswald.c
··· 1858 1858 1859 1859 /*----------------------------------------------------------------------*/ 1860 1860 /* File operation structure */ 1861 - static struct file_operations auerswald_fops = 1861 + static const struct file_operations auerswald_fops = 1862 1862 { 1863 1863 .owner = THIS_MODULE, 1864 1864 .llseek = no_llseek,
+1 -1
drivers/usb/misc/idmouse.c
··· 98 98 static void idmouse_disconnect(struct usb_interface *interface); 99 99 100 100 /* file operation pointers */ 101 - static struct file_operations idmouse_fops = { 101 + static const struct file_operations idmouse_fops = { 102 102 .owner = THIS_MODULE, 103 103 .read = idmouse_read, 104 104 .open = idmouse_open,
+1 -1
drivers/usb/misc/ldusb.c
··· 589 589 } 590 590 591 591 /* file operations needed when we register this driver */ 592 - static struct file_operations ld_usb_fops = { 592 + static const struct file_operations ld_usb_fops = { 593 593 .owner = THIS_MODULE, 594 594 .read = ld_usb_read, 595 595 .write = ld_usb_write,
+1 -1
drivers/usb/misc/legousbtower.c
··· 259 259 static DEFINE_MUTEX (disconnect_mutex); 260 260 261 261 /* file operations needed when we register this driver */ 262 - static struct file_operations tower_fops = { 262 + static const struct file_operations tower_fops = { 263 263 .owner = THIS_MODULE, 264 264 .read = tower_read, 265 265 .write = tower_write,
+1 -1
drivers/usb/misc/sisusbvga/sisusb.c
··· 3179 3179 } 3180 3180 #endif 3181 3181 3182 - static struct file_operations usb_sisusb_fops = { 3182 + static const struct file_operations usb_sisusb_fops = { 3183 3183 .owner = THIS_MODULE, 3184 3184 .open = sisusb_open, 3185 3185 .release = sisusb_release,
+1 -1
drivers/usb/misc/usblcd.c
··· 239 239 return retval; 240 240 } 241 241 242 - static struct file_operations lcd_fops = { 242 + static const struct file_operations lcd_fops = { 243 243 .owner = THIS_MODULE, 244 244 .read = lcd_read, 245 245 .write = lcd_write,
+1 -1
drivers/usb/mon/mon_stat.c
··· 62 62 return 0; 63 63 } 64 64 65 - struct file_operations mon_fops_stat = { 65 + const struct file_operations mon_fops_stat = { 66 66 .owner = THIS_MODULE, 67 67 .open = mon_stat_open, 68 68 .llseek = no_llseek,
+1 -1
drivers/usb/mon/mon_text.c
··· 435 435 return 0; 436 436 } 437 437 438 - struct file_operations mon_fops_text = { 438 + const struct file_operations mon_fops_text = { 439 439 .owner = THIS_MODULE, 440 440 .open = mon_text_open, 441 441 .llseek = no_llseek,
+2 -2
drivers/usb/mon/usb_mon.h
··· 53 53 54 54 extern struct mutex mon_lock; 55 55 56 - extern struct file_operations mon_fops_text; 57 - extern struct file_operations mon_fops_stat; 56 + extern const struct file_operations mon_fops_text; 57 + extern const struct file_operations mon_fops_stat; 58 58 59 59 #endif /* __USB_MON_H */
+1 -1
drivers/usb/usb-skeleton.c
··· 243 243 return retval; 244 244 } 245 245 246 - static struct file_operations skel_fops = { 246 + static const struct file_operations skel_fops = { 247 247 .owner = THIS_MODULE, 248 248 .read = skel_read, 249 249 .write = skel_write,