Hi,
Here's a patch against 2.4.3 that converts all of the usb-serial drivers
to have a 'debug' parameter to them (if they are modules) that enable
the debugging to be turned on without recompiling the drivers.
This matches the way that most all of the network drivers currently
work.
thanks,
greg k-h
--
greg@(kroah|wirex).com
diff -Naur -X dontdiff linux-2.4.3/drivers/usb/serial/Config.in
linux-2.4.3-greg/drivers/usb/serial/Config.in
--- linux-2.4.3/drivers/usb/serial/Config.in Wed Apr 4 15:19:44 2001
+++ linux-2.4.3-greg/drivers/usb/serial/Config.in Wed Apr 4 15:25:44 2001
@@ -6,7 +6,9 @@
tristate 'USB Serial Converter support' CONFIG_USB_SERIAL $CONFIG_USB
if [ "$CONFIG_USB_SERIAL" != "n" ]; then
- bool ' USB Serial Converter verbose debug' CONFIG_USB_SERIAL_DEBUG
+ if [ "$CONFIG_USB_SERIAL" = "y" ]; then
+ bool ' USB Serial Converter verbose debug' CONFIG_USB_SERIAL_DEBUG
+ fi
bool ' USB Generic Serial Driver' CONFIG_USB_SERIAL_GENERIC
dep_tristate ' USB Belkin and Peracom Single Port Serial Driver (EXPERIMENTAL)'
CONFIG_USB_SERIAL_BELKIN $CONFIG_USB_SERIAL $CONFIG_EXPERIMENTAL
dep_tristate ' USB ConnectTech WhiteHEAT Serial Driver (EXPERIMENTAL)'
CONFIG_USB_SERIAL_WHITEHEAT $CONFIG_USB_SERIAL $CONFIG_EXPERIMENTAL
diff -Naur -X dontdiff linux-2.4.3/drivers/usb/serial/belkin_sa.c
linux-2.4.3-greg/drivers/usb/serial/belkin_sa.c
--- linux-2.4.3/drivers/usb/serial/belkin_sa.c Wed Apr 4 15:19:44 2001
+++ linux-2.4.3-greg/drivers/usb/serial/belkin_sa.c Wed Apr 4 15:25:44 2001
@@ -68,13 +68,13 @@
#include <linux/tty_flip.h>
#include <linux/module.h>
#include <linux/spinlock.h>
+#include <linux/usb.h>
#ifdef CONFIG_USB_SERIAL_DEBUG
- #define DEBUG
+ static int debug = 1;
#else
- #undef DEBUG
+ static int debug;
#endif
-#include <linux/usb.h>
#include "usb-serial.h"
#include "belkin_sa.h"
@@ -607,3 +607,7 @@
module_exit (belkin_sa_exit);
MODULE_DESCRIPTION("USB Belkin Serial converter driver");
+
+MODULE_PARM(debug, "i");
+MODULE_PARM_DESC(debug, "Debug enabled or not");
+
diff -Naur -X dontdiff linux-2.4.3/drivers/usb/serial/digi_acceleport.c
linux-2.4.3-greg/drivers/usb/serial/digi_acceleport.c
--- linux-2.4.3/drivers/usb/serial/digi_acceleport.c Wed Apr 4 15:19:44 2001
+++ linux-2.4.3-greg/drivers/usb/serial/digi_acceleport.c Wed Apr 4 15:25:44
+2001
@@ -241,14 +241,14 @@
#include <linux/module.h>
#include <linux/spinlock.h>
#include <linux/tqueue.h>
+#include <linux/usb.h>
#ifdef CONFIG_USB_SERIAL_DEBUG
- #define DEBUG
+ static int debug = 1;
#else
- #undef DEBUG
+ static int debug;
#endif
-#include <linux/usb.h>
#include "usb-serial.h"
@@ -2085,4 +2085,7 @@
MODULE_AUTHOR("Peter Berger <[EMAIL PROTECTED]>, Al Borchers
<[EMAIL PROTECTED]>");
MODULE_DESCRIPTION("Digi AccelePort USB-2/USB-4 Serial Converter driver");
+
+MODULE_PARM(debug, "i");
+MODULE_PARM_DESC(debug, "Debug enabled or not");
diff -Naur -X dontdiff linux-2.4.3/drivers/usb/serial/empeg.c
linux-2.4.3-greg/drivers/usb/serial/empeg.c
--- linux-2.4.3/drivers/usb/serial/empeg.c Thu Feb 22 23:43:26 2001
+++ linux-2.4.3-greg/drivers/usb/serial/empeg.c Wed Apr 4 15:25:44 2001
@@ -55,12 +55,13 @@
#include <linux/tty_flip.h>
#include <linux/module.h>
#include <linux/spinlock.h>
+#include <linux/usb.h>
+
#ifdef CONFIG_USB_SERIAL_DEBUG
- #define DEBUG
+ static int debug = 1;
#else
- #undef DEBUG
+ static int debug;
#endif
-#include <linux/usb.h>
#include "usb-serial.h"
@@ -705,3 +706,7 @@
MODULE_AUTHOR("Gary Brubaker <[EMAIL PROTECTED]>");
MODULE_DESCRIPTION("USB Empeg Mark I/II Driver");
+
+MODULE_PARM(debug, "i");
+MODULE_PARM_DESC(debug, "Debug enabled or not");
+
diff -Naur -X dontdiff linux-2.4.3/drivers/usb/serial/ftdi_sio.c
linux-2.4.3-greg/drivers/usb/serial/ftdi_sio.c
--- linux-2.4.3/drivers/usb/serial/ftdi_sio.c Wed Apr 4 15:19:44 2001
+++ linux-2.4.3-greg/drivers/usb/serial/ftdi_sio.c Wed Apr 4 15:25:44 2001
@@ -78,16 +78,15 @@
#include <linux/tty_flip.h>
#include <linux/module.h>
#include <linux/spinlock.h>
+#include <linux/usb.h>
#ifdef CONFIG_USB_SERIAL_DEBUG
- #define DEBUG
+ static int debug = 1;
#else
- #undef DEBUG
+ static int debug;
#endif
-#include <linux/usb.h>
#include "usb-serial.h"
-
#include "ftdi_sio.h"
@@ -881,3 +880,7 @@
MODULE_AUTHOR("Greg Kroah-Hartman <[EMAIL PROTECTED]>, Bill Ryder <[EMAIL PROTECTED]>");
MODULE_DESCRIPTION("USB FTDI RS232 converters driver");
+
+MODULE_PARM(debug, "i");
+MODULE_PARM_DESC(debug, "Debug enabled or not");
+
diff -Naur -X dontdiff linux-2.4.3/drivers/usb/serial/io_edgeport.c
linux-2.4.3-greg/drivers/usb/serial/io_edgeport.c
--- linux-2.4.3/drivers/usb/serial/io_edgeport.c Wed Apr 4 15:19:44 2001
+++ linux-2.4.3-greg/drivers/usb/serial/io_edgeport.c Wed Apr 4 15:25:44 2001
@@ -239,15 +239,14 @@
#include <linux/serial.h>
#include <linux/ioctl.h>
#include <linux/proc_fs.h>
+#include <linux/usb.h>
#ifdef CONFIG_USB_SERIAL_DEBUG
- #define DEBUG
+ static int debug = 1;
#else
- #undef DEBUG
+ static int debug;
#endif
-#include <linux/usb.h>
-
#include "usb-serial.h"
#include "io_edgeport.h"
@@ -279,6 +278,9 @@
MODULE_AUTHOR("Greg Kroah-Hartman <[EMAIL PROTECTED]> and David Iacovelli");
MODULE_DESCRIPTION("Edgeport USB Serial Driver");
+MODULE_PARM(debug, "i");
+MODULE_PARM_DESC(debug, "Debug enabled or not");
+
#define MAX_NAME_LEN 64
@@ -474,47 +476,6 @@
-
-#ifdef DEBUG
-
-/* Dump a buffer in HEX and Ascii */
-void DbgDisplayBuffer( void *pBuffer, __u32 Len )
-{
- char DisplayBuf[80];
- char * pStr = DisplayBuf;
- __u8 *pBuf = pBuffer;
- __u32 i;
- __u8 d;
-
- while (Len) {
- // Init for new line
- memset( DisplayBuf, ' ', sizeof( DisplayBuf ));
- DisplayBuf[79]=0;
- pStr = DisplayBuf;
- pStr[54] = '[';
- pStr[71] = ']';
-
- for ( i = 0; i < MIN(16, Len) ; i++ ) {
- d = (__u8)(*pBuf >> 4);
- pStr[(i*3)+0] = (char)((d < 10) ? d+'0' : d -10 + 'A');
- d = (__u8)(*pBuf & 0xf);
- pStr[(i*3)+1] = (char)((d < 10) ? d+'0' : d -10 + 'A');
-
- if (*pBuf > 31 && *pBuf < 127)
- pStr[i+55]=*pBuf;
- else
- pStr[i+55]='.';
-
- pBuf++;
- }
- Len -= i;
- dbg("%s", DisplayBuf );
- }
-}
-#endif
-
-
-
// ************************************************************************
// ************************************************************************
// ************************************************************************
@@ -745,7 +706,6 @@
break;
}
-#ifdef DEBUG
// Dump Product Info structure
dbg("**Product Information:");
dbg(" ProductId %x", product_info->ProductId );
@@ -770,7 +730,6 @@
product_info->ManufactureDescDate[2]+1900);
dbg(" iDownloadFile 0x%x", product_info->iDownloadFile);
-#endif
}
@@ -812,14 +771,7 @@
// process this interrupt-read even if there are no ports open
if (length) {
-#ifdef DEBUG
- int i;
- printk (KERN_DEBUG __FILE__ ": "__FUNCTION__" - length = %d, data = ",
length);
- for (i = 0; i < length; ++i) {
- printk ("%.2x ", data[i]);
- }
- printk ("\n");
-#endif
+ usb_serial_debug_data (__FILE__, __FUNCTION__, length, data);
if (length > 1) {
bytes_avail = data[0] | (data[1] << 8);
@@ -894,13 +846,7 @@
if (urb->actual_length) {
raw_data_length = urb->actual_length;
-#ifdef DEBUG
- {
-// int i;
- dbg (__FUNCTION__" - length = %d, data = ", raw_data_length);
-// DbgDisplayBuffer((void *)data, raw_data_length);
- }
-#endif
+ usb_serial_debug_data (__FILE__, __FUNCTION__, raw_data_length, data);
/* decrement our rxBytes available by the number that we just got */
edge_serial->rxBytesAvail -= raw_data_length;
@@ -976,10 +922,8 @@
dbg(__FUNCTION__);
-#ifdef DEBUG
CmdUrbs--;
dbg(__FUNCTION__" - FREE URB %p (outstanding %d)", urb, CmdUrbs);
-#endif
/* if this urb had a transfer buffer already (old transfer) free it */
@@ -1412,12 +1356,9 @@
// No need to check for wrap since we can not get to end of fifo in
this part
}
-#ifdef DEBUG
if (copySize) {
- dbg (__FUNCTION__" - length = %d, data = ", copySize);
- DbgDisplayBuffer((void *)data, copySize);
+ usb_serial_debug_data (__FILE__, __FUNCTION__, copySize, data);
}
-#endif
send_more_port_data((struct edgeport_serial *)port->serial->private,
edge_port);
@@ -1519,12 +1460,9 @@
fifo->count -= secondhalf;
}
-#ifdef DEBUG
if (count) {
- dbg (__FUNCTION__" - length = %d, data = ", count);
- DbgDisplayBuffer((void *)&buffer[2], count);
+ usb_serial_debug_data (__FILE__, __FUNCTION__, count, &buffer[2]);
}
-#endif
/* fill up the urb with all of our data and submit it */
FILL_BULK_URB (urb, edge_serial->serial->dev,
@@ -2498,16 +2436,7 @@
urb_t *urb;
int timeout;
-#ifdef DEBUG
- if (length) {
- int i;
- printk (KERN_DEBUG __FILE__ ": "__FUNCTION__" - length = %d, buffer =
", length);
- for (i = 0; i < length; ++i) {
- printk ("%.2x ", buffer[i]);
- }
- printk ("\n");
- }
-#endif
+ usb_serial_debug_data (__FILE__, __FUNCTION__, length, buffer);
/* Allocate our next urb */
urb = usb_alloc_urb (0);
@@ -2857,7 +2786,6 @@
if (response < 1) {
err("error in getting manufacturer descriptor");
} else {
-#ifdef DEBUG
char string[30];
dbg("**Manufacturer Descriptor");
dbg(" RomSize: %dK", edge_serial->manuf_descriptor.RomSize);
@@ -2875,7 +2803,6 @@
dbg(" UartType: %d", edge_serial->manuf_descriptor.UartType);
dbg(" IonPid: %d", edge_serial->manuf_descriptor.IonPid);
dbg(" IonConfig: %d", edge_serial->manuf_descriptor.IonConfig);
-#endif
}
}
@@ -3138,6 +3065,4 @@
module_init(edgeport_init);
module_exit(edgeport_exit);
-
-
diff -Naur -X dontdiff linux-2.4.3/drivers/usb/serial/keyspan.c
linux-2.4.3-greg/drivers/usb/serial/keyspan.c
--- linux-2.4.3/drivers/usb/serial/keyspan.c Wed Apr 4 15:19:45 2001
+++ linux-2.4.3-greg/drivers/usb/serial/keyspan.c Wed Apr 4 15:25:44 2001
@@ -62,13 +62,14 @@
#include <linux/tty_flip.h>
#include <linux/module.h>
#include <linux/spinlock.h>
-
-#define DEBUG
-/* #ifdef CONFIG_USB_SERIAL_DEBUG */
- #define DEBUG
-/* #endif */
#include <linux/usb.h>
+#ifdef CONFIG_USB_SERIAL_DEBUG
+ static int debug = 1;
+#else
+ static int debug;
+#endif
+
#include "usb-serial.h"
#include "keyspan.h"
@@ -1671,3 +1672,7 @@
kfree(port->private);
}
}
+
+MODULE_PARM(debug, "i");
+MODULE_PARM_DESC(debug, "Debug enabled or not");
+
diff -Naur -X dontdiff linux-2.4.3/drivers/usb/serial/keyspan_pda.c
linux-2.4.3-greg/drivers/usb/serial/keyspan_pda.c
--- linux-2.4.3/drivers/usb/serial/keyspan_pda.c Thu Feb 22 23:43:26 2001
+++ linux-2.4.3-greg/drivers/usb/serial/keyspan_pda.c Wed Apr 4 15:25:44 2001
@@ -67,13 +67,14 @@
#include <linux/module.h>
#include <linux/spinlock.h>
#include <linux/tqueue.h>
+#include <linux/usb.h>
#ifdef CONFIG_USB_SERIAL_DEBUG
- #define DEBUG
+ static int debug = 1;
#else
- #undef DEBUG
+ static int debug;
#endif
-#include <linux/usb.h>
+
struct ezusb_hex_record {
__u16 address;
@@ -82,7 +83,6 @@
};
#include "keyspan_pda_fw.h"
-
#include "usb-serial.h"
struct keyspan_pda_private {
@@ -823,3 +823,7 @@
MODULE_AUTHOR("Brian Warner <[EMAIL PROTECTED]>");
MODULE_DESCRIPTION("USB Keyspan PDA Converter driver");
+
+MODULE_PARM(debug, "i");
+MODULE_PARM_DESC(debug, "Debug enabled or not");
+
diff -Naur -X dontdiff linux-2.4.3/drivers/usb/serial/mct_u232.c
linux-2.4.3-greg/drivers/usb/serial/mct_u232.c
--- linux-2.4.3/drivers/usb/serial/mct_u232.c Wed Apr 4 15:19:45 2001
+++ linux-2.4.3-greg/drivers/usb/serial/mct_u232.c Wed Apr 4 15:25:44 2001
@@ -53,13 +53,13 @@
#include <linux/tty_flip.h>
#include <linux/module.h>
#include <linux/spinlock.h>
+#include <linux/usb.h>
#ifdef CONFIG_USB_SERIAL_DEBUG
- #define DEBUG
+ static int debug = 1;
#else
- #undef DEBUG
+ static int debug;
#endif
-#include <linux/usb.h>
#include "usb-serial.h"
#include "mct_u232.h"
@@ -848,3 +848,7 @@
MODULE_PARM_DESC(write_blocking,
"The write function will block to write out all data");
#endif
+
+MODULE_PARM(debug, "i");
+MODULE_PARM_DESC(debug, "Debug enabled or not");
+
diff -Naur -X dontdiff linux-2.4.3/drivers/usb/serial/omninet.c
linux-2.4.3-greg/drivers/usb/serial/omninet.c
--- linux-2.4.3/drivers/usb/serial/omninet.c Wed Apr 4 15:19:45 2001
+++ linux-2.4.3-greg/drivers/usb/serial/omninet.c Wed Apr 4 15:25:44 2001
@@ -43,17 +43,14 @@
#include <linux/tty_flip.h>
#include <linux/module.h>
#include <linux/spinlock.h>
-
+#include <linux/usb.h>
#ifdef CONFIG_USB_SERIAL_DEBUG
- #define isalpha(x) ( ( x > 96 && x < 123) || ( x > 64 && x < 91) || (x > 47 &&
x < 58) )
- #define DEBUG
+ static int debug = 1;
#else
- #undef DEBUG
+ static int debug;
#endif
-#include <linux/usb.h>
-
#include "usb-serial.h"
@@ -252,8 +249,7 @@
return;
}
-#ifdef DEBUG
- if(header->oh_xxx != 0x30) {
+ if ((debug) && (header->oh_xxx != 0x30)) {
if (urb->actual_length) {
printk (KERN_DEBUG __FILE__ ": omninet_read %d: ",
header->oh_len);
for (i = 0; i < (header->oh_len + OMNINET_HEADERLEN); i++) {
@@ -262,7 +258,6 @@
printk ("\n");
}
}
-#endif
if (urb->actual_length && header->oh_len) {
for (i = 0; i < header->oh_len; i++) {
@@ -413,4 +408,7 @@
module_init(omninet_init);
module_exit(omninet_exit);
+
+MODULE_PARM(debug, "i");
+MODULE_PARM_DESC(debug, "Debug enabled or not");
diff -Naur -X dontdiff linux-2.4.3/drivers/usb/serial/usb-serial.h
linux-2.4.3-greg/drivers/usb/serial/usb-serial.h
--- linux-2.4.3/drivers/usb/serial/usb-serial.h Mon Dec 11 13:17:29 2000
+++ linux-2.4.3-greg/drivers/usb/serial/usb-serial.h Wed Apr 4 15:25:44 2001
@@ -219,15 +219,24 @@
static inline void usb_serial_debug_data (const char *file, const char *function, int
size, const unsigned char *data)
{
-#ifdef CONFIG_USB_SERIAL_DEBUG
int i;
+
+ if (!debug)
+ return;
+
printk (KERN_DEBUG "%s: %s - length = %d, data = ", file, function, size);
for (i = 0; i < size; ++i) {
printk ("%.2x ", data[i]);
}
printk ("\n");
-#endif
}
+
+
+/* Use our own dbg macro */
+#undef dbg
+#define dbg(format, arg...) do { if (debug) printk(KERN_DEBUG __FILE__ ": " format
+"\n" , ## arg); } while (0)
+
+
#endif /* ifdef __LINUX_USB_SERIAL_H */
diff -Naur -X dontdiff linux-2.4.3/drivers/usb/serial/usbserial.c
linux-2.4.3-greg/drivers/usb/serial/usbserial.c
--- linux-2.4.3/drivers/usb/serial/usbserial.c Wed Apr 4 15:19:45 2001
+++ linux-2.4.3-greg/drivers/usb/serial/usbserial.c Wed Apr 4 15:25:44 2001
@@ -272,19 +272,24 @@
#include <linux/spinlock.h>
#include <linux/list.h>
#include <linux/smp_lock.h>
+#include <linux/usb.h>
#ifdef CONFIG_USB_SERIAL_DEBUG
- #define DEBUG
+ static int debug = 1;
#else
- #undef DEBUG
+ static int debug;
#endif
-#include <linux/usb.h>
+
+#include "usb-serial.h"
+
/* Module information */
MODULE_AUTHOR("Greg Kroah-Hartman, [EMAIL PROTECTED], http://www.kroah.com/linux-usb/");
MODULE_DESCRIPTION("USB Serial Driver");
-#include "usb-serial.h"
+MODULE_PARM(debug, "i");
+MODULE_PARM_DESC(debug, "Debug enabled or not");
+
#define MAX(a,b) (((a)>(b))?(a):(b))
@@ -364,6 +369,7 @@
static struct termios * serial_termios[SERIAL_TTY_MINORS];
static struct termios * serial_termios_locked[SERIAL_TTY_MINORS];
static struct usb_serial *serial_table[SERIAL_TTY_MINORS]; /* initially
all NULL */
+
LIST_HEAD(usb_serial_driver_list);
diff -Naur -X dontdiff linux-2.4.3/drivers/usb/serial/visor.c
linux-2.4.3-greg/drivers/usb/serial/visor.c
--- linux-2.4.3/drivers/usb/serial/visor.c Wed Apr 4 15:19:45 2001
+++ linux-2.4.3-greg/drivers/usb/serial/visor.c Wed Apr 4 15:25:44 2001
@@ -92,16 +92,15 @@
#include <linux/tty_flip.h>
#include <linux/module.h>
#include <linux/spinlock.h>
+#include <linux/usb.h>
#ifdef CONFIG_USB_SERIAL_DEBUG
- #define DEBUG
+ static int debug = 1;
#else
- #undef DEBUG
+ static int debug;
#endif
-#include <linux/usb.h>
#include "usb-serial.h"
-
#include "visor.h"
#define MIN(a,b) (((a)<(b))?(a):(b))
@@ -689,3 +688,7 @@
MODULE_AUTHOR("Greg Kroah-Hartman <[EMAIL PROTECTED]>");
MODULE_DESCRIPTION("USB HandSpring Visor driver");
+
+MODULE_PARM(debug, "i");
+MODULE_PARM_DESC(debug, "Debug enabled or not");
+
diff -Naur -X dontdiff linux-2.4.3/drivers/usb/serial/whiteheat.c
linux-2.4.3-greg/drivers/usb/serial/whiteheat.c
--- linux-2.4.3/drivers/usb/serial/whiteheat.c Wed Apr 4 15:19:45 2001
+++ linux-2.4.3-greg/drivers/usb/serial/whiteheat.c Wed Apr 4 15:25:44 2001
@@ -67,18 +67,16 @@
#include <linux/tty_flip.h>
#include <linux/module.h>
#include <linux/spinlock.h>
+#include <linux/usb.h>
#ifdef CONFIG_USB_SERIAL_DEBUG
- #define DEBUG
+ static int debug = 1;
#else
- #undef DEBUG
+ static int debug;
#endif
-#include <linux/usb.h>
#include "usb-serial.h"
-
#include "whiteheat_fw.h" /* firmware for the ConnectTech WhiteHEAT
device */
-
#include "whiteheat.h" /* WhiteHEAT specific commands */
#define CONNECT_TECH_VENDOR_ID 0x0710
@@ -634,3 +632,7 @@
MODULE_AUTHOR("Greg Kroah-Hartman <[EMAIL PROTECTED]>");
MODULE_DESCRIPTION("USB ConnectTech WhiteHEAT driver");
+
+MODULE_PARM(debug, "i");
+MODULE_PARM_DESC(debug, "Debug enabled or not");
+