[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4FB3E6B8.7050909@acm.org>
Date: Wed, 16 May 2012 17:41:12 +0000
From: Bart Van Assche <bvanassche@....org>
To: Tim Chen <tim.c.chen@...ux.intel.com>
CC: linux-fsdevel <linux-fsdevel@...r.kernel.org>,
linux-scsi@...r.kernel.org,
linux-kernel <linux-kernel@...r.kernel.org>,
Matthew Wilcox <willy@...ux.intel.com>,
Andi Kleen <ak@...ux.intel.com>
Subject: Re: SCSI RAM driver ported to 3.3 kernel for file system and I/O
testing
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.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists