MFC r312876: Use ffs() to scan for first bit instead of using a for() loop. Minor code refactor while at it.
Sponsored by: Mellanox Technologies