From patchwork Wed May 31 20:52:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 9758103 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 93C3D60390 for ; Wed, 31 May 2017 20:53:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 86138284AF for ; Wed, 31 May 2017 20:53:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7B2DE284CF; Wed, 31 May 2017 20:53:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D2BD284C4 for ; Wed, 31 May 2017 20:53:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751153AbdEaUw7 (ORCPT ); Wed, 31 May 2017 16:52:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56912 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751193AbdEaUw7 (ORCPT ); Wed, 31 May 2017 16:52:59 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 89B177D0D0; Wed, 31 May 2017 20:52:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 89B177D0D0 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mchristi@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 89B177D0D0 Received: from rh2.redhat.com (ovpn-126-11.rdu2.redhat.com [10.10.126.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id EE1CC94D94; Wed, 31 May 2017 20:52:57 +0000 (UTC) From: Mike Christie To: target-devel@vger.kernel.org, nab@linux-iscsi.org Cc: Mike Christie Subject: [RFC PATCH 08/13] target: add helper to setup a se_cmd's sense Date: Wed, 31 May 2017 15:52:45 -0500 Message-Id: <1496263970-7632-9-git-send-email-mchristi@redhat.com> In-Reply-To: <1496263970-7632-1-git-send-email-mchristi@redhat.com> References: <1496263970-7632-1-git-send-email-mchristi@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 31 May 2017 20:52:58 +0000 (UTC) Sender: target-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Move sense setup from transport_send_check_condition_and_sense to a new helper. The next patch will convert usb f_tcm to use it. Signed-off-by: Mike Christie --- drivers/target/target_core_transport.c | 14 ++++++++++---- include/target/target_core_fabric.h | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 62937cf..ad2132e 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -3036,6 +3036,15 @@ static int translate_sense_reason(struct se_cmd *cmd, sense_reason_t reason) return 0; } +int transport_setup_sense(struct se_cmd *cmd, sense_reason_t reason) +{ + cmd->se_cmd_flags |= SCF_TASK_SENSE; + cmd->scsi_status = SAM_STAT_CHECK_CONDITION; + cmd->scsi_sense_length = TRANSPORT_SENSE_BUFFER; + return translate_sense_reason(cmd, reason); +} +EXPORT_SYMBOL(transport_setup_sense); + int transport_send_check_condition_and_sense(struct se_cmd *cmd, sense_reason_t reason, int from_transport) @@ -3053,10 +3062,7 @@ static int translate_sense_reason(struct se_cmd *cmd, sense_reason_t reason) if (!from_transport) { int rc; - cmd->se_cmd_flags |= SCF_TASK_SENSE; - cmd->scsi_status = SAM_STAT_CHECK_CONDITION; - cmd->scsi_sense_length = TRANSPORT_SENSE_BUFFER; - rc = translate_sense_reason(cmd, reason); + rc = transport_setup_sense(cmd, reason); if (rc) return rc; } diff --git a/include/target/target_core_fabric.h b/include/target/target_core_fabric.h index d7dd142..f0153dc 100644 --- a/include/target/target_core_fabric.h +++ b/include/target/target_core_fabric.h @@ -154,6 +154,7 @@ int target_submit_tmr(struct se_cmd *se_cmd, struct se_session *se_sess, bool transport_wait_for_tasks(struct se_cmd *); int transport_check_aborted_status(struct se_cmd *, int); +int transport_setup_sense(struct se_cmd *, sense_reason_t); int transport_send_check_condition_and_sense(struct se_cmd *, sense_reason_t, int); int target_get_sess_cmd(struct se_cmd *, bool);