pinctrl: ingenic: Make unreachable path more robust

In the second loop of ingenic_pinconf_set(), it annotates the switch
default case as unreachable().  The annotation is technically correct,
because that same case would have resulted in an early return in the
previous loop.

However, if a bug were to get introduced later, for example if an
additional case were added to the first loop without adjusting the
second loop, it would result in nasty undefined behavior: most likely
the function's generated code would fall through to the next function.

Another issue is that, while objtool normally understands unreachable()
annotations, there's one special case where it doesn't: when the
annotation occurs immediately after a 'ret' instruction.  That happens
to be the case here because unreachable() is immediately before the
return.

So change the unreachable() to BUG() so that the unreachable code, if
ever executed, would panic instead of introducing undefined behavior.
This also makes objtool happy.

This fixes the following objtool warning:

  drivers/pinctrl/pinctrl-ingenic.o: warning: objtool: ingenic_pinconf_set() falls through to next function ingenic_pinconf_group_set()

Reported-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
1 file changed