[PATCH 1/3] conf: Move mode detection into helper function