summaryrefslogtreecommitdiffstats
path: root/meta/packages/libusb/libusb-0.1.10a/debian-changes.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/packages/libusb/libusb-0.1.10a/debian-changes.patch')
-rw-r--r--meta/packages/libusb/libusb-0.1.10a/debian-changes.patch407
1 files changed, 407 insertions, 0 deletions
diff --git a/meta/packages/libusb/libusb-0.1.10a/debian-changes.patch b/meta/packages/libusb/libusb-0.1.10a/debian-changes.patch
new file mode 100644
index 0000000000..6f79bc7950
--- /dev/null
+++ b/meta/packages/libusb/libusb-0.1.10a/debian-changes.patch
@@ -0,0 +1,407 @@
1diff -urN libusb_0.1.10a.orig/bsd.c libusb-0.1.10a/bsd.c
2--- libusb_0.1.10a.orig/bsd.c 2004-02-18 08:34:52.000000000 +0100
3+++ libusb-0.1.10a/bsd.c 2005-06-30 19:40:00.000000000 +0200
4@@ -25,6 +25,10 @@
5 * for both read and write.
6 */
7
8+#if defined(__FreeBSD__) && !defined(__FreeBSD_kernel__)
9+#define __FreeBSD_kernel__ __FreeBSD__
10+#endif
11+
12 #include <stdlib.h>
13 #include <unistd.h>
14 #include <string.h>
15@@ -142,7 +146,7 @@
16 USB_ERROR(-ENOMEM);
17 dev->impl_info = info;
18
19-#if __FreeBSD__
20+#ifdef __FreeBSD_kernel__
21 snprintf(ctlpath, PATH_MAX, "%s", dev->device->filename);
22 #else
23 snprintf(ctlpath, PATH_MAX, "%s.00", dev->device->filename);
24@@ -255,7 +259,7 @@
25 ep = UE_GET_ADDR(ep);
26
27 if (info->ep_fd[ep] < 0) {
28-#if __FreeBSD__
29+#ifdef __FreeBSD_kernel__
30 snprintf(buf, sizeof(buf) - 1, "%s.%d", dev->device->filename, ep);
31 #else
32 snprintf(buf, sizeof(buf) - 1, "%s.%02d", dev->device->filename, ep);
33@@ -286,7 +290,7 @@
34 fd = ensure_ep_open(dev, ep, O_WRONLY);
35 if (fd < 0) {
36 if (usb_debug >= 2) {
37-#if __FreeBSD__
38+#ifdef __FreeBSD_kernel__
39 fprintf (stderr, "usb_bulk_write: got negative open file descriptor for endpoint %d\n", UE_GET_ADDR(ep));
40 #else
41 fprintf (stderr, "usb_bulk_write: got negative open file descriptor for endpoint %02d\n", UE_GET_ADDR(ep));
42@@ -302,7 +306,7 @@
43
44 ret = write(fd, bytes, size);
45 if (ret < 0)
46-#if __FreeBSD__
47+#ifdef __FreeBSD_kernel__
48 USB_ERROR_STR(-errno, "error writing to bulk endpoint %s.%d: %s",
49 dev->device->filename, UE_GET_ADDR(ep), strerror(errno));
50 #else
51@@ -324,7 +328,7 @@
52 fd = ensure_ep_open(dev, ep, O_RDONLY);
53 if (fd < 0) {
54 if (usb_debug >= 2) {
55-#if __FreeBSD__
56+#ifdef __FreeBSD_kernel__
57 fprintf (stderr, "usb_bulk_read: got negative open file descriptor for endpoint %d\n", UE_GET_ADDR(ep));
58 #else
59 fprintf (stderr, "usb_bulk_read: got negative open file descriptor for endpoint %02d\n", UE_GET_ADDR(ep));
60@@ -343,7 +347,7 @@
61
62 ret = read(fd, bytes, size);
63 if (ret < 0)
64-#if __FreeBSD__
65+#ifdef __FreeBSD_kernel__
66 USB_ERROR_STR(-errno, "error reading from bulk endpoint %s.%d: %s",
67 dev->device->filename, UE_GET_ADDR(ep), strerror(errno));
68 #else
69@@ -365,7 +369,7 @@
70 fd = ensure_ep_open(dev, ep, O_WRONLY);
71 if (fd < 0) {
72 if (usb_debug >= 2) {
73-#if __FreeBSD__
74+#ifdef __FreeBSD_kernel__
75 fprintf (stderr, "usb_interrupt_write: got negative open file descriptor for endpoint %d\n", UE_GET_ADDR(ep));
76 #else
77 fprintf (stderr, "usb_interrupt_write: got negative open file descriptor for endpoint %02d\n", UE_GET_ADDR(ep));
78@@ -382,7 +386,7 @@
79 do {
80 ret = write(fd, bytes+sent, size-sent);
81 if (ret < 0)
82-#if __FreeBSD__
83+#ifdef __FreeBSD_kernel__
84 USB_ERROR_STR(-errno, "error writing to interrupt endpoint %s.%d: %s",
85 dev->device->filename, UE_GET_ADDR(ep), strerror(errno));
86 #else
87@@ -407,7 +411,7 @@
88 fd = ensure_ep_open(dev, ep, O_RDONLY);
89 if (fd < 0) {
90 if (usb_debug >= 2) {
91-#if __FreeBSD__
92+#ifdef __FreeBSD_kernel__
93 fprintf (stderr, "usb_interrupt_read: got negative open file descriptor for endpoint %d\n", UE_GET_ADDR(ep));
94 #else
95 fprintf (stderr, "usb_interrupt_read: got negative open file descriptor for endpoint %02d\n", UE_GET_ADDR(ep));
96@@ -427,7 +431,7 @@
97 do {
98 ret = read(fd, bytes+retrieved, size-retrieved);
99 if (ret < 0)
100-#if __FreeBSD__
101+#ifdef __FreeBSD_kernel__
102 USB_ERROR_STR(-errno, "error reading from interrupt endpoint %s.%d: %s",
103 dev->device->filename, UE_GET_ADDR(ep), strerror(errno));
104 #else
105@@ -543,7 +547,7 @@
106 /* best not to play with things we don't understand */
107 continue;
108
109-#if __FreeBSD__
110+#ifdef __FreeBSD_kernel__
111 snprintf(buf, sizeof(buf) - 1, "/dev/%s", di.udi_devnames[0]);
112 #else
113 snprintf(buf, sizeof(buf) - 1, "/dev/%s.00", di.udi_devnames[0]);
114diff -urN libusb_0.1.10a.orig/linux.c libusb-0.1.10a/linux.c
115--- libusb_0.1.10a.orig/linux.c 2005-02-11 03:16:10.000000000 +0100
116+++ libusb-0.1.10a/linux.c 2005-06-30 19:40:00.000000000 +0200
117@@ -156,6 +156,8 @@
118 return ret;
119 }
120
121+#define URB_USERCONTEXT_COOKIE ((void *)0x1)
122+
123 /* Reading and writing are the same except for the endpoint */
124 static int usb_urb_transfer(usb_dev_handle *dev, int ep, int urbtype,
125 char *bytes, int size, int timeout)
126@@ -163,14 +165,16 @@
127 struct usb_urb urb;
128 unsigned int bytesdone = 0, requested;
129 struct timeval tv, tv_ref, tv_now;
130- void *context;
131+ struct usb_urb *context;
132 int ret, waiting;
133
134 /*
135- * FIXME: The use of the URB interface is incorrect here if there are
136- * multiple callers at the same time. We assume we're the only caller
137- * and if we get completions from another caller, this code will fail
138- * in interesting ways.
139+ * HACK: The use of urb.usercontext is a hack to get threaded applications
140+ * sort of working again. Threaded support is still not recommended, but
141+ * this should allow applications to work in the common cases. Basically,
142+ * if we get the completion for an URB we're not waiting for, then we update
143+ * the usercontext pointer to 1 for the other threads URB and it will see
144+ * the change after it wakes up from the the timeout. Ugly, but it works.
145 */
146
147 /*
148@@ -198,10 +202,10 @@
149 urb.flags = 0;
150 urb.buffer = bytes + bytesdone;
151 urb.buffer_length = requested;
152- urb.usercontext = (void *)ep;
153 urb.signr = 0;
154 urb.actual_length = 0;
155 urb.number_of_packets = 0; /* don't do isochronous yet */
156+ urb.usercontext = NULL;
157
158 ret = ioctl(dev->fd, IOCTL_USB_SUBMITURB, &urb);
159 if (ret < 0) {
160@@ -212,18 +216,28 @@
161 FD_ZERO(&writefds);
162 FD_SET(dev->fd, &writefds);
163
164+restart:
165 waiting = 1;
166- while (((ret = ioctl(dev->fd, IOCTL_USB_REAPURBNDELAY, &context)) == -1) && waiting) {
167+ context = NULL;
168+ while (!urb.usercontext && ((ret = ioctl(dev->fd, IOCTL_USB_REAPURBNDELAY, &context)) == -1) && waiting) {
169 tv.tv_sec = 0;
170 tv.tv_usec = 1000; // 1 msec
171 select(dev->fd + 1, NULL, &writefds, NULL, &tv); //sub second wait
172
173- /* compare with actual time, as the select timeout is not that precise */
174- gettimeofday(&tv_now, NULL);
175+ if (timeout) {
176+ /* compare with actual time, as the select timeout is not that precise */
177+ gettimeofday(&tv_now, NULL);
178+
179+ if ((tv_now.tv_sec > tv_ref.tv_sec) ||
180+ ((tv_now.tv_sec == tv_ref.tv_sec) && (tv_now.tv_usec >= tv_ref.tv_usec)))
181+ waiting = 0;
182+ }
183+ }
184
185- if ((tv_now.tv_sec > tv_ref.tv_sec) ||
186- ((tv_now.tv_sec == tv_ref.tv_sec) && (tv_now.tv_usec >= tv_ref.tv_usec)))
187- waiting = 0;
188+ if (context && context != &urb) {
189+ context->usercontext = URB_USERCONTEXT_COOKIE;
190+ /* We need to restart since we got a successful URB, but not ours */
191+ goto restart;
192 }
193
194 /*
195@@ -231,14 +245,14 @@
196 * something happened during the reaping and we should return that
197 * error now
198 */
199- if (ret < 0 && errno != EAGAIN)
200+ if (ret < 0 && !urb.usercontext && errno != EAGAIN)
201 USB_ERROR_STR(-errno, "error reaping URB: %s", strerror(errno));
202
203 bytesdone += urb.actual_length;
204- } while (ret == 0 && bytesdone < size && urb.actual_length == requested);
205+ } while ((ret == 0 || urb.usercontext) && bytesdone < size && urb.actual_length == requested);
206
207 /* If the URB didn't complete in success or error, then let's unlink it */
208- if (ret < 0) {
209+ if (ret < 0 && !urb.usercontext) {
210 int rc;
211
212 if (!waiting)
213diff -urN libusb_0.1.10a.orig/usb.h.in libusb-0.1.10a/usb.h.in
214--- libusb_0.1.10a.orig/usb.h.in 2004-08-03 20:20:38.000000000 +0200
215+++ libusb-0.1.10a/usb.h.in 2005-06-30 19:40:00.000000000 +0200
216@@ -13,8 +13,9 @@
217
218 #include <unistd.h>
219 #include <stdlib.h>
220+#include <stdint.h>
221 #include <limits.h>
222-
223+#include <sys/param.h>
224 #include <dirent.h>
225
226 /*
227@@ -63,40 +64,40 @@
228
229 /* All standard descriptors have these 2 fields in common */
230 struct usb_descriptor_header {
231- u_int8_t bLength;
232- u_int8_t bDescriptorType;
233-};
234+ uint8_t bLength;
235+ uint8_t bDescriptorType;
236+} __attribute__ ((packed));
237
238 /* String descriptor */
239 struct usb_string_descriptor {
240- u_int8_t bLength;
241- u_int8_t bDescriptorType;
242- u_int16_t wData[1];
243-};
244+ uint8_t bLength;
245+ uint8_t bDescriptorType;
246+ uint16_t wData[1];
247+} __attribute__ ((packed));
248
249 /* HID descriptor */
250 struct usb_hid_descriptor {
251- u_int8_t bLength;
252- u_int8_t bDescriptorType;
253- u_int16_t bcdHID;
254- u_int8_t bCountryCode;
255- u_int8_t bNumDescriptors;
256- /* u_int8_t bReportDescriptorType; */
257- /* u_int16_t wDescriptorLength; */
258+ uint8_t bLength;
259+ uint8_t bDescriptorType;
260+ uint16_t bcdHID;
261+ uint8_t bCountryCode;
262+ uint8_t bNumDescriptors;
263+ /* uint8_t bReportDescriptorType; */
264+ /* uint16_t wDescriptorLength; */
265 /* ... */
266-};
267+} __attribute__ ((packed));
268
269 /* Endpoint descriptor */
270 #define USB_MAXENDPOINTS 32
271 struct usb_endpoint_descriptor {
272- u_int8_t bLength;
273- u_int8_t bDescriptorType;
274- u_int8_t bEndpointAddress;
275- u_int8_t bmAttributes;
276- u_int16_t wMaxPacketSize;
277- u_int8_t bInterval;
278- u_int8_t bRefresh;
279- u_int8_t bSynchAddress;
280+ uint8_t bLength __attribute__ ((packed));
281+ uint8_t bDescriptorType __attribute__ ((packed));
282+ uint8_t bEndpointAddress __attribute__ ((packed));
283+ uint8_t bmAttributes __attribute__ ((packed));
284+ uint16_t wMaxPacketSize __attribute__ ((packed));
285+ uint8_t bInterval __attribute__ ((packed));
286+ uint8_t bRefresh __attribute__ ((packed));
287+ uint8_t bSynchAddress __attribute__ ((packed));
288
289 unsigned char *extra; /* Extra descriptors */
290 int extralen;
291@@ -114,15 +115,15 @@
292 /* Interface descriptor */
293 #define USB_MAXINTERFACES 32
294 struct usb_interface_descriptor {
295- u_int8_t bLength;
296- u_int8_t bDescriptorType;
297- u_int8_t bInterfaceNumber;
298- u_int8_t bAlternateSetting;
299- u_int8_t bNumEndpoints;
300- u_int8_t bInterfaceClass;
301- u_int8_t bInterfaceSubClass;
302- u_int8_t bInterfaceProtocol;
303- u_int8_t iInterface;
304+ uint8_t bLength __attribute__ ((packed));;
305+ uint8_t bDescriptorType __attribute__ ((packed));;
306+ uint8_t bInterfaceNumber __attribute__ ((packed));;
307+ uint8_t bAlternateSetting __attribute__ ((packed));;
308+ uint8_t bNumEndpoints __attribute__ ((packed));;
309+ uint8_t bInterfaceClass __attribute__ ((packed));;
310+ uint8_t bInterfaceSubClass __attribute__ ((packed));;
311+ uint8_t bInterfaceProtocol __attribute__ ((packed));;
312+ uint8_t iInterface __attribute__ ((packed));;
313
314 struct usb_endpoint_descriptor *endpoint;
315
316@@ -140,14 +141,14 @@
317 /* Configuration descriptor information.. */
318 #define USB_MAXCONFIG 8
319 struct usb_config_descriptor {
320- u_int8_t bLength;
321- u_int8_t bDescriptorType;
322- u_int16_t wTotalLength;
323- u_int8_t bNumInterfaces;
324- u_int8_t bConfigurationValue;
325- u_int8_t iConfiguration;
326- u_int8_t bmAttributes;
327- u_int8_t MaxPower;
328+ uint8_t bLength __attribute__ ((packed));
329+ uint8_t bDescriptorType __attribute__ ((packed));
330+ uint16_t wTotalLength __attribute__ ((packed));
331+ uint8_t bNumInterfaces __attribute__ ((packed));
332+ uint8_t bConfigurationValue __attribute__ ((packed));
333+ uint8_t iConfiguration __attribute__ ((packed));
334+ uint8_t bmAttributes __attribute__ ((packed));
335+ uint8_t MaxPower __attribute__ ((packed));
336
337 struct usb_interface *interface;
338
339@@ -157,29 +158,29 @@
340
341 /* Device descriptor */
342 struct usb_device_descriptor {
343- u_int8_t bLength;
344- u_int8_t bDescriptorType;
345- u_int16_t bcdUSB;
346- u_int8_t bDeviceClass;
347- u_int8_t bDeviceSubClass;
348- u_int8_t bDeviceProtocol;
349- u_int8_t bMaxPacketSize0;
350- u_int16_t idVendor;
351- u_int16_t idProduct;
352- u_int16_t bcdDevice;
353- u_int8_t iManufacturer;
354- u_int8_t iProduct;
355- u_int8_t iSerialNumber;
356- u_int8_t bNumConfigurations;
357-};
358+ uint8_t bLength;
359+ uint8_t bDescriptorType;
360+ uint16_t bcdUSB;
361+ uint8_t bDeviceClass;
362+ uint8_t bDeviceSubClass;
363+ uint8_t bDeviceProtocol;
364+ uint8_t bMaxPacketSize0;
365+ uint16_t idVendor;
366+ uint16_t idProduct;
367+ uint16_t bcdDevice;
368+ uint8_t iManufacturer;
369+ uint8_t iProduct;
370+ uint8_t iSerialNumber;
371+ uint8_t bNumConfigurations;
372+} __attribute__ ((packed));
373
374 struct usb_ctrl_setup {
375- u_int8_t bRequestType;
376- u_int8_t bRequest;
377- u_int16_t wValue;
378- u_int16_t wIndex;
379- u_int16_t wLength;
380-};
381+ uint8_t bRequestType;
382+ uint8_t bRequest;
383+ uint16_t wValue;
384+ uint16_t wIndex;
385+ uint16_t wLength;
386+} __attribute__ ((packed));
387
388 /*
389 * Standard requests
390@@ -249,7 +250,7 @@
391
392 void *dev; /* Darwin support */
393
394- u_int8_t devnum;
395+ uint8_t devnum;
396
397 unsigned char num_children;
398 struct usb_device **children;
399@@ -261,7 +262,7 @@
400 char dirname[PATH_MAX + 1];
401
402 struct usb_device *devices;
403- u_int32_t location;
404+ uint32_t location;
405
406 struct usb_device *root_dev;
407 };