1 diff -u -p linux/include/net/irda/irda-usb.d2.h linux/include/net/irda/irda-usb.h
2 --- linux/include/net/irda/irda-usb.d2.h Mon Nov 5 17:36:33 2001
3 +++ linux/include/net/irda/irda-usb.h Mon Nov 5 17:37:04 2001
4 @@ -120,6 +120,11 @@ struct irda_class_desc {
6 } __attribute__ ((packed));
8 +/* class specific interface request to get the IrDA-USB class descriptor
9 + * (6.2.5, USB-IrDA class spec 1.0) */
11 +#define IU_REQ_GET_CLASS_DESC 0x06
14 struct irda_class_desc *irda_desc;
15 struct usb_device *usbdev; /* init: probe_irda */
16 diff -u -p linux/drivers/net/irda/irda-usb.d2.c linux/drivers/net/irda/irda-usb.c
17 --- linux/drivers/net/irda/irda-usb.d2.c Thu Oct 11 15:55:57 2001
18 +++ linux/drivers/net/irda/irda-usb.c Mon Nov 5 17:39:51 2001
19 @@ -279,7 +279,7 @@ static void irda_usb_change_speed_xbofs(
20 purb->timeout = MSECS_TO_JIFFIES(100);
22 if ((ret = usb_submit_urb(purb))) {
23 - IRDA_DEBUG(0, __FUNCTION__ "(), failed Speed URB\n");
24 + WARNING(__FUNCTION__ "(), failed Speed URB\n");
26 spin_unlock_irqrestore(&self->lock, flags);
28 @@ -296,14 +296,14 @@ static void speed_bulk_callback(purb_t p
30 /* We should always have a context */
32 - IRDA_DEBUG(0, __FUNCTION__ "(), Bug : self == NULL\n");
33 + WARNING(__FUNCTION__ "(), Bug : self == NULL\n");
37 /* Check for timeout and other USB nasties */
38 if(purb->status != USB_ST_NOERROR) {
39 /* I get a lot of -ECONNABORTED = -103 here - Jean II */
40 - WARNING(__FUNCTION__ "(), URB complete status %d, transfer_flags 0x%04X\n", purb->status, purb->transfer_flags);
41 + IRDA_DEBUG(0, __FUNCTION__ "(), URB complete status %d, transfer_flags 0x%04X\n", purb->status, purb->transfer_flags);
43 /* Don't do anything here, that might confuse the USB layer.
44 * Instead, we will wait for irda_usb_net_timeout(), the
45 @@ -452,7 +452,7 @@ static int irda_usb_hard_xmit(struct sk_
47 /* Ask USB to send the packet */
48 if ((res = usb_submit_urb(purb))) {
49 - IRDA_DEBUG(0, __FUNCTION__ "(), failed Tx URB\n");
50 + WARNING(__FUNCTION__ "(), failed Tx URB\n");
51 self->stats.tx_errors++;
52 /* Let USB recover : We will catch that in the watchdog */
53 /*netif_start_queue(netdev);*/
54 @@ -481,7 +481,7 @@ static void write_bulk_callback(purb_t p
56 /* We should always have a context */
58 - IRDA_DEBUG(0, __FUNCTION__ "(), Bug : self == NULL\n");
59 + WARNING(__FUNCTION__ "(), Bug : self == NULL\n");
63 @@ -492,7 +492,7 @@ static void write_bulk_callback(purb_t p
64 /* Check for timeout and other USB nasties */
65 if(purb->status != USB_ST_NOERROR) {
66 /* I get a lot of -ECONNABORTED = -103 here - Jean II */
67 - WARNING(__FUNCTION__ "(), URB complete status %d, transfer_flags 0x%04X\n", purb->status, purb->transfer_flags);
68 + IRDA_DEBUG(0, __FUNCTION__ "(), URB complete status %d, transfer_flags 0x%04X\n", purb->status, purb->transfer_flags);
70 /* Don't do anything here, that might confuse the USB layer,
71 * and we could go in recursion and blow the kernel stack...
72 @@ -514,7 +514,7 @@ static void write_bulk_callback(purb_t p
74 /* If we need to change the speed or xbofs, do it now */
75 if ((self->new_speed != -1) || (self->new_xbofs != -1)) {
76 - IRDA_DEBUG(0, __FUNCTION__ "(), Changing speed now...\n");
77 + IRDA_DEBUG(1, __FUNCTION__ "(), Changing speed now...\n");
78 irda_usb_change_speed_xbofs(self);
80 /* Otherwise, allow the stack to send more packets */
81 @@ -548,7 +548,7 @@ static void irda_usb_net_timeout(struct
83 purb = &(self->speed_urb);
84 if (purb->status != USB_ST_NOERROR) {
85 - WARNING("%s: Speed change timed out, urb->status=%d, urb->transfer_flags=0x%04X\n", netdev->name, purb->status, purb->transfer_flags);
86 + IRDA_DEBUG(0, "%s: Speed change timed out, urb->status=%d, urb->transfer_flags=0x%04X\n", netdev->name, purb->status, purb->transfer_flags);
88 switch (purb->status) {
89 case USB_ST_URB_PENDING: /* -EINPROGRESS == -115 */
90 @@ -575,7 +575,7 @@ static void irda_usb_net_timeout(struct
91 if (purb->status != USB_ST_NOERROR) {
92 struct sk_buff *skb = purb->context;
94 - WARNING("%s: Tx timed out, urb->status=%d, urb->transfer_flags=0x%04X\n", netdev->name, purb->status, purb->transfer_flags);
95 + IRDA_DEBUG(0, "%s: Tx timed out, urb->status=%d, urb->transfer_flags=0x%04X\n", netdev->name, purb->status, purb->transfer_flags);
97 /* Increase error count */
98 self->stats.tx_errors++;
99 @@ -694,7 +694,7 @@ static void irda_usb_submit(struct irda_
101 /* Check that we have an urb */
103 - IRDA_DEBUG(0, __FUNCTION__ "(), Bug : purb == NULL\n");
104 + WARNING(__FUNCTION__ "(), Bug : purb == NULL\n");
108 @@ -704,7 +704,7 @@ static void irda_usb_submit(struct irda_
110 /* If this ever happen, we are in deep s***.
111 * Basically, the Rx path will stop... */
112 - IRDA_DEBUG(0, __FUNCTION__ "(), Failed to allocate Rx skb\n");
113 + WARNING(__FUNCTION__ "(), Failed to allocate Rx skb\n");
117 @@ -734,7 +734,7 @@ static void irda_usb_submit(struct irda_
119 /* If this ever happen, we are in deep s***.
120 * Basically, the Rx path will stop... */
121 - IRDA_DEBUG(0, __FUNCTION__ "(), Failed to submit Rx URB %d\n", ret);
122 + WARNING(__FUNCTION__ "(), Failed to submit Rx URB %d\n", ret);
126 @@ -775,13 +775,13 @@ static void irda_usb_receive(purb_t purb
127 self->stats.rx_crc_errors++;
129 case -ECONNRESET: /* -104 */
130 - WARNING(__FUNCTION__ "(), Connection Reset (-104), transfer_flags 0x%04X \n", purb->transfer_flags);
131 + IRDA_DEBUG(0, __FUNCTION__ "(), Connection Reset (-104), transfer_flags 0x%04X \n", purb->transfer_flags);
132 /* uhci_cleanup_unlink() is going to kill the Rx
133 * URB just after we return. No problem, at this
134 * point the URB will be idle ;-) - Jean II */
137 - WARNING(__FUNCTION__ "(), RX status %d,transfer_flags 0x%04X \n", purb->status, purb->transfer_flags);
138 + IRDA_DEBUG(0, __FUNCTION__ "(), RX status %d,transfer_flags 0x%04X \n", purb->status, purb->transfer_flags);
142 @@ -893,7 +893,7 @@ static int irda_usb_is_receiving(struct
144 static int irda_usb_net_init(struct net_device *dev)
146 - IRDA_DEBUG(0, __FUNCTION__ "()\n");
147 + IRDA_DEBUG(1, __FUNCTION__ "()\n");
149 /* Set up to be a normal IrDA network device driver */
150 irda_device_setup(dev);
151 @@ -917,7 +917,7 @@ static int irda_usb_net_open(struct net_
155 - IRDA_DEBUG(0, __FUNCTION__ "()\n");
156 + IRDA_DEBUG(1, __FUNCTION__ "()\n");
158 ASSERT(netdev != NULL, return -1;);
159 self = (struct irda_usb_cb *) netdev->priv;
160 @@ -977,7 +977,7 @@ static int irda_usb_net_close(struct net
161 struct irda_usb_cb *self;
164 - IRDA_DEBUG(0, __FUNCTION__ "()\n");
165 + IRDA_DEBUG(1, __FUNCTION__ "()\n");
167 ASSERT(netdev != NULL, return -1;);
168 self = (struct irda_usb_cb *) netdev->priv;
169 @@ -1142,7 +1142,7 @@ static inline int irda_usb_open(struct i
170 struct net_device *netdev;
173 - IRDA_DEBUG(0, __FUNCTION__ "()\n");
174 + IRDA_DEBUG(1, __FUNCTION__ "()\n");
176 spin_lock_init(&self->lock);
178 @@ -1197,7 +1197,7 @@ static inline int irda_usb_open(struct i
180 static inline int irda_usb_close(struct irda_usb_cb *self)
182 - IRDA_DEBUG(0, __FUNCTION__ "()\n");
183 + IRDA_DEBUG(1, __FUNCTION__ "()\n");
185 ASSERT(self != NULL, return -1;);
187 @@ -1326,39 +1326,43 @@ static inline void irda_usb_dump_class_d
189 static inline struct irda_class_desc *irda_usb_find_class_desc(struct usb_device *dev, unsigned int ifnum)
191 - struct usb_interface_descriptor *interface;
192 - struct irda_class_desc *desc, *ptr;
193 + struct irda_class_desc *desc;
196 - desc = kmalloc(sizeof (struct irda_class_desc), GFP_KERNEL);
198 + desc = kmalloc(sizeof (*desc), GFP_KERNEL);
201 - memset(desc, 0, sizeof(struct irda_class_desc));
203 - ret = usb_get_class_descriptor(dev, ifnum, USB_DT_IRDA, 0, (void *) desc, sizeof(struct irda_class_desc));
204 - IRDA_DEBUG(0, __FUNCTION__ "(), ret=%d\n", ret);
206 - WARNING("usb-irda: usb_get_class_descriptor failed (0x%x)\n", ret);
208 + memset(desc, 0, sizeof(*desc));
210 - /* Check if we found it? */
211 - if (desc->bDescriptorType == USB_DT_IRDA)
213 + /* USB-IrDA class spec 1.0:
214 + * 6.1.3: Standard "Get Descriptor" Device Request is not
215 + * appropriate to retrieve class-specific descriptor
216 + * 6.2.5: Class Specific "Get Class Descriptor" Interface Request
217 + * is mandatory and returns the USB-IrDA class descriptor
220 - IRDA_DEBUG(0, __FUNCTION__ "(), parsing extra descriptors ...\n");
221 + ret = usb_control_msg(dev, usb_rcvctrlpipe(dev,0),
222 + IU_REQ_GET_CLASS_DESC,
223 + USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
224 + 0, ifnum, desc, sizeof(*desc), MSECS_TO_JIFFIES(500));
226 - /* Check if the class descriptor is interleaved with standard descriptors */
227 - interface = &dev->actconfig->interface[ifnum].altsetting[0];
228 - ret = usb_get_extra_descriptor(interface, USB_DT_IRDA, &ptr);
232 + IRDA_DEBUG(1, __FUNCTION__ "(), ret=%d\n", ret);
233 + if (ret < sizeof(*desc)) {
234 + WARNING("usb-irda: class_descriptor read %s (%d)\n",
235 + (ret<0) ? "failed" : "too short", ret);
237 + else if (desc->bDescriptorType != USB_DT_IRDA) {
238 + WARNING("usb-irda: bad class_descriptor type\n");
242 #ifdef IU_DUMP_CLASS_DESC
243 - irda_usb_dump_class_desc(desc);
244 + irda_usb_dump_class_desc(desc);
245 #endif /* IU_DUMP_CLASS_DESC */
254 /*********************** USB DEVICE CALLBACKS ***********************/
255 @@ -1389,9 +1393,9 @@ static void *irda_usb_probe(struct usb_d
256 * don't need to check if the dongle is really ours.
259 - IRDA_DEBUG(0, "Vendor: %x, Product: %x\n", dev->descriptor.idVendor, dev->descriptor.idProduct);
261 - MESSAGE("IRDA-USB found at address %d\n", dev->devnum);
262 + MESSAGE("IRDA-USB found at address %d, Vendor: %x, Product: %x\n",
263 + dev->devnum, dev->descriptor.idVendor,
264 + dev->descriptor.idProduct);
266 /* Try to cleanup all instance that have a pending disconnect
267 * Instance will be in this state is the disconnect() occurs
268 @@ -1416,7 +1420,7 @@ static void *irda_usb_probe(struct usb_d
272 - IRDA_DEBUG(0, "Too many USB IrDA devices !!! (max = %d)\n",
273 + WARNING("Too many USB IrDA devices !!! (max = %d)\n",
277 @@ -1436,7 +1440,7 @@ static void *irda_usb_probe(struct usb_d
278 * specify an alternate, but very few driver do like this.
280 ret = usb_set_interface(dev, ifnum, 0);
281 - IRDA_DEBUG(0, "usb-irda: set interface %d result %d\n", ifnum, ret);
282 + IRDA_DEBUG(1, "usb-irda: set interface %d result %d\n", ifnum, ret);
284 case USB_ST_NOERROR: /* 0 */
286 @@ -1485,7 +1489,7 @@ static void irda_usb_disconnect(struct u
287 struct irda_usb_cb *self = (struct irda_usb_cb *) ptr;
290 - IRDA_DEBUG(0, __FUNCTION__ "()\n");
291 + IRDA_DEBUG(1, __FUNCTION__ "()\n");
293 /* Oups ! We are not there any more */