public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Matthew Wilcox <matthew@wil.cx>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Boaz Harrosh <bharrosh@panasas.com>,
	jens.axboe@oracle.com, harvey.harrison@gmail.com,
	James.Bottomley@HansenPartnership.com,
	linux-scsi@vger.kernel.org
Subject: Re: [PATCH] scsi: sr.c use unaligned access helpers
Date: Tue, 7 Oct 2008 13:37:11 -0600	[thread overview]
Message-ID: <20081007193711.GK25780@parisc-linux.org> (raw)
In-Reply-To: <20081007122531.fbe3c6b8.akpm@linux-foundation.org>

On Tue, Oct 07, 2008 at 12:25:31PM -0700, Andrew Morton wrote:
> On Tue, 07 Oct 2008 14:19:14 +0200
> Boaz Harrosh <bharrosh@panasas.com> wrote:
> > I feel the opposite. That is: put_unaligned_be32(block, SCpnt->cmnd + 2);
> > is much more readable for me. Coming from the spec, I'm looking for a __b32
> > at offset CDB+2 and not: "SCpnt->cmnd[4] = (unsigned char) (block >> 8) & 0xff;"
> > At offset CDB+4 the 2nd-or-3rd? order byte of "block".
> > 
> > And for BE systems it's a gain. So please DO
> 
> Yeah.  For neophytes it's a good change.  This:
> 
> 	SCpnt->cmnd[2] = (unsigned char) (block >> 24) & 0xff;
> 	SCpnt->cmnd[3] = (unsigned char) (block >> 16) & 0xff;
> 	SCpnt->cmnd[4] = (unsigned char) (block >> 8) & 0xff;
> 	SCpnt->cmnd[5] = (unsigned char) block & 0xff;
> 
> is "wtf is that doing?", whereas this:
> 
> 	put_unaligned_be32(block, SCpnt->cmnd + 2);
> 
> is "ah, I know what that's doing".

And scsi_put_u32(block, SCpnt->cmnd + 2); is even more obvious.  You
don't even need to know that SCSI is a big-endian protocol that way,
just that the u32 is being written in the appropriate way for SCSI
(see also ntohl et al).

Also, SCSI needs to be able to read/write 'u24' quantities, which is
potentially an ambiguous thing if you consider it in terms of
byteswapping.  I don't think we want a put_unaligned_be24() function,
but we do want a scsi_put_u24().

-- 
Matthew Wilcox				Intel Open Source Technology Centre
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."

      reply	other threads:[~2008-10-07 19:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-04  0:46 [PATCH] scsi: sr.c use unaligned access helpers Harvey Harrison
2008-10-07 12:10 ` Jens Axboe
2008-10-07 12:19   ` Boaz Harrosh
2008-10-07 19:25     ` Andrew Morton
2008-10-07 19:37       ` Matthew Wilcox [this message]

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=20081007193711.GK25780@parisc-linux.org \
    --to=matthew@wil.cx \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=akpm@linux-foundation.org \
    --cc=bharrosh@panasas.com \
    --cc=harvey.harrison@gmail.com \
    --cc=jens.axboe@oracle.com \
    --cc=linux-scsi@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