Split out error reporting and make it compile without SCSIVERBOSE

This commit is contained in:
reinoud 2018-06-13 19:59:14 +00:00
parent 5f8aba250d
commit 7e24c78564
1 changed files with 22 additions and 4 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: vatapi.c,v 1.1 2018/06/05 20:02:43 reinoud Exp $ */
/* $NetBSD: vatapi.c,v 1.2 2018/06/13 19:59:14 reinoud Exp $ */
/*-
* Copyright (c) 2018 Reinoud Zandijk <reinoud@NetBSD.org>
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: vatapi.c,v 1.1 2018/06/05 20:02:43 reinoud Exp $");
__KERNEL_RCSID(0, "$NetBSD: vatapi.c,v 1.2 2018/06/13 19:59:14 reinoud Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@ -48,6 +48,8 @@ __KERNEL_RCSID(0, "$NetBSD: vatapi.c,v 1.1 2018/06/05 20:02:43 reinoud Exp $");
#include <dev/scsipi/scsipiconf.h>
#include <dev/scsipi/atapiconf.h>
#include "opt_scsi.h"
/* parameter? */
#define VDEV_ATAPI_DRIVE 0
#define MAX_SIZE ((1<<16))
@ -68,7 +70,9 @@ static void vatapi_probe_device(struct atapibus_softc *, int);
static void vatapi_complete(void *arg);
/* for debugging */
#ifdef SCSIVERBOSE
void scsipi_print_sense_data_real(struct scsi_sense_data *sense, int verbosity);
#endif
/* Note its one vdev, one adapter, one channel for now */
@ -278,6 +282,21 @@ vatapi_scsipi_request(struct scsipi_channel *chan,
}
static void
vatapi_report_problem(scsireq_t *kreq)
{
#ifdef SCSIVERBOSE
printf("vatapi cmd failed: ");
for (int i = 0; i < kreq->cmdlen; i++) {
printf("%02x ", kreq->cmd[i]);
}
printf("\n");
scsipi_print_sense_data_real(
(struct scsi_sense_data *) kreq->sense, 1);
#endif
}
static void
vatapi_complete(void *arg)
{
@ -316,8 +335,7 @@ vatapi_complete(void *arg)
xs->error = XS_SHORTSENSE; /* ATAPI */
memcpy(&xs->sense.scsi_sense, kreq.sense,
sizeof(struct scsi_sense_data));
// scsipi_print_sense_data_real(
// (struct scsi_sense_data *) kreq.sense, 1);
vatapi_report_problem(&kreq);
break;
default:
thunk_printf("unhandled/unknown retstst %d\n", kreq.retsts);