ide-cd: fix endianity for the error message in cdrom_read_capacity
Aesthetic regards aside, commit e8e7b9eb11
still leaves a bug in the error message, because it uses the unconverted
big-endian value for printk.
Fix this by using a local variable in machine byte order. The result is
correct, more readable, and also produces slightly shorter code on i386.
Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
Cc: Jens Axboe <jens.axboe@oracle.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: <stable@kernel.org>
Acked-by: Borislav Petkov <petkovbb@gmail.com>
[bart: __u32 -> u32]
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
This commit is contained in:
parent
c5bfc3757f
commit
938bb03d18
|
@ -1307,6 +1307,7 @@ static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity,
|
||||||
int stat;
|
int stat;
|
||||||
unsigned char cmd[BLK_MAX_CDB];
|
unsigned char cmd[BLK_MAX_CDB];
|
||||||
unsigned len = sizeof(capbuf);
|
unsigned len = sizeof(capbuf);
|
||||||
|
u32 blocklen;
|
||||||
|
|
||||||
memset(cmd, 0, BLK_MAX_CDB);
|
memset(cmd, 0, BLK_MAX_CDB);
|
||||||
cmd[0] = GPCMD_READ_CDVD_CAPACITY;
|
cmd[0] = GPCMD_READ_CDVD_CAPACITY;
|
||||||
|
@ -1319,23 +1320,24 @@ static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity,
|
||||||
/*
|
/*
|
||||||
* Sanity check the given block size
|
* Sanity check the given block size
|
||||||
*/
|
*/
|
||||||
switch (capbuf.blocklen) {
|
blocklen = be32_to_cpu(capbuf.blocklen);
|
||||||
case __constant_cpu_to_be32(512):
|
switch (blocklen) {
|
||||||
case __constant_cpu_to_be32(1024):
|
case 512:
|
||||||
case __constant_cpu_to_be32(2048):
|
case 1024:
|
||||||
case __constant_cpu_to_be32(4096):
|
case 2048:
|
||||||
|
case 4096:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printk(KERN_ERR "%s: weird block size %u\n",
|
printk(KERN_ERR "%s: weird block size %u\n",
|
||||||
drive->name, capbuf.blocklen);
|
drive->name, blocklen);
|
||||||
printk(KERN_ERR "%s: default to 2kb block size\n",
|
printk(KERN_ERR "%s: default to 2kb block size\n",
|
||||||
drive->name);
|
drive->name);
|
||||||
capbuf.blocklen = __constant_cpu_to_be32(2048);
|
blocklen = 2048;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
*capacity = 1 + be32_to_cpu(capbuf.lba);
|
*capacity = 1 + be32_to_cpu(capbuf.lba);
|
||||||
*sectors_per_frame = be32_to_cpu(capbuf.blocklen) >> SECTOR_BITS;
|
*sectors_per_frame = blocklen >> SECTOR_BITS;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue