Bug Summary

File:dev/usb/uvisor.c
Warning:line 327, column 17
Assigned value is garbage or undefined

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple amd64-unknown-openbsd7.0 -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name uvisor.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -relaxed-aliasing -fno-rounding-math -mconstructor-aliases -ffreestanding -mcmodel=kernel -target-cpu x86-64 -target-feature +retpoline-indirect-calls -target-feature +retpoline-indirect-branches -target-feature -sse2 -target-feature -sse -target-feature -3dnow -target-feature -mmx -target-feature +save-args -disable-red-zone -no-implicit-float -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/usr/src/sys/arch/amd64/compile/GENERIC.MP/obj -nostdsysteminc -nobuiltininc -resource-dir /usr/local/lib/clang/13.0.0 -I /usr/src/sys -I /usr/src/sys/arch/amd64/compile/GENERIC.MP/obj -I /usr/src/sys/arch -I /usr/src/sys/dev/pci/drm/include -I /usr/src/sys/dev/pci/drm/include/uapi -I /usr/src/sys/dev/pci/drm/amd/include/asic_reg -I /usr/src/sys/dev/pci/drm/amd/include -I /usr/src/sys/dev/pci/drm/amd/amdgpu -I /usr/src/sys/dev/pci/drm/amd/display -I /usr/src/sys/dev/pci/drm/amd/display/include -I /usr/src/sys/dev/pci/drm/amd/display/dc -I /usr/src/sys/dev/pci/drm/amd/display/amdgpu_dm -I /usr/src/sys/dev/pci/drm/amd/pm/inc -I /usr/src/sys/dev/pci/drm/amd/pm/swsmu -I /usr/src/sys/dev/pci/drm/amd/pm/swsmu/smu11 -I /usr/src/sys/dev/pci/drm/amd/pm/swsmu/smu12 -I /usr/src/sys/dev/pci/drm/amd/pm/powerplay -I /usr/src/sys/dev/pci/drm/amd/pm/powerplay/hwmgr -I /usr/src/sys/dev/pci/drm/amd/pm/powerplay/smumgr -I /usr/src/sys/dev/pci/drm/amd/display/dc/inc -I /usr/src/sys/dev/pci/drm/amd/display/dc/inc/hw -I /usr/src/sys/dev/pci/drm/amd/display/dc/clk_mgr -I /usr/src/sys/dev/pci/drm/amd/display/modules/inc -I /usr/src/sys/dev/pci/drm/amd/display/modules/hdcp -I /usr/src/sys/dev/pci/drm/amd/display/dmub/inc -I /usr/src/sys/dev/pci/drm/i915 -D DDB -D DIAGNOSTIC -D KTRACE -D ACCOUNTING -D KMEMSTATS -D PTRACE -D POOL_DEBUG -D CRYPTO -D SYSVMSG -D SYSVSEM -D SYSVSHM -D UVM_SWAP_ENCRYPT -D FFS -D FFS2 -D FFS_SOFTUPDATES -D UFS_DIRHASH -D QUOTA -D EXT2FS -D MFS -D NFSCLIENT -D NFSSERVER -D CD9660 -D UDF -D MSDOSFS -D FIFO -D FUSE -D SOCKET_SPLICE -D TCP_ECN -D TCP_SIGNATURE -D INET6 -D IPSEC -D PPP_BSDCOMP -D PPP_DEFLATE -D PIPEX -D MROUTING -D MPLS -D BOOT_CONFIG -D USER_PCICONF -D APERTURE -D MTRR -D NTFS -D HIBERNATE -D PCIVERBOSE -D USBVERBOSE -D WSDISPLAY_COMPAT_USL -D WSDISPLAY_COMPAT_RAWKBD -D WSDISPLAY_DEFAULTSCREENS=6 -D X86EMU -D ONEWIREVERBOSE -D MULTIPROCESSOR -D MAXUSERS=80 -D _KERNEL -D CONFIG_DRM_AMD_DC_DCN3_0 -O2 -Wno-pointer-sign -Wno-address-of-packed-member -Wno-constant-conversion -Wno-unused-but-set-variable -Wno-gnu-folding-constant -fdebug-compilation-dir=/usr/src/sys/arch/amd64/compile/GENERIC.MP/obj -ferror-limit 19 -fwrapv -D_RET_PROTECTOR -ret-protector -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-valloc -fno-builtin-free -fno-builtin-strdup -fno-builtin-strndup -analyzer-output=html -faddrsig -o /usr/obj/sys/arch/amd64/compile/GENERIC.MP/scan-build/2022-01-12-131800-47421-1 -x c /usr/src/sys/dev/usb/uvisor.c
1/* $OpenBSD: uvisor.c,v 1.52 2020/02/22 14:01:35 jasper Exp $ */
2/* $NetBSD: uvisor.c,v 1.21 2003/08/03 21:59:26 nathanw Exp $ */
3
4/*
5 * Copyright (c) 2000 The NetBSD Foundation, Inc.
6 * All rights reserved.
7 *
8 * This code is derived from software contributed to The NetBSD Foundation
9 * by Lennart Augustsson (lennart@augustsson.net) at
10 * Carlstedt Research & Technology.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
32 */
33
34/*
35 * Handspring Visor (Palmpilot compatible PDA) driver
36 */
37
38#include <sys/param.h>
39#include <sys/systm.h>
40#include <sys/kernel.h>
41#include <sys/device.h>
42#include <sys/conf.h>
43#include <sys/tty.h>
44
45#include <dev/usb/usb.h>
46
47#include <dev/usb/usbdi.h>
48#include <dev/usb/usbdi_util.h>
49#include <dev/usb/usbdevs.h>
50
51#include <dev/usb/ucomvar.h>
52
53#ifdef UVISOR_DEBUG
54#define DPRINTF(x) if (uvisordebug) printf x
55#define DPRINTFN(n,x) if (uvisordebug>(n)) printf x
56int uvisordebug = 0;
57#else
58#define DPRINTF(x)
59#define DPRINTFN(n,x)
60#endif
61
62#define UVISOR_IFACE_INDEX0 0
63
64/* From the Linux driver */
65/*
66 * UVISOR_REQUEST_BYTES_AVAILABLE asks the visor for the number of bytes that
67 * are available to be transferred to the host for the specified endpoint.
68 * Currently this is not used, and always returns 0x0001
69 */
70#define UVISOR_REQUEST_BYTES_AVAILABLE0x01 0x01
71
72/*
73 * UVISOR_CLOSE_NOTIFICATION is set to the device to notify it that the host
74 * is now closing the pipe. An empty packet is sent in response.
75 */
76#define UVISOR_CLOSE_NOTIFICATION0x02 0x02
77
78/*
79 * UVISOR_GET_CONNECTION_INFORMATION is sent by the host during enumeration to
80 * get the endpoints used by the connection.
81 */
82#define UVISOR_GET_CONNECTION_INFORMATION0x03 0x03
83
84
85/*
86 * UVISOR_GET_CONNECTION_INFORMATION returns data in the following format
87 */
88#define UVISOR_MAX_CONN8 8
89struct uvisor_connection_info {
90 uWord num_ports;
91 struct {
92 uByte port_function_id;
93 uByte port;
94 } connections[UVISOR_MAX_CONN8];
95};
96#define UVISOR_CONNECTION_INFO_SIZE18 18
97
98/* struct uvisor_connection_info.connection[x].port_function_id defines: */
99#define UVISOR_FUNCTION_GENERIC0x00 0x00
100#define UVISOR_FUNCTION_DEBUGGER0x01 0x01
101#define UVISOR_FUNCTION_HOTSYNC0x02 0x02
102#define UVISOR_FUNCTION_CONSOLE0x03 0x03
103#define UVISOR_FUNCTION_REMOTE_FILE_SYS0x04 0x04
104
105/*
106 * Unknown PalmOS stuff.
107 */
108#define UVISOR_GET_PALM_INFORMATION0x04 0x04
109#define UVISOR_GET_PALM_INFORMATION_LEN0x44 0x44
110
111struct uvisor_palm_connection_info {
112 uByte num_ports;
113 uByte endpoint_numbers_different;
114 uWord reserved1;
115 struct {
116 uDWord port_function_id;
117 uByte port;
118 uByte end_point_info;
119 uWord reserved;
120 } connections[UVISOR_MAX_CONN8];
121};
122
123#define UVISORIBUFSIZE64 64
124#define UVISOROBUFSIZE1024 1024
125
126struct uvisor_softc {
127 struct device sc_dev; /* base device */
128 struct usbd_device *sc_udev; /* device */
129 struct usbd_interface *sc_iface; /* interface */
130/*
131 * added sc_vendor for later interrogation in failed initialisations
132 */
133 int sc_vendor; /* USB device vendor */
134
135 struct device *sc_subdevs[UVISOR_MAX_CONN8];
136 int sc_numcon;
137
138 u_int16_t sc_flags;
139};
140
141usbd_status uvisor_init(struct uvisor_softc *,
142 struct uvisor_connection_info *,
143 struct uvisor_palm_connection_info *);
144
145void uvisor_close(void *, int);
146
147
148struct ucom_methods uvisor_methods = {
149 NULL((void *)0),
150 NULL((void *)0),
151 NULL((void *)0),
152 NULL((void *)0),
153 NULL((void *)0),
154 uvisor_close,
155 NULL((void *)0),
156 NULL((void *)0),
157};
158
159struct uvisor_type {
160 struct usb_devno uv_dev;
161 u_int16_t uv_flags;
162#define PALM40x0001 0x0001
163#define VISOR0x0002 0x0002
164#define NOFRE0x0004 0x0004
165#define CLIE4(0x0002|0x0004) (VISOR0x0002|NOFRE0x0004)
166};
167static const struct uvisor_type uvisor_devs[] = {
168 {{ USB_VENDOR_ACEECA0x4766, USB_PRODUCT_ACEECA_MEZ10000x0001 }, PALM40x0001 },
169 {{ USB_VENDOR_FOSSIL0x0e67, USB_PRODUCT_FOSSIL_WRISTPDA0x0002 }, PALM40x0001 },
170 {{ USB_VENDOR_GARMIN0x091e, USB_PRODUCT_GARMIN_IQUE36000x0004 }, PALM40x0001 },
171 {{ USB_VENDOR_HANDSPRING0x082d, USB_PRODUCT_HANDSPRING_VISOR0x0100 }, VISOR0x0002 },
172 {{ USB_VENDOR_HANDSPRING0x082d, USB_PRODUCT_HANDSPRING_TREO0x0200 }, PALM40x0001 },
173 {{ USB_VENDOR_HANDSPRING0x082d, USB_PRODUCT_HANDSPRING_TREO6000x0300 }, VISOR0x0002 },
174 {{ USB_VENDOR_PALM0x0830, USB_PRODUCT_PALM_M5000x0001 }, PALM40x0001 },
175 {{ USB_VENDOR_PALM0x0830, USB_PRODUCT_PALM_M5050x0002 }, PALM40x0001 },
176 {{ USB_VENDOR_PALM0x0830, USB_PRODUCT_PALM_M5150x0003 }, PALM40x0001 },
177 {{ USB_VENDOR_PALM0x0830, USB_PRODUCT_PALM_I7050x0020 }, PALM40x0001 },
178 {{ USB_VENDOR_PALM0x0830, USB_PRODUCT_PALM_M1250x0040 }, PALM40x0001 },
179 {{ USB_VENDOR_PALM0x0830, USB_PRODUCT_PALM_M1300x0050 }, PALM40x0001 },
180 {{ USB_VENDOR_PALM0x0830, USB_PRODUCT_PALM_TUNGSTEN_Z0x0031 }, PALM40x0001 },
181 {{ USB_VENDOR_PALM0x0830, USB_PRODUCT_PALM_TUNGSTEN_T0x0060 }, PALM40x0001 },
182 {{ USB_VENDOR_PALM0x0830, USB_PRODUCT_PALM_ZIRE0x0070 }, PALM40x0001 },
183 {{ USB_VENDOR_PALM0x0830, USB_PRODUCT_PALM_ZIRE_310x0061 }, PALM40x0001 },
184 {{ USB_VENDOR_SONY0x054c, USB_PRODUCT_SONY_CLIE_400x0066 }, PALM40x0001 },
185 {{ USB_VENDOR_SONY0x054c, USB_PRODUCT_SONY_CLIE_410x009a }, PALM40x0001 },
186 {{ USB_VENDOR_SONY0x054c, USB_PRODUCT_SONY_CLIE_S3600x0095 }, PALM40x0001 },
187 {{ USB_VENDOR_SONY0x054c, USB_PRODUCT_SONY_CLIE_NX600x00da }, PALM40x0001 },
188 {{ USB_VENDOR_SONY0x054c, USB_PRODUCT_SONY_CLIE_TJ250x0169 }, PALM40x0001 },
189/* {{ USB_VENDOR_SONY, USB_PRODUCT_SONY_CLIE_25 }, PALM4 },*/
190 {{ USB_VENDOR_TAPWAVE0x12ef, USB_PRODUCT_TAPWAVE_ZODIAC0x0100 }, PALM40x0001 },
191};
192#define uvisor_lookup(v, p)((struct uvisor_type *)usbd_match_device((const struct usb_devno
*)(uvisor_devs), sizeof (uvisor_devs) / sizeof ((uvisor_devs
)[0]), sizeof ((uvisor_devs)[0]), (v), (p)))
((struct uvisor_type *)usb_lookup(uvisor_devs, v, p)usbd_match_device((const struct usb_devno *)(uvisor_devs), sizeof
(uvisor_devs) / sizeof ((uvisor_devs)[0]), sizeof ((uvisor_devs
)[0]), (v), (p))
)
193
194int uvisor_match(struct device *, void *, void *);
195void uvisor_attach(struct device *, struct device *, void *);
196int uvisor_detach(struct device *, int);
197
198struct cfdriver uvisor_cd = {
199 NULL((void *)0), "uvisor", DV_DULL
200};
201
202const struct cfattach uvisor_ca = {
203 sizeof(struct uvisor_softc), uvisor_match, uvisor_attach, uvisor_detach
204};
205
206int
207uvisor_match(struct device *parent, void *match, void *aux)
208{
209 struct usb_attach_arg *uaa = aux;
210
211 if (uaa->iface == NULL((void *)0))
212 return (UMATCH_NONE0);
213
214 DPRINTFN(20,("uvisor: vendor=0x%x, product=0x%x\n",
215 uaa->vendor, uaa->product));
216
217 return (uvisor_lookup(uaa->vendor, uaa->product)((struct uvisor_type *)usbd_match_device((const struct usb_devno
*)(uvisor_devs), sizeof (uvisor_devs) / sizeof ((uvisor_devs
)[0]), sizeof ((uvisor_devs)[0]), (uaa->vendor), (uaa->
product)))
!= NULL((void *)0) ?
218 UMATCH_VENDOR_PRODUCT13 : UMATCH_NONE0);
219}
220
221void
222uvisor_attach(struct device *parent, struct device *self, void *aux)
223{
224 struct uvisor_softc *sc = (struct uvisor_softc *)self;
225 struct usb_attach_arg *uaa = aux;
226 struct usbd_device *dev = uaa->device;
227 struct usbd_interface *iface;
228 usb_interface_descriptor_t *id;
229 struct uvisor_connection_info coninfo;
230 struct uvisor_palm_connection_info palmconinfo;
231 usb_endpoint_descriptor_t *ed;
232 int i, j, hasin, hasout, port;
233 usbd_status err;
234 struct ucom_attach_args uca;
235
236 DPRINTFN(10,("\nuvisor_attach: sc=%p\n", sc));
237
238 err = usbd_device2interface_handle(dev, UVISOR_IFACE_INDEX0, &iface);
239 if (err) {
1
Assuming 'err' is 0
2
Taking false branch
240 printf(": failed to get interface, err=%s\n",
241 usbd_errstr(err));
242 goto bad;
243 }
244
245 sc->sc_flags = uvisor_lookup(uaa->vendor, uaa->product)((struct uvisor_type *)usbd_match_device((const struct usb_devno
*)(uvisor_devs), sizeof (uvisor_devs) / sizeof ((uvisor_devs
)[0]), sizeof ((uvisor_devs)[0]), (uaa->vendor), (uaa->
product)))
->uv_flags;
246 sc->sc_vendor = uaa->vendor;
247
248 if ((sc->sc_flags & (VISOR0x0002 | PALM40x0001)) == 0) {
3
Assuming the condition is false
4
Taking false branch
249 printf("%s: device is neither visor nor palm\n",
250 sc->sc_dev.dv_xname);
251 goto bad;
252 }
253
254 id = usbd_get_interface_descriptor(iface);
255
256 sc->sc_udev = dev;
257 sc->sc_iface = iface;
258
259 uca.ibufsize = UVISORIBUFSIZE64;
260 uca.obufsize = UVISOROBUFSIZE1024;
261 uca.ibufsizepad = UVISORIBUFSIZE64;
262 uca.opkthdrlen = 0;
263 uca.device = dev;
264 uca.iface = iface;
265 uca.methods = &uvisor_methods;
266 uca.arg = sc;
267
268 err = uvisor_init(sc, &coninfo, &palmconinfo);
5
Calling 'uvisor_init'
14
Returning from 'uvisor_init'
269 if (err
14.1
'err' is 0
) {
15
Taking false branch
270 printf("%s: init failed, %s\n", sc->sc_dev.dv_xname,
271 usbd_errstr(err));
272 goto bad;
273 }
274
275 if (sc->sc_flags & VISOR0x0002) {
16
Taking false branch
276 sc->sc_numcon = UGETW(coninfo.num_ports)(*(u_int16_t *)(coninfo.num_ports));
277 if (sc->sc_numcon > UVISOR_MAX_CONN8)
278 sc->sc_numcon = UVISOR_MAX_CONN8;
279
280 /* Attach a ucom for each connection. */
281 for (i = 0; i < sc->sc_numcon; ++i) {
282 switch (coninfo.connections[i].port_function_id) {
283 case UVISOR_FUNCTION_GENERIC0x00:
284 uca.info = "Generic";
285 break;
286 case UVISOR_FUNCTION_DEBUGGER0x01:
287 uca.info = "Debugger";
288 break;
289 case UVISOR_FUNCTION_HOTSYNC0x02:
290 uca.info = "HotSync";
291 break;
292 case UVISOR_FUNCTION_REMOTE_FILE_SYS0x04:
293 uca.info = "Remote File System";
294 break;
295 default:
296 uca.info = "unknown";
297 break;
298 }
299 port = coninfo.connections[i].port;
300 uca.portno = port;
301 uca.bulkin = port | UE_DIR_IN0x80;
302 uca.bulkout = port | UE_DIR_OUT0x00;
303 /* Verify that endpoints exist. */
304 hasin = 0;
305 hasout = 0;
306 for (j = 0; j < id->bNumEndpoints; j++) {
307 ed = usbd_interface2endpoint_descriptor(iface, j);
308 if (ed == NULL((void *)0))
309 break;
310 if (UE_GET_ADDR(ed->bEndpointAddress)((ed->bEndpointAddress) & 0x0f) == port &&
311 UE_GET_XFERTYPE(ed->bmAttributes)((ed->bmAttributes) & 0x03) == UE_BULK0x02) {
312 if (UE_GET_DIR(ed->bEndpointAddress)((ed->bEndpointAddress) & 0x80)
313 == UE_DIR_IN0x80)
314 hasin++;
315 else
316 hasout++;
317 }
318 }
319 if (hasin == 1 && hasout == 1)
320 sc->sc_subdevs[i] = config_found_sm(self, &uca,
321 ucomprint, ucomsubmatch);
322 else
323 printf("%s: no proper endpoints for port %d (%d,%d)\n",
324 sc->sc_dev.dv_xname, port, hasin, hasout);
325 }
326 } else {
327 sc->sc_numcon = palmconinfo.num_ports;
17
Assigned value is garbage or undefined
328 if (sc->sc_numcon > UVISOR_MAX_CONN8)
329 sc->sc_numcon = UVISOR_MAX_CONN8;
330
331 /* Attach a ucom for each connection. */
332 for (i = 0; i < sc->sc_numcon; ++i) {
333 /*
334 * XXX this should copy out 4-char string from the
335 * XXX port_function_id, but where would the string go?
336 * XXX uca.info is a const char *, not an array.
337 */
338 uca.info = "sync";
339 uca.portno = i;
340 if (palmconinfo.endpoint_numbers_different) {
341 port = palmconinfo.connections[i].end_point_info;
342 uca.bulkin = (port >> 4) | UE_DIR_IN0x80;
343 uca.bulkout = (port & 0xf) | UE_DIR_OUT0x00;
344 } else {
345 port = palmconinfo.connections[i].port;
346 uca.bulkin = port | UE_DIR_IN0x80;
347 uca.bulkout = port | UE_DIR_OUT0x00;
348 }
349 sc->sc_subdevs[i] = config_found_sm(self, &uca,
350 ucomprint, ucomsubmatch);
351 }
352 }
353
354 return;
355
356bad:
357 DPRINTF(("uvisor_attach: ATTACH ERROR\n"));
358 usbd_deactivate(sc->sc_udev);
359}
360
361int
362uvisor_detach(struct device *self, int flags)
363{
364 struct uvisor_softc *sc = (struct uvisor_softc *)self;
365 int rv = 0;
366 int i;
367
368 DPRINTF(("uvisor_detach: sc=%p flags=%d\n", sc, flags));
369 for (i = 0; i < sc->sc_numcon; i++) {
370 if (sc->sc_subdevs[i] != NULL((void *)0)) {
371 rv |= config_detach(sc->sc_subdevs[i], flags);
372 sc->sc_subdevs[i] = NULL((void *)0);
373 }
374 }
375
376 return (rv);
377}
378
379usbd_status
380uvisor_init(struct uvisor_softc *sc, struct uvisor_connection_info *ci,
381 struct uvisor_palm_connection_info *cpi)
382{
383 usbd_status err = 0;
384 usb_device_request_t req;
385 int actlen;
386 uWord avail;
387
388 if (sc->sc_flags & PALM40x0001) {
6
Assuming the condition is false
7
Taking false branch
389 DPRINTF(("uvisor_init: getting Palm connection info\n"));
390 req.bmRequestType = UT_READ_VENDOR_ENDPOINT(0x80 | 0x40 | 0x02);
391 req.bRequest = UVISOR_GET_PALM_INFORMATION0x04;
392 USETW(req.wValue, 0)(*(u_int16_t *)(req.wValue) = (0));
393 USETW(req.wIndex, 0)(*(u_int16_t *)(req.wIndex) = (0));
394 USETW(req.wLength, UVISOR_GET_PALM_INFORMATION_LEN)(*(u_int16_t *)(req.wLength) = (0x44));
395 err = usbd_do_request_flags(sc->sc_udev, &req, cpi,
396 USBD_SHORT_XFER_OK0x04, &actlen, USBD_DEFAULT_TIMEOUT5000);
397 if (err == USBD_STALLED && sc->sc_vendor == USB_VENDOR_SONY0x054c) {
398 /* some sony clie devices stall on palm4 requests,
399 * switch them over to using visor. dont do free space
400 * checks on them since they dont like them either.
401 */
402 DPRINTF(("switching role for CLIE probe\n"));
403 sc->sc_flags = CLIE4(0x0002|0x0004);
404 err = 0;
405 }
406 if (err)
407 return (err);
408 }
409
410 if (sc->sc_flags & VISOR0x0002) {
8
Assuming the condition is false
9
Taking false branch
411 DPRINTF(("uvisor_init: getting Visor connection info\n"));
412 req.bmRequestType = UT_READ_VENDOR_ENDPOINT(0x80 | 0x40 | 0x02);
413 req.bRequest = UVISOR_GET_CONNECTION_INFORMATION0x03;
414 USETW(req.wValue, 0)(*(u_int16_t *)(req.wValue) = (0));
415 USETW(req.wIndex, 0)(*(u_int16_t *)(req.wIndex) = (0));
416 USETW(req.wLength, UVISOR_CONNECTION_INFO_SIZE)(*(u_int16_t *)(req.wLength) = (18));
417 err = usbd_do_request_flags(sc->sc_udev, &req, ci,
418 USBD_SHORT_XFER_OK0x04, &actlen, USBD_DEFAULT_TIMEOUT5000);
419 if (err)
420 return (err);
421 }
422
423 if (sc->sc_flags & NOFRE0x0004)
10
Assuming the condition is true
11
Taking true branch
424 return (err);
12
Returning without writing to 'cpi->num_ports'
13
Returning zero (loaded from 'err'), which participates in a condition later
425
426 DPRINTF(("uvisor_init: getting available bytes\n"));
427 req.bmRequestType = UT_READ_VENDOR_ENDPOINT(0x80 | 0x40 | 0x02);
428 req.bRequest = UVISOR_REQUEST_BYTES_AVAILABLE0x01;
429 USETW(req.wValue, 0)(*(u_int16_t *)(req.wValue) = (0));
430 USETW(req.wIndex, 5)(*(u_int16_t *)(req.wIndex) = (5));
431 USETW(req.wLength, sizeof avail)(*(u_int16_t *)(req.wLength) = (sizeof avail));
432 err = usbd_do_request(sc->sc_udev, &req, &avail);
433 if (err)
434 return (err);
435 DPRINTF(("uvisor_init: avail=%d\n", UGETW(avail)));
436 DPRINTF(("uvisor_init: done\n"));
437 return (err);
438}
439
440void
441uvisor_close(void *addr, int portno)
442{
443 struct uvisor_softc *sc = addr;
444 usb_device_request_t req;
445 struct uvisor_connection_info coninfo; /* XXX ? */
446 int actlen;
447
448 if (usbd_is_dying(sc->sc_udev))
449 return;
450
451 req.bmRequestType = UT_READ_VENDOR_ENDPOINT(0x80 | 0x40 | 0x02); /* XXX read? */
452 req.bRequest = UVISOR_CLOSE_NOTIFICATION0x02;
453 USETW(req.wValue, 0)(*(u_int16_t *)(req.wValue) = (0));
454 USETW(req.wIndex, 0)(*(u_int16_t *)(req.wIndex) = (0));
455 USETW(req.wLength, UVISOR_CONNECTION_INFO_SIZE)(*(u_int16_t *)(req.wLength) = (18));
456 (void)usbd_do_request_flags(sc->sc_udev, &req, &coninfo,
457 USBD_SHORT_XFER_OK0x04, &actlen, USBD_DEFAULT_TIMEOUT5000);
458}