@@ -1919,7 +1919,6 @@ int ata_dev_configure(struct ata_device *dev)
19191919 snprintf (revbuf , 7 , "ATA-%d" , ata_id_major_version (id ));
19201920
19211921 dev -> n_sectors = ata_id_n_sectors (id );
1922- dev -> n_sectors_boot = dev -> n_sectors ;
19231922
19241923 /* SCSI only uses 4-char revisions, dump full 8 chars from ATA */
19251924 ata_id_c_string (dev -> id , fwrevbuf , ATA_ID_FW_REV ,
@@ -3632,7 +3631,6 @@ static int ata_dev_same_device(struct ata_device *dev, unsigned int new_class,
36323631 const u16 * old_id = dev -> id ;
36333632 unsigned char model [2 ][ATA_ID_PROD_LEN + 1 ];
36343633 unsigned char serial [2 ][ATA_ID_SERNO_LEN + 1 ];
3635- u64 new_n_sectors ;
36363634
36373635 if (dev -> class != new_class ) {
36383636 ata_dev_printk (dev , KERN_INFO , "class mismatch %d != %d\n" ,
@@ -3644,7 +3642,6 @@ static int ata_dev_same_device(struct ata_device *dev, unsigned int new_class,
36443642 ata_id_c_string (new_id , model [1 ], ATA_ID_PROD , sizeof (model [1 ]));
36453643 ata_id_c_string (old_id , serial [0 ], ATA_ID_SERNO , sizeof (serial [0 ]));
36463644 ata_id_c_string (new_id , serial [1 ], ATA_ID_SERNO , sizeof (serial [1 ]));
3647- new_n_sectors = ata_id_n_sectors (new_id );
36483645
36493646 if (strcmp (model [0 ], model [1 ])) {
36503647 ata_dev_printk (dev , KERN_INFO , "model number mismatch "
@@ -3658,25 +3655,12 @@ static int ata_dev_same_device(struct ata_device *dev, unsigned int new_class,
36583655 return 0 ;
36593656 }
36603657
3661- if (dev -> class == ATA_DEV_ATA && dev -> n_sectors != new_n_sectors ) {
3662- ata_dev_printk (dev , KERN_INFO , "n_sectors mismatch "
3663- "%llu != %llu\n" ,
3664- (unsigned long long )dev -> n_sectors ,
3665- (unsigned long long )new_n_sectors );
3666- /* Are we the boot time size - if so we appear to be the
3667- same disk at this point and our HPA got reapplied */
3668- if (ata_ignore_hpa && dev -> n_sectors_boot == new_n_sectors
3669- && ata_id_hpa_enabled (new_id ))
3670- return 1 ;
3671- return 0 ;
3672- }
3673-
36743658 return 1 ;
36753659}
36763660
36773661/**
3678- * ata_dev_revalidate - Revalidate ATA device
3679- * @dev: device to revalidate
3662+ * ata_dev_reread_id - Re-read IDENTIFY data
3663+ * @adev: target ATA device
36803664 * @readid_flags: read ID flags
36813665 *
36823666 * Re-read IDENTIFY page and make sure @dev is still attached to
@@ -3688,34 +3672,68 @@ static int ata_dev_same_device(struct ata_device *dev, unsigned int new_class,
36883672 * RETURNS:
36893673 * 0 on success, negative errno otherwise
36903674 */
3691- int ata_dev_revalidate (struct ata_device * dev , unsigned int readid_flags )
3675+ int ata_dev_reread_id (struct ata_device * dev , unsigned int readid_flags )
36923676{
36933677 unsigned int class = dev -> class ;
36943678 u16 * id = (void * )dev -> ap -> sector_buf ;
36953679 int rc ;
36963680
3697- if (!ata_dev_enabled (dev )) {
3698- rc = - ENODEV ;
3699- goto fail ;
3700- }
3701-
37023681 /* read ID data */
37033682 rc = ata_dev_read_id (dev , & class , readid_flags , id );
37043683 if (rc )
3705- goto fail ;
3684+ return rc ;
37063685
37073686 /* is the device still there? */
3708- if (!ata_dev_same_device (dev , class , id )) {
3709- rc = - ENODEV ;
3710- goto fail ;
3711- }
3687+ if (!ata_dev_same_device (dev , class , id ))
3688+ return - ENODEV ;
37123689
37133690 memcpy (dev -> id , id , sizeof (id [0 ]) * ATA_ID_WORDS );
3691+ return 0 ;
3692+ }
3693+
3694+ /**
3695+ * ata_dev_revalidate - Revalidate ATA device
3696+ * @dev: device to revalidate
3697+ * @readid_flags: read ID flags
3698+ *
3699+ * Re-read IDENTIFY page, make sure @dev is still attached to the
3700+ * port and reconfigure it according to the new IDENTIFY page.
3701+ *
3702+ * LOCKING:
3703+ * Kernel thread context (may sleep)
3704+ *
3705+ * RETURNS:
3706+ * 0 on success, negative errno otherwise
3707+ */
3708+ int ata_dev_revalidate (struct ata_device * dev , unsigned int readid_flags )
3709+ {
3710+ u64 n_sectors = dev -> n_sectors ;
3711+ int rc ;
3712+
3713+ if (!ata_dev_enabled (dev ))
3714+ return - ENODEV ;
3715+
3716+ /* re-read ID */
3717+ rc = ata_dev_reread_id (dev , readid_flags );
3718+ if (rc )
3719+ goto fail ;
37143720
37153721 /* configure device according to the new ID */
37163722 rc = ata_dev_configure (dev );
3717- if (rc == 0 )
3718- return 0 ;
3723+ if (rc )
3724+ goto fail ;
3725+
3726+ /* verify n_sectors hasn't changed */
3727+ if (dev -> class == ATA_DEV_ATA && dev -> n_sectors != n_sectors ) {
3728+ ata_dev_printk (dev , KERN_INFO , "n_sectors mismatch "
3729+ "%llu != %llu\n" ,
3730+ (unsigned long long )n_sectors ,
3731+ (unsigned long long )dev -> n_sectors );
3732+ rc = - ENODEV ;
3733+ goto fail ;
3734+ }
3735+
3736+ return 0 ;
37193737
37203738 fail :
37213739 ata_dev_printk (dev , KERN_ERR , "revalidation failed (errno=%d)\n" , rc );
0 commit comments