public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Bart Van Assche <Bart.VanAssche@wdc.com>
To: "jthumshirn@suse.de" <jthumshirn@suse.de>,
	"martin.petersen@oracle.com" <martin.petersen@oracle.com>
Cc: "linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"tj@kernel.org" <tj@kernel.org>,
	Bart Van Assche <Bart.VanAssche@wdc.com>,
	"maier@linux.vnet.ibm.com" <maier@linux.vnet.ibm.com>,
	"stern@rowland.harvard.edu" <stern@rowland.harvard.edu>,
	"oneukum@suse.com" <oneukum@suse.com>
Subject: Re: [PATCH] scsi: use set_host_byte instead of open-coding it
Date: Tue, 10 Oct 2017 16:02:04 +0000	[thread overview]
Message-ID: <1507651323.2815.18.camel@wdc.com> (raw)
In-Reply-To: <20171010152939.21353-1-jthumshirn@suse.de>

On Tue, 2017-10-10 at 17:29 +0200, Johannes Thumshirn wrote:
> Call set_host_byte() instead of open-coding it.
> 
> Converted using this simple Coccinelle spatch
> 
> <SmPL>
> @@
> local idexpression struct scsi_cmnd *c;
> expression E1;
> @@
> 
> - c->result = E1 << 16;
> + set_host_byte(c, E1);
> </SmPL>

This is useful but I think we should take this a step further. How
about the following approach:
- Introduce four enumeration types - one for the msg byte codes, one
  for the host byte codes, one for the driver byte codes and one for
  SCSI sense codes.
- Update the signatures of functions that store or extract these four
  bytes.
- Change the data type of scsi_cmnd.result into something that makes
  regular assignments trigger a compiler error.

I'm proposing this because there are several drivers that do not assign the
SCSI host byte correctly:
$ git grep -nH '>result = DID_' | grep -v '<< *16' | grep -v ': \*'
drivers/scsi/ips.c:953:			scsi_cmd->result = DID_ERROR;
drivers/scsi/ips.c:2657:		SC->result = DID_OK;
drivers/scsi/libiscsi.c:1731:		sc->result = DID_REQUEUE;
drivers/scsi/qla2xxx/qla_bsg.c:152:			bsg_reply->result = DID_OK;
drivers/scsi/qla2xxx/qla_bsg.c:167:				bsg_reply->result = DID_OK;
drivers/scsi/qla2xxx/qla_bsg.c:184:		bsg_reply->result = DID_OK;
drivers/scsi/qla2xxx/qla_bsg.c:236:		bsg_reply->result = DID_OK;
drivers/scsi/qla2xxx/qla_bsg.c:976:		bsg_reply->result = DID_OK;
drivers/scsi/qla2xxx/qla_bsg.c:1078:		bsg_reply->result = DID_OK;
drivers/scsi/qla2xxx/qla_bsg.c:1261:		bsg_reply->result = DID_OK;
drivers/scsi/qla2xxx/qla_bsg.c:1375:		bsg_reply->result = DID_OK;
drivers/scsi/qla2xxx/qla_bsg.c:1480:	bsg_reply->result = DID_OK;
drivers/scsi/qla2xxx/qla_bsg.c:1516:	bsg_reply->result = DID_OK;
drivers/scsi/qlogicpti.c:1049:	Cmnd->result = DID_BUS_BUSY;
drivers/scsi/stex.c:615:		cmd->result = DID_NO_CONNECT;

Bart.

  reply	other threads:[~2017-10-10 16:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-10 15:29 [PATCH] scsi: use set_host_byte instead of open-coding it Johannes Thumshirn
2017-10-10 16:02 ` Bart Van Assche [this message]
2017-10-11 13:05 ` Steffen Maier
2017-10-11 13:25   ` Johannes Thumshirn

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=1507651323.2815.18.camel@wdc.com \
    --to=bart.vanassche@wdc.com \
    --cc=jthumshirn@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=maier@linux.vnet.ibm.com \
    --cc=martin.petersen@oracle.com \
    --cc=oneukum@suse.com \
    --cc=stern@rowland.harvard.edu \
    --cc=tj@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