@@ -99,12 +99,13 @@ static void ide_disk_put(struct ide_disk_obj *idkp)
9999 *
100100 * It is called only once for each drive.
101101 */
102- static int lba_capacity_is_ok (struct hd_driveid * id )
102+ static int lba_capacity_is_ok (u16 * id )
103103{
104+ struct hd_driveid * driveid = (struct hd_driveid * )id ;
104105 unsigned long lba_sects , chs_sects , head , tail ;
105106
106107 /* No non-LBA info .. so valid! */
107- if (id -> cyls == 0 )
108+ if (id [ ATA_ID_CYLS ] == 0 )
108109 return 1 ;
109110
110111 /*
@@ -113,15 +114,15 @@ static int lba_capacity_is_ok(struct hd_driveid *id)
113114 * Some drives can be jumpered to use 15 heads instead of 16.
114115 * Some drives can be jumpered to use 4092 cyls instead of 16383.
115116 */
116- if ((id -> cyls == 16383
117- || (id -> cyls == 4092 && id -> cur_cyls == 16383 )) &&
118- id -> sectors == 63 &&
119- (id -> heads == 15 || id -> heads == 16 ) &&
120- (id -> lba_capacity >= 16383 * 63 * id -> heads ))
117+ if ((id [ ATA_ID_CYLS ] == 16383 ||
118+ (id [ ATA_ID_CYLS ] == 4092 && id [ ATA_ID_CUR_CYLS ] == 16383 )) &&
119+ id [ ATA_ID_SECTORS ] == 63 &&
120+ (id [ ATA_ID_HEADS ] == 15 || id [ ATA_ID_HEADS ] == 16 ) &&
121+ (driveid -> lba_capacity >= 16383 * 63 * id [ ATA_ID_HEADS ] ))
121122 return 1 ;
122123
123- lba_sects = id -> lba_capacity ;
124- chs_sects = id -> cyls * id -> heads * id -> sectors ;
124+ lba_sects = driveid -> lba_capacity ;
125+ chs_sects = id [ ATA_ID_CYLS ] * id [ ATA_ID_HEADS ] * id [ ATA_ID_SECTORS ] ;
125126
126127 /* perform a rough sanity check on lba_sects: within 10% is OK */
127128 if ((lba_sects - chs_sects ) < chs_sects /10 )
@@ -132,7 +133,7 @@ static int lba_capacity_is_ok(struct hd_driveid *id)
132133 tail = (lba_sects & 0xffff );
133134 lba_sects = (head | (tail << 16 ));
134135 if ((lba_sects - chs_sects ) < chs_sects /10 ) {
135- id -> lba_capacity = lba_sects ;
136+ driveid -> lba_capacity = lba_sects ;
136137 return 1 ; /* lba_capacity is (now) good */
137138 }
138139
@@ -389,18 +390,20 @@ static unsigned long long sectors_to_MB(unsigned long long n)
389390 * so on non-buggy drives we need test only one.
390391 * However, we should also check whether these fields are valid.
391392 */
392- static inline int idedisk_supports_hpa (const struct hd_driveid * id )
393+ static inline int idedisk_supports_hpa (const u16 * id )
393394{
394- return (id -> command_set_1 & 0x0400 ) && (id -> cfs_enable_1 & 0x0400 );
395+ return (id [ATA_ID_COMMAND_SET_1 ] & 0x0400 ) &&
396+ (id [ATA_ID_CFS_ENABLE_1 ] & 0x0400 );
395397}
396398
397399/*
398400 * The same here.
399401 */
400- static inline int idedisk_supports_lba48 (const struct hd_driveid * id )
402+ static inline int idedisk_supports_lba48 (const u16 * id )
401403{
402- return (id -> command_set_2 & 0x0400 ) && (id -> cfs_enable_2 & 0x0400 )
403- && id -> lba_capacity_2 ;
404+ return (id [ATA_ID_COMMAND_SET_2 ] & 0x0400 ) &&
405+ (id [ATA_ID_CFS_ENABLE_2 ] & 0x0400 ) &&
406+ ((struct hd_driveid * )id )-> lba_capacity_2 ;
404407}
405408
406409/*
@@ -453,7 +456,8 @@ static void idedisk_check_hpa(ide_drive_t *drive)
453456
454457static void init_idedisk_capacity (ide_drive_t * drive )
455458{
456- struct hd_driveid * id = drive -> id ;
459+ struct hd_driveid * driveid = drive -> driveid ;
460+ u16 * id = drive -> id ;
457461 /*
458462 * If this drive supports the Host Protected Area feature set,
459463 * then we may need to change our opinion about the drive's capacity.
@@ -463,13 +467,13 @@ static void init_idedisk_capacity(ide_drive_t *drive)
463467 if (idedisk_supports_lba48 (id )) {
464468 /* drive speaks 48-bit LBA */
465469 drive -> select .b .lba = 1 ;
466- drive -> capacity64 = id -> lba_capacity_2 ;
470+ drive -> capacity64 = driveid -> lba_capacity_2 ;
467471 if (hpa )
468472 idedisk_check_hpa (drive );
469- } else if ((id -> capability & 2 ) && lba_capacity_is_ok (id )) {
473+ } else if ((driveid -> capability & 2 ) && lba_capacity_is_ok (id )) {
470474 /* drive speaks 28-bit LBA */
471475 drive -> select .b .lba = 1 ;
472- drive -> capacity64 = id -> lba_capacity ;
476+ drive -> capacity64 = driveid -> lba_capacity ;
473477 if (hpa )
474478 idedisk_check_hpa (drive );
475479 } else {
@@ -523,7 +527,7 @@ static int proc_idedisk_read_cache
523527 int len ;
524528
525529 if (drive -> id_read )
526- len = sprintf (out , "%i\n" , drive -> id -> buf_size / 2 );
530+ len = sprintf (out , "%i\n" , drive -> id [ ATA_ID_BUF_SIZE ] / 2 );
527531 else
528532 len = sprintf (out , "(none)\n" );
529533
@@ -618,7 +622,7 @@ static int set_multcount(ide_drive_t *drive, int arg)
618622 struct request * rq ;
619623 int error ;
620624
621- if (arg < 0 || arg > drive -> id -> max_multsect )
625+ if (arg < 0 || arg > drive -> driveid -> max_multsect )
622626 return - EINVAL ;
623627
624628 if (drive -> special .b .set_multmode )
@@ -650,7 +654,7 @@ static int set_nowerr(ide_drive_t *drive, int arg)
650654
651655static void update_ordered (ide_drive_t * drive )
652656{
653- struct hd_driveid * id = drive -> id ;
657+ u16 * id = drive -> id ;
654658 unsigned ordered = QUEUE_ORDERED_NONE ;
655659 prepare_flush_fn * prep_fn = NULL ;
656660
@@ -762,8 +766,6 @@ static int set_lba_addressing(ide_drive_t *drive, int arg)
762766#ifdef CONFIG_IDE_PROC_FS
763767static void idedisk_add_settings (ide_drive_t * drive )
764768{
765- struct hd_driveid * id = drive -> id ;
766-
767769 ide_add_setting (drive , "bios_cyl" , SETTING_RW , TYPE_INT , 0 , 65535 , 1 , 1 ,
768770 & drive -> bios_cyl , NULL );
769771 ide_add_setting (drive , "bios_head" , SETTING_RW , TYPE_BYTE , 0 , 255 , 1 , 1 ,
@@ -773,7 +775,7 @@ static void idedisk_add_settings(ide_drive_t *drive)
773775 ide_add_setting (drive , "address" , SETTING_RW , TYPE_BYTE , 0 , 2 , 1 , 1 ,
774776 & drive -> addressing , set_lba_addressing );
775777 ide_add_setting (drive , "multcount" , SETTING_RW , TYPE_BYTE , 0 ,
776- id -> max_multsect , 1 , 1 , & drive -> mult_count ,
778+ drive -> driveid -> max_multsect , 1 , 1 , & drive -> mult_count ,
777779 set_multcount );
778780 ide_add_setting (drive , "nowerr" , SETTING_RW , TYPE_BYTE , 0 , 1 , 1 , 1 ,
779781 & drive -> nowerr , set_nowerr );
@@ -795,7 +797,8 @@ static inline void idedisk_add_settings(ide_drive_t *drive) { ; }
795797static void idedisk_setup (ide_drive_t * drive )
796798{
797799 ide_hwif_t * hwif = drive -> hwif ;
798- struct hd_driveid * id = drive -> id ;
800+ u16 * id = drive -> id ;
801+ char * m = (char * )& id [ATA_ID_PROD ];
799802 unsigned long long capacity ;
800803
801804 idedisk_add_settings (drive );
@@ -807,7 +810,7 @@ static void idedisk_setup(ide_drive_t *drive)
807810 /*
808811 * Removable disks (eg. SYQUEST); ignore 'WD' drives
809812 */
810- if (id -> model [0 ] != 'W' || id -> model [1 ] != 'D' )
813+ if (m [0 ] != 'W' || m [1 ] != 'D' )
811814 drive -> doorlocking = 1 ;
812815 }
813816
@@ -880,14 +883,14 @@ static void idedisk_setup(ide_drive_t *drive)
880883 drive -> name , capacity , sectors_to_MB (capacity ));
881884
882885 /* Only print cache size when it was specified */
883- if (id -> buf_size )
884- printk (KERN_CONT " w/%dKiB Cache" , id -> buf_size / 2 );
886+ if (id [ ATA_ID_BUF_SIZE ] )
887+ printk (KERN_CONT " w/%dKiB Cache" , id [ ATA_ID_BUF_SIZE ] / 2 );
885888
886889 printk (KERN_CONT ", CHS=%d/%d/%d\n" ,
887890 drive -> bios_cyl , drive -> bios_head , drive -> bios_sect );
888891
889892 /* write cache enabled? */
890- if ((id -> csfo & 1 ) || (id -> cfs_enable_1 & (1 << 5 )))
893+ if ((id [ ATA_ID_CSFO ] & 1 ) || (id [ ATA_ID_CFS_ENABLE_1 ] & (1 << 5 )))
891894 drive -> wcache = 1 ;
892895
893896 write_cache (drive , 1 );
0 commit comments