kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] USB: constify usb_mon_operations structure
@ 2015-11-28 14:18 Julia Lawall
  2015-11-28 14:59 ` kbuild test robot
  2015-11-28 15:07 ` [PATCH v2] " Julia Lawall
  0 siblings, 2 replies; 3+ messages in thread
From: Julia Lawall @ 2015-11-28 14:18 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: kernel-janitors, linux-usb, linux-kernel

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>

---
 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] USB: constify usb_mon_operations structure
  2015-11-28 14:18 [PATCH 1/2] USB: constify usb_mon_operations structure Julia Lawall
@ 2015-11-28 14:59 ` kbuild test robot
  2015-11-28 15:07 ` [PATCH v2] " Julia Lawall
  1 sibling, 0 replies; 3+ messages in thread
From: kbuild test robot @ 2015-11-28 14:59 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 4903 bytes --]

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 97f842222711238f9fbca0d4cf79fcec2f31ed33 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 Gorelov    2006-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  3016  	if (mon_ops)
^1da177e Linus Torvalds     2005-04-16  3017  		return -EBUSY;
^1da177e Linus Torvalds     2005-04-16  3018  
^1da177e Linus Torvalds     2005-04-16  3019  	mon_ops = ops;
^1da177e Linus Torvalds     2005-04-16  3020  	mb();
^1da177e Linus Torvalds     2005-04-16  3021  	return 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 <torvalds@ppc970.osdl.org>
:::::: CC: Linus Torvalds <torvalds@ppc970.osdl.org>

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

[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 43263 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v2] USB: constify usb_mon_operations structure
  2015-11-28 14:18 [PATCH 1/2] USB: constify usb_mon_operations structure Julia Lawall
  2015-11-28 14:59 ` kbuild test robot
@ 2015-11-28 15:07 ` Julia Lawall
  1 sibling, 0 replies; 3+ messages in thread
From: Julia Lawall @ 2015-11-28 15:07 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: kernel-janitors, linux-usb, linux-kernel

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>

---
v2: Merge the previous 1/2 and 2/2 patches.

 drivers/usb/core/hcd.c     |    4 ++--
 drivers/usb/mon/mon_main.c |    2 +-
 include/linux/usb/hcd.h    |    4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 1c102d6..df0e3b9 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -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.
@@ -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)
diff --git a/drivers/usb/mon/mon_main.c b/drivers/usb/mon/mon_main.c
index f7c292f..fec3f11 100644
--- a/drivers/usb/mon/mon_main.c
+++ b/drivers/usb/mon/mon_main.c
@@ -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,
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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-11-28 15:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-28 14:18 [PATCH 1/2] USB: constify usb_mon_operations structure Julia Lawall
2015-11-28 14:59 ` kbuild test robot
2015-11-28 15:07 ` [PATCH v2] " Julia Lawall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).