Skip to content

Commit

Permalink
USB: constify usb_mon_operations structure
Browse files Browse the repository at this point in the history
The usb_mon_operations structure is never modified, so declare it as const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Julia Lawall authored and Greg Kroah-Hartman committed Dec 1, 2015
1 parent c7c7806 commit 6fb8ac8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions drivers/usb/core/hcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -3000,7 +3000,7 @@ EXPORT_SYMBOL_GPL(usb_hcd_platform_shutdown);

#if defined(CONFIG_USB_MON) || defined(CONFIG_USB_MON_MODULE)

struct usb_mon_operations *mon_ops;
const struct usb_mon_operations *mon_ops;

/*
* The registration is unlocked.
Expand All @@ -3010,7 +3010,7 @@ struct usb_mon_operations *mon_ops;
* symbols from usbcore, usbcore gets referenced and cannot be unloaded first.
*/

int usb_mon_register (struct usb_mon_operations *ops)
int usb_mon_register(const struct usb_mon_operations *ops)
{

if (mon_ops)
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/mon/mon_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ static struct notifier_block mon_nb = {
/*
* Ops
*/
static struct usb_mon_operations mon_ops_0 = {
static const struct usb_mon_operations mon_ops_0 = {
.urb_submit = mon_submit,
.urb_submit_error = mon_submit_error,
.urb_complete = mon_complete,
Expand Down
4 changes: 2 additions & 2 deletions include/linux/usb/hcd.h
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ struct usb_mon_operations {
/* void (*urb_unlink)(struct usb_bus *bus, struct urb *urb); */
};

extern struct usb_mon_operations *mon_ops;
extern const struct usb_mon_operations *mon_ops;

static inline void usbmon_urb_submit(struct usb_bus *bus, struct urb *urb)
{
Expand All @@ -682,7 +682,7 @@ static inline void usbmon_urb_complete(struct usb_bus *bus, struct urb *urb,
(*mon_ops->urb_complete)(bus, urb, status);
}

int usb_mon_register(struct usb_mon_operations *ops);
int usb_mon_register(const struct usb_mon_operations *ops);
void usb_mon_deregister(void);

#else
Expand Down

0 comments on commit 6fb8ac8

Please sign in to comment.