Deleted Added
full compact
uslcom.c (188942) uslcom.c (189265)
1/* $OpenBSD: uslcom.c,v 1.17 2007/11/24 10:52:12 jsg Exp $ */
2
3#include <sys/cdefs.h>
1/* $OpenBSD: uslcom.c,v 1.17 2007/11/24 10:52:12 jsg Exp $ */
2
3#include <sys/cdefs.h>
4__FBSDID("$FreeBSD: head/sys/dev/usb/serial/uslcom.c 188942 2009-02-23 18:31:00Z thompsa $");
4__FBSDID("$FreeBSD: head/sys/dev/usb/serial/uslcom.c 189265 2009-03-02 02:44:10Z thompsa $");
5
6/*
7 * Copyright (c) 2006 Jonathan Gray <jsg@openbsd.org>
8 *
9 * Permission to use, copy, modify, and distribute this software for any
10 * purpose with or without fee is hereby granted, provided that the above
11 * copyright notice and this permission notice appear in all copies.
12 *

--- 78 unchanged lines hidden (view full) ---

91};
92
93struct uslcom_softc {
94 struct usb2_com_super_softc sc_super_ucom;
95 struct usb2_com_softc sc_ucom;
96
97 struct usb2_xfer *sc_xfer[USLCOM_N_TRANSFER];
98 struct usb2_device *sc_udev;
5
6/*
7 * Copyright (c) 2006 Jonathan Gray <jsg@openbsd.org>
8 *
9 * Permission to use, copy, modify, and distribute this software for any
10 * purpose with or without fee is hereby granted, provided that the above
11 * copyright notice and this permission notice appear in all copies.
12 *

--- 78 unchanged lines hidden (view full) ---

91};
92
93struct uslcom_softc {
94 struct usb2_com_super_softc sc_super_ucom;
95 struct usb2_com_softc sc_ucom;
96
97 struct usb2_xfer *sc_xfer[USLCOM_N_TRANSFER];
98 struct usb2_device *sc_udev;
99 struct mtx sc_mtx;
99
100 uint8_t sc_msr;
101 uint8_t sc_lsr;
102};
103
104static device_probe_t uslcom_probe;
105static device_attach_t uslcom_attach;
106static device_detach_t uslcom_detach;

--- 115 unchanged lines hidden (view full) ---

222{
223 struct usb2_attach_arg *uaa = device_get_ivars(dev);
224 struct uslcom_softc *sc = device_get_softc(dev);
225 int error;
226
227 DPRINTFN(11, "\n");
228
229 device_set_usb2_desc(dev);
100
101 uint8_t sc_msr;
102 uint8_t sc_lsr;
103};
104
105static device_probe_t uslcom_probe;
106static device_attach_t uslcom_attach;
107static device_detach_t uslcom_detach;

--- 115 unchanged lines hidden (view full) ---

223{
224 struct usb2_attach_arg *uaa = device_get_ivars(dev);
225 struct uslcom_softc *sc = device_get_softc(dev);
226 int error;
227
228 DPRINTFN(11, "\n");
229
230 device_set_usb2_desc(dev);
231 mtx_init(&sc->sc_mtx, "uslcom", NULL, MTX_DEF);
230
231 sc->sc_udev = uaa->device;
232
233 error = usb2_transfer_setup(uaa->device,
234 &uaa->info.bIfaceIndex, sc->sc_xfer, uslcom_config,
232
233 sc->sc_udev = uaa->device;
234
235 error = usb2_transfer_setup(uaa->device,
236 &uaa->info.bIfaceIndex, sc->sc_xfer, uslcom_config,
235 USLCOM_N_TRANSFER, sc, &Giant);
237 USLCOM_N_TRANSFER, sc, &sc->sc_mtx);
236 if (error) {
237 DPRINTF("one or more missing USB endpoints, "
238 "error=%s\n", usb2_errstr(error));
239 goto detach;
240 }
241 /* clear stall at first run */
238 if (error) {
239 DPRINTF("one or more missing USB endpoints, "
240 "error=%s\n", usb2_errstr(error));
241 goto detach;
242 }
243 /* clear stall at first run */
244 mtx_lock(&sc->sc_mtx);
242 usb2_transfer_set_stall(sc->sc_xfer[USLCOM_BULK_DT_WR]);
243 usb2_transfer_set_stall(sc->sc_xfer[USLCOM_BULK_DT_RD]);
245 usb2_transfer_set_stall(sc->sc_xfer[USLCOM_BULK_DT_WR]);
246 usb2_transfer_set_stall(sc->sc_xfer[USLCOM_BULK_DT_RD]);
247 mtx_unlock(&sc->sc_mtx);
244
245 error = usb2_com_attach(&sc->sc_super_ucom, &sc->sc_ucom, 1, sc,
248
249 error = usb2_com_attach(&sc->sc_super_ucom, &sc->sc_ucom, 1, sc,
246 &uslcom_callback, &Giant);
250 &uslcom_callback, &sc->sc_mtx);
247 if (error) {
248 goto detach;
249 }
250 return (0);
251
252detach:
253 uslcom_detach(dev);
254 return (ENXIO);
255}
256
257static int
258uslcom_detach(device_t dev)
259{
260 struct uslcom_softc *sc = device_get_softc(dev);
261
262 DPRINTF("sc=%p\n", sc);
263
264 usb2_com_detach(&sc->sc_super_ucom, &sc->sc_ucom, 1);
251 if (error) {
252 goto detach;
253 }
254 return (0);
255
256detach:
257 uslcom_detach(dev);
258 return (ENXIO);
259}
260
261static int
262uslcom_detach(device_t dev)
263{
264 struct uslcom_softc *sc = device_get_softc(dev);
265
266 DPRINTF("sc=%p\n", sc);
267
268 usb2_com_detach(&sc->sc_super_ucom, &sc->sc_ucom, 1);
265
266 usb2_transfer_unsetup(sc->sc_xfer, USLCOM_N_TRANSFER);
269 usb2_transfer_unsetup(sc->sc_xfer, USLCOM_N_TRANSFER);
270 mtx_destroy(&sc->sc_mtx);
267
268 return (0);
269}
270
271static void
272uslcom_open(struct usb2_com_softc *ucom)
273{
274 struct uslcom_softc *sc = ucom->sc_parent;

--- 265 unchanged lines hidden ---
271
272 return (0);
273}
274
275static void
276uslcom_open(struct usb2_com_softc *ucom)
277{
278 struct uslcom_softc *sc = ucom->sc_parent;

--- 265 unchanged lines hidden ---