Re: SCSI RAM driver ported to 3.3 kernel for file system and I/Otesting

From: Bart Van Assche
Date: Wed May 16 2012 - 13:41:15 EST


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@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/