Skip to content

Commit

Permalink
[PATCH] aoe: use get_unaligned for accesses in ATA id buffer
Browse files Browse the repository at this point in the history
Signed-off-by: "Ed L. Cashin" <ecashin@coraid.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

Use get_unaligned for possibly-unaligned multi-byte accesses to the
ATA device identify response buffer.
  • Loading branch information
Ed L. Cashin authored and Greg Kroah-Hartman committed Oct 28, 2005
1 parent 741b225 commit 475172f
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions drivers/block/aoe/aoecmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <linux/blkdev.h>
#include <linux/skbuff.h>
#include <linux/netdevice.h>
#include <asm/unaligned.h>
#include "aoe.h"

#define TIMERTICK (HZ / 10)
Expand Down Expand Up @@ -311,16 +312,16 @@ ataid_complete(struct aoedev *d, unsigned char *id)
u16 n;

/* word 83: command set supported */
n = le16_to_cpup((__le16 *) &id[83<<1]);
n = le16_to_cpu(get_unaligned((__le16 *) &id[83<<1]));

/* word 86: command set/feature enabled */
n |= le16_to_cpup((__le16 *) &id[86<<1]);
n |= le16_to_cpu(get_unaligned((__le16 *) &id[86<<1]));

if (n & (1<<10)) { /* bit 10: LBA 48 */
d->flags |= DEVFL_EXT;

/* word 100: number lba48 sectors */
ssize = le64_to_cpup((__le64 *) &id[100<<1]);
ssize = le64_to_cpu(get_unaligned((__le64 *) &id[100<<1]));

/* set as in ide-disk.c:init_idedisk_capacity */
d->geo.cylinders = ssize;
Expand All @@ -331,12 +332,12 @@ ataid_complete(struct aoedev *d, unsigned char *id)
d->flags &= ~DEVFL_EXT;

/* number lba28 sectors */
ssize = le32_to_cpup((__le32 *) &id[60<<1]);
ssize = le32_to_cpu(get_unaligned((__le32 *) &id[60<<1]));

/* NOTE: obsolete in ATA 6 */
d->geo.cylinders = le16_to_cpup((__le16 *) &id[54<<1]);
d->geo.heads = le16_to_cpup((__le16 *) &id[55<<1]);
d->geo.sectors = le16_to_cpup((__le16 *) &id[56<<1]);
d->geo.cylinders = le16_to_cpu(get_unaligned((__le16 *) &id[54<<1]));
d->geo.heads = le16_to_cpu(get_unaligned((__le16 *) &id[55<<1]));
d->geo.sectors = le16_to_cpu(get_unaligned((__le16 *) &id[56<<1]));
}
d->ssize = ssize;
d->geo.start = 0;
Expand Down

0 comments on commit 475172f

Please sign in to comment.