File: hurd_usb.c

package info (click to toggle)
libusb-1.0 2:1.0.21-1
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 4,328 kB
  • ctags: 3,888
  • sloc: ansic: 22,875; sh: 11,332; cpp: 1,194; makefile: 169
file content (214 lines) | stat: -rw-r--r-- 5,299 bytes parent folder | download
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
/*
 * Copyright © 2016 Petter Reinholdtsen <pere@hungry.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

/*
 * Stup libusb implementation for GNU Hurd returning empty list of
 * devices.  This allow programs to build on Hurd without USB support
 * without having to update a lot of build dependencies.
 */

#include "libusbi.h"

static int
hurd_init(struct libusb_context *ctx)
{
	usbi_dbg(__FUNCTION__);
	return (LIBUSB_ERROR_NOT_SUPPORTED);
}

static int
hurd_get_device_list(struct libusb_context * ctx,
	struct discovered_devs **discdevs)
{
	usbi_dbg(__FUNCTION__);
	return (LIBUSB_ERROR_NOT_SUPPORTED);
}

static int
hurd_open(struct libusb_device_handle *handle)
{
	usbi_dbg(__FUNCTION__);
	return (LIBUSB_ERROR_NOT_SUPPORTED);
}

static void
hurd_close(struct libusb_device_handle *handle)
{
	usbi_dbg(__FUNCTION__);
}

static int
hurd_get_device_descriptor(struct libusb_device *dev, unsigned char *buf,
    int *host_endian)
{
	usbi_dbg(__FUNCTION__);
	return (LIBUSB_ERROR_NOT_SUPPORTED);
}

int
hurd_get_active_config_descriptor(struct libusb_device *dev,
    unsigned char *buf, size_t len, int *host_endian)
{
	usbi_dbg(__FUNCTION__);
	return (LIBUSB_ERROR_NOT_SUPPORTED);
}

int
hurd_get_config_descriptor(struct libusb_device *dev, uint8_t idx,
    unsigned char *buf, size_t len, int *host_endian)
{
	usbi_dbg(__FUNCTION__);
	return (LIBUSB_ERROR_NOT_SUPPORTED);
}

static int
hurd_get_configuration(struct libusb_device_handle *handle, int *config)
{
	usbi_dbg(__FUNCTION__);
	return (LIBUSB_ERROR_NOT_SUPPORTED);
}

static int
hurd_set_configuration(struct libusb_device_handle *handle, int config)
{
	usbi_dbg(__FUNCTION__);
	return (LIBUSB_ERROR_NOT_SUPPORTED);
}

static int
hurd_claim_interface(struct libusb_device_handle *handle, int iface)
{
	usbi_dbg(__FUNCTION__);
	return (LIBUSB_ERROR_NOT_SUPPORTED);
}

static int
hurd_release_interface(struct libusb_device_handle *handle, int iface)
{
	usbi_dbg(__FUNCTION__);
	return (LIBUSB_ERROR_NOT_SUPPORTED);
}

static int
hurd_set_interface_altsetting(struct libusb_device_handle *handle, int iface,
    int altsetting)
{
	usbi_dbg(__FUNCTION__);
	return (LIBUSB_ERROR_NOT_SUPPORTED);
}

static int
hurd_clear_halt(struct libusb_device_handle *handle, unsigned char endpoint)
{
	usbi_dbg(__FUNCTION__);
	return (LIBUSB_ERROR_NOT_SUPPORTED);
}

static int
hurd_reset_device(struct libusb_device_handle *handle)
{
	usbi_dbg(__FUNCTION__);
	return (LIBUSB_ERROR_NOT_SUPPORTED);
}

static int
hurd_alloc_streams(struct libusb_device_handle *handle,
		   uint32_t num_streams, unsigned char *endpoints, int num_endpoints)
{
	usbi_dbg(__FUNCTION__);
	return (LIBUSB_ERROR_NOT_SUPPORTED);
}

static int
hurd_free_streams(struct libusb_device_handle *handle,
		  unsigned char *endpoints, int num_endpoints)
{
	usbi_dbg(__FUNCTION__);
	return (LIBUSB_ERROR_NOT_SUPPORTED);
}

static void
hurd_destroy_device(struct libusb_device *dev)
{
	usbi_dbg(__FUNCTION__);
}

static int
hurd_submit_transfer(struct usbi_transfer *itransfer)
{
	usbi_dbg(__FUNCTION__);
	return (LIBUSB_ERROR_NOT_SUPPORTED);
}

int
hurd_cancel_transfer(struct usbi_transfer *itransfer)
{
	usbi_dbg(__FUNCTION__);
	return (LIBUSB_ERROR_NOT_SUPPORTED);
}

void
hurd_clear_transfer_priv(struct usbi_transfer *itransfer)
{
	usbi_dbg(__FUNCTION__);
}

int
hurd_handle_transfer_completion(struct usbi_transfer *itransfer)
{
	usbi_dbg(__FUNCTION__);
	return (LIBUSB_ERROR_NOT_SUPPORTED);
}

int
hurd_clock_gettime(int clkid, struct timespec *tp)
{
	usbi_dbg("clock %d", clkid);

	if (clkid == USBI_CLOCK_REALTIME)
		return clock_gettime(CLOCK_REALTIME, tp);

	if (clkid == USBI_CLOCK_MONOTONIC)
		return clock_gettime(CLOCK_MONOTONIC, tp);

	return (LIBUSB_ERROR_INVALID_PARAM);
}

const struct usbi_os_backend hurd_backend = {
	.name = "Synchronous Hurd backend",
	.caps = 0,
	.init = hurd_init,
	.get_device_list = hurd_get_device_list,
	.open = hurd_open,
	.close = hurd_close,
	.get_device_descriptor = hurd_get_device_descriptor,
	.get_active_config_descriptor = hurd_get_active_config_descriptor,
	.get_config_descriptor = hurd_get_config_descriptor,
	.set_configuration = hurd_set_configuration,
	.claim_interface = hurd_claim_interface,
	.release_interface = hurd_release_interface,
	.set_interface_altsetting = hurd_set_interface_altsetting,
	.clear_halt = hurd_clear_halt,
	.reset_device = hurd_reset_device,
	.alloc_streams = hurd_alloc_streams,
	.free_streams = hurd_free_streams,
	.submit_transfer = hurd_submit_transfer,
	.cancel_transfer = hurd_cancel_transfer,
	.clear_transfer_priv = hurd_clear_transfer_priv,
	.clock_gettime = hurd_clock_gettime,
};