/* RETURNS: Matching xfer_mask, 0 if no match found.  */
unsigned long ata_xfer_mode2mask(u8 xfer_mode)
/* RETURNS: Matching xfer_mask, 0 if no match found.  */
unsigned long ata_xfer_mode2mask(u8 xfer_mode)
{
	const struct ata_xfer_ent *ent;
	for (ent = ata_xfer_tbl; ent->shift >= 0; ent++)
		if (xfer_mode >= ent->base && xfer_mode < ent->base + ent->bits)
			return ((2 << (ent->shift + xfer_mode - ent->base)) - 1)
				& ~((1 << ent->shift) - 1);
	return 0;
}