unsigned char *cmd = scp->cmnd;
u32 alloc_len, n;
int ret;
- bool have_wlun, is_disk, is_zbc, is_disk_zbc;
+ bool have_wlun, is_disk, is_zbc, is_disk_zbc, is_tape;
alloc_len = get_unaligned_be16(cmd + 3);
arr = kzalloc(SDEBUG_MAX_INQ_ARR_SZ, GFP_ATOMIC);
if (! arr)
return DID_REQUEUE << 16;
- is_disk = (sdebug_ptype == TYPE_DISK);
+ if (scp->device->type >= 32) {
+ is_disk = (sdebug_ptype == TYPE_DISK);
+ is_tape = (sdebug_ptype == TYPE_TAPE);
+ } else {
+ is_disk = (scp->device->type == TYPE_DISK);
+ is_tape = (scp->device->type == TYPE_TAPE);
+ }
is_zbc = devip->zoned;
is_disk_zbc = (is_disk || is_zbc);
have_wlun = scsi_is_wlun(scp->device->lun);
else if (sdebug_no_lun_0 && (devip->lun == SDEBUG_LUN_0_VAL))
pq_pdt = 0x7f; /* not present, PQ=3, PDT=0x1f */
else
- pq_pdt = (sdebug_ptype & 0x1f);
+ pq_pdt = ((scp->device->type >= 32 ?
+ sdebug_ptype : scp->device->type) & 0x1f);
arr[0] = pq_pdt;
if (0x2 & cmd[1]) { /* CMDDT bit set */
mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, 1);
if (is_disk) { /* SBC-4 no version claimed */
put_unaligned_be16(0x600, arr + n);
n += 2;
- } else if (sdebug_ptype == TYPE_TAPE) { /* SSC-4 rev 3 */
+ } else if (is_tape) { /* SSC-4 rev 3 */
put_unaligned_be16(0x525, arr + n);
n += 2;
} else if (is_zbc) { /* ZBC BSR INCITS 536 revision 05 */
changing = (stopped_state != want_stop);
if (changing)
atomic_xchg(&devip->stopped, want_stop);
- if (sdebug_ptype == TYPE_TAPE && !want_stop) {
+ if (scp->device->type == TYPE_TAPE && !want_stop) {
int i;
set_bit(SDEBUG_UA_NOT_READY_TO_READY, devip->uas_bm); /* not legal! */
subpcode = cmd[3];
msense_6 = (MODE_SENSE == cmd[0]);
llbaa = msense_6 ? false : !!(cmd[1] & 0x10);
- is_disk = (sdebug_ptype == TYPE_DISK);
+ is_disk = (scp->device->type == TYPE_DISK);
is_zbc = devip->zoned;
- is_tape = (sdebug_ptype == TYPE_TAPE);
+ is_tape = (scp->device->type == TYPE_TAPE);
if ((is_disk || is_zbc || is_tape) && !dbd)
bd_len = llbaa ? 16 : 8;
else
md_len = mselect6 ? (arr[0] + 1) : (get_unaligned_be16(arr + 0) + 2);
bd_len = mselect6 ? arr[3] : get_unaligned_be16(arr + 6);
off = (mselect6 ? 4 : 8);
- if (sdebug_ptype == TYPE_TAPE) {
+ if (scp->device->type == TYPE_TAPE) {
int blksize;
if (bd_len != 8) {
}
break;
case 0xf: /* Compression mode page */
- if (sdebug_ptype != TYPE_TAPE)
+ if (scp->device->type != TYPE_TAPE)
goto bad_pcode;
if ((arr[off + 2] & 0x40) != 0) {
devip->tape_dce = (arr[off + 2] & 0x80) != 0;
}
break;
case 0x11: /* Medium Partition Mode Page (tape) */
- if (sdebug_ptype == TYPE_TAPE) {
+ if (scp->device->type == TYPE_TAPE) {
int fld;
fld = process_medium_part_m_pg(devip, &arr[off], pg_len);
debugfs_remove(devip->debugfs_entry);
- if (sdebug_ptype == TYPE_TAPE) {
+ if (sdp->type == TYPE_TAPE) {
kfree(devip->tape_blocks[0]);
devip->tape_blocks[0] = NULL;
}
static void scsi_tape_reset_clear(struct sdebug_dev_info *devip)
{
- if (sdebug_ptype == TYPE_TAPE) {
- int i;
+ int i;
- devip->tape_blksize = TAPE_DEF_BLKSIZE;
- devip->tape_density = TAPE_DEF_DENSITY;
- devip->tape_partition = 0;
- devip->tape_dce = 0;
- for (i = 0; i < TAPE_MAX_PARTITIONS; i++)
- devip->tape_location[i] = 0;
- devip->tape_pending_nbr_partitions = -1;
- /* Don't reset partitioning? */
- }
+ devip->tape_blksize = TAPE_DEF_BLKSIZE;
+ devip->tape_density = TAPE_DEF_DENSITY;
+ devip->tape_partition = 0;
+ devip->tape_dce = 0;
+ for (i = 0; i < TAPE_MAX_PARTITIONS; i++)
+ devip->tape_location[i] = 0;
+ devip->tape_pending_nbr_partitions = -1;
+ /* Don't reset partitioning? */
}
static int scsi_debug_device_reset(struct scsi_cmnd *SCpnt)
scsi_debug_stop_all_queued(sdp);
if (devip) {
set_bit(SDEBUG_UA_POR, devip->uas_bm);
- scsi_tape_reset_clear(devip);
+ if (SCpnt->device->type == TYPE_TAPE)
+ scsi_tape_reset_clear(devip);
}
if (sdebug_fail_lun_reset(SCpnt)) {
list_for_each_entry(devip, &sdbg_host->dev_info_list, dev_list) {
if (devip->target == sdp->id) {
set_bit(SDEBUG_UA_BUS_RESET, devip->uas_bm);
- scsi_tape_reset_clear(devip);
+ if (SCpnt->device->type == TYPE_TAPE)
+ scsi_tape_reset_clear(devip);
++k;
}
}
list_for_each_entry(devip, &sdbg_host->dev_info_list, dev_list) {
set_bit(SDEBUG_UA_BUS_RESET, devip->uas_bm);
- scsi_tape_reset_clear(devip);
+ if (SCpnt->device->type == TYPE_TAPE)
+ scsi_tape_reset_clear(devip);
++k;
}
list_for_each_entry(devip, &sdbg_host->dev_info_list,
dev_list) {
set_bit(SDEBUG_UA_BUS_RESET, devip->uas_bm);
- scsi_tape_reset_clear(devip);
+ if (SCpnt->device->type == TYPE_TAPE)
+ scsi_tape_reset_clear(devip);
++k;
}
}