aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2013-04-17 01:44:07 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-04-17 13:01:22 -0400
commit75b9130e8af64c6878a1aa396a8446f3ce2cfb49 (patch)
tree64337c23d416ce01c1ac2449143c478ad7379704 /drivers/usb
parent61ac6ac8d662ac7ac67c864954d39d1b19948354 (diff)
usb: storage: Add usb_stor_dbg, reduce object size
Reduce the size of the objects by consolidating the duplicated USB_STORAGE into a single function. Add function usb_stor_dbg to emit debugging messages. Always validate the format and arguments. Reduce the number of uses of CONFIG_USB_STORAGE_DEBUG. Reduces size of objects ~7KB when CONFIG_USB_STORAGE_DEBUG is set. $ size drivers/usb/storage/built-in.o* text data bss dec hex filename 140133 55296 70312 265741 40e0d drivers/usb/storage/built-in.o.new 147494 55248 70296 273038 42a8e drivers/usb/storage/built-in.o.old Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/storage/debug.c20
-rw-r--r--drivers/usb/storage/debug.h14
-rw-r--r--drivers/usb/storage/isd200.c12
3 files changed, 34 insertions, 12 deletions
diff --git a/drivers/usb/storage/debug.c b/drivers/usb/storage/debug.c
index a2b5526c9fa0..b428129526c1 100644
--- a/drivers/usb/storage/debug.c
+++ b/drivers/usb/storage/debug.c
@@ -150,7 +150,7 @@ void usb_stor_show_command(struct scsi_cmnd *srb)
150 default: what = "(unknown command)"; break; 150 default: what = "(unknown command)"; break;
151 } 151 }
152 US_DEBUGP("Command %s (%d bytes)\n", what, srb->cmd_len); 152 US_DEBUGP("Command %s (%d bytes)\n", what, srb->cmd_len);
153 US_DEBUGP(""); 153 US_DEBUGP("bytes: ");
154 for (i = 0; i < srb->cmd_len && i < 16; i++) 154 for (i = 0; i < srb->cmd_len && i < 16; i++)
155 US_DEBUGPX(" %02x", srb->cmnd[i]); 155 US_DEBUGPX(" %02x", srb->cmnd[i]);
156 US_DEBUGPX("\n"); 156 US_DEBUGPX("\n");
@@ -175,3 +175,21 @@ void usb_stor_show_sense(
175 US_DEBUGPX(what, ascq); 175 US_DEBUGPX(what, ascq);
176 US_DEBUGPX("\n"); 176 US_DEBUGPX("\n");
177} 177}
178
179int usb_stor_dbg(const char *fmt, ...)
180{
181 struct va_format vaf;
182 va_list args;
183 int r;
184
185 va_start(args, fmt);
186
187 vaf.fmt = fmt;
188 vaf.va = &args;
189
190 r = printk(KERN_DEBUG USB_STORAGE "%pV", &vaf);
191
192 va_end(args);
193
194 return r;
195}
diff --git a/drivers/usb/storage/debug.h b/drivers/usb/storage/debug.h
index dbb985d52423..d4280e1541a3 100644
--- a/drivers/usb/storage/debug.h
+++ b/drivers/usb/storage/debug.h
@@ -50,12 +50,16 @@
50void usb_stor_show_command(struct scsi_cmnd *srb); 50void usb_stor_show_command(struct scsi_cmnd *srb);
51void usb_stor_show_sense( unsigned char key, 51void usb_stor_show_sense( unsigned char key,
52 unsigned char asc, unsigned char ascq ); 52 unsigned char asc, unsigned char ascq );
53#define US_DEBUGP(x...) printk( KERN_DEBUG USB_STORAGE x ) 53__printf(1, 2) int usb_stor_dbg(const char *fmt, ...);
54#define US_DEBUGPX(x...) printk( x ) 54
55#define US_DEBUG(x) x 55#define US_DEBUGP(fmt, ...) usb_stor_dbg(fmt, ##__VA_ARGS__)
56#define US_DEBUGPX(fmt, ...) printk(fmt, ##__VA_ARGS__)
57#define US_DEBUG(x) x
56#else 58#else
57#define US_DEBUGP(x...) 59#define US_DEBUGP(fmt, ...) \
58#define US_DEBUGPX(x...) 60 do { if (0) printk(fmt, ##__VA_ARGS__); } while (0)
61#define US_DEBUGPX(fmt, ...) \
62 do { if (0) printk(fmt, ##__VA_ARGS__); } while (0)
59#define US_DEBUG(x) 63#define US_DEBUG(x)
60#endif 64#endif
61 65
diff --git a/drivers/usb/storage/isd200.c b/drivers/usb/storage/isd200.c
index 06a3d22db685..55571ae59592 100644
--- a/drivers/usb/storage/isd200.c
+++ b/drivers/usb/storage/isd200.c
@@ -926,10 +926,6 @@ static int isd200_try_enum(struct us_data *us, unsigned char master_slave,
926 926
927 /* loop until we detect !BSY or timeout */ 927 /* loop until we detect !BSY or timeout */
928 while(1) { 928 while(1) {
929#ifdef CONFIG_USB_STORAGE_DEBUG
930 char* mstr = master_slave == ATA_ADDRESS_DEVHEAD_STD ?
931 "Master" : "Slave";
932#endif
933 929
934 status = isd200_action( us, ACTION_ENUM, NULL, master_slave ); 930 status = isd200_action( us, ACTION_ENUM, NULL, master_slave );
935 if ( status != ISD200_GOOD ) 931 if ( status != ISD200_GOOD )
@@ -942,9 +938,13 @@ static int isd200_try_enum(struct us_data *us, unsigned char master_slave,
942 938
943 if (!detect) { 939 if (!detect) {
944 if (regs[ATA_REG_STATUS_OFFSET] & ATA_BUSY) { 940 if (regs[ATA_REG_STATUS_OFFSET] & ATA_BUSY) {
945 US_DEBUGP(" %s status is still BSY, try again...\n",mstr); 941 US_DEBUGP(" %s status is still BSY, try again...\n",
942 master_slave == ATA_ADDRESS_DEVHEAD_STD ?
943 "Master" : "Slave");
946 } else { 944 } else {
947 US_DEBUGP(" %s status !BSY, continue with next operation\n",mstr); 945 US_DEBUGP(" %s status !BSY, continue with next operation\n",
946 master_slave == ATA_ADDRESS_DEVHEAD_STD ?
947 "Master" : "Slave");
948 break; 948 break;
949 } 949 }
950 } 950 }