89
89
#include <linux/delay.h>
90
90
#include <linux/slab.h>
91
91
#include <linux/blkdev.h>
92
+ #include <linux/ata.h>
92
93
#include <linux/hdreg.h>
93
94
#include <linux/platform_device.h>
94
95
#if defined(CONFIG_OF )
@@ -208,7 +209,7 @@ struct ace_device {
208
209
struct gendisk * gd ;
209
210
210
211
/* Inserted CF card parameters */
211
- struct hd_driveid cf_id ;
212
+ u16 cf_id [ ATA_ID_WORDS ] ;
212
213
};
213
214
214
215
static int ace_major ;
@@ -402,21 +403,14 @@ static void ace_dump_regs(struct ace_device *ace)
402
403
ace_in32 (ace , ACE_CFGLBA ), ace_in (ace , ACE_FATSTAT ));
403
404
}
404
405
405
- void ace_fix_driveid (struct hd_driveid * id )
406
+ void ace_fix_driveid (u16 * id )
406
407
{
407
408
#if defined(__BIG_ENDIAN )
408
- u16 * buf = (void * )id ;
409
409
int i ;
410
410
411
411
/* All half words have wrong byte order; swap the bytes */
412
- for (i = 0 ; i < sizeof (struct hd_driveid ); i += 2 , buf ++ )
413
- * buf = le16_to_cpu (* buf );
414
-
415
- /* Some of the data values are 32bit; swap the half words */
416
- id -> lba_capacity = ((id -> lba_capacity >> 16 ) & 0x0000FFFF ) |
417
- ((id -> lba_capacity << 16 ) & 0xFFFF0000 );
418
- id -> spg = ((id -> spg >> 16 ) & 0x0000FFFF ) |
419
- ((id -> spg << 16 ) & 0xFFFF0000 );
412
+ for (i = 0 ; i < ATA_ID_WORDS ; i ++ , id ++ )
413
+ * id = le16_to_cpu (* id );
420
414
#endif
421
415
}
422
416
@@ -614,7 +608,7 @@ static void ace_fsm_dostate(struct ace_device *ace)
614
608
break ;
615
609
616
610
case ACE_FSM_STATE_IDENTIFY_COMPLETE :
617
- ace_fix_driveid (& ace -> cf_id );
611
+ ace_fix_driveid (& ace -> cf_id [ 0 ] );
618
612
ace_dump_mem (& ace -> cf_id , 512 ); /* Debug: Dump out disk ID */
619
613
620
614
if (ace -> data_result ) {
@@ -627,9 +621,10 @@ static void ace_fsm_dostate(struct ace_device *ace)
627
621
ace -> media_change = 0 ;
628
622
629
623
/* Record disk parameters */
630
- set_capacity (ace -> gd , ace -> cf_id .lba_capacity );
624
+ set_capacity (ace -> gd ,
625
+ ata_id_u32 (& ace -> cf_id , ATA_ID_LBA_CAPACITY ));
631
626
dev_info (ace -> dev , "capacity: %i sectors\n" ,
632
- ace -> cf_id . lba_capacity );
627
+ ata_id_u32 ( & ace -> cf_id , ATA_ID_LBA_CAPACITY ) );
633
628
}
634
629
635
630
/* We're done, drop to IDLE state and notify waiters */
@@ -928,12 +923,13 @@ static int ace_release(struct gendisk *disk, fmode_t mode)
928
923
static int ace_getgeo (struct block_device * bdev , struct hd_geometry * geo )
929
924
{
930
925
struct ace_device * ace = bdev -> bd_disk -> private_data ;
926
+ u16 * cf_id = & ace -> cf_id [0 ];
931
927
932
928
dev_dbg (ace -> dev , "ace_getgeo()\n" );
933
929
934
- geo -> heads = ace -> cf_id . heads ;
935
- geo -> sectors = ace -> cf_id . sectors ;
936
- geo -> cylinders = ace -> cf_id . cyls ;
930
+ geo -> heads = cf_id [ ATA_ID_HEADS ] ;
931
+ geo -> sectors = cf_id [ ATA_ID_SECTORS ] ;
932
+ geo -> cylinders = cf_id [ ATA_ID_CYLS ] ;
937
933
938
934
return 0 ;
939
935
}
0 commit comments