ChangeSet 1.1254.1.83, 2003/06/02 10:46:42-07:00, wahrenbruch@kobil.de [PATCH] USB: kobil_sct.c added support for KAAN SIM Reader as promised - here is the patch for 2.5.70: Added support for KAAN SIM in kobil_sct. drivers/usb/serial/Kconfig | 1 drivers/usb/serial/kobil_sct.c | 52 +++++++++++++++++++++++++++-------------- 2 files changed, 36 insertions(+), 17 deletions(-) diff -Nru a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig --- a/drivers/usb/serial/Kconfig Mon Jun 2 11:19:44 2003 +++ b/drivers/usb/serial/Kconfig Mon Jun 2 11:19:44 2003 @@ -351,6 +351,7 @@ - USB TWIN - KAAN Standard Plus + - KAAN SIM - SecOVID Reader Plus - B1 Professional - KAAN Professional diff -Nru a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c --- a/drivers/usb/serial/kobil_sct.c Mon Jun 2 11:19:44 2003 +++ b/drivers/usb/serial/kobil_sct.c Mon Jun 2 11:19:44 2003 @@ -21,7 +21,8 @@ * Supported readers: USB TWIN, KAAN Standard Plus and SecOVID Reader Plus * (Adapter K), B1 Professional and KAAN Professional (Adapter B) * - * TODO: High baudrates + * (28/05/2003) tw + * Add support for KAAN SIM * * (12/09/2002) tw * Adapted to 2.5. @@ -58,7 +59,7 @@ #include "usb-serial.h" /* Version Information */ -#define DRIVER_VERSION "12/09/2002" +#define DRIVER_VERSION "28/05/2003" #define DRIVER_AUTHOR "KOBIL Systems GmbH - http://www.kobil.com" #define DRIVER_DESC "KOBIL USB Smart Card Terminal Driver (experimental)" @@ -66,6 +67,7 @@ #define KOBIL_ADAPTER_B_PRODUCT_ID 0x2011 #define KOBIL_ADAPTER_K_PRODUCT_ID 0x2012 #define KOBIL_USBTWIN_PRODUCT_ID 0x0078 +#define KOBIL_KAAN_SIM_PRODUCT_ID 0x0081 #define KOBIL_TIMEOUT 500 #define KOBIL_BUF_LENGTH 300 @@ -92,12 +94,21 @@ { USB_DEVICE(KOBIL_VENDOR_ID, KOBIL_ADAPTER_B_PRODUCT_ID) }, { USB_DEVICE(KOBIL_VENDOR_ID, KOBIL_ADAPTER_K_PRODUCT_ID) }, { USB_DEVICE(KOBIL_VENDOR_ID, KOBIL_USBTWIN_PRODUCT_ID) }, + { USB_DEVICE(KOBIL_VENDOR_ID, KOBIL_KAAN_SIM_PRODUCT_ID) }, { } /* Terminating entry */ }; MODULE_DEVICE_TABLE (usb, id_table); +static struct usb_driver kobil_driver = { + .name = "kobil", + .probe = usb_serial_probe, + .disconnect = usb_serial_disconnect, + .id_table = id_table, +}; + + struct usb_serial_device_type kobil_device = { .owner = THIS_MODULE, .name = "KOBIL USB smart card terminal", @@ -161,6 +172,9 @@ case KOBIL_USBTWIN_PRODUCT_ID: printk(KERN_DEBUG "KOBIL USBTWIN detected\n"); break; + case KOBIL_KAAN_SIM_PRODUCT_ID: + printk(KERN_DEBUG "KOBIL KAAN SIM detected\n"); + break; } usb_set_serial_port_data(serial->port, priv); @@ -353,7 +367,7 @@ struct usb_serial_port *port = (struct usb_serial_port *) purb->context; struct tty_struct *tty; unsigned char *data = purb->transfer_buffer; - char *dbg_data; +// char *dbg_data; dbg("%s - port %d", __FUNCTION__, port->number); @@ -366,16 +380,18 @@ if (purb->actual_length) { // BEGIN DEBUG - dbg_data = (unsigned char *) kmalloc((3 * purb->actual_length + 10) * sizeof(char), GFP_KERNEL); - if (! dbg_data) { - return; - } - memset(dbg_data, 0, (3 * purb->actual_length + 10)); - for (i = 0; i < purb->actual_length; i++) { - sprintf(dbg_data +3*i, "%02X ", data[i]); - } - dbg(" <-- %s", dbg_data ); - kfree(dbg_data); + /* + dbg_data = (unsigned char *) kmalloc((3 * purb->actual_length + 10) * sizeof(char), GFP_KERNEL); + if (! dbg_data) { + return; + } + memset(dbg_data, 0, (3 * purb->actual_length + 10)); + for (i = 0; i < purb->actual_length; i++) { + sprintf(dbg_data +3*i, "%02X ", data[i]); + } + dbg(" <-- %s", dbg_data ); + kfree(dbg_data); + */ // END DEBUG for (i = 0; i < purb->actual_length; ++i) { @@ -438,7 +454,7 @@ priv->filled = priv->filled + count; - // only send complete block. TWIN and adapter K use the same protocol. + // only send complete block. TWIN, KAAN SIM and adapter K use the same protocol. if ( ((priv->device_type != KOBIL_ADAPTER_B_PRODUCT_ID) && (priv->filled > 2) && (priv->filled >= (priv->buf[1] + 3))) || ((priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) && (priv->filled > 3) && (priv->filled >= (priv->buf[2] + 4))) ) { @@ -503,7 +519,7 @@ int transfer_buffer_length = 8; priv = usb_get_serial_port_data(port); - if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID) { + if ((priv->device_type == KOBIL_USBTWIN_PRODUCT_ID) || (priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID)) { // This device doesn't support ioctl calls return -EINVAL; } @@ -549,7 +565,7 @@ int transfer_buffer_length = 8; priv = usb_get_serial_port_data(port); - if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID) { + if ((priv->device_type == KOBIL_USBTWIN_PRODUCT_ID) || (priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID)) { // This device doesn't support ioctl calls return -EINVAL; } @@ -616,7 +632,7 @@ char *settings; priv = usb_get_serial_port_data(port); - if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID) { + if ((priv->device_type == KOBIL_USBTWIN_PRODUCT_ID) || (priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID)) { // This device doesn't support ioctl calls return 0; } @@ -727,6 +743,7 @@ static int __init kobil_init (void) { usb_serial_register (&kobil_device); + usb_register (&kobil_driver); info(DRIVER_VERSION " " DRIVER_AUTHOR); info(DRIVER_DESC); @@ -737,6 +754,7 @@ static void __exit kobil_exit (void) { + usb_deregister (&kobil_driver); usb_serial_deregister (&kobil_device); }