debug.c (1cb6e73c556e8a61d41e531003cf205c16650a02) | debug.c (191648d03d20229523d9a75b8abef56421298d28) |
---|---|
1/* Driver for USB Mass Storage compliant devices 2 * Debugging Functions Source Code File 3 * 4 * Current development and maintenance by: 5 * (c) 1999-2002 Matthew Dharm (mdharm-usb@one-eyed-alien.net) 6 * 7 * Developed with the assistance of: 8 * (c) 2002 Alan Stern <stern@rowland.org> --- 28 unchanged lines hidden (view full) --- 37 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 38 * General Public License for more details. 39 * 40 * You should have received a copy of the GNU General Public License along 41 * with this program; if not, write to the Free Software Foundation, Inc., 42 * 675 Mass Ave, Cambridge, MA 02139, USA. 43 */ 44 | 1/* Driver for USB Mass Storage compliant devices 2 * Debugging Functions Source Code File 3 * 4 * Current development and maintenance by: 5 * (c) 1999-2002 Matthew Dharm (mdharm-usb@one-eyed-alien.net) 6 * 7 * Developed with the assistance of: 8 * (c) 2002 Alan Stern <stern@rowland.org> --- 28 unchanged lines hidden (view full) --- 37 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 38 * General Public License for more details. 39 * 40 * You should have received a copy of the GNU General Public License along 41 * with this program; if not, write to the Free Software Foundation, Inc., 42 * 675 Mass Ave, Cambridge, MA 02139, USA. 43 */ 44 |
45#include <linux/device.h> |
|
45#include <linux/cdrom.h> 46#include <linux/export.h> 47#include <scsi/scsi.h> 48#include <scsi/scsi_cmnd.h> 49#include <scsi/scsi_dbg.h> 50 | 46#include <linux/cdrom.h> 47#include <linux/export.h> 48#include <scsi/scsi.h> 49#include <scsi/scsi_cmnd.h> 50#include <scsi/scsi_dbg.h> 51 |
52#include "usb.h" |
|
51#include "debug.h" 52#include "scsi.h" 53 54 | 53#include "debug.h" 54#include "scsi.h" 55 56 |
55void usb_stor_show_command(struct scsi_cmnd *srb) | 57void usb_stor_show_command(const struct us_data *us, struct scsi_cmnd *srb) |
56{ 57 char *what = NULL; 58 int i; 59 60 switch (srb->cmnd[0]) { 61 case TEST_UNIT_READY: what = "TEST_UNIT_READY"; break; 62 case REZERO_UNIT: what = "REZERO_UNIT"; break; 63 case REQUEST_SENSE: what = "REQUEST_SENSE"; break; --- 81 unchanged lines hidden (view full) --- 145 case GPCMD_SCAN: what = "SCAN"; break; 146 case GPCMD_SET_SPEED: what = "SET CD SPEED"; break; 147 case GPCMD_MECHANISM_STATUS: what = "MECHANISM STATUS"; break; 148 case GPCMD_READ_CD: what = "READ CD"; break; 149 case 0xE1: what = "WRITE CONTINUE"; break; 150 case WRITE_LONG_2: what = "WRITE_LONG_2"; break; 151 default: what = "(unknown command)"; break; 152 } | 58{ 59 char *what = NULL; 60 int i; 61 62 switch (srb->cmnd[0]) { 63 case TEST_UNIT_READY: what = "TEST_UNIT_READY"; break; 64 case REZERO_UNIT: what = "REZERO_UNIT"; break; 65 case REQUEST_SENSE: what = "REQUEST_SENSE"; break; --- 81 unchanged lines hidden (view full) --- 147 case GPCMD_SCAN: what = "SCAN"; break; 148 case GPCMD_SET_SPEED: what = "SET CD SPEED"; break; 149 case GPCMD_MECHANISM_STATUS: what = "MECHANISM STATUS"; break; 150 case GPCMD_READ_CD: what = "READ CD"; break; 151 case 0xE1: what = "WRITE CONTINUE"; break; 152 case WRITE_LONG_2: what = "WRITE_LONG_2"; break; 153 default: what = "(unknown command)"; break; 154 } |
153 US_DEBUGP("Command %s (%d bytes)\n", what, srb->cmd_len); 154 US_DEBUGP("bytes: "); | 155 usb_stor_dbg(us, "Command %s (%d bytes)\n", what, srb->cmd_len); 156 usb_stor_dbg(us, "bytes: "); |
155 for (i = 0; i < srb->cmd_len && i < 16; i++) 156 US_DEBUGPX(" %02x", srb->cmnd[i]); 157 US_DEBUGPX("\n"); 158} 159 | 157 for (i = 0; i < srb->cmd_len && i < 16; i++) 158 US_DEBUGPX(" %02x", srb->cmnd[i]); 159 US_DEBUGPX("\n"); 160} 161 |
160void usb_stor_show_sense( 161 unsigned char key, 162 unsigned char asc, 163 unsigned char ascq) { 164 | 162void usb_stor_show_sense(const struct us_data *us, 163 unsigned char key, 164 unsigned char asc, 165 unsigned char ascq) 166{ |
165 const char *what, *keystr; 166 167 keystr = scsi_sense_key_string(key); 168 what = scsi_extd_sense_format(asc, ascq); 169 170 if (keystr == NULL) 171 keystr = "(Unknown Key)"; 172 if (what == NULL) 173 what = "(unknown ASC/ASCQ)"; 174 | 167 const char *what, *keystr; 168 169 keystr = scsi_sense_key_string(key); 170 what = scsi_extd_sense_format(asc, ascq); 171 172 if (keystr == NULL) 173 keystr = "(Unknown Key)"; 174 if (what == NULL) 175 what = "(unknown ASC/ASCQ)"; 176 |
175 US_DEBUGP("%s: ", keystr); | 177 usb_stor_dbg(us, "%s: ", keystr); |
176 US_DEBUGPX(what, ascq); 177 US_DEBUGPX("\n"); 178} 179 | 178 US_DEBUGPX(what, ascq); 179 US_DEBUGPX("\n"); 180} 181 |
180int usb_stor_dbg(const char *fmt, ...) | 182int usb_stor_dbg(const struct us_data *us, const char *fmt, ...) |
181{ | 183{ |
182 struct va_format vaf; | |
183 va_list args; 184 int r; 185 186 va_start(args, fmt); 187 | 184 va_list args; 185 int r; 186 187 va_start(args, fmt); 188 |
188 vaf.fmt = fmt; 189 vaf.va = &args; | 189 r = dev_vprintk_emit(7, &us->pusb_dev->dev, fmt, args); |
190 | 190 |
191 r = printk(KERN_DEBUG USB_STORAGE "%pV", &vaf); 192 | |
193 va_end(args); 194 195 return r; 196} 197EXPORT_SYMBOL_GPL(usb_stor_dbg); | 191 va_end(args); 192 193 return r; 194} 195EXPORT_SYMBOL_GPL(usb_stor_dbg); |