aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/gigaset/usb-gigaset.c
diff options
context:
space:
mode:
authorTilman Schmidt <tilman@imap.cc>2006-04-11 01:55:00 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-04-11 09:18:49 -0400
commit917f5085ddb3498033551e711fb22f48ddeb8378 (patch)
treeff67547a8f4cbf27e4a30b795635778d8e6cc79d /drivers/isdn/gigaset/usb-gigaset.c
parent08a53cdce62d37d918530bbbf726cc01b21dc3d1 (diff)
[PATCH] isdn4linux: Siemens Gigaset drivers: code cleanup
With Hansjoerg Lipp <hjlipp@web.de> Source code formatting cleanups for the Siemens Gigaset drivers, such as line length, comments, removal of unused declarations, and typo corrections. It does not introduce any functional changes. Signed-off-by: Hansjoerg Lipp <hjlipp@web.de> Signed-off-by: Tilman Schmidt <tilman@imap.cc> Cc: Karsten Keil <kkeil@suse.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/isdn/gigaset/usb-gigaset.c')
-rw-r--r--drivers/isdn/gigaset/usb-gigaset.c129
1 files changed, 38 insertions, 91 deletions
diff --git a/drivers/isdn/gigaset/usb-gigaset.c b/drivers/isdn/gigaset/usb-gigaset.c
index 323fc7349dec..0f5aa46cf8f3 100644
--- a/drivers/isdn/gigaset/usb-gigaset.c
+++ b/drivers/isdn/gigaset/usb-gigaset.c
@@ -13,10 +13,6 @@
13 * published by the Free Software Foundation; either version 2 of 13 * published by the Free Software Foundation; either version 2 of
14 * the License, or (at your option) any later version. 14 * the License, or (at your option) any later version.
15 * ===================================================================== 15 * =====================================================================
16 * ToDo: ...
17 * =====================================================================
18 * Version: $Id: usb-gigaset.c,v 1.85.4.18 2006/02/04 18:28:16 hjlipp Exp $
19 * =====================================================================
20 */ 16 */
21 17
22#include "gigaset.h" 18#include "gigaset.h"
@@ -62,10 +58,6 @@ static struct usb_device_id gigaset_table [] = {
62 58
63MODULE_DEVICE_TABLE(usb, gigaset_table); 59MODULE_DEVICE_TABLE(usb, gigaset_table);
64 60
65/* Get a minor range for your devices from the usb maintainer */
66#define USB_SKEL_MINOR_BASE 200
67
68
69/* 61/*
70 * Control requests (empty fields: 00) 62 * Control requests (empty fields: 00)
71 * 63 *
@@ -122,29 +114,29 @@ static struct cardstate *cardstate = NULL;
122 114
123/* usb specific object needed to register this driver with the usb subsystem */ 115/* usb specific object needed to register this driver with the usb subsystem */
124static struct usb_driver gigaset_usb_driver = { 116static struct usb_driver gigaset_usb_driver = {
125 .name = GIGASET_MODULENAME, 117 .name = GIGASET_MODULENAME,
126 .probe = gigaset_probe, 118 .probe = gigaset_probe,
127 .disconnect = gigaset_disconnect, 119 .disconnect = gigaset_disconnect,
128 .id_table = gigaset_table, 120 .id_table = gigaset_table,
129}; 121};
130 122
131struct usb_cardstate { 123struct usb_cardstate {
132 struct usb_device *udev; /* save off the usb device pointer */ 124 struct usb_device *udev; /* usb device pointer */
133 struct usb_interface *interface; /* the interface for this device */ 125 struct usb_interface *interface; /* interface for this device */
134 atomic_t busy; /* bulk output in progress */ 126 atomic_t busy; /* bulk output in progress */
135 127
136 /* Output buffer for commands (M105: and data)*/ 128 /* Output buffer */
137 unsigned char *bulk_out_buffer; /* the buffer to send data */ 129 unsigned char *bulk_out_buffer; /* send buffer */
138 int bulk_out_size; /* the size of the send buffer */ 130 int bulk_out_size; /* send buffer size */
139 __u8 bulk_out_endpointAddr; /* the address of the bulk out endpoint */ 131 __u8 bulk_out_endpointAddr; /* bulk out endpoint */
140 struct urb *bulk_out_urb; /* the urb used to transmit data */ 132 struct urb *bulk_out_urb; /* bulk out urb */
141 133
142 /* Input buffer for command responses (M105: and data)*/ 134 /* Input buffer */
143 int rcvbuf_size; /* the size of the receive buffer */ 135 int rcvbuf_size; /* rcv buffer */
144 struct urb *read_urb; /* the urb used to receive data */ 136 struct urb *read_urb; /* rcv buffer size */
145 __u8 int_in_endpointAddr; /* the address of the bulk in endpoint */ 137 __u8 int_in_endpointAddr; /* int in endpoint */
146 138
147 char bchars[6]; /* req. 0x19 */ 139 char bchars[6]; /* request 0x19 */
148}; 140};
149 141
150struct usb_bc_state {}; 142struct usb_bc_state {};
@@ -166,10 +158,11 @@ static int gigaset_set_modem_ctrl(struct cardstate *cs, unsigned old_state,
166 val = tiocm_to_gigaset(new_state); 158 val = tiocm_to_gigaset(new_state);
167 159
168 dbg(DEBUG_USBREQ, "set flags 0x%02x with mask 0x%02x", val, mask); 160 dbg(DEBUG_USBREQ, "set flags 0x%02x with mask 0x%02x", val, mask);
161 // don't use this in an interrupt/BH
169 r = usb_control_msg(cs->hw.usb->udev, 162 r = usb_control_msg(cs->hw.usb->udev,
170 usb_sndctrlpipe(cs->hw.usb->udev, 0), 7, 0x41, 163 usb_sndctrlpipe(cs->hw.usb->udev, 0), 7, 0x41,
171 (val & 0xff) | ((mask & 0xff) << 8), 0, 164 (val & 0xff) | ((mask & 0xff) << 8), 0,
172 NULL, 0, 2000 /*timeout??*/); // don't use this in an interrupt/BH 165 NULL, 0, 2000 /* timeout? */);
173 if (r < 0) 166 if (r < 0)
174 return r; 167 return r;
175 //.. 168 //..
@@ -309,15 +302,12 @@ static int gigaset_close_bchannel(struct bc_state *bcs)
309 return 0; 302 return 0;
310} 303}
311 304
312//void send_ack_to_LL(void *data);
313static int write_modem(struct cardstate *cs); 305static int write_modem(struct cardstate *cs);
314static int send_cb(struct cardstate *cs, struct cmdbuf_t *cb); 306static int send_cb(struct cardstate *cs, struct cmdbuf_t *cb);
315 307
316 308
317/* Handling of send queue. If there is already a skb opened, put data to 309/* Write tasklet handler: Continue sending current skb, or send command, or
318 * the transfer buffer by calling "write_modem". Otherwise take a new skb out of the queue. 310 * start sending an skb from the send queue.
319 * This function will be called by the ISR via "transmit_chars" (USB: B-Channel Bulk callback handler
320 * via immediate task queue) or by writebuf_from_LL if the LL wants to transmit data.
321 */ 311 */
322static void gigaset_modem_fill(unsigned long data) 312static void gigaset_modem_fill(unsigned long data)
323{ 313{
@@ -345,7 +335,8 @@ static void gigaset_modem_fill(unsigned long data)
345 if (send_cb(cs, cb) < 0) { 335 if (send_cb(cs, cb) < 0) {
346 dbg(DEBUG_OUTPUT, 336 dbg(DEBUG_OUTPUT,
347 "modem_fill: send_cb failed"); 337 "modem_fill: send_cb failed");
348 again = 1; /* no callback will be called! */ 338 again = 1; /* no callback will be
339 called! */
349 } 340 }
350 } else { /* skbs to send? */ 341 } else { /* skbs to send? */
351 bcs->tx_skb = skb_dequeue(&bcs->squeue); 342 bcs->tx_skb = skb_dequeue(&bcs->squeue);
@@ -371,8 +362,7 @@ static void gigaset_modem_fill(unsigned long data)
371/** 362/**
372 * gigaset_read_int_callback 363 * gigaset_read_int_callback
373 * 364 *
374 * It is called if the data was received from the device. This is almost similiar to 365 * It is called if the data was received from the device.
375 * the interrupt service routine in the serial device.
376 */ 366 */
377static void gigaset_read_int_callback(struct urb *urb, struct pt_regs *regs) 367static void gigaset_read_int_callback(struct urb *urb, struct pt_regs *regs)
378{ 368{
@@ -381,13 +371,11 @@ static void gigaset_read_int_callback(struct urb *urb, struct pt_regs *regs)
381 struct cardstate *cs; 371 struct cardstate *cs;
382 unsigned numbytes; 372 unsigned numbytes;
383 unsigned char *src; 373 unsigned char *src;
384 //unsigned long flags;
385 struct inbuf_t *inbuf; 374 struct inbuf_t *inbuf;
386 375
387 IFNULLRET(urb); 376 IFNULLRET(urb);
388 inbuf = (struct inbuf_t *) urb->context; 377 inbuf = (struct inbuf_t *) urb->context;
389 IFNULLRET(inbuf); 378 IFNULLRET(inbuf);
390 //spin_lock_irqsave(&inbuf->lock, flags);
391 cs = inbuf->cs; 379 cs = inbuf->cs;
392 IFNULLGOTO(cs, exit); 380 IFNULLGOTO(cs, exit);
393 IFNULLGOTO(cardstate, exit); 381 IFNULLGOTO(cardstate, exit);
@@ -422,7 +410,6 @@ static void gigaset_read_int_callback(struct urb *urb, struct pt_regs *regs)
422 resubmit = 1; 410 resubmit = 1;
423 } 411 }
424exit: 412exit:
425 //spin_unlock_irqrestore(&inbuf->lock, flags);
426 if (resubmit) { 413 if (resubmit) {
427 r = usb_submit_urb(urb, SLAB_ATOMIC); 414 r = usb_submit_urb(urb, SLAB_ATOMIC);
428 if (r) 415 if (r)
@@ -431,11 +418,7 @@ exit:
431} 418}
432 419
433 420
434/* This callback routine is called when data was transmitted to a B-Channel. 421/* This callback routine is called when data was transmitted to the device. */
435 * Therefore it has to check if there is still data to transmit. This
436 * happens by calling modem_fill via task queue.
437 *
438 */
439static void gigaset_write_bulk_callback(struct urb *urb, struct pt_regs *regs) 422static void gigaset_write_bulk_callback(struct urb *urb, struct pt_regs *regs)
440{ 423{
441 struct cardstate *cs = (struct cardstate *) urb->context; 424 struct cardstate *cs = (struct cardstate *) urb->context;
@@ -448,8 +431,9 @@ static void gigaset_write_bulk_callback(struct urb *urb, struct pt_regs *regs)
448 } 431 }
449#endif 432#endif
450 if (urb->status) 433 if (urb->status)
451 err("bulk transfer failed (status %d)", -urb->status); /* That's all we can do. Communication problems 434 err("bulk transfer failed (status %d)", -urb->status);
452 are handeled by timeouts or network protocols */ 435 /* That's all we can do. Communication problems
436 are handeled by timeouts or network protocols */
453 437
454 atomic_set(&cs->hw.usb->busy, 0); 438 atomic_set(&cs->hw.usb->busy, 0);
455 tasklet_schedule(&cs->write_tasklet); 439 tasklet_schedule(&cs->write_tasklet);
@@ -503,16 +487,16 @@ static int send_cb(struct cardstate *cs, struct cmdbuf_t *cb)
503 atomic_set(&ucs->busy, 0); 487 atomic_set(&ucs->busy, 0);
504 err("could not submit urb (error %d).", 488 err("could not submit urb (error %d).",
505 -status); 489 -status);
506 cb->len = 0; /* skip urb => remove cb+wakeup in next loop cycle */ 490 cb->len = 0; /* skip urb => remove cb+wakeup
491 in next loop cycle */
507 } 492 }
508 } 493 }
509 } while (cb && status); /* bei Fehler naechster Befehl //FIXME: ist das OK? */ 494 } while (cb && status); /* next command on error */
510 495
511 return status; 496 return status;
512} 497}
513 498
514/* Write string into transbuf and send it to modem. 499/* Send command to device. */
515 */
516static int gigaset_write_cmd(struct cardstate *cs, const unsigned char *buf, 500static int gigaset_write_cmd(struct cardstate *cs, const unsigned char *buf,
517 int len, struct tasklet_struct *wake_tasklet) 501 int len, struct tasklet_struct *wake_tasklet)
518{ 502{
@@ -604,7 +588,6 @@ static int gigaset_initbcshw(struct bc_state *bcs)
604 if (!bcs->hw.usb) 588 if (!bcs->hw.usb)
605 return 0; 589 return 0;
606 590
607 //bcs->hw.usb->trans_flg = READY_TO_TRNSMIT; /* B-Channel ready to transmit */
608 return 1; 591 return 1;
609} 592}
610 593
@@ -614,7 +597,6 @@ static void gigaset_reinitbcshw(struct bc_state *bcs)
614 597
615static void gigaset_freecshw(struct cardstate *cs) 598static void gigaset_freecshw(struct cardstate *cs)
616{ 599{
617 //FIXME
618 tasklet_kill(&cs->write_tasklet); 600 tasklet_kill(&cs->write_tasklet);
619 kfree(cs->hw.usb); 601 kfree(cs->hw.usb);
620} 602}
@@ -644,19 +626,13 @@ static int gigaset_initcshw(struct cardstate *cs)
644 return 1; 626 return 1;
645} 627}
646 628
647/* Writes the data of the current open skb into the modem. 629/* Send data from current skb to the device. */
648 * We have to protect against multiple calls until the
649 * callback handler () is called , due to the fact that we
650 * are just allowed to send data once to an endpoint. Therefore
651 * we using "trans_flg" to synchonize ...
652 */
653static int write_modem(struct cardstate *cs) 630static int write_modem(struct cardstate *cs)
654{ 631{
655 int ret; 632 int ret;
656 int count; 633 int count;
657 struct bc_state *bcs = &cs->bcs[0]; /* only one channel */ 634 struct bc_state *bcs = &cs->bcs[0]; /* only one channel */
658 struct usb_cardstate *ucs = cs->hw.usb; 635 struct usb_cardstate *ucs = cs->hw.usb;
659 //unsigned long flags;
660 636
661 IFNULLRETVAL(bcs->tx_skb, -EINVAL); 637 IFNULLRETVAL(bcs->tx_skb, -EINVAL);
662 638
@@ -720,12 +696,9 @@ static int gigaset_probe(struct usb_interface *interface,
720 struct usb_host_interface *hostif; 696 struct usb_host_interface *hostif;
721 struct cardstate *cs = NULL; 697 struct cardstate *cs = NULL;
722 struct usb_cardstate *ucs = NULL; 698 struct usb_cardstate *ucs = NULL;
723 //struct usb_interface_descriptor *iface_desc;
724 struct usb_endpoint_descriptor *endpoint; 699 struct usb_endpoint_descriptor *endpoint;
725 //isdn_ctrl command;
726 int buffer_size; 700 int buffer_size;
727 int alt; 701 int alt;
728 //unsigned long flags;
729 702
730 info("%s: Check if device matches .. (Vendor: 0x%x, Product: 0x%x)", 703 info("%s: Check if device matches .. (Vendor: 0x%x, Product: 0x%x)",
731 __func__, le16_to_cpu(udev->descriptor.idVendor), 704 __func__, le16_to_cpu(udev->descriptor.idVendor),
@@ -766,29 +739,6 @@ static int gigaset_probe(struct usb_interface *interface,
766 } 739 }
767 ucs = cs->hw.usb; 740 ucs = cs->hw.usb;
768 741
769#if 0
770 if (usb_set_configuration(udev, udev->config[0].desc.bConfigurationValue) < 0) {
771 warn("set_configuration failed");
772 goto error;
773 }
774
775
776 if (usb_set_interface(udev, ifnum/*==0*/, alt/*==0*/) < 0) {
777 warn("usb_set_interface failed, device %d interface %d altsetting %d",
778 udev->devnum, ifnum, alt);
779 goto error;
780 }
781#endif
782
783 /* set up the endpoint information */
784 /* check out the endpoints */
785 /* We will get 2 endpoints: One for sending commands to the device (bulk out) and one to
786 * poll messages from the device(int in).
787 * Therefore we will have an almost similiar situation as with our serial port handler.
788 * If an connection will be established, we will have to create data in/out pipes
789 * dynamically...
790 */
791
792 endpoint = &hostif->endpoint[0].desc; 742 endpoint = &hostif->endpoint[0].desc;
793 743
794 buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); 744 buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
@@ -896,18 +846,15 @@ static void gigaset_disconnect(struct usb_interface *interface)
896 846
897 tasklet_kill(&cs->write_tasklet); 847 tasklet_kill(&cs->write_tasklet);
898 848
899 usb_kill_urb(ucs->bulk_out_urb); /* FIXME: nur, wenn noetig */ 849 usb_kill_urb(ucs->bulk_out_urb); /* FIXME: only if active? */
900 //usb_kill_urb(ucs->urb_cmd_out); /* FIXME: nur, wenn noetig */
901 850
902 kfree(ucs->bulk_out_buffer); 851 kfree(ucs->bulk_out_buffer);
903 if (ucs->bulk_out_urb != NULL) 852 if (ucs->bulk_out_urb != NULL)
904 usb_free_urb(ucs->bulk_out_urb); 853 usb_free_urb(ucs->bulk_out_urb);
905 //if(ucs->urb_cmd_out != NULL)
906 // usb_free_urb(ucs->urb_cmd_out);
907 kfree(cs->inbuf[0].rcvbuf); 854 kfree(cs->inbuf[0].rcvbuf);
908 if (ucs->read_urb != NULL) 855 if (ucs->read_urb != NULL)
909 usb_free_urb(ucs->read_urb); 856 usb_free_urb(ucs->read_urb);
910 ucs->read_urb = ucs->bulk_out_urb/*=ucs->urb_cmd_out*/=NULL; 857 ucs->read_urb = ucs->bulk_out_urb = NULL;
911 cs->inbuf[0].rcvbuf = ucs->bulk_out_buffer = NULL; 858 cs->inbuf[0].rcvbuf = ucs->bulk_out_buffer = NULL;
912 859
913 gigaset_unassign(cs); 860 gigaset_unassign(cs);