aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/libata-core.c
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2006-02-12 08:47:04 -0500
committerJeff Garzik <jgarzik@pobox.com>2006-02-12 14:24:41 -0500
commit2940740bcaa5948967d261dfceec04f40b2d2fa1 (patch)
treed70740391c607cd40222200085b0b028233f6880 /drivers/scsi/libata-core.c
parent2e02671daa2cd69d93c828c40579bbe953f17210 (diff)
[PATCH] libata: separate out ata_id_n_sectors()
Separate out n_sectors calculation into ata_id_n_sectors() from ata_dev_identify(). This will be used by revalidation. Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
Diffstat (limited to 'drivers/scsi/libata-core.c')
-rw-r--r--drivers/scsi/libata-core.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index 1d65f703348e..4df5024c3888 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -548,6 +548,21 @@ void ata_dev_id_c_string(const u16 *id, unsigned char *s,
548 *p = '\0'; 548 *p = '\0';
549} 549}
550 550
551static u64 ata_id_n_sectors(const u16 *id)
552{
553 if (ata_id_has_lba(id)) {
554 if (ata_id_has_lba48(id))
555 return ata_id_u64(id, 100);
556 else
557 return ata_id_u32(id, 60);
558 } else {
559 if (ata_id_current_chs_valid(id))
560 return ata_id_u32(id, 57);
561 else
562 return id[1] * id[3] * id[6];
563 }
564}
565
551/** 566/**
552 * ata_noop_dev_select - Select device 0/1 on ATA bus 567 * ata_noop_dev_select - Select device 0/1 on ATA bus
553 * @ap: ATA channel to manipulate 568 * @ap: ATA channel to manipulate
@@ -1009,6 +1024,8 @@ retry:
1009 1024
1010 /* ATA-specific feature tests */ 1025 /* ATA-specific feature tests */
1011 if (dev->class == ATA_DEV_ATA) { 1026 if (dev->class == ATA_DEV_ATA) {
1027 dev->n_sectors = ata_id_n_sectors(dev->id);
1028
1012 if (!ata_id_is_ata(dev->id)) /* sanity check */ 1029 if (!ata_id_is_ata(dev->id)) /* sanity check */
1013 goto err_out_nosup; 1030 goto err_out_nosup;
1014 1031
@@ -1038,12 +1055,8 @@ retry:
1038 if (ata_id_has_lba(dev->id)) { 1055 if (ata_id_has_lba(dev->id)) {
1039 dev->flags |= ATA_DFLAG_LBA; 1056 dev->flags |= ATA_DFLAG_LBA;
1040 1057
1041 if (ata_id_has_lba48(dev->id)) { 1058 if (ata_id_has_lba48(dev->id))
1042 dev->flags |= ATA_DFLAG_LBA48; 1059 dev->flags |= ATA_DFLAG_LBA48;
1043 dev->n_sectors = ata_id_u64(dev->id, 100);
1044 } else {
1045 dev->n_sectors = ata_id_u32(dev->id, 60);
1046 }
1047 1060
1048 /* print device info to dmesg */ 1061 /* print device info to dmesg */
1049 printk(KERN_INFO "ata%u: dev %u ATA-%d, max %s, %Lu sectors:%s\n", 1062 printk(KERN_INFO "ata%u: dev %u ATA-%d, max %s, %Lu sectors:%s\n",
@@ -1059,15 +1072,12 @@ retry:
1059 dev->cylinders = dev->id[1]; 1072 dev->cylinders = dev->id[1];
1060 dev->heads = dev->id[3]; 1073 dev->heads = dev->id[3];
1061 dev->sectors = dev->id[6]; 1074 dev->sectors = dev->id[6];
1062 dev->n_sectors = dev->cylinders * dev->heads * dev->sectors;
1063 1075
1064 if (ata_id_current_chs_valid(dev->id)) { 1076 if (ata_id_current_chs_valid(dev->id)) {
1065 /* Current CHS translation is valid. */ 1077 /* Current CHS translation is valid. */
1066 dev->cylinders = dev->id[54]; 1078 dev->cylinders = dev->id[54];
1067 dev->heads = dev->id[55]; 1079 dev->heads = dev->id[55];
1068 dev->sectors = dev->id[56]; 1080 dev->sectors = dev->id[56];
1069
1070 dev->n_sectors = ata_id_u32(dev->id, 57);
1071 } 1081 }
1072 1082
1073 /* print device info to dmesg */ 1083 /* print device info to dmesg */