/* RETURNS: Matching XFER_* value, 0xff if no match found.  */
u8 ata_xfer_mask2mode(unsigned long xfer_mask)
/* RETURNS: Matching XFER_* value, 0xff if no match found.  */
u8 ata_xfer_mask2mode(unsigned long xfer_mask)
{
	int highbit = fls(xfer_mask) - 1;
	const struct ata_xfer_ent *ent;
	for (ent = ata_xfer_tbl; ent->shift >= 0; ent++)
		if (highbit >= ent->shift && highbit < ent->shift + ent->bits)
			return ent->base + highbit - ent->shift;
	return 0xff;
}