1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
$NetBSD: patch-ad,v 1.2 2002/03/03 15:22:28 veego Exp $
--- bsd.c.orig Thu Feb 7 07:43:25 2002
+++ bsd.c Sun Mar 3 14:59:58 2002
@@ -37,6 +37,16 @@
#include <dev/usb/usb.h>
+#ifndef USB_STACK_VERSION
+#define uai_interface_index interface_index
+#define uai_alt_no alt_no
+#define ucr_request request
+#define ucr_data data
+#define ucr_flags flags
+#define udi_addr addr
+#define udi_devnames devnames
+#endif
+
#include "usbi.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -151,8 +161,8 @@
if (dev->interface < 0)
USB_ERROR(-EINVAL);
- intf.interface_index = dev->interface;
- intf.alt_no = alternate;
+ intf.uai_interface_index = dev->interface;
+ intf.uai_alt_no = alternate;
ret = ioctl(dev->fd, USB_SET_ALTINTERFACE, &intf);
if (ret < 0)
@@ -182,6 +192,11 @@
#else
snprintf(buf, sizeof(buf) - 1, "%s.%02d", dev->device->filename, ep);
#endif
+ /* Try to open it O_RDWR first for those devices which have in and out
+ * endpoints with the same address (eg 0x02 and 0x82)
+ */
+ fd = open(buf, O_RDWR);
+ if (fd < 0 && errno == ENXIO)
fd = open(buf, mode);
if (fd < 0)
USB_ERROR_STR(fd, "can't open %s for bulk read: %s\n",
@@ -284,14 +299,14 @@
fprintf(stderr, "usb_control_msg: %d %d %d %d %p %d %d\n",
requesttype, request, value, index, bytes, size, timeout);
- req.request.bmRequestType = requesttype;
- req.request.bRequest = request;
- USETW(req.request.wValue, value);
- USETW(req.request.wIndex, index);
- USETW(req.request.wLength, size);
+ req.ucr_request.bmRequestType = requesttype;
+ req.ucr_request.bRequest = request;
+ USETW(req.ucr_request.wValue, value);
+ USETW(req.ucr_request.wIndex, index);
+ USETW(req.ucr_request.wLength, size);
- req.data = bytes;
- req.flags = 0;
+ req.ucr_data = bytes;
+ req.ucr_flags = 0;
ret = ioctl(dev->fd, USB_SET_TIMEOUT, &timeout);
if (ret < 0)
@@ -303,7 +318,7 @@
USB_ERROR_STR(ret, "error sending control message: %s",
strerror(errno));
- return UGETW(req.request.wLength);
+ return UGETW(req.ucr_request.wLength);
}
int usb_find_devices_on_bus(struct usb_bus *bus)
@@ -321,20 +336,20 @@
struct usb_device *dev;
char buf[20];
- di.addr = device;
+ di.udi_addr = device;
if (ioctl(cfd, USB_DEVICEINFO, &di) < 0)
continue;
/* There's a device; is it one we should mess with? */
- if (strncmp(di.devnames[0], "ugen", 4) != 0)
+ if (strncmp(di.udi_devnames[0], "ugen", 4) != 0)
/* best not to play with things we don't understand */
continue;
#if __FreeBSD__
- snprintf(buf, sizeof(buf) - 1, "/dev/%s", di.devnames[0]);
+ snprintf(buf, sizeof(buf) - 1, "/dev/%s", di.udi_devnames[0]);
#else
- snprintf(buf, sizeof(buf) - 1, "/dev/%s.00", di.devnames[0]);
+ snprintf(buf, sizeof(buf) - 1, "/dev/%s.00", di.udi_devnames[0]);
#endif
/* Don't re-add it if we were called multiple times */
@@ -364,7 +379,7 @@
* This seemed easier than having 2 variables...
*/
#if __NetBSD__
- snprintf(buf, sizeof(buf) - 1, "/dev/%s", di.devnames[0]);
+ snprintf(buf, sizeof(buf) - 1, "/dev/%s", di.udi_devnames[0]);
#endif
strncpy(dev->filename, buf, sizeof(dev->filename) - 1);
|