Commit 6c952a0d authored by Hannes Reinecke's avatar Hannes Reinecke Committed by Damien Le Moal
Browse files

ata: libata: Add ata_port_classify() helper



Add an ata_port_classify() helper to print out the results from
the device classification and remove the debugging statements
from ata_dev_classify().

Signed-off-by: default avatarHannes Reinecke <hare@suse.de>
Signed-off-by: default avatarDamien Le Moal <damien.lemoal@opensource.wdc.com>
parent bb6a42d7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1300,7 +1300,7 @@ unsigned int ahci_dev_classify(struct ata_port *ap)
	tf.lbal		= (tmp >> 8)	& 0xff;
	tf.nsect	= (tmp)		& 0xff;

	return ata_dev_classify(&tf);
	return ata_port_classify(ap, &tf);
}
EXPORT_SYMBOL_GPL(ahci_dev_classify);

+5 −16
Original line number Diff line number Diff line
@@ -1007,32 +1007,21 @@ unsigned int ata_dev_classify(const struct ata_taskfile *tf)
	 * SEMB signature.  This is worked around in
	 * ata_dev_read_id().
	 */
	if ((tf->lbam == 0) && (tf->lbah == 0)) {
		DPRINTK("found ATA device by sig\n");
	if (tf->lbam == 0 && tf->lbah == 0)
		return ATA_DEV_ATA;
	}

	if ((tf->lbam == 0x14) && (tf->lbah == 0xeb)) {
		DPRINTK("found ATAPI device by sig\n");
	if (tf->lbam == 0x14 && tf->lbah == 0xeb)
		return ATA_DEV_ATAPI;
	}

	if ((tf->lbam == 0x69) && (tf->lbah == 0x96)) {
		DPRINTK("found PMP device by sig\n");
	if (tf->lbam == 0x69 && tf->lbah == 0x96)
		return ATA_DEV_PMP;
	}

	if ((tf->lbam == 0x3c) && (tf->lbah == 0xc3)) {
		DPRINTK("found SEMB device by sig (could be ATA device)\n");
	if (tf->lbam == 0x3c && tf->lbah == 0xc3)
		return ATA_DEV_SEMB;
	}

	if ((tf->lbam == 0xcd) && (tf->lbah == 0xab)) {
		DPRINTK("found ZAC device by sig\n");
	if (tf->lbam == 0xcd && tf->lbah == 0xab)
		return ATA_DEV_ZAC;
	}

	DPRINTK("unknown device\n");
	return ATA_DEV_UNKNOWN;
}
EXPORT_SYMBOL_GPL(ata_dev_classify);
+1 −1
Original line number Diff line number Diff line
@@ -1853,7 +1853,7 @@ unsigned int ata_sff_dev_classify(struct ata_device *dev, int present,
		return ATA_DEV_NONE;

	/* determine if device is ATA or ATAPI */
	class = ata_dev_classify(&tf);
	class = ata_port_classify(ap, &tf);

	if (class == ATA_DEV_UNKNOWN) {
		/* If the device failed diagnostic, it's likely to
+30 −0
Original line number Diff line number Diff line
@@ -321,6 +321,36 @@ int ata_tport_add(struct device *parent,
	return error;
}

/**
 *     ata_port_classify - determine device type based on ATA-spec signature
 *     @ap: ATA port device on which the classification should be run
 *     @tf: ATA taskfile register set for device to be identified
 *
 *     A wrapper around ata_dev_classify() to provide additional logging
 *
 *     RETURNS:
 *     Device type, %ATA_DEV_ATA, %ATA_DEV_ATAPI, %ATA_DEV_PMP,
 *     %ATA_DEV_ZAC, or %ATA_DEV_UNKNOWN the event of failure.
 */
unsigned int ata_port_classify(struct ata_port *ap,
			       const struct ata_taskfile *tf)
{
	int i;
	unsigned int class = ata_dev_classify(tf);

	/* Start with index '1' to skip the 'unknown' entry */
	for (i = 1; i < ARRAY_SIZE(ata_class_names); i++) {
		if (ata_class_names[i].value == class) {
			ata_port_dbg(ap, "found %s device by sig\n",
				     ata_class_names[i].name);
			return class;
		}
	}

	ata_port_info(ap, "found unknown device (class %u)\n", class);
	return class;
}
EXPORT_SYMBOL_GPL(ata_port_classify);

/*
 * ATA link attributes
+1 −1
Original line number Diff line number Diff line
@@ -814,7 +814,7 @@ static unsigned int sata_fsl_dev_classify(struct ata_port *ap)
	tf.lbal = (temp >> 8) & 0xff;
	tf.nsect = temp & 0xff;

	return ata_dev_classify(&tf);
	return ata_port_classify(ap, &tf);
}

static int sata_fsl_hardreset(struct ata_link *link, unsigned int *class,
Loading