Deleted Added
full compact
uark.c (188942) uark.c (189265)
1/* $OpenBSD: uark.c,v 1.1 2006/08/14 08:30:22 jsg Exp $ */
2
3/*
4 * Copyright (c) 2006 Jonathan Gray <jsg@openbsd.org>
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 *
1/* $OpenBSD: uark.c,v 1.1 2006/08/14 08:30:22 jsg Exp $ */
2
3/*
4 * Copyright (c) 2006 Jonathan Gray <jsg@openbsd.org>
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 *
18 * $FreeBSD: head/sys/dev/usb/serial/uark.c 188942 2009-02-23 18:31:00Z thompsa $
18 * $FreeBSD: head/sys/dev/usb/serial/uark.c 189265 2009-03-02 02:44:10Z thompsa $
19 */
20
21/*
22 * NOTE: all function names beginning like "uark_cfg_" can only
23 * be called from within the config thread function !
24 */
25
26#include "usbdevs.h"

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

68};
69
70struct uark_softc {
71 struct usb2_com_super_softc sc_super_ucom;
72 struct usb2_com_softc sc_ucom;
73
74 struct usb2_xfer *sc_xfer[UARK_N_TRANSFER];
75 struct usb2_device *sc_udev;
19 */
20
21/*
22 * NOTE: all function names beginning like "uark_cfg_" can only
23 * be called from within the config thread function !
24 */
25
26#include "usbdevs.h"

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

68};
69
70struct uark_softc {
71 struct usb2_com_super_softc sc_super_ucom;
72 struct usb2_com_softc sc_ucom;
73
74 struct usb2_xfer *sc_xfer[UARK_N_TRANSFER];
75 struct usb2_device *sc_udev;
76 struct mtx sc_mtx;
76
77 uint8_t sc_msr;
78 uint8_t sc_lsr;
79};
80
81/* prototypes */
82
83static device_probe_t uark_probe;

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

176uark_attach(device_t dev)
177{
178 struct usb2_attach_arg *uaa = device_get_ivars(dev);
179 struct uark_softc *sc = device_get_softc(dev);
180 int32_t error;
181 uint8_t iface_index;
182
183 device_set_usb2_desc(dev);
77
78 uint8_t sc_msr;
79 uint8_t sc_lsr;
80};
81
82/* prototypes */
83
84static device_probe_t uark_probe;

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

177uark_attach(device_t dev)
178{
179 struct usb2_attach_arg *uaa = device_get_ivars(dev);
180 struct uark_softc *sc = device_get_softc(dev);
181 int32_t error;
182 uint8_t iface_index;
183
184 device_set_usb2_desc(dev);
185 mtx_init(&sc->sc_mtx, "uark", NULL, MTX_DEF);
184
185 sc->sc_udev = uaa->device;
186
187 iface_index = UARK_IFACE_INDEX;
188 error = usb2_transfer_setup
189 (uaa->device, &iface_index, sc->sc_xfer,
186
187 sc->sc_udev = uaa->device;
188
189 iface_index = UARK_IFACE_INDEX;
190 error = usb2_transfer_setup
191 (uaa->device, &iface_index, sc->sc_xfer,
190 uark_xfer_config, UARK_N_TRANSFER, sc, &Giant);
192 uark_xfer_config, UARK_N_TRANSFER, sc, &sc->sc_mtx);
191
192 if (error) {
193 device_printf(dev, "allocating control USB "
194 "transfers failed!\n");
195 goto detach;
196 }
197 /* clear stall at first run */
193
194 if (error) {
195 device_printf(dev, "allocating control USB "
196 "transfers failed!\n");
197 goto detach;
198 }
199 /* clear stall at first run */
200 mtx_lock(&sc->sc_mtx);
198 usb2_transfer_set_stall(sc->sc_xfer[UARK_BULK_DT_WR]);
199 usb2_transfer_set_stall(sc->sc_xfer[UARK_BULK_DT_RD]);
201 usb2_transfer_set_stall(sc->sc_xfer[UARK_BULK_DT_WR]);
202 usb2_transfer_set_stall(sc->sc_xfer[UARK_BULK_DT_RD]);
203 mtx_unlock(&sc->sc_mtx);
200
201 error = usb2_com_attach(&sc->sc_super_ucom, &sc->sc_ucom, 1, sc,
204
205 error = usb2_com_attach(&sc->sc_super_ucom, &sc->sc_ucom, 1, sc,
202 &uark_callback, &Giant);
206 &uark_callback, &sc->sc_mtx);
203 if (error) {
204 DPRINTF("usb2_com_attach failed\n");
205 goto detach;
206 }
207 return (0); /* success */
208
209detach:
210 uark_detach(dev);
211 return (ENXIO); /* failure */
212}
213
214static int
215uark_detach(device_t dev)
216{
217 struct uark_softc *sc = device_get_softc(dev);
218
219 usb2_com_detach(&sc->sc_super_ucom, &sc->sc_ucom, 1);
207 if (error) {
208 DPRINTF("usb2_com_attach failed\n");
209 goto detach;
210 }
211 return (0); /* success */
212
213detach:
214 uark_detach(dev);
215 return (ENXIO); /* failure */
216}
217
218static int
219uark_detach(device_t dev)
220{
221 struct uark_softc *sc = device_get_softc(dev);
222
223 usb2_com_detach(&sc->sc_super_ucom, &sc->sc_ucom, 1);
220
221 usb2_transfer_unsetup(sc->sc_xfer, UARK_N_TRANSFER);
224 usb2_transfer_unsetup(sc->sc_xfer, UARK_N_TRANSFER);
225 mtx_destroy(&sc->sc_mtx);
222
223 return (0);
224}
225
226static void
227uark_bulk_write_callback(struct usb2_xfer *xfer)
228{
229 struct uark_softc *sc = xfer->priv_sc;

--- 178 unchanged lines hidden ---
226
227 return (0);
228}
229
230static void
231uark_bulk_write_callback(struct usb2_xfer *xfer)
232{
233 struct uark_softc *sc = xfer->priv_sc;

--- 178 unchanged lines hidden ---