git: 8580e334b075 - main - umodem: ignore CDC_CM descriptor for baltech smartcard reader

From: Corvin Köhne <corvink_at_FreeBSD.org>
Date: Wed, 18 Jan 2023 11:18:30 UTC
The branch main has been updated by corvink:

URL: https://cgit.FreeBSD.org/src/commit/?id=8580e334b0757c8d55e51b8dc7fc4051521beedf

commit 8580e334b0757c8d55e51b8dc7fc4051521beedf
Author:     Steffen Dirkwinkel <s.dirkwinkel@beckhoff.com>
AuthorDate: 2022-11-04 14:46:07 +0000
Commit:     Corvin Köhne <corvink@FreeBSD.org>
CommitDate: 2023-01-18 11:17:17 +0000

    umodem: ignore CDC_CM descriptor for baltech smartcard reader
    
    The CDC_CM descriptor points to the wrong interface for serial port use.
    Ignore it to use the CDC_UNION descriptor.
    
    usbconfig dump (spec at: https://usb.org/sites/default/files/CDC1.2_WMC1.1_012011.zip):
    ugen0.2: <Baltech AG Smartcard Reader> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (300mA)
    
      bLength = 0x0012
      bDescriptorType = 0x0001
      bcdUSB = 0x0200
      bDeviceClass = 0x0000  <Probed by interface class>
      bDeviceSubClass = 0x0000
      bDeviceProtocol = 0x0000
      bMaxPacketSize0 = 0x0040
      idVendor = 0x13ad
      idProduct = 0xf019
      bcdDevice = 0x0100
      iManufacturer = 0x0001  <Baltech AG>
      iProduct = 0x0002  <Smartcard Reader>
      iSerialNumber = 0x0003  <45031910>
      bNumConfigurations = 0x0001
    
     Configuration index 0
    
        bLength = 0x0009
        bDescriptorType = 0x0002
        wTotalLength = 0x0064
        bNumInterfaces = 0x0003
        bConfigurationValue = 0x0001
        iConfiguration = 0x0000  <no string>
        bmAttributes = 0x0080
        bMaxPower = 0x0096
    
        Interface 0
          bLength = 0x0009
          bDescriptorType = 0x0004
          bInterfaceNumber = 0x0000
          bAlternateSetting = 0x0000
          bNumEndpoints = 0x0001
          bInterfaceClass = 0x0003  <HID device>
          bInterfaceSubClass = 0x0000
          bInterfaceProtocol = 0x0000
          iInterface = 0x0000  <no string>
    
          Additional Descriptor
    
          bLength = 0x09
          bDescriptorType = 0x21
          bDescriptorSubType = 0x11
           RAW dump:
           0x00 | 0x09, 0x21, 0x11, 0x01, 0x00, 0x01, 0x22, 0xd0,
           0x08 | 0x00
    
         Endpoint 0
            bLength = 0x0007
            bDescriptorType = 0x0005
            bEndpointAddress = 0x0081  <IN>
            bmAttributes = 0x0003  <INTERRUPT>
            wMaxPacketSize = 0x0040
            bInterval = 0x0001
            bRefresh = 0x0000
            bSynchAddress = 0x0000
    
          Additional Descriptor
    
          bLength = 0x08
          bDescriptorType = 0x0b
          bDescriptorSubType = 0x01
           RAW dump:
           0x00 | 0x08, 0x0b, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00
    
        Interface 1
          bLength = 0x0009
          bDescriptorType = 0x0004
          bInterfaceNumber = 0x0001
          bAlternateSetting = 0x0000
          bNumEndpoints = 0x0001
          bInterfaceClass = 0x0002  <Communication device>
          bInterfaceSubClass = 0x0002
          bInterfaceProtocol = 0x0000
          iInterface = 0x0000  <no string>
    
          Additional Descriptor
    
          bLength = 0x05
          bDescriptorType = 0x24
          bDescriptorSubType = 0x00
           RAW dump:
           0x00 | 0x05, 0x24, 0x00, 0x10, 0x01
    
          Additional Descriptor
    
          bLength = 0x04
          bDescriptorType = 0x24
          bDescriptorSubType = 0x02
           RAW dump:
           0x00 | 0x04, 0x24, 0x02, 0x00
    
          Additional Descriptor
    
          bLength = 0x05
          bDescriptorType = 0x24
          bDescriptorSubType = 0x06
           RAW dump:
           0x00 | 0x05, 0x24, 0x06, 0x01, 0x02
    
          Additional Descriptor
    
          bLength = 0x05
          bDescriptorType = 0x24
          bDescriptorSubType = 0x01
           RAW dump:
           0x00 | 0x05, 0x24, 0x01, 0x00, 0x01
    
         Endpoint 0
            bLength = 0x0007
            bDescriptorType = 0x0005
            bEndpointAddress = 0x0085  <IN>
            bmAttributes = 0x0003  <INTERRUPT>
            wMaxPacketSize = 0x0008
            bInterval = 0x0010
            bRefresh = 0x0000
            bSynchAddress = 0x0000
    
        Interface 2
          bLength = 0x0009
          bDescriptorType = 0x0004
          bInterfaceNumber = 0x0002
          bAlternateSetting = 0x0000
          bNumEndpoints = 0x0002
          bInterfaceClass = 0x000a  <CDC-data>
          bInterfaceSubClass = 0x0000
          bInterfaceProtocol = 0x0000
          iInterface = 0x0000  <no string>
    
         Endpoint 0
            bLength = 0x0007
            bDescriptorType = 0x0005
            bEndpointAddress = 0x0086  <IN>
            bmAttributes = 0x0002  <BULK>
            wMaxPacketSize = 0x0040
            bInterval = 0x0000
            bRefresh = 0x0000
            bSynchAddress = 0x0000
    
         Endpoint 1
            bLength = 0x0007
            bDescriptorType = 0x0005
            bEndpointAddress = 0x0006  <OUT>
            bmAttributes = 0x0002  <BULK>
            wMaxPacketSize = 0x0040
            bInterval = 0x0000
            bRefresh = 0x0000
            bSynchAddress = 0x0000
    
    Reviewed by:            manu
    MFC after:              1 week
    Sponsored by:           Beckhoff Automation GmbH & Co. KG
    Differential Revision:  https://reviews.freebsd.org/D37942
---
 sys/dev/usb/quirk/usb_quirk.c | 1 +
 sys/dev/usb/usbdevs           | 1 +
 2 files changed, 2 insertions(+)

diff --git a/sys/dev/usb/quirk/usb_quirk.c b/sys/dev/usb/quirk/usb_quirk.c
index 3baa3acba187..d67007012251 100644
--- a/sys/dev/usb/quirk/usb_quirk.c
+++ b/sys/dev/usb/quirk/usb_quirk.c
@@ -188,6 +188,7 @@ static struct usb_quirk_entry usb_quirks[USB_DEV_QUIRKS_MAX] = {
 	USB_QUIRK(CURITEL, UM150, 0x0000, 0xffff, UQ_ASSUME_CM_OVER_DATA),
 	USB_QUIRK(CURITEL, UM175, 0x0000, 0xffff, UQ_ASSUME_CM_OVER_DATA),
 	USB_QUIRK(VERTEX, VW110L, 0x0000, 0xffff, UQ_ASSUME_CM_OVER_DATA),
+	USB_QUIRK(BALTECH, SMARTCARDREADER, 0x0000, 0xffff, UQ_IGNORE_CDC_CM),
 
 	/* USB Mass Storage Class Quirks */
 	USB_QUIRK_VP(USB_VENDOR_ASAHIOPTICAL, 0, UQ_MSC_NO_RS_CLEAR_UA,
diff --git a/sys/dev/usb/usbdevs b/sys/dev/usb/usbdevs
index 77a7908d45c3..005a5d9c1037 100644
--- a/sys/dev/usb/usbdevs
+++ b/sys/dev/usb/usbdevs
@@ -1337,6 +1337,7 @@ product AZUREWAVE RTL8192SU_5	0x3325	RTL8192SU
 
 /* Baltech products */
 product BALTECH CARDREADER	0x9999	Card reader
+product BALTECH SMARTCARDREADER	0xf019	SmartCard reader
 
 /* Bayer products */
 product BAYER CONTOUR_CABLE	0x6001	FTDI compatible adapter