usb/145455: USB debug support cannot be disabled

Sebastian Huber sebastian.huber at embedded-brains.de
Wed Apr 7 12:50:06 UTC 2010


>Number:         145455
>Category:       usb
>Synopsis:       USB debug support cannot be disabled
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-usb
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Apr 07 12:50:05 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator:     Sebastian Huber
>Release:        9-current
>Organization:
embedded brains GmbH
>Environment:
>Description:
You cannot disable the USB debug support completely (USB_DEBUG define) due to an intermix of #if and #ifdef handling.  The header file usb_freebsd.h defines USB_DEBUG if it is undefined.  So the USB_DEBUG pre-processor symbol is always defined.  Thus you cannot use #ifdef and #ifndef to test if debugging support should be enabled or disabled.
>How-To-Repeat:

>Fix:
Please have a look at the attached patch.

Patch attached with submission follows:

Index: dev/usb/controller/at91dci.c
===================================================================
--- dev/usb/controller/at91dci.c	(revision 206339)
+++ dev/usb/controller/at91dci.c	(working copy)
@@ -89,7 +89,7 @@
 #define	AT9100_DCI_PC2SC(pc) \
    AT9100_DCI_BUS2SC(USB_DMATAG_TO_XROOT((pc)->tag_parent)->bus)
 
-#ifdef USB_DEBUG
+#if USB_DEBUG
 static int at91dcidebug = 0;
 
 SYSCTL_NODE(_hw_usb, OID_AUTO, at91dci, CTLFLAG_RW, 0, "USB at91dci");
Index: dev/usb/controller/atmegadci.c
===================================================================
--- dev/usb/controller/atmegadci.c	(revision 206339)
+++ dev/usb/controller/atmegadci.c	(working copy)
@@ -81,7 +81,7 @@
 #define	ATMEGA_PC2SC(pc) \
    ATMEGA_BUS2SC(USB_DMATAG_TO_XROOT((pc)->tag_parent)->bus)
 
-#ifdef USB_DEBUG
+#if USB_DEBUG
 static int atmegadci_debug = 0;
 
 SYSCTL_NODE(_hw_usb, OID_AUTO, atmegadci, CTLFLAG_RW, 0, "USB ATMEGA DCI");
Index: dev/usb/controller/musb_otg.c
===================================================================
--- dev/usb/controller/musb_otg.c	(revision 206339)
+++ dev/usb/controller/musb_otg.c	(working copy)
@@ -83,7 +83,7 @@
 #define	MUSBOTG_PC2SC(pc) \
    MUSBOTG_BUS2SC(USB_DMATAG_TO_XROOT((pc)->tag_parent)->bus)
 
-#ifdef USB_DEBUG
+#if USB_DEBUG
 static int musbotgdebug = 0;
 
 SYSCTL_NODE(_hw_usb, OID_AUTO, musbotg, CTLFLAG_RW, 0, "USB musbotg");
Index: dev/usb/controller/uhci_pci.c
===================================================================
--- dev/usb/controller/uhci_pci.c	(revision 206339)
+++ dev/usb/controller/uhci_pci.c	(working copy)
@@ -372,7 +372,7 @@
 	 * that the BIOS won't touch the keyboard anymore if it is connected
 	 * to the ports of the root hub?
 	 */
-#ifdef USB_DEBUG
+#if USB_DEBUG
 	if (pci_read_config(self, PCI_LEGSUP, 2) != PCI_LEGSUP_USBPIRQDEN) {
 		device_printf(self, "LegSup = 0x%04x\n",
 		    pci_read_config(self, PCI_LEGSUP, 2));
Index: dev/usb/controller/usb_controller.c
===================================================================
--- dev/usb/controller/usb_controller.c	(revision 206339)
+++ dev/usb/controller/usb_controller.c	(working copy)
@@ -72,7 +72,7 @@
 
 /* static variables */
 
-#ifdef USB_DEBUG
+#if USB_DEBUG
 static int usb_ctrl_debug = 0;
 
 SYSCTL_NODE(_hw_usb, OID_AUTO, ctrl, CTLFLAG_RW, 0, "USB controller");
Index: dev/usb/controller/avr32dci.c
===================================================================
--- dev/usb/controller/avr32dci.c	(revision 206339)
+++ dev/usb/controller/avr32dci.c	(working copy)
@@ -81,7 +81,7 @@
 #define	AVR32_PC2SC(pc) \
    AVR32_BUS2SC(USB_DMATAG_TO_XROOT((pc)->tag_parent)->bus)
 
-#ifdef USB_DEBUG
+#if USB_DEBUG
 static int avr32dci_debug = 0;
 
 SYSCTL_NODE(_hw_usb, OID_AUTO, avr32dci, CTLFLAG_RW, 0, "USB AVR32 DCI");
Index: dev/usb/controller/ohci.c
===================================================================
--- dev/usb/controller/ohci.c	(revision 206339)
+++ dev/usb/controller/ohci.c	(working copy)
@@ -78,7 +78,7 @@
    ((ohci_softc_t *)(((uint8_t *)(bus)) - \
     ((uint8_t *)&(((ohci_softc_t *)0)->sc_bus))))
 
-#ifdef USB_DEBUG
+#if USB_DEBUG
 static int ohcidebug = 0;
 
 SYSCTL_NODE(_hw_usb, OID_AUTO, ohci, CTLFLAG_RW, 0, "USB ohci");
@@ -228,7 +228,7 @@
 		device_printf(sc->sc_bus.bdev, "reset timeout\n");
 		return (USB_ERR_IOERROR);
 	}
-#ifdef USB_DEBUG
+#if USB_DEBUG
 	if (ohcidebug > 15) {
 		ohci_dumpregs(sc);
 	}
@@ -287,7 +287,7 @@
 		sc->sc_noport = OHCI_GET_NDP(OREAD4(sc, OHCI_RH_DESCRIPTOR_A));
 	}
 
-#ifdef USB_DEBUG
+#if USB_DEBUG
 	if (ohcidebug > 5) {
 		ohci_dumpregs(sc);
 	}
@@ -403,7 +403,7 @@
 
 	usb_callout_init_mtx(&sc->sc_tmo_rhsc, &sc->sc_bus.bus_mtx, 0);
 
-#ifdef USB_DEBUG
+#if USB_DEBUG
 	if (ohcidebug > 15) {
 		for (i = 0; i != OHCI_NO_EDS; i++) {
 			printf("ed#%d ", i);
@@ -456,7 +456,7 @@
 
 	USB_BUS_LOCK(&sc->sc_bus);
 
-#ifdef USB_DEBUG
+#if USB_DEBUG
 	DPRINTF("\n");
 	if (ohcidebug > 2) {
 		ohci_dumpregs(sc);
@@ -486,7 +486,7 @@
 {
 	uint32_t ctl;
 
-#ifdef USB_DEBUG
+#if USB_DEBUG
 	DPRINTF("\n");
 	if (ohcidebug > 2) {
 		ohci_dumpregs(sc);
@@ -520,7 +520,7 @@
 	ohci_do_poll(&sc->sc_bus);
 }
 
-#ifdef USB_DEBUG
+#if USB_DEBUG
 static void
 ohci_dumpregs(ohci_softc_t *sc)
 {
@@ -767,7 +767,7 @@
 			panic("%s:%d: out of TD's\n",
 			    __FUNCTION__, __LINE__);
 		}
-#ifdef USB_DEBUG
+#if USB_DEBUG
 		if (ohcidebug > 5) {
 			DPRINTF("isoc TD\n");
 			ohci_dump_itd(td);
@@ -808,7 +808,7 @@
 	ohci_device_done(xfer, USB_ERR_NORMAL_COMPLETION);
 }
 
-#ifdef USB_DEBUG
+#if USB_DEBUG
 static const char *const
 	ohci_cc_strs[] =
 {
@@ -936,7 +936,7 @@
 	DPRINTFN(13, "xfer=%p endpoint=%p transfer done\n",
 	    xfer, xfer->endpoint);
 
-#ifdef USB_DEBUG
+#if USB_DEBUG
 	if (ohcidebug > 10) {
 		ohci_dump_tds(xfer->td_transfer_first);
 	}
@@ -1161,7 +1161,7 @@
 
 	DPRINTFN(16, "real interrupt\n");
 
-#ifdef USB_DEBUG
+#if USB_DEBUG
 	if (ohcidebug > 15) {
 		ohci_dumpregs(sc);
 	}
@@ -1587,7 +1587,7 @@
 
 	xfer->td_transfer_last = td;
 
-#ifdef USB_DEBUG
+#if USB_DEBUG
 	if (ohcidebug > 8) {
 		DPRINTF("nexttog=%d; data before transfer:\n",
 		    xfer->endpoint->toggle_next);
@@ -2018,7 +2018,7 @@
 
 	xfer->td_transfer_last = td_last;
 
-#ifdef USB_DEBUG
+#if USB_DEBUG
 	if (ohcidebug > 8) {
 		DPRINTF("data before transfer:\n");
 		ohci_dump_itds(xfer->td_transfer_first);
Index: dev/usb/usb_debug.h
===================================================================
--- dev/usb/usb_debug.h	(revision 206339)
+++ dev/usb/usb_debug.h	(working copy)
@@ -34,7 +34,7 @@
 
 /* Check if USB debugging is enabled. */
 #ifdef USB_DEBUG_VAR
-#if (USB_DEBUG != 0)
+#if USB_DEBUG
 #define	DPRINTFN(n,fmt,...) do {		\
   if ((USB_DEBUG_VAR) >= (n)) {			\
     printf("%s: " fmt,				\
Index: dev/usb/storage/umass.c
===================================================================
--- dev/usb/storage/umass.c	(revision 206339)
+++ dev/usb/storage/umass.c	(working copy)
@@ -2147,7 +2147,7 @@
 static void
 umass_cam_attach(struct umass_softc *sc)
 {
-#ifndef USB_DEBUG
+#if !USB_DEBUG
 	if (bootverbose)
 #endif
 		printf("%s:%d:%d:%d: Attached to scbus%d\n",
Index: dev/usb/usb_busdma.c
===================================================================
--- dev/usb/usb_busdma.c	(revision 206339)
+++ dev/usb/usb_busdma.c	(working copy)
@@ -440,7 +440,7 @@
 	pc->page_offset_buf = rem;
 	pc->page_offset_end += rem;
 	nseg--;
-#ifdef USB_DEBUG
+#if USB_DEBUG
 	if (rem != (USB_P2U(pc->buffer) & (USB_PAGE_SIZE - 1))) {
 		/*
 		 * This check verifies that the physical address is correct:
Index: dev/usb/usb_hub.c
===================================================================
--- dev/usb/usb_hub.c	(revision 206339)
+++ dev/usb/usb_hub.c	(working copy)
@@ -73,7 +73,7 @@
 #define	UHUB_INTR_INTERVAL 250		/* ms */
 #define	UHUB_N_TRANSFER 1
 
-#ifdef USB_DEBUG
+#if USB_DEBUG
 static int uhub_debug = 0;
 
 SYSCTL_NODE(_hw_usb, OID_AUTO, uhub, CTLFLAG_RW, 0, "USB HUB");
Index: dev/usb/usb_dev.c
===================================================================
--- dev/usb/usb_dev.c	(revision 206339)
+++ dev/usb/usb_dev.c	(working copy)
@@ -79,7 +79,7 @@
 
 #if USB_HAVE_UGEN
 
-#ifdef USB_DEBUG
+#if USB_DEBUG
 static int usb_fifo_debug = 0;
 
 SYSCTL_NODE(_hw_usb, OID_AUTO, dev, CTLFLAG_RW, 0, "USB device");
Index: dev/usb/usb_freebsd.h
===================================================================
--- dev/usb/usb_freebsd.h	(revision 206339)
+++ dev/usb/usb_freebsd.h	(working copy)
@@ -57,7 +57,7 @@
 #define	USB_HUB_MAX_DEPTH	5
 #define	USB_EP0_BUFSIZE		1024	/* bytes */
 
-#ifndef USB_DEBUG
+#if USB_DEBUG
 #define USB_DEBUG 1
 #endif
 
Index: dev/usb/net/uhso.c
===================================================================
--- dev/usb/net/uhso.c	(revision 206339)
+++ dev/usb/net/uhso.c	(working copy)
@@ -280,7 +280,7 @@
 SYSCTL_INT(_hw_usb_uhso, OID_AUTO, auto_switch, CTLFLAG_RW,
     &uhso_autoswitch, 0, "Automatically switch to modem mode");
 
-#ifdef USB_DEBUG
+#if USB_DEBUG
 #ifdef UHSO_DEBUG
 static int uhso_debug = UHSO_DEBUG;
 #else
Index: dev/usb/usb_generic.c
===================================================================
--- dev/usb/usb_generic.c	(revision 206339)
+++ dev/usb/usb_generic.c	(working copy)
@@ -124,7 +124,7 @@
 	.f_stop_write = &ugen_stop_io,
 };
 
-#ifdef USB_DEBUG
+#if USB_DEBUG
 static int ugen_debug = 0;
 
 SYSCTL_NODE(_hw_usb, OID_AUTO, ugen, CTLFLAG_RW, 0, "USB generic");
Index: dev/usb/usb_process.c
===================================================================
--- dev/usb/usb_process.c	(revision 206339)
+++ dev/usb/usb_process.c	(working copy)
@@ -77,7 +77,7 @@
 #define	USB_THREAD_EXIT(err)	kthread_exit(err)
 #endif
 
-#ifdef USB_DEBUG
+#if USB_DEBUG
 static int usb_proc_debug;
 
 SYSCTL_NODE(_hw_usb, OID_AUTO, proc, CTLFLAG_RW, 0, "USB process");


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-usb mailing list