From a83fcf58be0b92102883dd0836d6010f33a27622 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Sun, 12 Feb 2006 22:47:04 +0900 Subject: [PATCH] --- yaml --- r: 21843 b: refs/heads/master c: 2940740bcaa5948967d261dfceec04f40b2d2fa1 h: refs/heads/master i: 21841: 55f1e2c8f28a7f25d47b148963ca231d9a3e4736 21839: 03e0b7bbfa84be86dd601b5b08d892cccdac2b10 v: v3 --- [refs] | 2 +- trunk/drivers/scsi/libata-core.c | 26 ++++++++++++++++++-------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/[refs] b/[refs] index cdfd217188e8..887efe7ed344 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 2e02671daa2cd69d93c828c40579bbe953f17210 +refs/heads/master: 2940740bcaa5948967d261dfceec04f40b2d2fa1 diff --git a/trunk/drivers/scsi/libata-core.c b/trunk/drivers/scsi/libata-core.c index 1d65f703348e..4df5024c3888 100644 --- a/trunk/drivers/scsi/libata-core.c +++ b/trunk/drivers/scsi/libata-core.c @@ -548,6 +548,21 @@ void ata_dev_id_c_string(const u16 *id, unsigned char *s, *p = '\0'; } +static u64 ata_id_n_sectors(const u16 *id) +{ + if (ata_id_has_lba(id)) { + if (ata_id_has_lba48(id)) + return ata_id_u64(id, 100); + else + return ata_id_u32(id, 60); + } else { + if (ata_id_current_chs_valid(id)) + return ata_id_u32(id, 57); + else + return id[1] * id[3] * id[6]; + } +} + /** * ata_noop_dev_select - Select device 0/1 on ATA bus * @ap: ATA channel to manipulate @@ -1009,6 +1024,8 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device) /* ATA-specific feature tests */ if (dev->class == ATA_DEV_ATA) { + dev->n_sectors = ata_id_n_sectors(dev->id); + if (!ata_id_is_ata(dev->id)) /* sanity check */ goto err_out_nosup; @@ -1038,12 +1055,8 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device) if (ata_id_has_lba(dev->id)) { dev->flags |= ATA_DFLAG_LBA; - if (ata_id_has_lba48(dev->id)) { + if (ata_id_has_lba48(dev->id)) dev->flags |= ATA_DFLAG_LBA48; - dev->n_sectors = ata_id_u64(dev->id, 100); - } else { - dev->n_sectors = ata_id_u32(dev->id, 60); - } /* print device info to dmesg */ printk(KERN_INFO "ata%u: dev %u ATA-%d, max %s, %Lu sectors:%s\n", @@ -1059,15 +1072,12 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device) dev->cylinders = dev->id[1]; dev->heads = dev->id[3]; dev->sectors = dev->id[6]; - dev->n_sectors = dev->cylinders * dev->heads * dev->sectors; if (ata_id_current_chs_valid(dev->id)) { /* Current CHS translation is valid. */ dev->cylinders = dev->id[54]; dev->heads = dev->id[55]; dev->sectors = dev->id[56]; - - dev->n_sectors = ata_id_u32(dev->id, 57); } /* print device info to dmesg */