xref: /linux-6.15/drivers/usb/storage/debug.h (revision f0183a33)
1*f0183a33SFelipe Balbi /*
2*f0183a33SFelipe Balbi  * Driver for USB Mass Storage compliant devices
31da177e4SLinus Torvalds  * Debugging Functions Header File
41da177e4SLinus Torvalds  *
51da177e4SLinus Torvalds  * Current development and maintenance by:
61da177e4SLinus Torvalds  *   (c) 1999-2002 Matthew Dharm ([email protected])
71da177e4SLinus Torvalds  *
81da177e4SLinus Torvalds  * Initial work by:
91da177e4SLinus Torvalds  *   (c) 1999 Michael Gee ([email protected])
101da177e4SLinus Torvalds  *
111da177e4SLinus Torvalds  * This driver is based on the 'USB Mass Storage Class' document. This
121da177e4SLinus Torvalds  * describes in detail the protocol used to communicate with such
131da177e4SLinus Torvalds  * devices.  Clearly, the designers had SCSI and ATAPI commands in
141da177e4SLinus Torvalds  * mind when they created this document.  The commands are all very
151da177e4SLinus Torvalds  * similar to commands in the SCSI-II and ATAPI specifications.
161da177e4SLinus Torvalds  *
171da177e4SLinus Torvalds  * It is important to note that in a number of cases this class
181da177e4SLinus Torvalds  * exhibits class-specific exemptions from the USB specification.
191da177e4SLinus Torvalds  * Notably the usage of NAK, STALL and ACK differs from the norm, in
201da177e4SLinus Torvalds  * that they are used to communicate wait, failed and OK on commands.
211da177e4SLinus Torvalds  *
221da177e4SLinus Torvalds  * Also, for certain devices, the interrupt endpoint is used to convey
231da177e4SLinus Torvalds  * status of a command.
241da177e4SLinus Torvalds  *
251da177e4SLinus Torvalds  * Please see http://www.one-eyed-alien.net/~mdharm/linux-usb for more
261da177e4SLinus Torvalds  * information about this driver.
271da177e4SLinus Torvalds  *
281da177e4SLinus Torvalds  * This program is free software; you can redistribute it and/or modify it
291da177e4SLinus Torvalds  * under the terms of the GNU General Public License as published by the
301da177e4SLinus Torvalds  * Free Software Foundation; either version 2, or (at your option) any
311da177e4SLinus Torvalds  * later version.
321da177e4SLinus Torvalds  *
331da177e4SLinus Torvalds  * This program is distributed in the hope that it will be useful, but
341da177e4SLinus Torvalds  * WITHOUT ANY WARRANTY; without even the implied warranty of
351da177e4SLinus Torvalds  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
361da177e4SLinus Torvalds  * General Public License for more details.
371da177e4SLinus Torvalds  *
381da177e4SLinus Torvalds  * You should have received a copy of the GNU General Public License along
391da177e4SLinus Torvalds  * with this program; if not, write to the Free Software Foundation, Inc.,
401da177e4SLinus Torvalds  * 675 Mass Ave, Cambridge, MA 02139, USA.
411da177e4SLinus Torvalds  */
421da177e4SLinus Torvalds 
431da177e4SLinus Torvalds #ifndef _DEBUG_H_
441da177e4SLinus Torvalds #define _DEBUG_H_
451da177e4SLinus Torvalds 
461da177e4SLinus Torvalds #include <linux/kernel.h>
471da177e4SLinus Torvalds 
481da177e4SLinus Torvalds #define USB_STORAGE "usb-storage: "
491da177e4SLinus Torvalds 
501da177e4SLinus Torvalds #ifdef CONFIG_USB_STORAGE_DEBUG
51191648d0SJoe Perches void usb_stor_show_command(const struct us_data *us, struct scsi_cmnd *srb);
52191648d0SJoe Perches void usb_stor_show_sense(const struct us_data *us, unsigned char key,
531da177e4SLinus Torvalds 			 unsigned char asc, unsigned char ascq);
54e5283626SJoe Perches __printf(2, 3) void usb_stor_dbg(const struct us_data *us,
55191648d0SJoe Perches 				 const char *fmt, ...);
5675b9130eSJoe Perches 
571da177e4SLinus Torvalds #define US_DEBUG(x)		x
581da177e4SLinus Torvalds #else
59191648d0SJoe Perches __printf(2, 3)
60e5283626SJoe Perches static inline void _usb_stor_dbg(const struct us_data *us,
61e5283626SJoe Perches 				 const char *fmt, ...)
62e5283626SJoe Perches {
63e5283626SJoe Perches }
64191648d0SJoe Perches #define usb_stor_dbg(us, fmt, ...)				\
65191648d0SJoe Perches 	do { if (0) _usb_stor_dbg(us, fmt, ##__VA_ARGS__); } while (0)
661da177e4SLinus Torvalds #define US_DEBUG(x)
671da177e4SLinus Torvalds #endif
681da177e4SLinus Torvalds 
691da177e4SLinus Torvalds #endif
70