@@ -4420,6 +4420,79 @@ static inline ata_xlat_func_t ata_get_xlat_func(struct ata_device *dev, u8 cmd)
44204420 return NULL ;
44214421}
44224422
4423+ /**
4424+ * ata_scsi_simulate - simulate SCSI command on ATA device
4425+ * @dev: the target device
4426+ * @cmd: SCSI command being sent to device.
4427+ *
4428+ * Interprets and directly executes a select list of SCSI commands
4429+ * that can be handled internally.
4430+ *
4431+ * LOCKING:
4432+ * spin_lock_irqsave(host lock)
4433+ */
4434+ static void ata_scsi_simulate (struct ata_device * dev , struct scsi_cmnd * cmd )
4435+ {
4436+ const u8 * scsicmd = cmd -> cmnd ;
4437+ u8 tmp8 ;
4438+
4439+ switch (scsicmd [0 ]) {
4440+ case INQUIRY :
4441+ ata_scsi_rbuf_fill (dev , cmd , ata_scsiop_inquiry );
4442+ break ;
4443+
4444+ case MODE_SENSE :
4445+ case MODE_SENSE_10 :
4446+ ata_scsi_rbuf_fill (dev , cmd , ata_scsiop_mode_sense );
4447+ break ;
4448+
4449+ case READ_CAPACITY :
4450+ case SERVICE_ACTION_IN_16 :
4451+ ata_scsi_rbuf_fill (dev , cmd , ata_scsiop_read_cap );
4452+ break ;
4453+
4454+ case REPORT_LUNS :
4455+ ata_scsi_rbuf_fill (dev , cmd , ata_scsiop_report_luns );
4456+ break ;
4457+
4458+ case REQUEST_SENSE :
4459+ ata_scsi_set_sense (dev , cmd , 0 , 0 , 0 );
4460+ break ;
4461+
4462+ /* if we reach this, then writeback caching is disabled,
4463+ * turning this into a no-op.
4464+ */
4465+ case SYNCHRONIZE_CACHE :
4466+ case SYNCHRONIZE_CACHE_16 :
4467+ fallthrough ;
4468+
4469+ /* no-op's, complete with success */
4470+ case REZERO_UNIT :
4471+ case SEEK_6 :
4472+ case SEEK_10 :
4473+ case TEST_UNIT_READY :
4474+ break ;
4475+
4476+ case SEND_DIAGNOSTIC :
4477+ tmp8 = scsicmd [1 ] & ~(1 << 3 );
4478+ if (tmp8 != 0x4 || scsicmd [3 ] || scsicmd [4 ])
4479+ ata_scsi_set_invalid_field (dev , cmd , 1 , 0xff );
4480+ break ;
4481+
4482+ case MAINTENANCE_IN :
4483+ ata_scsi_rbuf_fill (dev , cmd , ata_scsiop_maint_in );
4484+ break ;
4485+
4486+ /* all other commands */
4487+ default :
4488+ ata_scsi_set_sense (dev , cmd , ILLEGAL_REQUEST , 0x20 , 0x0 );
4489+ /* "Invalid command operation code" */
4490+ break ;
4491+ }
4492+
4493+ scsi_done (cmd );
4494+ }
4495+
44234496enum scsi_qc_status __ata_scsi_queuecmd (struct scsi_cmnd * scmd ,
44244497 struct ata_device * dev )
44254498{
@@ -4522,80 +4595,6 @@ enum scsi_qc_status ata_scsi_queuecmd(struct Scsi_Host *shost,
45224595}
45234596EXPORT_SYMBOL_GPL (ata_scsi_queuecmd );
45244597
4525- /**
4526- * ata_scsi_simulate - simulate SCSI command on ATA device
4527- * @dev: the target device
4528- * @cmd: SCSI command being sent to device.
4529- *
4530- * Interprets and directly executes a select list of SCSI commands
4531- * that can be handled internally.
4532- *
4533- * LOCKING:
4534- * spin_lock_irqsave(host lock)
4535- */
4536-
4537- void ata_scsi_simulate (struct ata_device * dev , struct scsi_cmnd * cmd )
4538- {
4539- const u8 * scsicmd = cmd -> cmnd ;
4540- u8 tmp8 ;
4541-
4542- switch (scsicmd [0 ]) {
4543- case INQUIRY :
4544- ata_scsi_rbuf_fill (dev , cmd , ata_scsiop_inquiry );
4545- break ;
4546-
4547- case MODE_SENSE :
4548- case MODE_SENSE_10 :
4549- ata_scsi_rbuf_fill (dev , cmd , ata_scsiop_mode_sense );
4550- break ;
4551-
4552- case READ_CAPACITY :
4553- case SERVICE_ACTION_IN_16 :
4554- ata_scsi_rbuf_fill (dev , cmd , ata_scsiop_read_cap );
4555- break ;
4556-
4557- case REPORT_LUNS :
4558- ata_scsi_rbuf_fill (dev , cmd , ata_scsiop_report_luns );
4559- break ;
4560-
4561- case REQUEST_SENSE :
4562- ata_scsi_set_sense (dev , cmd , 0 , 0 , 0 );
4563- break ;
4564-
4565- /* if we reach this, then writeback caching is disabled,
4566- * turning this into a no-op.
4567- */
4568- case SYNCHRONIZE_CACHE :
4569- case SYNCHRONIZE_CACHE_16 :
4570- fallthrough ;
4571-
4572- /* no-op's, complete with success */
4573- case REZERO_UNIT :
4574- case SEEK_6 :
4575- case SEEK_10 :
4576- case TEST_UNIT_READY :
4577- break ;
4578-
4579- case SEND_DIAGNOSTIC :
4580- tmp8 = scsicmd [1 ] & ~(1 << 3 );
4581- if (tmp8 != 0x4 || scsicmd [3 ] || scsicmd [4 ])
4582- ata_scsi_set_invalid_field (dev , cmd , 1 , 0xff );
4583- break ;
4584-
4585- case MAINTENANCE_IN :
4586- ata_scsi_rbuf_fill (dev , cmd , ata_scsiop_maint_in );
4587- break ;
4588-
4589- /* all other commands */
4590- default :
4591- ata_scsi_set_sense (dev , cmd , ILLEGAL_REQUEST , 0x20 , 0x0 );
4592- /* "Invalid command operation code" */
4593- break ;
4594- }
4595-
4596- scsi_done (cmd );
4597- }
4598-
45994598int ata_scsi_add_hosts (struct ata_host * host , const struct scsi_host_template * sht )
46004599{
46014600 int i , rc ;
0 commit comments