aboutsummaryrefslogtreecommitdiffstats
path: root/target
diff options
context:
space:
mode:
authorFlorian Fainelli <florian@openwrt.org>2008-07-15 10:22:28 +0000
committerFlorian Fainelli <florian@openwrt.org>2008-07-15 10:22:28 +0000
commitb83064f4e2ff5fbd99a9327f5482d94e6f6e294c (patch)
treeafa7d9b69b94aafa33fd146843042791b4f97fd1 /target
parenta3e9c5a2b96dc2b255e57e631cd49784bd039276 (diff)
downloadupstream-b83064f4e2ff5fbd99a9327f5482d94e6f6e294c.tar.gz
upstream-b83064f4e2ff5fbd99a9327f5482d94e6f6e294c.tar.bz2
upstream-b83064f4e2ff5fbd99a9327f5482d94e6f6e294c.zip
Fix the CF serial number byteswapping (#3133)
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@11837 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target')
-rw-r--r--target/linux/rb532/files/drivers/block/rb500/ata.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/target/linux/rb532/files/drivers/block/rb500/ata.c b/target/linux/rb532/files/drivers/block/rb500/ata.c
index e4085c27ad..31e6782fa4 100644
--- a/target/linux/rb532/files/drivers/block/rb500/ata.c
+++ b/target/linux/rb532/files/drivers/block/rb500/ata.c
@@ -358,6 +358,8 @@ static int do_identify(struct cf_mips_dev *dev)
u16 sbuf[CF_SECT_SIZE >> 1];
int res;
char tstr[17]; //serial
+ char tmp;
+ int i;
BUG_ON(dev->tstate!=TS_IDLE);
dev->tbuf = (char *) sbuf;
dev->tbuf_size = CF_SECT_SIZE;
@@ -381,8 +383,16 @@ static int do_identify(struct cf_mips_dev *dev)
dev->spt = sbuf[6];
dev->sectors = ((unsigned long) sbuf[7] << 16) | sbuf[8];
dev->dtype=sbuf[0];
- memcpy(tstr,&sbuf[12],16);
- tstr[16]=0;
+ memcpy(tstr, &sbuf[12], 16);
+ tstr[16] = '\0';
+
+ /* Byte-swap the serial number */
+ for (i = 0; i<8; i++) {
+ tmp = tstr[i * 2];
+ tstr[i * 2] = tstr[i * 2 +1];
+ tstr[i * 2 + 1] = tmp;
+ }
+
printk(KERN_INFO "cf-mips: %s detected, C/H/S=%d/%d/%d sectors=%u (%uMB) Serial=%s\n",
(sbuf[0] == 0x848A ? "CF card" : "ATA drive"), dev->cyl, dev->head,
dev->spt, dev->sectors, dev->sectors >> 11, tstr);