From: Randy Dunlap <rdunlap@xxxxxxxxxxxx> Add stubs for some usb core functions when CONFIG_USB is not enabled. This fixes these comedi build errors: ERROR: "usb_deregister" [drivers/staging/comedi/comedi.ko] undefined! ERROR: "usb_register_driver" [drivers/staging/comedi/comedi.ko] undefined! Signed-off-by: Randy Dunlap <rdunlap@xxxxxxxxxxxx> --- I am only adding the stubs that are needed for comedi to build. I expect that more stubs will be needed as more build errors are found. It seems to me that linux/usb.h might need more (major) moving of lines to support more stubs in the future. Documentation/usb/error-codes.txt | 2 ++ include/linux/usb.h | 25 ++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) --- linux-next-20120518.orig/include/linux/usb.h +++ linux-next-20120518/include/linux/usb.h @@ -10,10 +10,11 @@ #ifdef __KERNEL__ -#include <linux/errno.h> /* for -ENODEV */ +#include <linux/errno.h> /* for -ENODEV, -ENOSYS */ #include <linux/delay.h> /* for mdelay() */ #include <linux/interrupt.h> /* for in_interrupt() */ #include <linux/list.h> /* for struct list_head */ +#include <linux/kconfig.h> /* for IS_ENABLED() */ #include <linux/kref.h> /* for struct kref */ #include <linux/device.h> /* for struct device */ #include <linux/fs.h> /* for struct file_operations */ @@ -515,6 +516,8 @@ static inline struct usb_device *interfa return to_usb_device(intf->dev.parent); } +#if IS_ENABLED(CONFIG_USB) + extern struct usb_device *usb_get_dev(struct usb_device *dev); extern void usb_put_dev(struct usb_device *dev); @@ -976,6 +979,26 @@ extern void usb_deregister_dev(struct us extern int usb_disabled(void); +#else /* stubs for USB not enabled */ + +static inline int usb_register(struct usb_driver *driver) +{ + return -ENOSYS; +} + +static inline int usb_register_driver(struct usb_driver *driver, + struct module *mod, + const char *modname) +{ + return -ENOSYS; +} + +static inline void usb_deregister(struct usb_driver *driver) +{ +} + +#endif + /* ----------------------------------------------------------------------- */ /* --- linux-next-20120518.orig/Documentation/usb/error-codes.txt +++ linux-next-20120518/Documentation/usb/error-codes.txt @@ -167,6 +167,8 @@ processing, devices may receive such fau usb_register(): -EINVAL error during registering new driver +-ENOSYS CONFIG_USB is not enabled, so the function stub + returns an error. usb_get_*/usb_set_*(): usb_control_msg(): -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html