Skip to content

Commit 066202d

Browse files
Luiz Fernando N. Capitulinogregkh
authored andcommitted
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>
1 parent f2ebf92 commit 066202d

24 files changed

Lines changed: 33 additions & 33 deletions

‎drivers/usb/class/usblp.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ static unsigned int usblp_quirks (__u16 vendor, __u16 product)
813813
return 0;
814814
}
815815

816-
static struct file_operations usblp_fops = {
816+
static const struct file_operations usblp_fops = {
817817
.owner = THIS_MODULE,
818818
.read = usblp_read,
819819
.write = usblp_write,

‎drivers/usb/core/devices.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ static loff_t usb_device_lseek(struct file * file, loff_t offset, int orig)
667667
return ret;
668668
}
669669

670-
struct file_operations usbfs_devices_fops = {
670+
const struct file_operations usbfs_devices_fops = {
671671
.llseek = usb_device_lseek,
672672
.read = usb_device_read,
673673
.poll = usb_device_poll,

‎drivers/usb/core/devio.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1572,7 +1572,7 @@ static unsigned int usbdev_poll(struct file *file, struct poll_table_struct *wai
15721572
return mask;
15731573
}
15741574

1575-
struct file_operations usbfs_device_file_operations = {
1575+
const struct file_operations usbfs_device_file_operations = {
15761576
.llseek = usbdev_lseek,
15771577
.read = usbdev_read,
15781578
.poll = usbdev_poll,

‎drivers/usb/core/file.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ static int usb_open(struct inode * inode, struct file * file)
5555
return err;
5656
}
5757

58-
static struct file_operations usb_fops = {
58+
static const struct file_operations usb_fops = {
5959
.owner = THIS_MODULE,
6060
.open = usb_open,
6161
};

‎drivers/usb/core/inode.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
#include "hcd.h"
4545

4646
static struct super_operations usbfs_ops;
47-
static struct file_operations default_file_operations;
47+
static const struct file_operations default_file_operations;
4848
static struct vfsmount *usbfs_mount;
4949
static int usbfs_mount_count; /* = 0 */
5050
static int ignore_mount = 0;
@@ -407,7 +407,7 @@ static int default_open (struct inode *inode, struct file *file)
407407
return 0;
408408
}
409409

410-
static struct file_operations default_file_operations = {
410+
static const struct file_operations default_file_operations = {
411411
.read = default_read_file,
412412
.write = default_write_file,
413413
.open = default_open,
@@ -494,7 +494,7 @@ static int fs_create_by_name (const char *name, mode_t mode,
494494

495495
static struct dentry *fs_create_file (const char *name, mode_t mode,
496496
struct dentry *parent, void *data,
497-
struct file_operations *fops,
497+
const struct file_operations *fops,
498498
uid_t uid, gid_t gid)
499499
{
500500
struct dentry *dentry;

‎drivers/usb/core/usb.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ extern const char *usbcore_name;
9090
/* usbfs stuff */
9191
extern struct mutex usbfs_mutex;
9292
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;
9595
extern void usbfs_conn_disc_event(void);
9696

9797
extern int usbdev_init(void);

‎drivers/usb/gadget/at91_udc.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ static int proc_udc_open(struct inode *inode, struct file *file)
247247
return single_open(file, proc_udc_show, PDE(inode)->data);
248248
}
249249

250-
static struct file_operations proc_ops = {
250+
static const struct file_operations proc_ops = {
251251
.open = proc_udc_open,
252252
.read = seq_read,
253253
.llseek = seq_lseek,

‎drivers/usb/gadget/inode.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ ep_aio_write(struct kiocb *iocb, const char __user *ubuf, size_t len, loff_t o)
714714
/*----------------------------------------------------------------------*/
715715

716716
/* used after endpoint configuration */
717-
static struct file_operations ep_io_operations = {
717+
static const struct file_operations ep_io_operations = {
718718
.owner = THIS_MODULE,
719719
.llseek = no_llseek,
720720

@@ -873,7 +873,7 @@ ep_open (struct inode *inode, struct file *fd)
873873
}
874874

875875
/* used before endpoint configuration */
876-
static struct file_operations ep_config_operations = {
876+
static const struct file_operations ep_config_operations = {
877877
.owner = THIS_MODULE,
878878
.llseek = no_llseek,
879879

@@ -1247,7 +1247,7 @@ static int dev_ioctl (struct inode *inode, struct file *fd,
12471247
}
12481248

12491249
/* used after device configuration */
1250-
static struct file_operations ep0_io_operations = {
1250+
static const struct file_operations ep0_io_operations = {
12511251
.owner = THIS_MODULE,
12521252
.llseek = no_llseek,
12531253

@@ -1929,7 +1929,7 @@ dev_open (struct inode *inode, struct file *fd)
19291929
return value;
19301930
}
19311931

1932-
static struct file_operations dev_init_operations = {
1932+
static const struct file_operations dev_init_operations = {
19331933
.owner = THIS_MODULE,
19341934
.llseek = no_llseek,
19351935

‎drivers/usb/gadget/omap_udc.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2437,7 +2437,7 @@ static int proc_udc_open(struct inode *inode, struct file *file)
24372437
return single_open(file, proc_udc_show, NULL);
24382438
}
24392439

2440-
static struct file_operations proc_ops = {
2440+
static const struct file_operations proc_ops = {
24412441
.open = proc_udc_open,
24422442
.read = seq_read,
24432443
.llseek = seq_lseek,

‎drivers/usb/host/isp116x-hcd.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1207,7 +1207,7 @@ static int isp116x_open_seq(struct inode *inode, struct file *file)
12071207
return single_open(file, isp116x_show_dbg, inode->i_private);
12081208
}
12091209

1210-
static struct file_operations isp116x_debug_fops = {
1210+
static const struct file_operations isp116x_debug_fops = {
12111211
.open = isp116x_open_seq,
12121212
.read = seq_read,
12131213
.llseek = seq_lseek,

0 commit comments

Comments
 (0)