Skip to content

Commit

Permalink
Kapelse: simplify code
Browse files Browse the repository at this point in the history
Move the standard cases with the other USE_COMPOSITE_AS_MULTISLOT cases.
  • Loading branch information
LudovicRousseau committed Dec 18, 2023
1 parent 833be70 commit cb34fd6
Showing 1 changed file with 33 additions and 36 deletions.
69 changes: 33 additions & 36 deletions src/ccid_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,34 @@ status_t OpenUSBByName(unsigned int reader_index, /*@null@*/ char *device)
max_interface_number = 3; /* 4 interfaces */
num_CCID_interfaces = 4; /* 4 CCID interfaces */
break;

/* Kap-eCV: only the first interface is a CCID one
* 0: CCID contactless
* 1: HID
* 2: CDC
* We need to handle this case here even if
* because we have a generic test for all Kapelse
* readers (VENDOR_KAPELSE) later in the code
*/
case KAPELSE_KAPECV:
max_interface_number = 0;
num_CCID_interfaces = 1;
break;

/* Kap&Link2: only 3 first interfaces are CCID ones
* 0: CCID contact
* 1: CCID contactless
* 2: CCID contactless
* or, depending on user configuration:
* 0: CCID contact
* 1: CCID contactless
* 2: CCID contactless
* 3: CDC-ACM
*/
case KAPELSE_KAPLIN2:
max_interface_number = 2;
num_CCID_interfaces = 3;
break;
}

interface_number = static_interface;
Expand Down Expand Up @@ -655,43 +683,12 @@ status_t OpenUSBByName(unsigned int reader_index, /*@null@*/ char *device)
#endif

#ifdef USE_COMPOSITE_AS_MULTISLOT
if (VENDOR_KAPELSE == GET_VENDOR(readerID))
if ((VENDOR_KAPELSE == GET_VENDOR(readerID))
&& (-1 == max_interface_number))
{
switch (readerID)
{
case KAPELSE_KAPECV:
/* Kap-eCV: only first interface is a CCID one
* 0: CCID contactless
* 1: HID
* 2: CDC
* */
max_interface_number = 0;
num_CCID_interfaces = max_interface_number+1;
DEBUG_INFO1("Kapelse reader forced as monoslot!");
break;

case KAPELSE_KAPLIN2:
/* Kap&Link2: only 3 first interfaces are CCID ones
* 0: CCID contact
* 1: CCID contactless
* 2: CCID contactless
* or, depending on user configuration:
* 0: CCID contact
* 1: CCID contactless
* 2: CCID contactless
* 3: CDC-ACM
* */
max_interface_number = 2;
num_CCID_interfaces = max_interface_number+1;
break;

default:
/* Kapelse: all interfaces are CCID ones */
max_interface_number = config_desc->bNumInterfaces-1;
num_CCID_interfaces = max_interface_number+1;
DEBUG_INFO2("Kapelse reader forced as multislot with %d slots!",max_interface_number+1);
break;
}
/* Kapelse: all interfaces are CCID ones */
num_CCID_interfaces = config_desc->bNumInterfaces;
max_interface_number = num_CCID_interfaces-1;
}
#endif

Expand Down

0 comments on commit cb34fd6

Please sign in to comment.