Hi,
Here's the updated "nousb" patch for vanilla 2.5.41.
It applies with 2 small offsets to 2.5.41-bk3.
Comments/feedback please.
~Randy
--- ./drivers/usb/core/hcd-pci.c.nousb Mon Oct 7 11:24:14 2002
+++ ./drivers/usb/core/hcd-pci.c Thu Oct 10 21:23:11 2002
@@ -62,6 +62,9 @@
int retval, region;
char buf [8], *bufp = buf;
+ if (usb_disabled())
+ return -ENODEV;
+
if (!id || !(driver = (struct hc_driver *) id->driver_data))
return -EINVAL;
--- ./drivers/usb/core/usb.c.nousb Mon Oct 7 11:24:36 2002
+++ ./drivers/usb/core/usb.c Thu Oct 10 23:31:01 2002
@@ -50,6 +50,9 @@
extern void usb_major_cleanup(void);
+int nousb; /* Disable USB when built into kernel image */
+ /* Not honored on modular build */
+
static int generic_probe (struct device *dev)
{
@@ -167,6 +170,9 @@
{
int retval = 0;
+ if (nousb)
+ return -ENODEV;
+
new_driver->driver.name = (char *)new_driver->name;
new_driver->driver.bus = &usb_bus_type;
new_driver->driver.probe = usb_device_probe;
@@ -1346,11 +1352,37 @@
.hotplug = usb_hotplug,
};
+#ifndef MODULE
+
+static int __init usb_setup_disable(char *str)
+{
+ nousb = 1;
+ return 1;
+}
+
+/* format to disable USB on kernel command line is: nousb */
+__setup("nousb", usb_setup_disable);
+
+#endif
+
+/*
+ * for external read access to <nousb>
+ */
+int usb_disabled(void)
+{
+ return nousb;
+}
+
/*
* Init
*/
static int __init usb_init(void)
{
+ if (nousb) {
+ info("USB support disabled\n");
+ return 0;
+ }
+
bus_register(&usb_bus_type);
usb_major_init();
usbfs_init();
@@ -1366,6 +1398,10 @@
*/
static void __exit usb_exit(void)
{
+ /* This will matter if shutdown/reboot does exitcalls. */
+ if (nousb)
+ return;
+
remove_driver(&usb_generic_driver);
usb_major_cleanup();
usbfs_cleanup();
@@ -1385,6 +1421,7 @@
EXPORT_SYMBOL(usb_register);
EXPORT_SYMBOL(usb_deregister);
+EXPORT_SYMBOL(usb_disabled);
EXPORT_SYMBOL(usb_device_probe);
EXPORT_SYMBOL(usb_device_remove);
--- ./drivers/usb/host/ohci-sa1111.c.nousb Mon Oct 7 11:24:37 2002
+++ ./drivers/usb/host/ohci-sa1111.c Thu Oct 10 21:30:42 2002
@@ -23,6 +23,8 @@
#error "This file is SA-1111 bus glue. CONFIG_SA1111 must be defined."
#endif
+extern int usb_disabled(void);
+
/*-------------------------------------------------------------------------*/
static void sa1111_start_hc(struct sa1111_dev *dev)
@@ -354,6 +356,9 @@
struct sa1111_dev *dev = SA1111_DEV(_dev);
struct usb_hcd *hcd = NULL;
int ret;
+
+ if (usb_disabled())
+ return -ENODEV;
ret = usb_hcd_sa1111_probe(&ohci_sa1111_hc_driver, &hcd, dev);
--- ./drivers/usb/host/hc_sl811.c.nousb Mon Oct 7 11:24:47 2002
+++ ./drivers/usb/host/hc_sl811.c Thu Oct 10 21:38:07 2002
@@ -1322,6 +1322,9 @@
int ret;
DBGFUNC ("Enter hci_hcd_init\n");
+ if (usb_disabled())
+ return -ENODEV;
+
ret = hc_found_hci (base_addr, data_reg_addr, irq);
return ret;
--- ./drivers/usb/host/uhci-hcd.c.nousb Mon Oct 7 11:24:51 2002
+++ ./drivers/usb/host/uhci-hcd.c Thu Oct 10 22:36:30 2002
@@ -2484,6 +2484,9 @@
info(DRIVER_DESC " " DRIVER_VERSION);
+ if (usb_disabled())
+ return -ENODEV;
+
if (debug) {
errbuf = kmalloc(ERRBUF_LEN, GFP_KERNEL);
if (!errbuf)
--- ./drivers/usb/host/ohci-pci.c.nousb Thu Oct 10 22:37:47 2002
+++ ./drivers/usb/host/ohci-pci.c Thu Oct 10 22:38:50 2002
@@ -365,6 +365,9 @@
static int __init ohci_hcd_pci_init (void)
{
dbg (DRIVER_INFO " (PCI)");
+ if (usb_disabled())
+ return -ENODEV;
+
dbg ("block sizes: ed %d td %d",
sizeof (struct ed), sizeof (struct td));
return pci_module_init (&ohci_pci_driver);
--- ./drivers/usb/host/ehci-hcd.c.nousb Thu Oct 10 22:39:02 2002
+++ ./drivers/usb/host/ehci-hcd.c Thu Oct 10 22:39:20 2002
@@ -985,6 +985,9 @@
static int __init init (void)
{
dbg (DRIVER_INFO);
+ if (usb_disabled())
+ return -ENODEV;
+
dbg ("block sizes: qh %Zd qtd %Zd itd %Zd sitd %Zd",
sizeof (struct ehci_qh), sizeof (struct ehci_qtd),
sizeof (struct ehci_itd), sizeof (struct ehci_sitd));
--- ./include/linux/usb.h.nousb Mon Oct 7 11:24:11 2002
+++ ./include/linux/usb.h Thu Oct 10 21:39:23 2002
@@ -670,6 +670,7 @@
extern int usb_device_probe(struct device *dev);
extern int usb_device_remove(struct device *dev);
+extern int usb_disabled(void);
/* -------------------------------------------------------------------------- */