public inbox for linux-ide@vger.kernel.org
 help / color / mirror / Atom feed
From: Damien Le Moal <dlemoal@kernel.org>
To: linux-ide@vger.kernel.org, Niklas Cassel <cassel@kernel.org>
Subject: [PATCH 5/5] ata: libata-scsi: rename and improve ata_qc_done()
Date: Thu, 19 Feb 2026 15:23:12 +0900	[thread overview]
Message-ID: <20260219062312.1030867-6-dlemoal@kernel.org> (raw)
In-Reply-To: <20260219062312.1030867-1-dlemoal@kernel.org>

Rename ata_qc_done() to ata_scsi_qc_done() and allow to pass a scsi
command result value to set for the completed command to simplify the
caller sites.

No functional changes.

Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
---
 drivers/ata/libata-scsi.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index ad628b398fc3..4225c6d7ff35 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -1649,12 +1649,16 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc)
 	return 1;
 }
 
-static void ata_qc_done(struct ata_queued_cmd *qc)
+static void ata_scsi_qc_done(struct ata_queued_cmd *qc, bool set_result,
+			     u32 scmd_result)
 {
 	struct scsi_cmnd *cmd = qc->scsicmd;
 	void (*done)(struct scsi_cmnd *) = qc->scsidone;
 
 	ata_qc_free(qc);
+
+	if (set_result)
+		cmd->result = scmd_result;
 	done(cmd);
 }
 
@@ -1693,12 +1697,10 @@ void ata_scsi_requeue_deferred_qc(struct ata_port *ap)
 	 * do not try to be smart about what to do with this deferred command
 	 * and simply retry it by completing it with DID_SOFT_ERROR.
 	 */
-	if (!qc)
-		return;
-
-	ap->deferred_qc = NULL;
-	qc->scsicmd->result = (DID_SOFT_ERROR << 16);
-	ata_qc_done(qc);
+	if (qc) {
+		ap->deferred_qc = NULL;
+		ata_scsi_qc_done(qc, true, DID_SOFT_ERROR << 16);
+	}
 }
 
 static void ata_scsi_schedule_deferred_qc(struct ata_port *ap)
@@ -1754,7 +1756,7 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc)
 		ata_scsi_set_sense_information(qc);
 	}
 
-	ata_qc_done(qc);
+	ata_scsi_qc_done(qc, false, 0);
 
 	ata_scsi_schedule_deferred_qc(ap);
 }
@@ -2913,17 +2915,15 @@ static void atapi_qc_complete(struct ata_queued_cmd *qc)
 		if (qc->cdb[0] == ALLOW_MEDIUM_REMOVAL && qc->dev->sdev)
 			qc->dev->sdev->locked = 0;
 
-		qc->scsicmd->result = SAM_STAT_CHECK_CONDITION;
-		ata_qc_done(qc);
+		ata_scsi_qc_done(qc, true, SAM_STAT_CHECK_CONDITION);
 		return;
 	}
 
 	/* successful completion path */
 	if (cmd->cmnd[0] == INQUIRY && (cmd->cmnd[1] & 0x03) == 0)
 		atapi_fixup_inquiry(cmd);
-	cmd->result = SAM_STAT_GOOD;
 
-	ata_qc_done(qc);
+	ata_scsi_qc_done(qc, true, SAM_STAT_GOOD);
 }
 /**
  *	atapi_xlat - Initialize PACKET taskfile
-- 
2.53.0


  parent reply	other threads:[~2026-02-19  6:28 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-19  6:23 [PATCH 0/5] libata cleanups Damien Le Moal
2026-02-19  6:23 ` [PATCH 1/5] ata: libata-core: improve tag checks in ata_qc_issue() Damien Le Moal
2026-02-19  8:19   ` Hannes Reinecke
2026-02-19  6:23 ` [PATCH 2/5] ata: libata-sata: simplify ata_sas_queuecmd() Damien Le Moal
2026-02-19  8:20   ` Hannes Reinecke
2026-02-19  6:23 ` [PATCH 3/5] ata: libata-scsi: simplify ata_scsi_schedule_deferred_qc() Damien Le Moal
2026-02-19  7:52   ` Sergey Shtylyov
2026-02-19  8:21   ` Hannes Reinecke
2026-02-19 21:38     ` Damien Le Moal
2026-02-19  6:23 ` [PATCH 4/5] ata: libata-scsi: make ata_scsi_simulate() static Damien Le Moal
2026-02-19  8:22   ` Hannes Reinecke
2026-02-19  6:23 ` Damien Le Moal [this message]
2026-02-19  8:26   ` [PATCH 5/5] ata: libata-scsi: rename and improve ata_qc_done() Hannes Reinecke
2026-02-24  0:43 ` [PATCH 0/5] libata cleanups Damien Le Moal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260219062312.1030867-6-dlemoal@kernel.org \
    --to=dlemoal@kernel.org \
    --cc=cassel@kernel.org \
    --cc=linux-ide@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox