All of lore.kernel.org
 help / color / mirror / Atom feed
From: Boaz Harrosh <bharrosh@panasas.com>
To: Jens Axboe <jens.axboe@oracle.com>
Cc: Harvey Harrison <harvey.harrison@gmail.com>,
	James Bottomley <James.Bottomley@HansenPartnership.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-scsi <linux-scsi@vger.kernel.org>
Subject: Re: [PATCH] scsi: sr.c use unaligned access helpers
Date: Tue, 07 Oct 2008 14:19:14 +0200	[thread overview]
Message-ID: <48EB53C2.6050101@panasas.com> (raw)
In-Reply-To: <20081007121025.GY19428@kernel.dk>

Jens Axboe wrote:
> On Fri, Oct 03 2008, Harvey Harrison wrote:
>> Preserve the cd->capacity indentation near the #if 0'd if() statement.
>>
>> Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
>> ---
>>  drivers/scsi/sr.c |   26 ++++++++------------------
>>  1 files changed, 8 insertions(+), 18 deletions(-)
>>
>> diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
>> index 27f5bfd..f1b650e 100644
>> --- a/drivers/scsi/sr.c
>> +++ b/drivers/scsi/sr.c
>> @@ -45,6 +45,7 @@
>>  #include <linux/blkdev.h>
>>  #include <linux/mutex.h>
>>  #include <asm/uaccess.h>
>> +#include <asm/unaligned.h>
>>  
>>  #include <scsi/scsi.h>
>>  #include <scsi/scsi_dbg.h>
>> @@ -280,10 +281,7 @@ static int sr_done(struct scsi_cmnd *SCpnt)
>>  		case ILLEGAL_REQUEST:
>>  			if (!(SCpnt->sense_buffer[0] & 0x90))
>>  				break;
>> -			error_sector = (SCpnt->sense_buffer[3] << 24) |
>> -				(SCpnt->sense_buffer[4] << 16) |
>> -				(SCpnt->sense_buffer[5] << 8) |
>> -				SCpnt->sense_buffer[6];
>> +			error_sector = get_unaligned_be32(SCpnt->sense_buffer + 3);
>>  			if (SCpnt->request->bio != NULL)
>>  				block_sectors =
>>  					bio_sectors(SCpnt->request->bio);
>> @@ -445,13 +443,9 @@ static int sr_prep_fn(struct request_queue *q, struct request *rq)
>>  		SCpnt->sdb.length = this_count * s_size;
>>  	}
>>  
>> -	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;
>> +	put_unaligned_be32(block, SCpnt->cmnd + 2);
>>  	SCpnt->cmnd[6] = SCpnt->cmnd[9] = 0;
>> -	SCpnt->cmnd[7] = (unsigned char) (this_count >> 8) & 0xff;
>> -	SCpnt->cmnd[8] = (unsigned char) this_count & 0xff;
>> +	put_unaligned_be16(this_count, SCpnt->cmnd + 7);
>>  
>>  	/*
>>  	 * We shouldn't disconnect in the middle of a sector, so with a dumb
> 
> Lets not please, it reduces readability a lot when you are used to SCSI
> cdb filling.
> 
> 

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

My $0.017
Boaz


  reply	other threads:[~2008-10-07 12:19 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 [this message]
2008-10-07 19:25     ` Andrew Morton
2008-10-07 19:37       ` Matthew Wilcox

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=48EB53C2.6050101@panasas.com \
    --to=bharrosh@panasas.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=akpm@linux-foundation.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.