Code:
int blah( unsigned char b )
{
    return b&1?0:b&2?1:b&4?2:b&8?3:b&16?4:b&32?5:b&64?6:b&128?7:-1;
}
Assuming you don't want a look up table, as mentioned before, a series of if checks is as fast as you're going to get. However, I don't see the point of doing any math (dividing in a loop, etc), when you can just AND each bit. This assumes you want eight channels, numbered from zero to seven, with -1 for error.

Quzah.