Skip to content

Commit 4aaf2fe

Browse files
committed
xsysace: make it 'struct hd_driveid'-free
* Change cf_id field in struct ace_device from 'struct hd_driveid *id' to 'u16 *id' and update driver accordingly. * Include <linux/ata.h> directly instead of through <linux/hdreg.h>. While at it: * Use ata_id_u32() macro. There should be no functional changes caused by this patch. Cc: Grant Likely <grant.likely@secretlab.ca> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
1 parent 73855e1 commit 4aaf2fe

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

drivers/block/xsysace.c

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
#include <linux/delay.h>
9090
#include <linux/slab.h>
9191
#include <linux/blkdev.h>
92+
#include <linux/ata.h>
9293
#include <linux/hdreg.h>
9394
#include <linux/platform_device.h>
9495
#if defined(CONFIG_OF)
@@ -208,7 +209,7 @@ struct ace_device {
208209
struct gendisk *gd;
209210

210211
/* Inserted CF card parameters */
211-
struct hd_driveid cf_id;
212+
u16 cf_id[ATA_ID_WORDS];
212213
};
213214

214215
static int ace_major;
@@ -402,21 +403,14 @@ static void ace_dump_regs(struct ace_device *ace)
402403
ace_in32(ace, ACE_CFGLBA), ace_in(ace, ACE_FATSTAT));
403404
}
404405

405-
void ace_fix_driveid(struct hd_driveid *id)
406+
void ace_fix_driveid(u16 *id)
406407
{
407408
#if defined(__BIG_ENDIAN)
408-
u16 *buf = (void *)id;
409409
int i;
410410

411411
/* 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);
420414
#endif
421415
}
422416

@@ -614,7 +608,7 @@ static void ace_fsm_dostate(struct ace_device *ace)
614608
break;
615609

616610
case ACE_FSM_STATE_IDENTIFY_COMPLETE:
617-
ace_fix_driveid(&ace->cf_id);
611+
ace_fix_driveid(&ace->cf_id[0]);
618612
ace_dump_mem(&ace->cf_id, 512); /* Debug: Dump out disk ID */
619613

620614
if (ace->data_result) {
@@ -627,9 +621,10 @@ static void ace_fsm_dostate(struct ace_device *ace)
627621
ace->media_change = 0;
628622

629623
/* 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));
631626
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));
633628
}
634629

635630
/* We're done, drop to IDLE state and notify waiters */
@@ -928,12 +923,13 @@ static int ace_release(struct gendisk *disk, fmode_t mode)
928923
static int ace_getgeo(struct block_device *bdev, struct hd_geometry *geo)
929924
{
930925
struct ace_device *ace = bdev->bd_disk->private_data;
926+
u16 *cf_id = &ace->cf_id[0];
931927

932928
dev_dbg(ace->dev, "ace_getgeo()\n");
933929

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];
937933

938934
return 0;
939935
}

0 commit comments

Comments
 (0)