[PATCH 1/2] USB: constify usb_mon_operations structure

2015-11-28 Thread Julia Lawall
The usb_mon_operations structure is never modified, so declare it as const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall 

---
 include/linux/usb/hcd.h |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
index f89c24b..4dcf844 100644
--- a/include/linux/usb/hcd.h
+++ b/include/linux/usb/hcd.h
@@ -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)
 {
@@ -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

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] USB: constify usb_mon_operations structure

2015-11-28 Thread kbuild test robot
Hi Julia,

[auto build test ERROR on: v4.4-rc2]
[also build test ERROR on: next-20151127]

url:
https://github.com/0day-ci/linux/commits/Julia-Lawall/USB-constify-usb_mon_operations-structure/20151128-223726
config: xtensa-allyesconfig (attached as .config)
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=xtensa 

Note: the 
linux-review/Julia-Lawall/USB-constify-usb_mon_operations-structure/20151128-223726
 HEAD 97f84711238f9fbca0d4cf79fcec2f31ed33 builds fine.
  It only hurts bisectibility.

All error/warnings (new ones prefixed by >>):

>> drivers/usb/core/hcd.c:3003:28: error: conflicting types for 'mon_ops'
struct usb_mon_operations *mon_ops;
   ^
   In file included from drivers/usb/core/hcd.c:47:0:
   include/linux/usb/hcd.h:663:41: note: previous declaration of 'mon_ops' was 
here
extern const struct usb_mon_operations *mon_ops;
^
>> drivers/usb/core/hcd.c:3013:5: error: conflicting types for 
>> 'usb_mon_register'
int usb_mon_register (struct usb_mon_operations *ops)
^
   In file included from drivers/usb/core/hcd.c:47:0:
   include/linux/usb/hcd.h:685:5: note: previous declaration of 
'usb_mon_register' was here
int usb_mon_register(const struct usb_mon_operations *ops);
^
   In file included from include/linux/linkage.h:6:0,
from include/linux/kernel.h:6,
from include/linux/list.h:8,
from include/linux/module.h:9,
from drivers/usb/core/hcd.c:26:
   drivers/usb/core/hcd.c:3023:20: error: conflicting types for 
'usb_mon_register'
EXPORT_SYMBOL_GPL (usb_mon_register);
   ^
   include/linux/export.h:57:21: note: in definition of macro '__EXPORT_SYMBOL'
 extern typeof(sym) sym; \
^
>> drivers/usb/core/hcd.c:3023:1: note: in expansion of macro 
>> 'EXPORT_SYMBOL_GPL'
EXPORT_SYMBOL_GPL (usb_mon_register);
^
   In file included from drivers/usb/core/hcd.c:47:0:
   include/linux/usb/hcd.h:685:5: note: previous declaration of 
'usb_mon_register' was here
int usb_mon_register(const struct usb_mon_operations *ops);
^

vim +/mon_ops +3003 drivers/usb/core/hcd.c

782e70c6 Greg Kroah-Hartman 2008-01-25  2997  
EXPORT_SYMBOL_GPL(usb_hcd_platform_shutdown);
64a21d02 Aleksey Gorelov2006-08-08  2998  
^1da177e Linus Torvalds 2005-04-16  2999  
/*-*/
^1da177e Linus Torvalds 2005-04-16  3000  
f150fa1a Pete Zaitcev   2008-11-13  3001  #if defined(CONFIG_USB_MON) || 
defined(CONFIG_USB_MON_MODULE)
^1da177e Linus Torvalds 2005-04-16  3002  
^1da177e Linus Torvalds 2005-04-16 @3003  struct usb_mon_operations 
*mon_ops;
^1da177e Linus Torvalds 2005-04-16  3004  
^1da177e Linus Torvalds 2005-04-16  3005  /*
^1da177e Linus Torvalds 2005-04-16  3006   * The registration is unlocked.
^1da177e Linus Torvalds 2005-04-16  3007   * We do it this way because we 
do not want to lock in hot paths.
^1da177e Linus Torvalds 2005-04-16  3008   *
^1da177e Linus Torvalds 2005-04-16  3009   * Notice that the code is 
minimally error-proof. Because usbmon needs
^1da177e Linus Torvalds 2005-04-16  3010   * symbols from usbcore, usbcore 
gets referenced and cannot be unloaded first.
^1da177e Linus Torvalds 2005-04-16  3011   */
^1da177e Linus Torvalds 2005-04-16  3012  
^1da177e Linus Torvalds 2005-04-16 @3013  int usb_mon_register (struct 
usb_mon_operations *ops)
^1da177e Linus Torvalds 2005-04-16  3014  {
^1da177e Linus Torvalds 2005-04-16  3015  
^1da177e Linus Torvalds 2005-04-16  3016if (mon_ops)
^1da177e Linus Torvalds 2005-04-16  3017return -EBUSY;
^1da177e Linus Torvalds 2005-04-16  3018  
^1da177e Linus Torvalds 2005-04-16  3019mon_ops = ops;
^1da177e Linus Torvalds 2005-04-16  3020mb();
^1da177e Linus Torvalds 2005-04-16  3021return 0;
^1da177e Linus Torvalds 2005-04-16  3022  }
^1da177e Linus Torvalds 2005-04-16 @3023  EXPORT_SYMBOL_GPL 
(usb_mon_register);
^1da177e Linus Torvalds 2005-04-16  3024  
^1da177e Linus Torvalds 2005-04-16  3025  void usb_mon_deregister (void)
^1da177e Linus Torvalds 2005-04-16  3026  {

:: The code at line 3003 was first introduced by commit
:: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2

:: TO: Linus Torvalds 
:: CC: Linus Torvalds 

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data