ufoma.c (239181) | ufoma.c (239299) |
---|---|
1/* $NetBSD: umodem.c,v 1.45 2002/09/23 05:51:23 simonb Exp $ */ 2 3#include <sys/cdefs.h> | 1/* $NetBSD: umodem.c,v 1.45 2002/09/23 05:51:23 simonb Exp $ */ 2 3#include <sys/cdefs.h> |
4__FBSDID("$FreeBSD: head/sys/dev/usb/serial/ufoma.c 239181 2012-08-10 17:42:14Z hselasky $"); | 4__FBSDID("$FreeBSD: head/sys/dev/usb/serial/ufoma.c 239299 2012-08-15 15:42:57Z hselasky $"); |
5#define UFOMA_HANDSFREE 6/*- 7 * Copyright (c) 2005, Takanori Watanabe 8 * Copyright (c) 2003, M. Warner Losh <imp@FreeBSD.org>. 9 * All rights reserved. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions --- 184 unchanged lines hidden (view full) --- 197 uint8_t sc_currentmode; 198}; 199 200/* prototypes */ 201 202static device_probe_t ufoma_probe; 203static device_attach_t ufoma_attach; 204static device_detach_t ufoma_detach; | 5#define UFOMA_HANDSFREE 6/*- 7 * Copyright (c) 2005, Takanori Watanabe 8 * Copyright (c) 2003, M. Warner Losh <imp@FreeBSD.org>. 9 * All rights reserved. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions --- 184 unchanged lines hidden (view full) --- 197 uint8_t sc_currentmode; 198}; 199 200/* prototypes */ 201 202static device_probe_t ufoma_probe; 203static device_attach_t ufoma_attach; 204static device_detach_t ufoma_detach; |
205static device_free_softc_t ufoma_free_softc; | 205static void ufoma_free_softc(struct ufoma_softc *); |
206 207static usb_callback_t ufoma_ctrl_read_callback; 208static usb_callback_t ufoma_ctrl_write_callback; 209static usb_callback_t ufoma_intr_callback; 210static usb_callback_t ufoma_bulk_write_callback; 211static usb_callback_t ufoma_bulk_read_callback; 212 213static void *ufoma_get_intconf(struct usb_config_descriptor *, --- 94 unchanged lines hidden (view full) --- 308 .ucom_free = &ufoma_free, 309}; 310 311static device_method_t ufoma_methods[] = { 312 /* Device methods */ 313 DEVMETHOD(device_probe, ufoma_probe), 314 DEVMETHOD(device_attach, ufoma_attach), 315 DEVMETHOD(device_detach, ufoma_detach), | 206 207static usb_callback_t ufoma_ctrl_read_callback; 208static usb_callback_t ufoma_ctrl_write_callback; 209static usb_callback_t ufoma_intr_callback; 210static usb_callback_t ufoma_bulk_write_callback; 211static usb_callback_t ufoma_bulk_read_callback; 212 213static void *ufoma_get_intconf(struct usb_config_descriptor *, --- 94 unchanged lines hidden (view full) --- 308 .ucom_free = &ufoma_free, 309}; 310 311static device_method_t ufoma_methods[] = { 312 /* Device methods */ 313 DEVMETHOD(device_probe, ufoma_probe), 314 DEVMETHOD(device_attach, ufoma_attach), 315 DEVMETHOD(device_detach, ufoma_detach), |
316 DEVMETHOD(device_free_softc, ufoma_free_softc), | |
317 DEVMETHOD_END 318}; 319 320static devclass_t ufoma_devclass; 321 322static driver_t ufoma_driver = { 323 .name = "ufoma", 324 .methods = ufoma_methods, --- 168 unchanged lines hidden (view full) --- 493 usbd_transfer_unsetup(sc->sc_ctrl_xfer, UFOMA_CTRL_ENDPT_MAX); 494 usbd_transfer_unsetup(sc->sc_bulk_xfer, UFOMA_BULK_ENDPT_MAX); 495 496 if (sc->sc_modetable) { 497 free(sc->sc_modetable, M_USBDEV); 498 } 499 cv_destroy(&sc->sc_cv); 500 | 316 DEVMETHOD_END 317}; 318 319static devclass_t ufoma_devclass; 320 321static driver_t ufoma_driver = { 322 .name = "ufoma", 323 .methods = ufoma_methods, --- 168 unchanged lines hidden (view full) --- 492 usbd_transfer_unsetup(sc->sc_ctrl_xfer, UFOMA_CTRL_ENDPT_MAX); 493 usbd_transfer_unsetup(sc->sc_bulk_xfer, UFOMA_BULK_ENDPT_MAX); 494 495 if (sc->sc_modetable) { 496 free(sc->sc_modetable, M_USBDEV); 497 } 498 cv_destroy(&sc->sc_cv); 499 |
500 device_claim_softc(dev); 501 502 ufoma_free_softc(sc); 503 |
|
501 return (0); 502} 503 504UCOM_UNLOAD_DRAIN(ufoma); 505 506static void | 504 return (0); 505} 506 507UCOM_UNLOAD_DRAIN(ufoma); 508 509static void |
507ufoma_free_softc(device_t dev, void *arg) | 510ufoma_free_softc(struct ufoma_softc *sc) |
508{ | 511{ |
509 struct ufoma_softc *sc = arg; 510 | |
511 if (ucom_unref(&sc->sc_super_ucom)) { | 512 if (ucom_unref(&sc->sc_super_ucom)) { |
512 if (mtx_initialized(&sc->sc_mtx)) 513 mtx_destroy(&sc->sc_mtx); 514 device_free_softc(dev, sc); | 513 mtx_destroy(&sc->sc_mtx); 514 device_free_softc(sc); |
515 } 516} 517 518static void 519ufoma_free(struct ucom_softc *ucom) 520{ | 515 } 516} 517 518static void 519ufoma_free(struct ucom_softc *ucom) 520{ |
521 ufoma_free_softc(NULL, ucom->sc_parent); | 521 ufoma_free_softc(ucom->sc_parent); |
522} 523 524static void * 525ufoma_get_intconf(struct usb_config_descriptor *cd, struct usb_interface_descriptor *id, 526 uint8_t type, uint8_t subtype) 527{ 528 struct usb_descriptor *desc = (void *)id; 529 --- 751 unchanged lines hidden --- | 522} 523 524static void * 525ufoma_get_intconf(struct usb_config_descriptor *cd, struct usb_interface_descriptor *id, 526 uint8_t type, uint8_t subtype) 527{ 528 struct usb_descriptor *desc = (void *)id; 529 --- 751 unchanged lines hidden --- |