hidpp20: force at least one profile to be enabled

fix #428

Signed-off-by: Ogier Bouvier <obouvier@logitech.com>
This commit is contained in:
Ogier Bouvier
2017-12-12 10:57:38 +01:00
committed by Benjamin Tissoires
parent 573d3d399e
commit ec223eb2e6

View File

@@ -2545,6 +2545,7 @@ hidpp20_onboard_profiles_commit(struct hidpp20_device *device,
{
struct hidpp20_profile *profile;
unsigned int i;
bool enabled_profile = false;
int rc;
for (i = 0; i < profiles_list->num_profiles; i++) {
@@ -2556,6 +2557,19 @@ hidpp20_onboard_profiles_commit(struct hidpp20_device *device,
i);
if (rc < 0)
return rc;
enabled_profile = true;
}
}
if (!enabled_profile) {
if (profiles_list->num_profiles > 0) {
profiles_list->profiles[0].enabled = 1;
rc = hidpp20_onboard_profiles_write_profile(device,
profiles_list,
0);
if (rc < 0)
return rc;
}
}