umoscom.c (239180) | umoscom.c (239299) |
---|---|
1/* $FreeBSD: head/sys/dev/usb/serial/umoscom.c 239180 2012-08-10 15:29:41Z hselasky $ */ | 1/* $FreeBSD: head/sys/dev/usb/serial/umoscom.c 239299 2012-08-15 15:42:57Z hselasky $ */ |
2/* $OpenBSD: umoscom.c,v 1.2 2006/10/26 06:02:43 jsg Exp $ */ 3 4/* 5 * Copyright (c) 2006 Jonathan Gray <jsg@openbsd.org> 6 * 7 * Permission to use, copy, modify, and distribute this software for any 8 * purpose with or without fee is hereby granted, provided that the above 9 * copyright notice and this permission notice appear in all copies. --- 174 unchanged lines hidden (view full) --- 184 uint8_t sc_lcr; 185}; 186 187/* prototypes */ 188 189static device_probe_t umoscom_probe; 190static device_attach_t umoscom_attach; 191static device_detach_t umoscom_detach; | 2/* $OpenBSD: umoscom.c,v 1.2 2006/10/26 06:02:43 jsg Exp $ */ 3 4/* 5 * Copyright (c) 2006 Jonathan Gray <jsg@openbsd.org> 6 * 7 * Permission to use, copy, modify, and distribute this software for any 8 * purpose with or without fee is hereby granted, provided that the above 9 * copyright notice and this permission notice appear in all copies. --- 174 unchanged lines hidden (view full) --- 184 uint8_t sc_lcr; 185}; 186 187/* prototypes */ 188 189static device_probe_t umoscom_probe; 190static device_attach_t umoscom_attach; 191static device_detach_t umoscom_detach; |
192static device_free_softc_t umoscom_free_softc; | 192static void umoscom_free_softc(struct umoscom_softc *); |
193 194static usb_callback_t umoscom_write_callback; 195static usb_callback_t umoscom_read_callback; 196static usb_callback_t umoscom_intr_callback; 197 198static void umoscom_free(struct ucom_softc *); 199static void umoscom_cfg_open(struct ucom_softc *); 200static void umoscom_cfg_close(struct ucom_softc *); --- 61 unchanged lines hidden (view full) --- 262 .ucom_poll = &umoscom_poll, 263 .ucom_free = &umoscom_free, 264}; 265 266static device_method_t umoscom_methods[] = { 267 DEVMETHOD(device_probe, umoscom_probe), 268 DEVMETHOD(device_attach, umoscom_attach), 269 DEVMETHOD(device_detach, umoscom_detach), | 193 194static usb_callback_t umoscom_write_callback; 195static usb_callback_t umoscom_read_callback; 196static usb_callback_t umoscom_intr_callback; 197 198static void umoscom_free(struct ucom_softc *); 199static void umoscom_cfg_open(struct ucom_softc *); 200static void umoscom_cfg_close(struct ucom_softc *); --- 61 unchanged lines hidden (view full) --- 262 .ucom_poll = &umoscom_poll, 263 .ucom_free = &umoscom_free, 264}; 265 266static device_method_t umoscom_methods[] = { 267 DEVMETHOD(device_probe, umoscom_probe), 268 DEVMETHOD(device_attach, umoscom_attach), 269 DEVMETHOD(device_detach, umoscom_detach), |
270 DEVMETHOD(device_free_softc, umoscom_free_softc), | |
271 DEVMETHOD_END 272}; 273 274static devclass_t umoscom_devclass; 275 276static driver_t umoscom_driver = { 277 .name = "umoscom", 278 .methods = umoscom_methods, --- 76 unchanged lines hidden (view full) --- 355static int 356umoscom_detach(device_t dev) 357{ 358 struct umoscom_softc *sc = device_get_softc(dev); 359 360 ucom_detach(&sc->sc_super_ucom, &sc->sc_ucom); 361 usbd_transfer_unsetup(sc->sc_xfer, UMOSCOM_N_TRANSFER); 362 | 270 DEVMETHOD_END 271}; 272 273static devclass_t umoscom_devclass; 274 275static driver_t umoscom_driver = { 276 .name = "umoscom", 277 .methods = umoscom_methods, --- 76 unchanged lines hidden (view full) --- 354static int 355umoscom_detach(device_t dev) 356{ 357 struct umoscom_softc *sc = device_get_softc(dev); 358 359 ucom_detach(&sc->sc_super_ucom, &sc->sc_ucom); 360 usbd_transfer_unsetup(sc->sc_xfer, UMOSCOM_N_TRANSFER); 361 |
362 device_claim_softc(dev); 363 364 umoscom_free_softc(sc); 365 |
|
363 return (0); 364} 365 366UCOM_UNLOAD_DRAIN(umoscom); 367 368static void | 366 return (0); 367} 368 369UCOM_UNLOAD_DRAIN(umoscom); 370 371static void |
369umoscom_free_softc(device_t dev, void *arg) | 372umoscom_free_softc(struct umoscom_softc *sc) |
370{ | 373{ |
371 struct umoscom_softc *sc = arg; 372 | |
373 if (ucom_unref(&sc->sc_super_ucom)) { | 374 if (ucom_unref(&sc->sc_super_ucom)) { |
374 if (mtx_initialized(&sc->sc_mtx)) 375 mtx_destroy(&sc->sc_mtx); 376 device_free_softc(dev, sc); | 375 mtx_destroy(&sc->sc_mtx); 376 device_free_softc(sc); |
377 } 378} 379 380static void 381umoscom_free(struct ucom_softc *ucom) 382{ | 377 } 378} 379 380static void 381umoscom_free(struct ucom_softc *ucom) 382{ |
383 umoscom_free_softc(NULL, ucom->sc_parent); | 383 umoscom_free_softc(ucom->sc_parent); |
384} 385 386static void 387umoscom_cfg_open(struct ucom_softc *ucom) 388{ 389 struct umoscom_softc *sc = ucom->sc_parent; 390 391 DPRINTF("\n"); --- 340 unchanged lines hidden --- | 384} 385 386static void 387umoscom_cfg_open(struct ucom_softc *ucom) 388{ 389 struct umoscom_softc *sc = ucom->sc_parent; 390 391 DPRINTF("\n"); --- 340 unchanged lines hidden --- |