Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 24630dc6 authored by Bartlomiej Zolnierkiewicz's avatar Bartlomiej Zolnierkiewicz
Browse files

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
Loading
Loading
Loading
Loading
+81 −73
Original line number Original line Diff line number Diff line
@@ -101,71 +101,32 @@ static void ide_disk_init_mult_count(ide_drive_t *drive)
	}
	}
}
}


/**
static void ide_classify_ata_dev(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)
{
{
	ide_hwif_t *hwif = HWIF(drive);
	u16 *id = drive->id;
	u16 *id = drive->id;
	char *m = (char *)&id[ATA_ID_PROD];
	char *m = (char *)&id[ATA_ID_PROD];
	unsigned long flags;
	int is_cfa = ata_id_is_cfa(id);
	int bswap = 1, is_cfa;


	/* local CPU only; some systems need this */
	/* CF devices are *not* removable in Linux definition of the term */
	local_irq_save(flags);
	if (is_cfa == 0 && (id[ATA_ID_CONFIG] & (1 << 7)))
	/* read 512 bytes of id info */
		drive->dev_flags |= IDE_DFLAG_REMOVABLE;
	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);

	/* 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"))
	drive->media = ide_disk;
		goto err_misc;


	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;
	printk(KERN_INFO "%s: %s, %s DISK drive\n", drive->name, m,
	drive->dev_flags &= ~IDE_DFLAG_DEAD;
		is_cfa ? "CFA" : "ATA");
}


	/*
static void ide_classify_atapi_dev(ide_drive_t *drive)
	 * Check for an ATAPI device
{
	 */
	u16 *id = drive->id;
	if (cmd == ATA_CMD_ID_ATAPI) {
	char *m = (char *)&id[ATA_ID_PROD];
	u8 type = (id[ATA_ID_CONFIG] >> 8) & 0x1f;
	u8 type = (id[ATA_ID_CONFIG] >> 8) & 0x1f;


		printk(KERN_CONT "ATAPI ");
	printk(KERN_INFO "%s: %s, ATAPI ", drive->name, m);
	switch (type) {
	switch (type) {
	case ide_floppy:
	case ide_floppy:
		if (!strstr(m, "CD-ROM")) {
		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);
		printk(KERN_CONT "UNKNOWN (type %d)", type);
		break;
		break;
	}
	}

	printk(KERN_CONT " drive\n");
	printk(KERN_CONT " drive\n");
	drive->media = type;
	drive->media = type;
	/* an ATAPI device ignores DRDY */
	/* 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;
	drive->dev_flags |= IDE_DFLAG_DOORLOCKING;
	/* we don't do head unloading on ATAPI devices */
	/* we don't do head unloading on ATAPI devices */
	drive->dev_flags |= IDE_DFLAG_NO_UNLOAD;
	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 */
	/* local CPU only; some systems need this */
	if (is_cfa == 0 && (id[ATA_ID_CONFIG] & (1 << 7)))
	local_irq_save(flags);
		drive->dev_flags |= IDE_DFLAG_REMOVABLE;
	/* 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:
err_misc:
	kfree(id);
	kfree(id);
	drive->dev_flags &= ~IDE_DFLAG_PRESENT;
	drive->dev_flags &= ~IDE_DFLAG_PRESENT;
	return;
}
}


/**
/**