/* Some direct events for decodes of event bus byte 3 have alternative PMCSEL values on other counters. This returns the alternative event code for those that do, or -1 otherwise.  */
static s64 find_alternative_bdecode(u64 event)
/* Some direct events for decodes of event bus byte 3 have alternative PMCSEL values on other counters. This returns the alternative event code for those that do, or -1 otherwise.  */
static s64 find_alternative_bdecode(u64 event)
{
	int pmc, altpmc, pp, j;
	pmc = (event >> PM_PMC_SH) & PM_PMC_MSK;
	if (pmc == 0 || pmc > 4)
		return -1;
	altpmc = 5 - pmc;
	pp = event & PM_PMCSEL_MSK;
	for (j = 0; j < 4; ++j) {
		if (bytedecode_alternatives[pmc - 1][j] == pp) {
			return (event & ~(PM_PMC_MSKS | PM_PMCSEL_MSK)) |
				(altpmc << PM_PMC_SH) |
				bytedecode_alternatives[altpmc - 1][j];
		}
	}
	return -1;
}