ide: factor out device type classifying from do_identify()

Factor out device type classifying from do_identify()
to ide_classify_ata_dev() and ide_classify_atapi_dev().

There should be no functional changes caused by this patch.
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent 96d40941
......@@ -101,71 +101,32 @@ static void ide_disk_init_mult_count(ide_drive_t *drive)
}
}
/**
* do_identify - identify a drive
* @drive: drive to identify
* @cmd: command used
*
* Called when we have issued a drive identify command to
* read and parse the results. This function is run with
* interrupts disabled.
*/
static void do_identify(ide_drive_t *drive, u8 cmd)
static void ide_classify_ata_dev(ide_drive_t *drive)
{
ide_hwif_t *hwif = HWIF(drive);
u16 *id = drive->id;
char *m = (char *)&id[ATA_ID_PROD];
unsigned long flags;
int bswap = 1, is_cfa;
/* local CPU only; some systems need this */
local_irq_save(flags);
/* read 512 bytes of id info */
hwif->tp_ops->input_data(drive, NULL, id, SECTOR_SIZE);
local_irq_restore(flags);
drive->dev_flags |= IDE_DFLAG_ID_READ;
#ifdef DEBUG
printk(KERN_INFO "%s: dumping identify data\n", drive->name);
ide_dump_identify((u8 *)id);
#endif
ide_fix_driveid(id);
/*
* ATA_CMD_ID_ATA returns little-endian info,
* ATA_CMD_ID_ATAPI *usually* returns little-endian info.
*/
if (cmd == ATA_CMD_ID_ATAPI) {
if ((m[0] == 'N' && m[1] == 'E') || /* NEC */
(m[0] == 'F' && m[1] == 'X') || /* Mitsumi */
(m[0] == 'P' && m[1] == 'i')) /* Pioneer */
/* Vertos drives may still be weird */
bswap ^= 1;
}
ide_fixstring(m, ATA_ID_PROD_LEN, bswap);
ide_fixstring((char *)&id[ATA_ID_FW_REV], ATA_ID_FW_REV_LEN, bswap);
ide_fixstring((char *)&id[ATA_ID_SERNO], ATA_ID_SERNO_LEN, bswap);
int is_cfa = ata_id_is_cfa(id);
/* we depend on this a lot! */
m[ATA_ID_PROD_LEN - 1] = '\0';
/* CF devices are *not* removable in Linux definition of the term */
if (is_cfa == 0 && (id[ATA_ID_CONFIG] & (1 << 7)))
drive->dev_flags |= IDE_DFLAG_REMOVABLE;
if (strstr(m, "E X A B Y T E N E S T"))
goto err_misc;
drive->media = ide_disk;
printk(KERN_INFO "%s: %s, ", drive->name, m);
if (!ata_id_has_unload(drive->id))
drive->dev_flags |= IDE_DFLAG_NO_UNLOAD;
drive->dev_flags |= IDE_DFLAG_PRESENT;
drive->dev_flags &= ~IDE_DFLAG_DEAD;
printk(KERN_INFO "%s: %s, %s DISK drive\n", drive->name, m,
is_cfa ? "CFA" : "ATA");
}
/*
* Check for an ATAPI device
*/
if (cmd == ATA_CMD_ID_ATAPI) {
static void ide_classify_atapi_dev(ide_drive_t *drive)
{
u16 *id = drive->id;
char *m = (char *)&id[ATA_ID_PROD];
u8 type = (id[ATA_ID_CONFIG] >> 8) & 0x1f;
printk(KERN_CONT "ATAPI ");
printk(KERN_INFO "%s: %s, ATAPI ", drive->name, m);
switch (type) {
case ide_floppy:
if (!strstr(m, "CD-ROM")) {
......@@ -204,6 +165,7 @@ static void do_identify(ide_drive_t *drive, u8 cmd)
printk(KERN_CONT "UNKNOWN (type %d)", type);
break;
}
printk(KERN_CONT " drive\n");
drive->media = type;
/* an ATAPI device ignores DRDY */
......@@ -213,32 +175,78 @@ static void do_identify(ide_drive_t *drive, u8 cmd)
drive->dev_flags |= IDE_DFLAG_DOORLOCKING;
/* we don't do head unloading on ATAPI devices */
drive->dev_flags |= IDE_DFLAG_NO_UNLOAD;
return;
}
}
/*
* Not an ATAPI device: looks like a "regular" hard disk
/**
* do_identify - identify a drive
* @drive: drive to identify
* @cmd: command used
*
* Called when we have issued a drive identify command to
* read and parse the results. This function is run with
* interrupts disabled.
*/
is_cfa = ata_id_is_cfa(id);
static void do_identify(ide_drive_t *drive, u8 cmd)
{
ide_hwif_t *hwif = HWIF(drive);
u16 *id = drive->id;
char *m = (char *)&id[ATA_ID_PROD];
unsigned long flags;
int bswap = 1;
/* CF devices are *not* removable in Linux definition of the term */
if (is_cfa == 0 && (id[ATA_ID_CONFIG] & (1 << 7)))
drive->dev_flags |= IDE_DFLAG_REMOVABLE;
/* local CPU only; some systems need this */
local_irq_save(flags);
/* read 512 bytes of id info */
hwif->tp_ops->input_data(drive, NULL, id, SECTOR_SIZE);
local_irq_restore(flags);
drive->media = ide_disk;
drive->dev_flags |= IDE_DFLAG_ID_READ;
#ifdef DEBUG
printk(KERN_INFO "%s: dumping identify data\n", drive->name);
ide_dump_identify((u8 *)id);
#endif
ide_fix_driveid(id);
if (!ata_id_has_unload(drive->id))
drive->dev_flags |= IDE_DFLAG_NO_UNLOAD;
/*
* ATA_CMD_ID_ATA returns little-endian info,
* ATA_CMD_ID_ATAPI *usually* returns little-endian info.
*/
if (cmd == ATA_CMD_ID_ATAPI) {
if ((m[0] == 'N' && m[1] == 'E') || /* NEC */
(m[0] == 'F' && m[1] == 'X') || /* Mitsumi */
(m[0] == 'P' && m[1] == 'i')) /* Pioneer */
/* Vertos drives may still be weird */
bswap ^= 1;
}
printk(KERN_CONT "%s DISK drive\n", is_cfa ? "CFA" : "ATA");
ide_fixstring(m, ATA_ID_PROD_LEN, bswap);
ide_fixstring((char *)&id[ATA_ID_FW_REV], ATA_ID_FW_REV_LEN, bswap);
ide_fixstring((char *)&id[ATA_ID_SERNO], ATA_ID_SERNO_LEN, bswap);
return;
/* we depend on this a lot! */
m[ATA_ID_PROD_LEN - 1] = '\0';
if (strstr(m, "E X A B Y T E N E S T"))
goto err_misc;
drive->dev_flags |= IDE_DFLAG_PRESENT;
drive->dev_flags &= ~IDE_DFLAG_DEAD;
/*
* Check for an ATAPI device
*/
if (cmd == ATA_CMD_ID_ATAPI)
ide_classify_atapi_dev(drive);
else
/*
* Not an ATAPI device: looks like a "regular" hard disk
*/
ide_classify_ata_dev(drive);
return;
err_misc:
kfree(id);
drive->dev_flags &= ~IDE_DFLAG_PRESENT;
return;
}
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment