aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-cd.c
diff options
context:
space:
mode:
authorPetr Tesarik <ptesarik@suse.cz>2008-08-05 12:17:02 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-08-05 12:17:02 -0400
commit938bb03d188a1e688fb0bcae49788f540193e80a (patch)
tree75cbe491a4537acab55b37e24384f6a7915b8e73 /drivers/ide/ide-cd.c
parentc5bfc3757f1d843a8e1261840c1f53c5062f8e92 (diff)
ide-cd: fix endianity for the error message in cdrom_read_capacity
Aesthetic regards aside, commit e8e7b9eb11c34ee18bde8b7011af41938d1ad667 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>
Diffstat (limited to 'drivers/ide/ide-cd.c')
-rw-r--r--drivers/ide/ide-cd.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index e19caa1453a3..89a112d513ad 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -1307,6 +1307,7 @@ static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity,
1307 int stat; 1307 int stat;
1308 unsigned char cmd[BLK_MAX_CDB]; 1308 unsigned char cmd[BLK_MAX_CDB];
1309 unsigned len = sizeof(capbuf); 1309 unsigned len = sizeof(capbuf);
1310 u32 blocklen;
1310 1311
1311 memset(cmd, 0, BLK_MAX_CDB); 1312 memset(cmd, 0, BLK_MAX_CDB);
1312 cmd[0] = GPCMD_READ_CDVD_CAPACITY; 1313 cmd[0] = GPCMD_READ_CDVD_CAPACITY;
@@ -1319,23 +1320,24 @@ static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity,
1319 /* 1320 /*
1320 * Sanity check the given block size 1321 * Sanity check the given block size
1321 */ 1322 */
1322 switch (capbuf.blocklen) { 1323 blocklen = be32_to_cpu(capbuf.blocklen);
1323 case __constant_cpu_to_be32(512): 1324 switch (blocklen) {
1324 case __constant_cpu_to_be32(1024): 1325 case 512:
1325 case __constant_cpu_to_be32(2048): 1326 case 1024:
1326 case __constant_cpu_to_be32(4096): 1327 case 2048:
1328 case 4096:
1327 break; 1329 break;
1328 default: 1330 default:
1329 printk(KERN_ERR "%s: weird block size %u\n", 1331 printk(KERN_ERR "%s: weird block size %u\n",
1330 drive->name, capbuf.blocklen); 1332 drive->name, blocklen);
1331 printk(KERN_ERR "%s: default to 2kb block size\n", 1333 printk(KERN_ERR "%s: default to 2kb block size\n",
1332 drive->name); 1334 drive->name);
1333 capbuf.blocklen = __constant_cpu_to_be32(2048); 1335 blocklen = 2048;
1334 break; 1336 break;
1335 } 1337 }
1336 1338
1337 *capacity = 1 + be32_to_cpu(capbuf.lba); 1339 *capacity = 1 + be32_to_cpu(capbuf.lba);
1338 *sectors_per_frame = be32_to_cpu(capbuf.blocklen) >> SECTOR_BITS; 1340 *sectors_per_frame = blocklen >> SECTOR_BITS;
1339 return 0; 1341 return 0;
1340} 1342}
1341 1343