linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: Tim Chen <tim.c.chen@linux.intel.com>
Cc: linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	linux-scsi@vger.kernel.org,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Matthew Wilcox <willy@linux.intel.com>,
	Andi Kleen <ak@linux.intel.com>
Subject: Re: SCSI RAM driver ported to 3.3 kernel for file system and I/O testing
Date: Wed, 16 May 2012 17:41:12 +0000	[thread overview]
Message-ID: <4FB3E6B8.7050909@acm.org> (raw)
In-Reply-To: <1337188023.3796.130.camel@schen9-DESK>

On 05/16/12 17:07, Tim Chen wrote:

> +/*
> + * SCSI requires quantities to be written MSB.  They're frequently misaligned,
> + * so don't mess about with cpu_to_beN, just access it byte-wise
> + */
> +static void scsi_ram_put_u32(unsigned char *addr, unsigned int data)
> +{
> +	addr[0] = data >> 24;
> +	addr[1] = data >> 16;
> +	addr[2] = data >> 8;
> +	addr[3] = data;
> +}
> +
> +static unsigned int scsi_ram_get_u16(unsigned char *addr)
> +{
> +	unsigned int data;
> +	data = addr[0] << 8;
> +	data |= addr[1];
> +
> +	return data;
> +}
> +
> +static unsigned int scsi_ram_get_u24(unsigned char *addr)
> +{
> +	unsigned int data;
> +	data = addr[0] << 16;
> +	data |= addr[1] << 8;
> +	data |= addr[2];
> +
> +	return data;
> +}
> +
> +static unsigned int scsi_ram_get_u32(unsigned char *addr)
> +{
> +	unsigned int data;
> +	data = addr[0] << 24;
> +	data |= addr[1] << 16;
> +	data |= addr[2] << 8;
> +	data |= addr[3];
> +
> +	return data;
> +}


Please drop these functions and use get/put_unaligned_be*() instead.
Maybe it's a good idea to add get/put_unaligned_be24() helper functions
in the appropriate <linux/unaligned/...> header file - there is more
SCSI code that stores and retrieves 24-bit numbers.

Thanks,

Bart.

  parent reply	other threads:[~2012-05-16 17:41 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-16 17:07 SCSI RAM driver ported to 3.3 kernel for file system and I/O testing Tim Chen
2012-05-16 17:18 ` Joe Perches
2012-05-16 19:02   ` Tim Chen
2012-05-16 17:41 ` Bart Van Assche [this message]
2012-05-16 19:31 ` chetan loke
2012-05-16 19:35   ` Matthew Wilcox
2012-05-16 19:37     ` chetan loke
2012-05-16 19:43       ` Matthew Wilcox
2012-05-16 19:54         ` chetan loke
2012-05-16 20:22           ` Matthew Wilcox
2012-05-16 20:05   ` Tim Chen

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=4FB3E6B8.7050909@acm.org \
    --to=bvanassche@acm.org \
    --cc=ak@linux.intel.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=tim.c.chen@linux.intel.com \
    --cc=willy@linux.intel.com \
    /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;
as well as URLs for NNTP newsgroup(s).