From 8a53a5408197df90d946a76fb605e2806940d6ce Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Mon, 28 Apr 2014 22:30:03 +0000 Subject: [PATCH] Let REPORT SUPPORTED OPERATION CODES be handled by dev handler as well git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@5489 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_lib.c | 5 +++-- scst/src/scst_targ.c | 16 +++++----------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 6ddf71540..5d359acd4 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -7143,8 +7143,9 @@ static int get_cdb_info_min(struct scst_cmd *cmd, break; case MI_REPORT_SUPPORTED_OPERATION_CODES: cmd->op_name = "REPORT SUPPORTED OPERATION CODES"; - cmd->op_flags |= SCST_WRITE_EXCL_ALLOWED | - SCST_LOCAL_CMD | SCST_FULLY_LOCAL_CMD; + cmd->op_flags |= SCST_WRITE_EXCL_ALLOWED; + if (cmd->devt->get_supported_opcodes != NULL) + cmd->op_flags |= SCST_LOCAL_CMD | SCST_FULLY_LOCAL_CMD; break; case MI_REPORT_SUPPORTED_TASK_MANAGEMENT_FUNCTIONS: cmd->op_name = "REPORT SUPPORTED TASK MANAGEMENT FUNCTIONS"; diff --git a/scst/src/scst_targ.c b/scst/src/scst_targ.c index 3011e43eb..41de5b8fb 100644 --- a/scst/src/scst_targ.c +++ b/scst/src/scst_targ.c @@ -2134,21 +2134,15 @@ static int scst_report_supported_opcodes(struct scst_cmd *cmd) int req_sa = get_unaligned_be16(&cmd->cdb[4]); const struct scst_opcode_descriptor *op = NULL; const struct scst_opcode_descriptor **supp_opcodes = NULL; - int supp_opcodes_cnt; + int supp_opcodes_cnt, rc; TRACE_ENTRY(); - if (cmd->devt->get_supported_opcodes == NULL) { - TRACE(TRACE_MINOR, "REPORT SUPPORTED OPCODES not supported by " - "dev handler %s", cmd->devt->name); - scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_invalid_opcode)); + /* get_cdb_info_min() ensures that get_supported_opcodes is not NULL here */ + + rc = cmd->devt->get_supported_opcodes(cmd, &supp_opcodes, &supp_opcodes_cnt); + if (rc != 0) goto out_compl; - } else { - int rc = cmd->devt->get_supported_opcodes(cmd, &supp_opcodes, - &supp_opcodes_cnt); - if (rc != 0) - goto out_compl; - } TRACE_DBG("cmd %p, options %d, req_opcode %x, req_sa %x, rctd %d", cmd, options, req_opcode, req_sa, rctd);