From 75b9130e8af64c6878a1aa396a8446f3ce2cfb49 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Tue, 16 Apr 2013 22:44:07 -0700 Subject: 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 Signed-off-by: Greg Kroah-Hartman --- drivers/usb/storage/debug.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'drivers/usb/storage/debug.h') 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 @@ void usb_stor_show_command(struct scsi_cmnd *srb); void usb_stor_show_sense( unsigned char key, unsigned char asc, unsigned char ascq ); -#define US_DEBUGP(x...) printk( KERN_DEBUG USB_STORAGE x ) -#define US_DEBUGPX(x...) printk( x ) -#define US_DEBUG(x) x +__printf(1, 2) int usb_stor_dbg(const char *fmt, ...); + +#define US_DEBUGP(fmt, ...) usb_stor_dbg(fmt, ##__VA_ARGS__) +#define US_DEBUGPX(fmt, ...) printk(fmt, ##__VA_ARGS__) +#define US_DEBUG(x) x #else -#define US_DEBUGP(x...) -#define US_DEBUGPX(x...) +#define US_DEBUGP(fmt, ...) \ + do { if (0) printk(fmt, ##__VA_ARGS__); } while (0) +#define US_DEBUGPX(fmt, ...) \ + do { if (0) printk(fmt, ##__VA_ARGS__); } while (0) #define US_DEBUG(x) #endif -- cgit v1.2.1 From 191648d03d20229523d9a75b8abef56421298d28 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Fri, 19 Apr 2013 11:44:00 -0700 Subject: usb: storage: Convert US_DEBUGP to usb_stor_dbg Use a more current logging style with dev_printk where possible. o Convert uses of US_DEBUGP to usb_stor_dbg o Add "struct us_data *" to usb_stor_dbg uses o usb_stor_dbg now uses struct device */dev_vprint_emit o Removed embedded function names o Coalesce formats o Remove trailing whitespace o Remove useless OOM messages o Remove useless function entry/exit logging o Convert some US_DEBUGP uses to dev_info and dev_dbg Object size is slightly reduced when debugging is enabled, slightly increased with no debugging because some initialization and removal messages are now always emitted. Signed-off-by: Joe Perches Signed-off-by: Greg Kroah-Hartman --- drivers/usb/storage/debug.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'drivers/usb/storage/debug.h') diff --git a/drivers/usb/storage/debug.h b/drivers/usb/storage/debug.h index d4280e1541a3..b1273f03e223 100644 --- a/drivers/usb/storage/debug.h +++ b/drivers/usb/storage/debug.h @@ -47,17 +47,20 @@ #define USB_STORAGE "usb-storage: " #ifdef CONFIG_USB_STORAGE_DEBUG -void usb_stor_show_command(struct scsi_cmnd *srb); -void usb_stor_show_sense( unsigned char key, - unsigned char asc, unsigned char ascq ); -__printf(1, 2) int usb_stor_dbg(const char *fmt, ...); +void usb_stor_show_command(const struct us_data *us, struct scsi_cmnd *srb); +void usb_stor_show_sense(const struct us_data *us, unsigned char key, + unsigned char asc, unsigned char ascq); +__printf(2, 3) int usb_stor_dbg(const struct us_data *us, + const char *fmt, ...); -#define US_DEBUGP(fmt, ...) usb_stor_dbg(fmt, ##__VA_ARGS__) #define US_DEBUGPX(fmt, ...) printk(fmt, ##__VA_ARGS__) #define US_DEBUG(x) x #else -#define US_DEBUGP(fmt, ...) \ - do { if (0) printk(fmt, ##__VA_ARGS__); } while (0) +__printf(2, 3) +static inline int _usb_stor_dbg(const struct us_data *us, + const char *fmt, ...) {return 1;} +#define usb_stor_dbg(us, fmt, ...) \ + do { if (0) _usb_stor_dbg(us, fmt, ##__VA_ARGS__); } while (0) #define US_DEBUGPX(fmt, ...) \ do { if (0) printk(fmt, ##__VA_ARGS__); } while (0) #define US_DEBUG(x) -- cgit v1.2.1