[stgt] [PATCH] changed cpu_to_be to put_unaligned_be macros in sbc.c
Alexander Nezhinsky
alexandern at Voltaire.COM
Thu Dec 30 16:33:28 CET 2010
changed __cpu_to_be* to put_unaligned_be* macros in sbc.c
Signed-off-by: Alexander Nezhinsky <alexandern at voltaire.com>
---
usr/sbc.c | 18 ++++++++----------
1 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/usr/sbc.c b/usr/sbc.c
index d73306b..07d8640 100644
--- a/usr/sbc.c
+++ b/usr/sbc.c
@@ -183,9 +183,8 @@ static int sbc_read_capacity(int host_no, struct scsi_cmd *cmd)
bshift = cmd->dev->blk_shift;
size = cmd->dev->size >> bshift;
- data[0] = (size >> 32) ?
- __cpu_to_be32(0xffffffff) : __cpu_to_be32(size - 1);
- data[1] = __cpu_to_be32(1U << bshift);
+ put_unaligned_be32(size >> 32 ? 0xffffffff : size - 1, &data[0]);
+ put_unaligned_be32(1U << bshift, &data[1]);
overflow:
scsi_set_in_resid_by_actual(cmd, 8);
@@ -222,8 +221,8 @@ static int sbc_service_action(int host_no, struct scsi_cmd *cmd)
bshift = cmd->dev->blk_shift;
size = cmd->dev->size >> bshift;
- *((uint64_t *)(data)) = __cpu_to_be64(size - 1);
- data[2] = __cpu_to_be32(1UL << bshift);
+ put_unaligned_be64(size - 1, (uint64_t *)&data[0]);
+ put_unaligned_be32(1UL << bshift, &data[2]);
overflow:
scsi_set_in_resid_by_actual(cmd, len);
@@ -271,7 +270,7 @@ sense:
static int sbc_lu_init(struct scsi_lu *lu)
{
uint64_t size;
- uint8_t *data;
+ uint32_t *data;
if (spc_lu_init(lu))
return TGTADM_NOMEM;
@@ -281,15 +280,14 @@ static int sbc_lu_init(struct scsi_lu *lu)
lu->attrs.version_desc[1] = 0x0960; /* iSCSI */
lu->attrs.version_desc[2] = 0x0300; /* SPC-3 */
- data = lu->mode_block_descriptor;
+ data = (uint32_t *)lu->mode_block_descriptor;
if (!lu->blk_shift)
lu->blk_shift = blk_shift; /* if unset, use default shift */
size = lu->size >> lu->blk_shift; /* calculate size in blocks */
- *(uint32_t *)(data) = (size >> 32) ?
- __cpu_to_be32(0xffffffff) : __cpu_to_be32(size);
- *(uint32_t *)(data + 4) = __cpu_to_be32(1 << lu->blk_shift);
+ put_unaligned_be32(size >> 32 ? 0xffffffff : (uint32_t)size, &data[0]);
+ put_unaligned_be32(1 << lu->blk_shift, &data[1]);
/* Vendor uniq - However most apps seem to call for mode page 0*/
add_mode_page(lu, "0:0:0");
--
1.7.3
--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
More information about the stgt
mailing list