regulator: Fix the logic to ensure new voltage setting in valid range