]>
Commit | Line | Data |
---|---|---|
f9435081 | 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 { | |
5 | __u8 bMaxUnicastList; | |
6 | } __attribute__ ((packed)); | |
7 | ||
8 | +/* class specific interface request to get the IrDA-USB class descriptor | |
9 | + * (6.2.5, USB-IrDA class spec 1.0) */ | |
10 | + | |
11 | +#define IU_REQ_GET_CLASS_DESC 0x06 | |
12 | + | |
13 | struct irda_usb_cb { | |
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); | |
21 | ||
22 | if ((ret = usb_submit_urb(purb))) { | |
23 | - IRDA_DEBUG(0, __FUNCTION__ "(), failed Speed URB\n"); | |
24 | + WARNING(__FUNCTION__ "(), failed Speed URB\n"); | |
25 | } | |
26 | spin_unlock_irqrestore(&self->lock, flags); | |
27 | } | |
28 | @@ -296,14 +296,14 @@ static void speed_bulk_callback(purb_t p | |
29 | ||
30 | /* We should always have a context */ | |
31 | if (self == NULL) { | |
32 | - IRDA_DEBUG(0, __FUNCTION__ "(), Bug : self == NULL\n"); | |
33 | + WARNING(__FUNCTION__ "(), Bug : self == NULL\n"); | |
34 | return; | |
35 | } | |
36 | ||
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); | |
42 | ||
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_ | |
46 | ||
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 | |
55 | ||
56 | /* We should always have a context */ | |
57 | if (self == NULL) { | |
58 | - IRDA_DEBUG(0, __FUNCTION__ "(), Bug : self == NULL\n"); | |
59 | + WARNING(__FUNCTION__ "(), Bug : self == NULL\n"); | |
60 | return; | |
61 | } | |
62 | ||
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); | |
69 | ||
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 | |
73 | ||
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); | |
79 | } else { | |
80 | /* Otherwise, allow the stack to send more packets */ | |
81 | @@ -548,7 +548,7 @@ static void irda_usb_net_timeout(struct | |
82 | /* Check speed URB */ | |
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); | |
87 | ||
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; | |
93 | ||
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); | |
96 | ||
97 | /* Increase error count */ | |
98 | self->stats.tx_errors++; | |
99 | @@ -694,7 +694,7 @@ static void irda_usb_submit(struct irda_ | |
100 | ||
101 | /* Check that we have an urb */ | |
102 | if (!purb) { | |
103 | - IRDA_DEBUG(0, __FUNCTION__ "(), Bug : purb == NULL\n"); | |
104 | + WARNING(__FUNCTION__ "(), Bug : purb == NULL\n"); | |
105 | return; | |
106 | } | |
107 | ||
108 | @@ -704,7 +704,7 @@ static void irda_usb_submit(struct irda_ | |
109 | if (!skb) { | |
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"); | |
114 | return; | |
115 | } | |
116 | } else { | |
117 | @@ -734,7 +734,7 @@ static void irda_usb_submit(struct irda_ | |
118 | if (ret) { | |
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); | |
123 | } | |
124 | } | |
125 | ||
126 | @@ -775,13 +775,13 @@ static void irda_usb_receive(purb_t purb | |
127 | self->stats.rx_crc_errors++; | |
128 | break; | |
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 */ | |
135 | break; | |
136 | default: | |
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); | |
139 | break; | |
140 | } | |
141 | goto done; | |
142 | @@ -893,7 +893,7 @@ static int irda_usb_is_receiving(struct | |
143 | */ | |
144 | static int irda_usb_net_init(struct net_device *dev) | |
145 | { | |
146 | - IRDA_DEBUG(0, __FUNCTION__ "()\n"); | |
147 | + IRDA_DEBUG(1, __FUNCTION__ "()\n"); | |
148 | ||
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_ | |
152 | char hwname[16]; | |
153 | int i; | |
154 | ||
155 | - IRDA_DEBUG(0, __FUNCTION__ "()\n"); | |
156 | + IRDA_DEBUG(1, __FUNCTION__ "()\n"); | |
157 | ||
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; | |
162 | int i; | |
163 | ||
164 | - IRDA_DEBUG(0, __FUNCTION__ "()\n"); | |
165 | + IRDA_DEBUG(1, __FUNCTION__ "()\n"); | |
166 | ||
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; | |
171 | int err; | |
172 | ||
173 | - IRDA_DEBUG(0, __FUNCTION__ "()\n"); | |
174 | + IRDA_DEBUG(1, __FUNCTION__ "()\n"); | |
175 | ||
176 | spin_lock_init(&self->lock); | |
177 | ||
178 | @@ -1197,7 +1197,7 @@ static inline int irda_usb_open(struct i | |
179 | */ | |
180 | static inline int irda_usb_close(struct irda_usb_cb *self) | |
181 | { | |
182 | - IRDA_DEBUG(0, __FUNCTION__ "()\n"); | |
183 | + IRDA_DEBUG(1, __FUNCTION__ "()\n"); | |
184 | ||
185 | ASSERT(self != NULL, return -1;); | |
186 | ||
187 | @@ -1326,39 +1326,43 @@ static inline void irda_usb_dump_class_d | |
188 | */ | |
189 | static inline struct irda_class_desc *irda_usb_find_class_desc(struct usb_device *dev, unsigned int ifnum) | |
190 | { | |
191 | - struct usb_interface_descriptor *interface; | |
192 | - struct irda_class_desc *desc, *ptr; | |
193 | + struct irda_class_desc *desc; | |
194 | int ret; | |
195 | - | |
196 | - desc = kmalloc(sizeof (struct irda_class_desc), GFP_KERNEL); | |
197 | + | |
198 | + desc = kmalloc(sizeof (*desc), GFP_KERNEL); | |
199 | if (desc == NULL) | |
200 | return NULL; | |
201 | - memset(desc, 0, sizeof(struct irda_class_desc)); | |
202 | - | |
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); | |
205 | - if (ret) { | |
206 | - WARNING("usb-irda: usb_get_class_descriptor failed (0x%x)\n", ret); | |
207 | - } | |
208 | + memset(desc, 0, sizeof(*desc)); | |
209 | ||
210 | - /* Check if we found it? */ | |
211 | - if (desc->bDescriptorType == USB_DT_IRDA) | |
212 | - return desc; | |
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 | |
218 | + */ | |
219 | ||
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)); | |
225 | ||
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); | |
229 | - if (ret) { | |
230 | - kfree(desc); | |
231 | - return NULL; | |
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); | |
236 | + } | |
237 | + else if (desc->bDescriptorType != USB_DT_IRDA) { | |
238 | + WARNING("usb-irda: bad class_descriptor type\n"); | |
239 | } | |
240 | - *desc = *ptr; | |
241 | + else { | |
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 */ | |
246 | - return desc; | |
247 | + | |
248 | + return desc; | |
249 | + } | |
250 | + kfree(desc); | |
251 | + return NULL; | |
252 | } | |
253 | ||
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. | |
257 | * Jean II */ | |
258 | ||
259 | - IRDA_DEBUG(0, "Vendor: %x, Product: %x\n", dev->descriptor.idVendor, dev->descriptor.idProduct); | |
260 | - | |
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); | |
265 | ||
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 | |
269 | } | |
270 | } | |
271 | if(self == NULL) { | |
272 | - IRDA_DEBUG(0, "Too many USB IrDA devices !!! (max = %d)\n", | |
273 | + WARNING("Too many USB IrDA devices !!! (max = %d)\n", | |
274 | NIRUSB); | |
275 | return NULL; | |
276 | } | |
277 | @@ -1436,7 +1440,7 @@ static void *irda_usb_probe(struct usb_d | |
278 | * specify an alternate, but very few driver do like this. | |
279 | * Jean II */ | |
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); | |
283 | switch (ret) { | |
284 | case USB_ST_NOERROR: /* 0 */ | |
285 | break; | |
286 | @@ -1485,7 +1489,7 @@ static void irda_usb_disconnect(struct u | |
287 | struct irda_usb_cb *self = (struct irda_usb_cb *) ptr; | |
288 | int i; | |
289 | ||
290 | - IRDA_DEBUG(0, __FUNCTION__ "()\n"); | |
291 | + IRDA_DEBUG(1, __FUNCTION__ "()\n"); | |
292 | ||
293 | /* Oups ! We are not there any more */ | |
294 | self->present = 0; | |
295 |