Deleted Added
full compact
ubsa.c (233774) ubsa.c (239180)
1/*-
2 * Copyright (c) 2002, Alexander Kabaev <kan.FreeBSD.org>.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2002, Alexander Kabaev <kan.FreeBSD.org>.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/dev/usb/serial/ubsa.c 233774 2012-04-02 10:50:42Z hselasky $");
28__FBSDID("$FreeBSD: head/sys/dev/usb/serial/ubsa.c 239180 2012-08-10 15:29:41Z hselasky $");
29/*-
30 * Copyright (c) 2001 The NetBSD Foundation, Inc.
31 * All rights reserved.
32 *
33 * This code is derived from software contributed to The NetBSD Foundation
34 * by Ichiro FUKUHARA (ichiro@ichiro.org).
35 *
36 * Redistribution and use in source and binary forms, with or without

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

171 uint8_t sc_iface_index; /* interface index */
172 uint8_t sc_lsr; /* local status register */
173 uint8_t sc_msr; /* UBSA status register */
174};
175
176static device_probe_t ubsa_probe;
177static device_attach_t ubsa_attach;
178static device_detach_t ubsa_detach;
29/*-
30 * Copyright (c) 2001 The NetBSD Foundation, Inc.
31 * All rights reserved.
32 *
33 * This code is derived from software contributed to The NetBSD Foundation
34 * by Ichiro FUKUHARA (ichiro@ichiro.org).
35 *
36 * Redistribution and use in source and binary forms, with or without

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

171 uint8_t sc_iface_index; /* interface index */
172 uint8_t sc_lsr; /* local status register */
173 uint8_t sc_msr; /* UBSA status register */
174};
175
176static device_probe_t ubsa_probe;
177static device_attach_t ubsa_attach;
178static device_detach_t ubsa_detach;
179static device_free_softc_t ubsa_free_softc;
179
180static usb_callback_t ubsa_write_callback;
181static usb_callback_t ubsa_read_callback;
182static usb_callback_t ubsa_intr_callback;
183
184static void ubsa_cfg_request(struct ubsa_softc *, uint8_t, uint16_t);
180
181static usb_callback_t ubsa_write_callback;
182static usb_callback_t ubsa_read_callback;
183static usb_callback_t ubsa_intr_callback;
184
185static void ubsa_cfg_request(struct ubsa_softc *, uint8_t, uint16_t);
186static void ubsa_free(struct ucom_softc *);
185static void ubsa_cfg_set_dtr(struct ucom_softc *, uint8_t);
186static void ubsa_cfg_set_rts(struct ucom_softc *, uint8_t);
187static void ubsa_cfg_set_break(struct ucom_softc *, uint8_t);
188static int ubsa_pre_param(struct ucom_softc *, struct termios *);
189static void ubsa_cfg_param(struct ucom_softc *, struct termios *);
190static void ubsa_start_read(struct ucom_softc *);
191static void ubsa_stop_read(struct ucom_softc *);
192static void ubsa_start_write(struct ucom_softc *);

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

232 .ucom_cfg_set_break = &ubsa_cfg_set_break,
233 .ucom_cfg_param = &ubsa_cfg_param,
234 .ucom_pre_param = &ubsa_pre_param,
235 .ucom_start_read = &ubsa_start_read,
236 .ucom_stop_read = &ubsa_stop_read,
237 .ucom_start_write = &ubsa_start_write,
238 .ucom_stop_write = &ubsa_stop_write,
239 .ucom_poll = &ubsa_poll,
187static void ubsa_cfg_set_dtr(struct ucom_softc *, uint8_t);
188static void ubsa_cfg_set_rts(struct ucom_softc *, uint8_t);
189static void ubsa_cfg_set_break(struct ucom_softc *, uint8_t);
190static int ubsa_pre_param(struct ucom_softc *, struct termios *);
191static void ubsa_cfg_param(struct ucom_softc *, struct termios *);
192static void ubsa_start_read(struct ucom_softc *);
193static void ubsa_stop_read(struct ucom_softc *);
194static void ubsa_start_write(struct ucom_softc *);

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

234 .ucom_cfg_set_break = &ubsa_cfg_set_break,
235 .ucom_cfg_param = &ubsa_cfg_param,
236 .ucom_pre_param = &ubsa_pre_param,
237 .ucom_start_read = &ubsa_start_read,
238 .ucom_stop_read = &ubsa_stop_read,
239 .ucom_start_write = &ubsa_start_write,
240 .ucom_stop_write = &ubsa_stop_write,
241 .ucom_poll = &ubsa_poll,
242 .ucom_free = &ubsa_free,
240};
241
242static const STRUCT_USB_HOST_ID ubsa_devs[] = {
243 /* AnyData ADU-500A */
244 {USB_VPI(USB_VENDOR_ANYDATA, USB_PRODUCT_ANYDATA_ADU_500A, 0)},
245 /* AnyData ADU-E100A/H */
246 {USB_VPI(USB_VENDOR_ANYDATA, USB_PRODUCT_ANYDATA_ADU_E100X, 0)},
247 /* Axesstel MV100H */

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

257 /* Peracom */
258 {USB_VPI(USB_VENDOR_PERACOM, USB_PRODUCT_PERACOM_SERIAL1, 0)},
259};
260
261static device_method_t ubsa_methods[] = {
262 DEVMETHOD(device_probe, ubsa_probe),
263 DEVMETHOD(device_attach, ubsa_attach),
264 DEVMETHOD(device_detach, ubsa_detach),
243};
244
245static const STRUCT_USB_HOST_ID ubsa_devs[] = {
246 /* AnyData ADU-500A */
247 {USB_VPI(USB_VENDOR_ANYDATA, USB_PRODUCT_ANYDATA_ADU_500A, 0)},
248 /* AnyData ADU-E100A/H */
249 {USB_VPI(USB_VENDOR_ANYDATA, USB_PRODUCT_ANYDATA_ADU_E100X, 0)},
250 /* Axesstel MV100H */

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

260 /* Peracom */
261 {USB_VPI(USB_VENDOR_PERACOM, USB_PRODUCT_PERACOM_SERIAL1, 0)},
262};
263
264static device_method_t ubsa_methods[] = {
265 DEVMETHOD(device_probe, ubsa_probe),
266 DEVMETHOD(device_attach, ubsa_attach),
267 DEVMETHOD(device_detach, ubsa_detach),
265 {0, 0}
268 DEVMETHOD(device_free_softc, ubsa_free_softc),
269 DEVMETHOD_END
266};
267
268static devclass_t ubsa_devclass;
269
270static driver_t ubsa_driver = {
271 .name = "ubsa",
272 .methods = ubsa_methods,
273 .size = sizeof(struct ubsa_softc),

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

301 struct usb_attach_arg *uaa = device_get_ivars(dev);
302 struct ubsa_softc *sc = device_get_softc(dev);
303 int error;
304
305 DPRINTF("sc=%p\n", sc);
306
307 device_set_usb_desc(dev);
308 mtx_init(&sc->sc_mtx, "ubsa", NULL, MTX_DEF);
270};
271
272static devclass_t ubsa_devclass;
273
274static driver_t ubsa_driver = {
275 .name = "ubsa",
276 .methods = ubsa_methods,
277 .size = sizeof(struct ubsa_softc),

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

305 struct usb_attach_arg *uaa = device_get_ivars(dev);
306 struct ubsa_softc *sc = device_get_softc(dev);
307 int error;
308
309 DPRINTF("sc=%p\n", sc);
310
311 device_set_usb_desc(dev);
312 mtx_init(&sc->sc_mtx, "ubsa", NULL, MTX_DEF);
313 ucom_ref(&sc->sc_super_ucom);
309
310 sc->sc_udev = uaa->device;
311 sc->sc_iface_no = uaa->info.bIfaceNum;
312 sc->sc_iface_index = UBSA_IFACE_INDEX;
313
314 error = usbd_transfer_setup(uaa->device, &sc->sc_iface_index,
315 sc->sc_xfer, ubsa_config, UBSA_N_TRANSFER, sc, &sc->sc_mtx);
316

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

343ubsa_detach(device_t dev)
344{
345 struct ubsa_softc *sc = device_get_softc(dev);
346
347 DPRINTF("sc=%p\n", sc);
348
349 ucom_detach(&sc->sc_super_ucom, &sc->sc_ucom);
350 usbd_transfer_unsetup(sc->sc_xfer, UBSA_N_TRANSFER);
314
315 sc->sc_udev = uaa->device;
316 sc->sc_iface_no = uaa->info.bIfaceNum;
317 sc->sc_iface_index = UBSA_IFACE_INDEX;
318
319 error = usbd_transfer_setup(uaa->device, &sc->sc_iface_index,
320 sc->sc_xfer, ubsa_config, UBSA_N_TRANSFER, sc, &sc->sc_mtx);
321

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

348ubsa_detach(device_t dev)
349{
350 struct ubsa_softc *sc = device_get_softc(dev);
351
352 DPRINTF("sc=%p\n", sc);
353
354 ucom_detach(&sc->sc_super_ucom, &sc->sc_ucom);
355 usbd_transfer_unsetup(sc->sc_xfer, UBSA_N_TRANSFER);
351 mtx_destroy(&sc->sc_mtx);
352
353 return (0);
354}
355
356
357 return (0);
358}
359
360UCOM_UNLOAD_DRAIN(ubsa);
361
356static void
362static void
363ubsa_free_softc(device_t dev, void *arg)
364{
365 struct ubsa_softc *sc = arg;
366
367 if (ucom_unref(&sc->sc_super_ucom)) {
368 if (mtx_initialized(&sc->sc_mtx))
369 mtx_destroy(&sc->sc_mtx);
370 device_free_softc(dev, sc);
371 }
372}
373
374static void
375ubsa_free(struct ucom_softc *ucom)
376{
377 ubsa_free_softc(NULL, ucom->sc_parent);
378}
379
380static void
357ubsa_cfg_request(struct ubsa_softc *sc, uint8_t index, uint16_t value)
358{
359 struct usb_device_request req;
360 usb_error_t err;
361
362 req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
363 req.bRequest = index;
364 USETW(req.wValue, value);

--- 308 unchanged lines hidden ---
381ubsa_cfg_request(struct ubsa_softc *sc, uint8_t index, uint16_t value)
382{
383 struct usb_device_request req;
384 usb_error_t err;
385
386 req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
387 req.bRequest = index;
388 USETW(req.wValue, value);

--- 308 unchanged lines hidden ---