diff options
author | Alan Cox <alan@redhat.com> | 2008-07-22 06:14:10 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-22 16:03:25 -0400 |
commit | dee0a7ccaa0bcdeebb590879d68739cce4ff1b07 (patch) | |
tree | a4c5cef90c89e29c0b1cbe3b0b2323a81873b1f3 /drivers | |
parent | 0c265f4e8598e251108759685dbb3789868086b2 (diff) |
tty-usb-kobil-sct: Coding style
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/usb/serial/kobil_sct.c | 557 |
1 files changed, 297 insertions, 260 deletions
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c index 40c67f0096b1..f0f8353ec1ac 100644 --- a/drivers/usb/serial/kobil_sct.c +++ b/drivers/usb/serial/kobil_sct.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * KOBIL USB Smart Card Terminal Driver | 2 | * KOBIL USB Smart Card Terminal Driver |
3 | * | 3 | * |
4 | * Copyright (C) 2002 KOBIL Systems GmbH | 4 | * Copyright (C) 2002 KOBIL Systems GmbH |
5 | * Author: Thomas Wahrenbruch | 5 | * Author: Thomas Wahrenbruch |
6 | * | 6 | * |
7 | * Contact: linuxusb@kobil.de | 7 | * Contact: linuxusb@kobil.de |
@@ -20,7 +20,7 @@ | |||
20 | * | 20 | * |
21 | * Supported readers: USB TWIN, KAAN Standard Plus and SecOVID Reader Plus | 21 | * Supported readers: USB TWIN, KAAN Standard Plus and SecOVID Reader Plus |
22 | * (Adapter K), B1 Professional and KAAN Professional (Adapter B) | 22 | * (Adapter K), B1 Professional and KAAN Professional (Adapter B) |
23 | * | 23 | * |
24 | * (21/05/2004) tw | 24 | * (21/05/2004) tw |
25 | * Fix bug with P'n'P readers | 25 | * Fix bug with P'n'P readers |
26 | * | 26 | * |
@@ -44,7 +44,7 @@ | |||
44 | #include <linux/tty_flip.h> | 44 | #include <linux/tty_flip.h> |
45 | #include <linux/module.h> | 45 | #include <linux/module.h> |
46 | #include <linux/spinlock.h> | 46 | #include <linux/spinlock.h> |
47 | #include <asm/uaccess.h> | 47 | #include <linux/uaccess.h> |
48 | #include <linux/usb.h> | 48 | #include <linux/usb.h> |
49 | #include <linux/usb/serial.h> | 49 | #include <linux/usb/serial.h> |
50 | #include <linux/ioctl.h> | 50 | #include <linux/ioctl.h> |
@@ -68,13 +68,13 @@ static int debug; | |||
68 | 68 | ||
69 | 69 | ||
70 | /* Function prototypes */ | 70 | /* Function prototypes */ |
71 | static int kobil_startup (struct usb_serial *serial); | 71 | static int kobil_startup(struct usb_serial *serial); |
72 | static void kobil_shutdown (struct usb_serial *serial); | 72 | static void kobil_shutdown(struct usb_serial *serial); |
73 | static int kobil_open (struct tty_struct *tty, | 73 | static int kobil_open(struct tty_struct *tty, |
74 | struct usb_serial_port *port, struct file *filp); | 74 | struct usb_serial_port *port, struct file *filp); |
75 | static void kobil_close (struct tty_struct *tty, struct usb_serial_port *port, | 75 | static void kobil_close(struct tty_struct *tty, struct usb_serial_port *port, |
76 | struct file *filp); | 76 | struct file *filp); |
77 | static int kobil_write (struct tty_struct *tty, struct usb_serial_port *port, | 77 | static int kobil_write(struct tty_struct *tty, struct usb_serial_port *port, |
78 | const unsigned char *buf, int count); | 78 | const unsigned char *buf, int count); |
79 | static int kobil_write_room(struct tty_struct *tty); | 79 | static int kobil_write_room(struct tty_struct *tty); |
80 | static int kobil_ioctl(struct tty_struct *tty, struct file *file, | 80 | static int kobil_ioctl(struct tty_struct *tty, struct file *file, |
@@ -82,9 +82,9 @@ static int kobil_ioctl(struct tty_struct *tty, struct file *file, | |||
82 | static int kobil_tiocmget(struct tty_struct *tty, struct file *file); | 82 | static int kobil_tiocmget(struct tty_struct *tty, struct file *file); |
83 | static int kobil_tiocmset(struct tty_struct *tty, struct file *file, | 83 | static int kobil_tiocmset(struct tty_struct *tty, struct file *file, |
84 | unsigned int set, unsigned int clear); | 84 | unsigned int set, unsigned int clear); |
85 | static void kobil_read_int_callback( struct urb *urb ); | 85 | static void kobil_read_int_callback(struct urb *urb); |
86 | static void kobil_write_callback( struct urb *purb ); | 86 | static void kobil_write_callback(struct urb *purb); |
87 | static void kobil_set_termios(struct tty_struct *tty, | 87 | static void kobil_set_termios(struct tty_struct *tty, |
88 | struct usb_serial_port *port, struct ktermios *old); | 88 | struct usb_serial_port *port, struct ktermios *old); |
89 | 89 | ||
90 | 90 | ||
@@ -97,7 +97,7 @@ static struct usb_device_id id_table [] = { | |||
97 | }; | 97 | }; |
98 | 98 | ||
99 | 99 | ||
100 | MODULE_DEVICE_TABLE (usb, id_table); | 100 | MODULE_DEVICE_TABLE(usb, id_table); |
101 | 101 | ||
102 | static struct usb_driver kobil_driver = { | 102 | static struct usb_driver kobil_driver = { |
103 | .name = "kobil", | 103 | .name = "kobil", |
@@ -134,14 +134,14 @@ static struct usb_serial_driver kobil_device = { | |||
134 | struct kobil_private { | 134 | struct kobil_private { |
135 | int write_int_endpoint_address; | 135 | int write_int_endpoint_address; |
136 | int read_int_endpoint_address; | 136 | int read_int_endpoint_address; |
137 | unsigned char buf[KOBIL_BUF_LENGTH]; // buffer for the APDU to send | 137 | unsigned char buf[KOBIL_BUF_LENGTH]; /* buffer for the APDU to send */ |
138 | int filled; // index of the last char in buf | 138 | int filled; /* index of the last char in buf */ |
139 | int cur_pos; // index of the next char to send in buf | 139 | int cur_pos; /* index of the next char to send in buf */ |
140 | __u16 device_type; | 140 | __u16 device_type; |
141 | }; | 141 | }; |
142 | 142 | ||
143 | 143 | ||
144 | static int kobil_startup (struct usb_serial *serial) | 144 | static int kobil_startup(struct usb_serial *serial) |
145 | { | 145 | { |
146 | int i; | 146 | int i; |
147 | struct kobil_private *priv; | 147 | struct kobil_private *priv; |
@@ -152,20 +152,20 @@ static int kobil_startup (struct usb_serial *serial) | |||
152 | struct usb_host_endpoint *endpoint; | 152 | struct usb_host_endpoint *endpoint; |
153 | 153 | ||
154 | priv = kmalloc(sizeof(struct kobil_private), GFP_KERNEL); | 154 | priv = kmalloc(sizeof(struct kobil_private), GFP_KERNEL); |
155 | if (!priv){ | 155 | if (!priv) |
156 | return -ENOMEM; | 156 | return -ENOMEM; |
157 | } | ||
158 | 157 | ||
159 | priv->filled = 0; | 158 | priv->filled = 0; |
160 | priv->cur_pos = 0; | 159 | priv->cur_pos = 0; |
161 | priv->device_type = le16_to_cpu(serial->dev->descriptor.idProduct); | 160 | priv->device_type = le16_to_cpu(serial->dev->descriptor.idProduct); |
162 | 161 | ||
163 | switch (priv->device_type){ | 162 | switch (priv->device_type) { |
164 | case KOBIL_ADAPTER_B_PRODUCT_ID: | 163 | case KOBIL_ADAPTER_B_PRODUCT_ID: |
165 | printk(KERN_DEBUG "KOBIL B1 PRO / KAAN PRO detected\n"); | 164 | printk(KERN_DEBUG "KOBIL B1 PRO / KAAN PRO detected\n"); |
166 | break; | 165 | break; |
167 | case KOBIL_ADAPTER_K_PRODUCT_ID: | 166 | case KOBIL_ADAPTER_K_PRODUCT_ID: |
168 | printk(KERN_DEBUG "KOBIL KAAN Standard Plus / SecOVID Reader Plus detected\n"); | 167 | printk(KERN_DEBUG |
168 | "KOBIL KAAN Standard Plus / SecOVID Reader Plus detected\n"); | ||
169 | break; | 169 | break; |
170 | case KOBIL_USBTWIN_PRODUCT_ID: | 170 | case KOBIL_USBTWIN_PRODUCT_ID: |
171 | printk(KERN_DEBUG "KOBIL USBTWIN detected\n"); | 171 | printk(KERN_DEBUG "KOBIL USBTWIN detected\n"); |
@@ -176,37 +176,40 @@ static int kobil_startup (struct usb_serial *serial) | |||
176 | } | 176 | } |
177 | usb_set_serial_port_data(serial->port[0], priv); | 177 | usb_set_serial_port_data(serial->port[0], priv); |
178 | 178 | ||
179 | // search for the necessary endpoints | 179 | /* search for the necessary endpoints */ |
180 | pdev = serial->dev; | 180 | pdev = serial->dev; |
181 | actconfig = pdev->actconfig; | 181 | actconfig = pdev->actconfig; |
182 | interface = actconfig->interface[0]; | 182 | interface = actconfig->interface[0]; |
183 | altsetting = interface->cur_altsetting; | 183 | altsetting = interface->cur_altsetting; |
184 | endpoint = altsetting->endpoint; | 184 | endpoint = altsetting->endpoint; |
185 | 185 | ||
186 | for (i = 0; i < altsetting->desc.bNumEndpoints; i++) { | 186 | for (i = 0; i < altsetting->desc.bNumEndpoints; i++) { |
187 | endpoint = &altsetting->endpoint[i]; | 187 | endpoint = &altsetting->endpoint[i]; |
188 | if (usb_endpoint_is_int_out(&endpoint->desc)) { | 188 | if (usb_endpoint_is_int_out(&endpoint->desc)) { |
189 | dbg("%s Found interrupt out endpoint. Address: %d", __func__, endpoint->desc.bEndpointAddress); | 189 | dbg("%s Found interrupt out endpoint. Address: %d", |
190 | priv->write_int_endpoint_address = endpoint->desc.bEndpointAddress; | 190 | __func__, endpoint->desc.bEndpointAddress); |
191 | } | 191 | priv->write_int_endpoint_address = |
192 | endpoint->desc.bEndpointAddress; | ||
193 | } | ||
192 | if (usb_endpoint_is_int_in(&endpoint->desc)) { | 194 | if (usb_endpoint_is_int_in(&endpoint->desc)) { |
193 | dbg("%s Found interrupt in endpoint. Address: %d", __func__, endpoint->desc.bEndpointAddress); | 195 | dbg("%s Found interrupt in endpoint. Address: %d", |
194 | priv->read_int_endpoint_address = endpoint->desc.bEndpointAddress; | 196 | __func__, endpoint->desc.bEndpointAddress); |
195 | } | 197 | priv->read_int_endpoint_address = |
198 | endpoint->desc.bEndpointAddress; | ||
199 | } | ||
196 | } | 200 | } |
197 | return 0; | 201 | return 0; |
198 | } | 202 | } |
199 | 203 | ||
200 | 204 | ||
201 | static void kobil_shutdown (struct usb_serial *serial) | 205 | static void kobil_shutdown(struct usb_serial *serial) |
202 | { | 206 | { |
203 | int i; | 207 | int i; |
204 | dbg("%s - port %d", __func__, serial->port[0]->number); | 208 | dbg("%s - port %d", __func__, serial->port[0]->number); |
205 | 209 | ||
206 | for (i=0; i < serial->num_ports; ++i) { | 210 | for (i = 0; i < serial->num_ports; ++i) { |
207 | while (serial->port[i]->port.count > 0) { | 211 | while (serial->port[i]->port.count > 0) |
208 | kobil_close (NULL, serial->port[i], NULL); | 212 | kobil_close(NULL, serial->port[i], NULL); |
209 | } | ||
210 | kfree(usb_get_serial_port_data(serial->port[i])); | 213 | kfree(usb_get_serial_port_data(serial->port[i])); |
211 | usb_set_serial_port_data(serial->port[i], NULL); | 214 | usb_set_serial_port_data(serial->port[i], NULL); |
212 | } | 215 | } |
@@ -225,7 +228,7 @@ static int kobil_open(struct tty_struct *tty, | |||
225 | dbg("%s - port %d", __func__, port->number); | 228 | dbg("%s - port %d", __func__, port->number); |
226 | priv = usb_get_serial_port_data(port); | 229 | priv = usb_get_serial_port_data(port); |
227 | 230 | ||
228 | // someone sets the dev to 0 if the close method has been called | 231 | /* someone sets the dev to 0 if the close method has been called */ |
229 | port->interrupt_in_urb->dev = port->serial->dev; | 232 | port->interrupt_in_urb->dev = port->serial->dev; |
230 | 233 | ||
231 | 234 | ||
@@ -238,96 +241,110 @@ static int kobil_open(struct tty_struct *tty, | |||
238 | 241 | ||
239 | /* Default to echo off and other sane device settings */ | 242 | /* Default to echo off and other sane device settings */ |
240 | tty->termios->c_lflag = 0; | 243 | tty->termios->c_lflag = 0; |
241 | tty->termios->c_lflag &= ~(ISIG | ICANON | ECHO | IEXTEN | XCASE); | 244 | tty->termios->c_lflag &= ~(ISIG | ICANON | ECHO | IEXTEN | |
245 | XCASE); | ||
242 | tty->termios->c_iflag = IGNBRK | IGNPAR | IXOFF; | 246 | tty->termios->c_iflag = IGNBRK | IGNPAR | IXOFF; |
243 | tty->termios->c_oflag &= ~ONLCR; // do NOT translate CR to CR-NL (0x0A -> 0x0A 0x0D) | 247 | /* do NOT translate CR to CR-NL (0x0A -> 0x0A 0x0D) */ |
244 | } | 248 | tty->termios->c_oflag &= ~ONLCR; |
245 | // allocate memory for transfer buffer | 249 | } |
250 | /* allocate memory for transfer buffer */ | ||
246 | transfer_buffer = kzalloc(transfer_buffer_length, GFP_KERNEL); | 251 | transfer_buffer = kzalloc(transfer_buffer_length, GFP_KERNEL); |
247 | if (! transfer_buffer) { | 252 | if (!transfer_buffer) |
248 | return -ENOMEM; | 253 | return -ENOMEM; |
249 | } | 254 | |
250 | 255 | /* allocate write_urb */ | |
251 | // allocate write_urb | 256 | if (!port->write_urb) { |
252 | if (!port->write_urb) { | 257 | dbg("%s - port %d Allocating port->write_urb", |
253 | dbg("%s - port %d Allocating port->write_urb", __func__, port->number); | 258 | __func__, port->number); |
254 | port->write_urb = usb_alloc_urb(0, GFP_KERNEL); | 259 | port->write_urb = usb_alloc_urb(0, GFP_KERNEL); |
255 | if (!port->write_urb) { | 260 | if (!port->write_urb) { |
256 | dbg("%s - port %d usb_alloc_urb failed", __func__, port->number); | 261 | dbg("%s - port %d usb_alloc_urb failed", |
262 | __func__, port->number); | ||
257 | kfree(transfer_buffer); | 263 | kfree(transfer_buffer); |
258 | return -ENOMEM; | 264 | return -ENOMEM; |
259 | } | 265 | } |
260 | } | 266 | } |
261 | 267 | ||
262 | // allocate memory for write_urb transfer buffer | 268 | /* allocate memory for write_urb transfer buffer */ |
263 | port->write_urb->transfer_buffer = kmalloc(write_urb_transfer_buffer_length, GFP_KERNEL); | 269 | port->write_urb->transfer_buffer = |
264 | if (! port->write_urb->transfer_buffer) { | 270 | kmalloc(write_urb_transfer_buffer_length, GFP_KERNEL); |
271 | if (!port->write_urb->transfer_buffer) { | ||
265 | kfree(transfer_buffer); | 272 | kfree(transfer_buffer); |
266 | usb_free_urb(port->write_urb); | 273 | usb_free_urb(port->write_urb); |
267 | port->write_urb = NULL; | 274 | port->write_urb = NULL; |
268 | return -ENOMEM; | 275 | return -ENOMEM; |
269 | } | 276 | } |
270 | 277 | ||
271 | // get hardware version | 278 | /* get hardware version */ |
272 | result = usb_control_msg( port->serial->dev, | 279 | result = usb_control_msg(port->serial->dev, |
273 | usb_rcvctrlpipe(port->serial->dev, 0 ), | 280 | usb_rcvctrlpipe(port->serial->dev, 0), |
274 | SUSBCRequest_GetMisc, | 281 | SUSBCRequest_GetMisc, |
275 | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_IN, | 282 | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_IN, |
276 | SUSBCR_MSC_GetHWVersion, | 283 | SUSBCR_MSC_GetHWVersion, |
277 | 0, | 284 | 0, |
278 | transfer_buffer, | 285 | transfer_buffer, |
279 | transfer_buffer_length, | 286 | transfer_buffer_length, |
280 | KOBIL_TIMEOUT | 287 | KOBIL_TIMEOUT |
288 | ); | ||
289 | dbg("%s - port %d Send get_HW_version URB returns: %i", | ||
290 | __func__, port->number, result); | ||
291 | dbg("Harware version: %i.%i.%i", | ||
292 | transfer_buffer[0], transfer_buffer[1], transfer_buffer[2]); | ||
293 | |||
294 | /* get firmware version */ | ||
295 | result = usb_control_msg(port->serial->dev, | ||
296 | usb_rcvctrlpipe(port->serial->dev, 0), | ||
297 | SUSBCRequest_GetMisc, | ||
298 | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_IN, | ||
299 | SUSBCR_MSC_GetFWVersion, | ||
300 | 0, | ||
301 | transfer_buffer, | ||
302 | transfer_buffer_length, | ||
303 | KOBIL_TIMEOUT | ||
304 | ); | ||
305 | dbg("%s - port %d Send get_FW_version URB returns: %i", | ||
306 | __func__, port->number, result); | ||
307 | dbg("Firmware version: %i.%i.%i", | ||
308 | transfer_buffer[0], transfer_buffer[1], transfer_buffer[2]); | ||
309 | |||
310 | if (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID || | ||
311 | priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID) { | ||
312 | /* Setting Baudrate, Parity and Stopbits */ | ||
313 | result = usb_control_msg(port->serial->dev, | ||
314 | usb_rcvctrlpipe(port->serial->dev, 0), | ||
315 | SUSBCRequest_SetBaudRateParityAndStopBits, | ||
316 | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT, | ||
317 | SUSBCR_SBR_9600 | SUSBCR_SPASB_EvenParity | | ||
318 | SUSBCR_SPASB_1StopBit, | ||
319 | 0, | ||
320 | transfer_buffer, | ||
321 | 0, | ||
322 | KOBIL_TIMEOUT | ||
281 | ); | 323 | ); |
282 | dbg("%s - port %d Send get_HW_version URB returns: %i", __func__, port->number, result); | 324 | dbg("%s - port %d Send set_baudrate URB returns: %i", |
283 | dbg("Harware version: %i.%i.%i", transfer_buffer[0], transfer_buffer[1], transfer_buffer[2] ); | 325 | __func__, port->number, result); |
284 | 326 | ||
285 | // get firmware version | 327 | /* reset all queues */ |
286 | result = usb_control_msg( port->serial->dev, | 328 | result = usb_control_msg(port->serial->dev, |
287 | usb_rcvctrlpipe(port->serial->dev, 0 ), | 329 | usb_rcvctrlpipe(port->serial->dev, 0), |
288 | SUSBCRequest_GetMisc, | 330 | SUSBCRequest_Misc, |
289 | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_IN, | 331 | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT, |
290 | SUSBCR_MSC_GetFWVersion, | 332 | SUSBCR_MSC_ResetAllQueues, |
291 | 0, | 333 | 0, |
292 | transfer_buffer, | 334 | transfer_buffer, |
293 | transfer_buffer_length, | 335 | 0, |
294 | KOBIL_TIMEOUT | 336 | KOBIL_TIMEOUT |
295 | ); | 337 | ); |
296 | dbg("%s - port %d Send get_FW_version URB returns: %i", __func__, port->number, result); | 338 | dbg("%s - port %d Send reset_all_queues URB returns: %i", |
297 | dbg("Firmware version: %i.%i.%i", transfer_buffer[0], transfer_buffer[1], transfer_buffer[2] ); | 339 | __func__, port->number, result); |
298 | |||
299 | if (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID || priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID) { | ||
300 | // Setting Baudrate, Parity and Stopbits | ||
301 | result = usb_control_msg( port->serial->dev, | ||
302 | usb_rcvctrlpipe(port->serial->dev, 0 ), | ||
303 | SUSBCRequest_SetBaudRateParityAndStopBits, | ||
304 | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT, | ||
305 | SUSBCR_SBR_9600 | SUSBCR_SPASB_EvenParity | SUSBCR_SPASB_1StopBit, | ||
306 | 0, | ||
307 | transfer_buffer, | ||
308 | 0, | ||
309 | KOBIL_TIMEOUT | ||
310 | ); | ||
311 | dbg("%s - port %d Send set_baudrate URB returns: %i", __func__, port->number, result); | ||
312 | |||
313 | // reset all queues | ||
314 | result = usb_control_msg( port->serial->dev, | ||
315 | usb_rcvctrlpipe(port->serial->dev, 0 ), | ||
316 | SUSBCRequest_Misc, | ||
317 | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT, | ||
318 | SUSBCR_MSC_ResetAllQueues, | ||
319 | 0, | ||
320 | transfer_buffer, | ||
321 | 0, | ||
322 | KOBIL_TIMEOUT | ||
323 | ); | ||
324 | dbg("%s - port %d Send reset_all_queues URB returns: %i", __func__, port->number, result); | ||
325 | } | 340 | } |
326 | if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID || priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID || | 341 | if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID || |
342 | priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID || | ||
327 | priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID) { | 343 | priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID) { |
328 | // start reading (Adapter B 'cause PNP string) | 344 | /* start reading (Adapter B 'cause PNP string) */ |
329 | result = usb_submit_urb( port->interrupt_in_urb, GFP_ATOMIC ); | 345 | result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); |
330 | dbg("%s - port %d Send read URB returns: %i", __func__, port->number, result); | 346 | dbg("%s - port %d Send read URB returns: %i", |
347 | __func__, port->number, result); | ||
331 | } | 348 | } |
332 | 349 | ||
333 | kfree(transfer_buffer); | 350 | kfree(transfer_buffer); |
@@ -342,7 +359,7 @@ static void kobil_close(struct tty_struct *tty, | |||
342 | 359 | ||
343 | if (port->write_urb) { | 360 | if (port->write_urb) { |
344 | usb_kill_urb(port->write_urb); | 361 | usb_kill_urb(port->write_urb); |
345 | usb_free_urb( port->write_urb ); | 362 | usb_free_urb(port->write_urb); |
346 | port->write_urb = NULL; | 363 | port->write_urb = NULL; |
347 | } | 364 | } |
348 | usb_kill_urb(port->interrupt_in_urb); | 365 | usb_kill_urb(port->interrupt_in_urb); |
@@ -356,7 +373,7 @@ static void kobil_read_int_callback(struct urb *urb) | |||
356 | struct tty_struct *tty; | 373 | struct tty_struct *tty; |
357 | unsigned char *data = urb->transfer_buffer; | 374 | unsigned char *data = urb->transfer_buffer; |
358 | int status = urb->status; | 375 | int status = urb->status; |
359 | // char *dbg_data; | 376 | /* char *dbg_data; */ |
360 | 377 | ||
361 | dbg("%s - port %d", __func__, port->number); | 378 | dbg("%s - port %d", __func__, port->number); |
362 | 379 | ||
@@ -369,48 +386,50 @@ static void kobil_read_int_callback(struct urb *urb) | |||
369 | tty = port->port.tty; | 386 | tty = port->port.tty; |
370 | if (urb->actual_length) { | 387 | if (urb->actual_length) { |
371 | 388 | ||
372 | // BEGIN DEBUG | 389 | /* BEGIN DEBUG */ |
373 | /* | 390 | /* |
374 | dbg_data = kzalloc((3 * purb->actual_length + 10) * sizeof(char), GFP_KERNEL); | 391 | dbg_data = kzalloc((3 * purb->actual_length + 10) |
392 | * sizeof(char), GFP_KERNEL); | ||
375 | if (! dbg_data) { | 393 | if (! dbg_data) { |
376 | return; | 394 | return; |
377 | } | 395 | } |
378 | for (i = 0; i < purb->actual_length; i++) { | 396 | for (i = 0; i < purb->actual_length; i++) { |
379 | sprintf(dbg_data +3*i, "%02X ", data[i]); | 397 | sprintf(dbg_data +3*i, "%02X ", data[i]); |
380 | } | 398 | } |
381 | dbg(" <-- %s", dbg_data ); | 399 | dbg(" <-- %s", dbg_data); |
382 | kfree(dbg_data); | 400 | kfree(dbg_data); |
383 | */ | 401 | */ |
384 | // END DEBUG | 402 | /* END DEBUG */ |
385 | 403 | ||
386 | tty_buffer_request_room(tty, urb->actual_length); | 404 | tty_buffer_request_room(tty, urb->actual_length); |
387 | tty_insert_flip_string(tty, data, urb->actual_length); | 405 | tty_insert_flip_string(tty, data, urb->actual_length); |
388 | tty_flip_buffer_push(tty); | 406 | tty_flip_buffer_push(tty); |
389 | } | 407 | } |
390 | 408 | /* someone sets the dev to 0 if the close method has been called */ | |
391 | // someone sets the dev to 0 if the close method has been called | ||
392 | port->interrupt_in_urb->dev = port->serial->dev; | 409 | port->interrupt_in_urb->dev = port->serial->dev; |
393 | 410 | ||
394 | result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); | 411 | result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); |
395 | dbg("%s - port %d Send read URB returns: %i", __func__, port->number, result); | 412 | dbg("%s - port %d Send read URB returns: %i", |
413 | __func__, port->number, result); | ||
396 | } | 414 | } |
397 | 415 | ||
398 | 416 | ||
399 | static void kobil_write_callback( struct urb *purb ) | 417 | static void kobil_write_callback(struct urb *purb) |
400 | { | 418 | { |
401 | } | 419 | } |
402 | 420 | ||
403 | 421 | ||
404 | static int kobil_write (struct tty_struct *tty, struct usb_serial_port *port, | 422 | static int kobil_write(struct tty_struct *tty, struct usb_serial_port *port, |
405 | const unsigned char *buf, int count) | 423 | const unsigned char *buf, int count) |
406 | { | 424 | { |
407 | int length = 0; | 425 | int length = 0; |
408 | int result = 0; | 426 | int result = 0; |
409 | int todo = 0; | 427 | int todo = 0; |
410 | struct kobil_private * priv; | 428 | struct kobil_private *priv; |
411 | 429 | ||
412 | if (count == 0) { | 430 | if (count == 0) { |
413 | dbg("%s - port %d write request of 0 bytes", __func__, port->number); | 431 | dbg("%s - port %d write request of 0 bytes", |
432 | __func__, port->number); | ||
414 | return 0; | 433 | return 0; |
415 | } | 434 | } |
416 | 435 | ||
@@ -421,69 +440,77 @@ static int kobil_write (struct tty_struct *tty, struct usb_serial_port *port, | |||
421 | return -ENOMEM; | 440 | return -ENOMEM; |
422 | } | 441 | } |
423 | 442 | ||
424 | // Copy data to buffer | 443 | /* Copy data to buffer */ |
425 | memcpy (priv->buf + priv->filled, buf, count); | 444 | memcpy(priv->buf + priv->filled, buf, count); |
426 | usb_serial_debug_data(debug, &port->dev, __func__, count, priv->buf + priv->filled); | 445 | usb_serial_debug_data(debug, &port->dev, __func__, count, |
446 | priv->buf + priv->filled); | ||
427 | priv->filled = priv->filled + count; | 447 | priv->filled = priv->filled + count; |
428 | 448 | ||
429 | // only send complete block. TWIN, KAAN SIM and adapter K use the same protocol. | 449 | /* only send complete block. TWIN, KAAN SIM and adapter K |
430 | if ( ((priv->device_type != KOBIL_ADAPTER_B_PRODUCT_ID) && (priv->filled > 2) && (priv->filled >= (priv->buf[1] + 3))) || | 450 | use the same protocol. */ |
431 | ((priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) && (priv->filled > 3) && (priv->filled >= (priv->buf[2] + 4))) ) { | 451 | if (((priv->device_type != KOBIL_ADAPTER_B_PRODUCT_ID) && (priv->filled > 2) && (priv->filled >= (priv->buf[1] + 3))) || |
432 | 452 | ((priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) && (priv->filled > 3) && (priv->filled >= (priv->buf[2] + 4)))) { | |
433 | // stop reading (except TWIN and KAAN SIM) | 453 | /* stop reading (except TWIN and KAAN SIM) */ |
434 | if ( (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) || (priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID) ) | 454 | if ((priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) |
455 | || (priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID)) | ||
435 | usb_kill_urb(port->interrupt_in_urb); | 456 | usb_kill_urb(port->interrupt_in_urb); |
436 | 457 | ||
437 | todo = priv->filled - priv->cur_pos; | 458 | todo = priv->filled - priv->cur_pos; |
438 | 459 | ||
439 | while(todo > 0) { | 460 | while (todo > 0) { |
440 | // max 8 byte in one urb (endpoint size) | 461 | /* max 8 byte in one urb (endpoint size) */ |
441 | length = (todo < 8) ? todo : 8; | 462 | length = (todo < 8) ? todo : 8; |
442 | // copy data to transfer buffer | 463 | /* copy data to transfer buffer */ |
443 | memcpy(port->write_urb->transfer_buffer, priv->buf + priv->cur_pos, length ); | 464 | memcpy(port->write_urb->transfer_buffer, |
444 | usb_fill_int_urb( port->write_urb, | 465 | priv->buf + priv->cur_pos, length); |
445 | port->serial->dev, | 466 | usb_fill_int_urb(port->write_urb, |
446 | usb_sndintpipe(port->serial->dev, priv->write_int_endpoint_address), | 467 | port->serial->dev, |
447 | port->write_urb->transfer_buffer, | 468 | usb_sndintpipe(port->serial->dev, |
448 | length, | 469 | priv->write_int_endpoint_address), |
449 | kobil_write_callback, | 470 | port->write_urb->transfer_buffer, |
450 | port, | 471 | length, |
451 | 8 | 472 | kobil_write_callback, |
452 | ); | 473 | port, |
474 | 8 | ||
475 | ); | ||
453 | 476 | ||
454 | priv->cur_pos = priv->cur_pos + length; | 477 | priv->cur_pos = priv->cur_pos + length; |
455 | result = usb_submit_urb( port->write_urb, GFP_NOIO ); | 478 | result = usb_submit_urb(port->write_urb, GFP_NOIO); |
456 | dbg("%s - port %d Send write URB returns: %i", __func__, port->number, result); | 479 | dbg("%s - port %d Send write URB returns: %i", |
480 | __func__, port->number, result); | ||
457 | todo = priv->filled - priv->cur_pos; | 481 | todo = priv->filled - priv->cur_pos; |
458 | 482 | ||
459 | if (todo > 0) { | 483 | if (todo > 0) |
460 | msleep(24); | 484 | msleep(24); |
461 | } | 485 | } |
462 | 486 | ||
463 | } // end while | ||
464 | |||
465 | priv->filled = 0; | 487 | priv->filled = 0; |
466 | priv->cur_pos = 0; | 488 | priv->cur_pos = 0; |
467 | 489 | ||
468 | // someone sets the dev to 0 if the close method has been called | 490 | /* someone sets the dev to 0 if the close method |
491 | has been called */ | ||
469 | port->interrupt_in_urb->dev = port->serial->dev; | 492 | port->interrupt_in_urb->dev = port->serial->dev; |
470 | 493 | ||
471 | // start reading (except TWIN and KAAN SIM) | 494 | /* start reading (except TWIN and KAAN SIM) */ |
472 | if ( (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) || (priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID) ) { | 495 | if (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID || |
473 | // someone sets the dev to 0 if the close method has been called | 496 | priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID) { |
497 | /* someone sets the dev to 0 if the close method has | ||
498 | been called */ | ||
474 | port->interrupt_in_urb->dev = port->serial->dev; | 499 | port->interrupt_in_urb->dev = port->serial->dev; |
475 | 500 | ||
476 | result = usb_submit_urb( port->interrupt_in_urb, GFP_NOIO ); | 501 | result = usb_submit_urb(port->interrupt_in_urb, |
477 | dbg("%s - port %d Send read URB returns: %i", __func__, port->number, result); | 502 | GFP_NOIO); |
503 | dbg("%s - port %d Send read URB returns: %i", | ||
504 | __func__, port->number, result); | ||
478 | } | 505 | } |
479 | } | 506 | } |
480 | return count; | 507 | return count; |
481 | } | 508 | } |
482 | 509 | ||
483 | 510 | ||
484 | static int kobil_write_room (struct tty_struct *tty) | 511 | static int kobil_write_room(struct tty_struct *tty) |
485 | { | 512 | { |
486 | //dbg("%s - port %d", __func__, port->number); | 513 | /* dbg("%s - port %d", __func__, port->number); */ |
487 | /* FIXME */ | 514 | /* FIXME */ |
488 | return 8; | 515 | return 8; |
489 | } | 516 | } |
@@ -492,34 +519,34 @@ static int kobil_write_room (struct tty_struct *tty) | |||
492 | static int kobil_tiocmget(struct tty_struct *tty, struct file *file) | 519 | static int kobil_tiocmget(struct tty_struct *tty, struct file *file) |
493 | { | 520 | { |
494 | struct usb_serial_port *port = tty->driver_data; | 521 | struct usb_serial_port *port = tty->driver_data; |
495 | struct kobil_private * priv; | 522 | struct kobil_private *priv; |
496 | int result; | 523 | int result; |
497 | unsigned char *transfer_buffer; | 524 | unsigned char *transfer_buffer; |
498 | int transfer_buffer_length = 8; | 525 | int transfer_buffer_length = 8; |
499 | 526 | ||
500 | priv = usb_get_serial_port_data(port); | 527 | priv = usb_get_serial_port_data(port); |
501 | if ((priv->device_type == KOBIL_USBTWIN_PRODUCT_ID) || (priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID)) { | 528 | if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID |
502 | // This device doesn't support ioctl calls | 529 | || priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID) { |
530 | /* This device doesn't support ioctl calls */ | ||
503 | return -EINVAL; | 531 | return -EINVAL; |
504 | } | 532 | } |
505 | 533 | ||
506 | // allocate memory for transfer buffer | 534 | /* allocate memory for transfer buffer */ |
507 | transfer_buffer = kzalloc(transfer_buffer_length, GFP_KERNEL); | 535 | transfer_buffer = kzalloc(transfer_buffer_length, GFP_KERNEL); |
508 | if (!transfer_buffer) { | 536 | if (!transfer_buffer) |
509 | return -ENOMEM; | 537 | return -ENOMEM; |
510 | } | ||
511 | 538 | ||
512 | result = usb_control_msg( port->serial->dev, | 539 | result = usb_control_msg(port->serial->dev, |
513 | usb_rcvctrlpipe(port->serial->dev, 0 ), | 540 | usb_rcvctrlpipe(port->serial->dev, 0), |
514 | SUSBCRequest_GetStatusLineState, | 541 | SUSBCRequest_GetStatusLineState, |
515 | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_IN, | 542 | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_IN, |
516 | 0, | 543 | 0, |
517 | 0, | 544 | 0, |
518 | transfer_buffer, | 545 | transfer_buffer, |
519 | transfer_buffer_length, | 546 | transfer_buffer_length, |
520 | KOBIL_TIMEOUT); | 547 | KOBIL_TIMEOUT); |
521 | 548 | ||
522 | dbg("%s - port %d Send get_status_line_state URB returns: %i. Statusline: %02x", | 549 | dbg("%s - port %d Send get_status_line_state URB returns: %i. Statusline: %02x", |
523 | __func__, port->number, result, transfer_buffer[0]); | 550 | __func__, port->number, result, transfer_buffer[0]); |
524 | 551 | ||
525 | result = 0; | 552 | result = 0; |
@@ -533,7 +560,7 @@ static int kobil_tiocmset(struct tty_struct *tty, struct file *file, | |||
533 | unsigned int set, unsigned int clear) | 560 | unsigned int set, unsigned int clear) |
534 | { | 561 | { |
535 | struct usb_serial_port *port = tty->driver_data; | 562 | struct usb_serial_port *port = tty->driver_data; |
536 | struct kobil_private * priv; | 563 | struct kobil_private *priv; |
537 | int result; | 564 | int result; |
538 | int dtr = 0; | 565 | int dtr = 0; |
539 | int rts = 0; | 566 | int rts = 0; |
@@ -542,16 +569,16 @@ static int kobil_tiocmset(struct tty_struct *tty, struct file *file, | |||
542 | 569 | ||
543 | /* FIXME: locking ? */ | 570 | /* FIXME: locking ? */ |
544 | priv = usb_get_serial_port_data(port); | 571 | priv = usb_get_serial_port_data(port); |
545 | if ((priv->device_type == KOBIL_USBTWIN_PRODUCT_ID) || (priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID)) { | 572 | if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID |
546 | // This device doesn't support ioctl calls | 573 | || priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID) { |
574 | /* This device doesn't support ioctl calls */ | ||
547 | return -EINVAL; | 575 | return -EINVAL; |
548 | } | 576 | } |
549 | 577 | ||
550 | // allocate memory for transfer buffer | 578 | /* allocate memory for transfer buffer */ |
551 | transfer_buffer = kzalloc(transfer_buffer_length, GFP_KERNEL); | 579 | transfer_buffer = kzalloc(transfer_buffer_length, GFP_KERNEL); |
552 | if (! transfer_buffer) { | 580 | if (!transfer_buffer) |
553 | return -ENOMEM; | 581 | return -ENOMEM; |
554 | } | ||
555 | 582 | ||
556 | if (set & TIOCM_RTS) | 583 | if (set & TIOCM_RTS) |
557 | rts = 1; | 584 | rts = 1; |
@@ -564,34 +591,39 @@ static int kobil_tiocmset(struct tty_struct *tty, struct file *file, | |||
564 | 591 | ||
565 | if (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) { | 592 | if (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) { |
566 | if (dtr != 0) | 593 | if (dtr != 0) |
567 | dbg("%s - port %d Setting DTR", __func__, port->number); | 594 | dbg("%s - port %d Setting DTR", |
595 | __func__, port->number); | ||
568 | else | 596 | else |
569 | dbg("%s - port %d Clearing DTR", __func__, port->number); | 597 | dbg("%s - port %d Clearing DTR", |
570 | result = usb_control_msg( port->serial->dev, | 598 | __func__, port->number); |
571 | usb_rcvctrlpipe(port->serial->dev, 0 ), | 599 | result = usb_control_msg(port->serial->dev, |
572 | SUSBCRequest_SetStatusLinesOrQueues, | 600 | usb_rcvctrlpipe(port->serial->dev, 0), |
573 | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT, | 601 | SUSBCRequest_SetStatusLinesOrQueues, |
574 | ((dtr != 0) ? SUSBCR_SSL_SETDTR : SUSBCR_SSL_CLRDTR), | 602 | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT, |
575 | 0, | 603 | ((dtr != 0) ? SUSBCR_SSL_SETDTR : SUSBCR_SSL_CLRDTR), |
576 | transfer_buffer, | 604 | 0, |
577 | 0, | 605 | transfer_buffer, |
578 | KOBIL_TIMEOUT); | 606 | 0, |
607 | KOBIL_TIMEOUT); | ||
579 | } else { | 608 | } else { |
580 | if (rts != 0) | 609 | if (rts != 0) |
581 | dbg("%s - port %d Setting RTS", __func__, port->number); | 610 | dbg("%s - port %d Setting RTS", |
611 | __func__, port->number); | ||
582 | else | 612 | else |
583 | dbg("%s - port %d Clearing RTS", __func__, port->number); | 613 | dbg("%s - port %d Clearing RTS", |
584 | result = usb_control_msg( port->serial->dev, | 614 | __func__, port->number); |
585 | usb_rcvctrlpipe(port->serial->dev, 0 ), | 615 | result = usb_control_msg(port->serial->dev, |
586 | SUSBCRequest_SetStatusLinesOrQueues, | 616 | usb_rcvctrlpipe(port->serial->dev, 0), |
587 | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT, | 617 | SUSBCRequest_SetStatusLinesOrQueues, |
588 | ((rts != 0) ? SUSBCR_SSL_SETRTS : SUSBCR_SSL_CLRRTS), | 618 | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT, |
589 | 0, | 619 | ((rts != 0) ? SUSBCR_SSL_SETRTS : SUSBCR_SSL_CLRRTS), |
590 | transfer_buffer, | 620 | 0, |
591 | 0, | 621 | transfer_buffer, |
592 | KOBIL_TIMEOUT); | 622 | 0, |
623 | KOBIL_TIMEOUT); | ||
593 | } | 624 | } |
594 | dbg("%s - port %d Send set_status_line URB returns: %i", __func__, port->number, result); | 625 | dbg("%s - port %d Send set_status_line URB returns: %i", |
626 | __func__, port->number, result); | ||
595 | kfree(transfer_buffer); | 627 | kfree(transfer_buffer); |
596 | return (result < 0) ? result : 0; | 628 | return (result < 0) ? result : 0; |
597 | } | 629 | } |
@@ -599,32 +631,35 @@ static int kobil_tiocmset(struct tty_struct *tty, struct file *file, | |||
599 | static void kobil_set_termios(struct tty_struct *tty, | 631 | static void kobil_set_termios(struct tty_struct *tty, |
600 | struct usb_serial_port *port, struct ktermios *old) | 632 | struct usb_serial_port *port, struct ktermios *old) |
601 | { | 633 | { |
602 | struct kobil_private * priv; | 634 | struct kobil_private *priv; |
603 | int result; | 635 | int result; |
604 | unsigned short urb_val = 0; | 636 | unsigned short urb_val = 0; |
605 | int c_cflag = tty->termios->c_cflag; | 637 | int c_cflag = tty->termios->c_cflag; |
606 | speed_t speed; | 638 | speed_t speed; |
607 | void * settings; | 639 | void *settings; |
608 | 640 | ||
609 | priv = usb_get_serial_port_data(port); | 641 | priv = usb_get_serial_port_data(port); |
610 | if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID || priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID) | 642 | if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID || |
611 | // This device doesn't support ioctl calls | 643 | priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID) |
644 | /* This device doesn't support ioctl calls */ | ||
612 | return; | 645 | return; |
613 | 646 | ||
614 | switch (speed = tty_get_baud_rate(tty)) { | 647 | speed = tty_get_baud_rate(tty); |
615 | case 1200: | 648 | switch (speed) { |
616 | urb_val = SUSBCR_SBR_1200; | 649 | case 1200: |
617 | break; | 650 | urb_val = SUSBCR_SBR_1200; |
618 | default: | 651 | break; |
619 | speed = 9600; | 652 | default: |
620 | case 9600: | 653 | speed = 9600; |
621 | urb_val = SUSBCR_SBR_9600; | 654 | case 9600: |
622 | break; | 655 | urb_val = SUSBCR_SBR_9600; |
656 | break; | ||
623 | } | 657 | } |
624 | urb_val |= (c_cflag & CSTOPB) ? SUSBCR_SPASB_2StopBits : SUSBCR_SPASB_1StopBit; | 658 | urb_val |= (c_cflag & CSTOPB) ? SUSBCR_SPASB_2StopBits : |
659 | SUSBCR_SPASB_1StopBit; | ||
625 | 660 | ||
626 | settings = kzalloc(50, GFP_KERNEL); | 661 | settings = kzalloc(50, GFP_KERNEL); |
627 | if (! settings) | 662 | if (!settings) |
628 | return; | 663 | return; |
629 | 664 | ||
630 | sprintf(settings, "%d ", speed); | 665 | sprintf(settings, "%d ", speed); |
@@ -644,48 +679,50 @@ static void kobil_set_termios(struct tty_struct *tty, | |||
644 | tty->termios->c_cflag &= ~CMSPAR; | 679 | tty->termios->c_cflag &= ~CMSPAR; |
645 | tty_encode_baud_rate(tty, speed, speed); | 680 | tty_encode_baud_rate(tty, speed, speed); |
646 | 681 | ||
647 | result = usb_control_msg( port->serial->dev, | 682 | result = usb_control_msg(port->serial->dev, |
648 | usb_rcvctrlpipe(port->serial->dev, 0 ), | 683 | usb_rcvctrlpipe(port->serial->dev, 0), |
649 | SUSBCRequest_SetBaudRateParityAndStopBits, | 684 | SUSBCRequest_SetBaudRateParityAndStopBits, |
650 | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT, | 685 | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT, |
651 | urb_val, | 686 | urb_val, |
652 | 0, | 687 | 0, |
653 | settings, | 688 | settings, |
654 | 0, | 689 | 0, |
655 | KOBIL_TIMEOUT | 690 | KOBIL_TIMEOUT |
656 | ); | 691 | ); |
657 | kfree(settings); | 692 | kfree(settings); |
658 | } | 693 | } |
659 | 694 | ||
660 | static int kobil_ioctl(struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg) | 695 | static int kobil_ioctl(struct tty_struct *tty, struct file *file, |
696 | unsigned int cmd, unsigned long arg) | ||
661 | { | 697 | { |
662 | struct usb_serial_port *port = tty->driver_data; | 698 | struct usb_serial_port *port = tty->driver_data; |
663 | struct kobil_private * priv = usb_get_serial_port_data(port); | 699 | struct kobil_private *priv = usb_get_serial_port_data(port); |
664 | unsigned char *transfer_buffer; | 700 | unsigned char *transfer_buffer; |
665 | int transfer_buffer_length = 8; | 701 | int transfer_buffer_length = 8; |
666 | int result; | 702 | int result; |
667 | 703 | ||
668 | if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID || priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID) | 704 | if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID || |
669 | // This device doesn't support ioctl calls | 705 | priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID) |
706 | /* This device doesn't support ioctl calls */ | ||
670 | return 0; | 707 | return 0; |
671 | 708 | ||
672 | switch (cmd) { | 709 | switch (cmd) { |
673 | case TCFLSH: | 710 | case TCFLSH: |
674 | transfer_buffer = kmalloc(transfer_buffer_length, GFP_KERNEL); | 711 | transfer_buffer = kmalloc(transfer_buffer_length, GFP_KERNEL); |
675 | if (! transfer_buffer) | 712 | if (!transfer_buffer) |
676 | return -ENOBUFS; | 713 | return -ENOBUFS; |
677 | 714 | ||
678 | result = usb_control_msg( port->serial->dev, | 715 | result = usb_control_msg(port->serial->dev, |
679 | usb_rcvctrlpipe(port->serial->dev, 0 ), | 716 | usb_rcvctrlpipe(port->serial->dev, 0), |
680 | SUSBCRequest_Misc, | 717 | SUSBCRequest_Misc, |
681 | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT, | 718 | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT, |
682 | SUSBCR_MSC_ResetAllQueues, | 719 | SUSBCR_MSC_ResetAllQueues, |
683 | 0, | 720 | 0, |
684 | NULL,//transfer_buffer, | 721 | NULL, /* transfer_buffer, */ |
685 | 0, | 722 | 0, |
686 | KOBIL_TIMEOUT | 723 | KOBIL_TIMEOUT |
687 | ); | 724 | ); |
688 | 725 | ||
689 | dbg("%s - port %d Send reset_all_queues (FLUSH) URB returns: %i", __func__, port->number, result); | 726 | dbg("%s - port %d Send reset_all_queues (FLUSH) URB returns: %i", __func__, port->number, result); |
690 | kfree(transfer_buffer); | 727 | kfree(transfer_buffer); |
691 | return (result < 0) ? -EIO: 0; | 728 | return (result < 0) ? -EIO: 0; |
@@ -694,14 +731,14 @@ static int kobil_ioctl(struct tty_struct *tty, struct file * file, unsigned int | |||
694 | } | 731 | } |
695 | } | 732 | } |
696 | 733 | ||
697 | static int __init kobil_init (void) | 734 | static int __init kobil_init(void) |
698 | { | 735 | { |
699 | int retval; | 736 | int retval; |
700 | retval = usb_serial_register(&kobil_device); | 737 | retval = usb_serial_register(&kobil_device); |
701 | if (retval) | 738 | if (retval) |
702 | goto failed_usb_serial_register; | 739 | goto failed_usb_serial_register; |
703 | retval = usb_register(&kobil_driver); | 740 | retval = usb_register(&kobil_driver); |
704 | if (retval) | 741 | if (retval) |
705 | goto failed_usb_register; | 742 | goto failed_usb_register; |
706 | 743 | ||
707 | info(DRIVER_VERSION " " DRIVER_AUTHOR); | 744 | info(DRIVER_VERSION " " DRIVER_AUTHOR); |
@@ -715,18 +752,18 @@ failed_usb_serial_register: | |||
715 | } | 752 | } |
716 | 753 | ||
717 | 754 | ||
718 | static void __exit kobil_exit (void) | 755 | static void __exit kobil_exit(void) |
719 | { | 756 | { |
720 | usb_deregister (&kobil_driver); | 757 | usb_deregister(&kobil_driver); |
721 | usb_serial_deregister (&kobil_device); | 758 | usb_serial_deregister(&kobil_device); |
722 | } | 759 | } |
723 | 760 | ||
724 | module_init(kobil_init); | 761 | module_init(kobil_init); |
725 | module_exit(kobil_exit); | 762 | module_exit(kobil_exit); |
726 | 763 | ||
727 | MODULE_AUTHOR( DRIVER_AUTHOR ); | 764 | MODULE_AUTHOR(DRIVER_AUTHOR); |
728 | MODULE_DESCRIPTION( DRIVER_DESC ); | 765 | MODULE_DESCRIPTION(DRIVER_DESC); |
729 | MODULE_LICENSE( "GPL" ); | 766 | MODULE_LICENSE("GPL"); |
730 | 767 | ||
731 | module_param(debug, bool, S_IRUGO | S_IWUSR); | 768 | module_param(debug, bool, S_IRUGO | S_IWUSR); |
732 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | 769 | MODULE_PARM_DESC(debug, "Debug enabled or not"); |