Commit 4dae99638097b254c863c541368598f5a80e41bf

Authored by Greg Kroah-Hartman
1 parent fef526cae7

USB: legotower: remove custom debug macro and module parameter

Now that we don't use the dbg() macro, remove it, and the module
parameter.  Also fix up the "dump_data" function to properly use the
dynamic debug core and the correct printk options, and don't call it
twice per function, as the data doesn't change from the beginning and
the end of the call.

Cc: Juergen Stuber <starblue@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Showing 1 changed file with 9 additions and 34 deletions Side-by-side Diff

drivers/usb/misc/legousbtower.c
... ... @@ -87,28 +87,11 @@
87 87 #include <linux/poll.h>
88 88  
89 89  
90   -#ifdef CONFIG_USB_DEBUG
91   - static int debug = 4;
92   -#else
93   - static int debug = 0;
94   -#endif
95   -
96   -/* Use our own dbg macro */
97   -#undef dbg
98   -#define dbg(lvl, format, arg...) \
99   -do { \
100   - if (debug >= lvl) \
101   - printk(KERN_DEBUG "%s: " format "\n", __FILE__, ##arg); \
102   -} while (0)
103   -
104 90 /* Version Information */
105 91 #define DRIVER_VERSION "v0.96"
106 92 #define DRIVER_AUTHOR "Juergen Stuber <starblue@sourceforge.net>"
107 93 #define DRIVER_DESC "LEGO USB Tower Driver"
108 94  
109   -/* Module parameters */
110   -module_param(debug, int, S_IRUGO | S_IWUSR);
111   -MODULE_PARM_DESC(debug, "Debug enabled or not");
112 95  
113 96 /* The defaults are chosen to work with the latest versions of leJOS and NQC.
114 97 */
115 98  
... ... @@ -298,18 +281,12 @@
298 281 /**
299 282 * lego_usb_tower_debug_data
300 283 */
301   -static inline void lego_usb_tower_debug_data (int level, const char *function, int size, const unsigned char *data)
  284 +static inline void lego_usb_tower_debug_data(struct device *dev,
  285 + const char *function, int size,
  286 + const unsigned char *data)
302 287 {
303   - int i;
304   -
305   - if (debug < level)
306   - return;
307   -
308   - printk (KERN_DEBUG "%s: %s - length = %d, data = ", __FILE__, function, size);
309   - for (i = 0; i < size; ++i) {
310   - printk ("%.2x ", data[i]);
311   - }
312   - printk ("\n");
  288 + dev_dbg(dev, "%s - length = %d, data = %*ph\n",
  289 + function, size, size, data);
313 290 }
314 291  
315 292  
... ... @@ -744,7 +721,8 @@
744 721 int status = urb->status;
745 722 int retval;
746 723  
747   - lego_usb_tower_debug_data(5, __func__, urb->actual_length, urb->transfer_buffer);
  724 + lego_usb_tower_debug_data(&dev->udev->dev, __func__,
  725 + urb->actual_length, urb->transfer_buffer);
748 726  
749 727 if (status) {
750 728 if (status == -ENOENT ||
... ... @@ -788,8 +766,6 @@
788 766 exit:
789 767 dev->interrupt_in_done = 1;
790 768 wake_up_interruptible (&dev->read_wait);
791   -
792   - lego_usb_tower_debug_data(5, __func__, urb->actual_length, urb->transfer_buffer);
793 769 }
794 770  
795 771  
... ... @@ -801,7 +777,8 @@
801 777 struct lego_usb_tower *dev = urb->context;
802 778 int status = urb->status;
803 779  
804   - lego_usb_tower_debug_data(5, __func__, urb->actual_length, urb->transfer_buffer);
  780 + lego_usb_tower_debug_data(&dev->udev->dev, __func__,
  781 + urb->actual_length, urb->transfer_buffer);
805 782  
806 783 /* sync/async unlink faults aren't errors */
807 784 if (status && !(status == -ENOENT ||
... ... @@ -814,8 +791,6 @@
814 791  
815 792 dev->interrupt_out_busy = 0;
816 793 wake_up_interruptible(&dev->write_wait);
817   -
818   - lego_usb_tower_debug_data(5, __func__, urb->actual_length, urb->transfer_buffer);
819 794 }
820 795  
821 796