mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-16 00:51:51 -04:00
ata: libata-scsi: Refactor ata_scsiop_maint_in()
Move the check for MI_REPORT_SUPPORTED_OPERATION_CODES from ata_scsi_simulate() into ata_scsiop_maint_in() to simplify ata_scsi_simulate() code. Furthermore, since an rbuff fill actor function returning a non-zero value causes no data to be returned for the command, directly return an error (return 1) for invalid command formt after setting the invalid field in cdb error. Signed-off-by: Damien Le Moal <dlemoal@kernel.org> Link: https://lore.kernel.org/r/20241022024537.251905-4-dlemoal@kernel.org Signed-off-by: Niklas Cassel <cassel@kernel.org>
This commit is contained in:
committed by
Niklas Cassel
parent
44bdde151a
commit
4ab7bb9763
@@ -3388,12 +3388,16 @@ static unsigned int ata_scsiop_maint_in(struct ata_scsi_args *args, u8 *rbuf)
|
|||||||
struct ata_device *dev = args->dev;
|
struct ata_device *dev = args->dev;
|
||||||
u8 *cdb = args->cmd->cmnd;
|
u8 *cdb = args->cmd->cmnd;
|
||||||
u8 supported = 0, cdlp = 0, rwcdlp = 0;
|
u8 supported = 0, cdlp = 0, rwcdlp = 0;
|
||||||
unsigned int err = 0;
|
|
||||||
|
if ((cdb[1] & 0x1f) != MI_REPORT_SUPPORTED_OPERATION_CODES) {
|
||||||
|
ata_scsi_set_invalid_field(dev, args->cmd, 1, 0xff);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (cdb[2] != 1 && cdb[2] != 3) {
|
if (cdb[2] != 1 && cdb[2] != 3) {
|
||||||
ata_dev_warn(dev, "invalid command format %d\n", cdb[2]);
|
ata_dev_warn(dev, "invalid command format %d\n", cdb[2]);
|
||||||
err = 2;
|
ata_scsi_set_invalid_field(dev, args->cmd, 1, 0xff);
|
||||||
goto out;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (cdb[3]) {
|
switch (cdb[3]) {
|
||||||
@@ -3461,11 +3465,12 @@ static unsigned int ata_scsiop_maint_in(struct ata_scsi_args *args, u8 *rbuf)
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
out:
|
|
||||||
/* One command format */
|
/* One command format */
|
||||||
rbuf[0] = rwcdlp;
|
rbuf[0] = rwcdlp;
|
||||||
rbuf[1] = cdlp | supported;
|
rbuf[1] = cdlp | supported;
|
||||||
return err;
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -4377,10 +4382,7 @@ void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case MAINTENANCE_IN:
|
case MAINTENANCE_IN:
|
||||||
if ((scsicmd[1] & 0x1f) == MI_REPORT_SUPPORTED_OPERATION_CODES)
|
ata_scsi_rbuf_fill(&args, ata_scsiop_maint_in);
|
||||||
ata_scsi_rbuf_fill(&args, ata_scsiop_maint_in);
|
|
||||||
else
|
|
||||||
ata_scsi_set_invalid_field(dev, cmd, 1, 0xff);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* all other commands */
|
/* all other commands */
|
||||||
|
|||||||
Reference in New Issue
Block a user