In fact I was generally speaking, not taking into account the presence of the relay config where we would need the same for all three roles, which might make the approach "at least as complicated" as simply always checking the pins...
Maybe we could use a new or changed function (like) "PIN_FindPinIndexForRole()":
A "PIN_FindPinIndexForRole_new(int role, int actual_index)" could help doing the same for all drivers.
First checking, if "g_cfg.pins.roles[actual_index] == role" an only if not searching.
If we return a predefined "-1" (no valid pin) in case of an unsuccessful search, we might even change a lot of drivers to use this new function with only little changes.
I didn't check if we might even replace the original function by changing the code...
(in case the call uses "defaultIndexToReturnIfNotFound" to return a valid pin, this would need some special treatment in the calling code...)
Maybe we could use a new or changed function (like) "PIN_FindPinIndexForRole()":
A "PIN_FindPinIndexForRole_new(int role, int actual_index)" could help doing the same for all drivers.
First checking, if "g_cfg.pins.roles[actual_index] == role" an only if not searching.
If we return a predefined "-1" (no valid pin) in case of an unsuccessful search, we might even change a lot of drivers to use this new function with only little changes.
I didn't check if we might even replace the original function by changing the code...
(in case the call uses "defaultIndexToReturnIfNotFound" to return a valid pin, this would need some special treatment in the calling code...)
