ucycom.c (239181) | ucycom.c (239299) |
---|---|
1#include <sys/cdefs.h> | 1#include <sys/cdefs.h> |
2__FBSDID("$FreeBSD: head/sys/dev/usb/serial/ucycom.c 239181 2012-08-10 17:42:14Z hselasky $"); | 2__FBSDID("$FreeBSD: head/sys/dev/usb/serial/ucycom.c 239299 2012-08-15 15:42:57Z hselasky $"); |
3 4/*- 5 * Copyright (c) 2004 Dag-Erling Co��dan Sm��rgrav 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: --- 94 unchanged lines hidden (view full) --- 105 uint8_t sc_temp_cfg[32]; 106}; 107 108/* prototypes */ 109 110static device_probe_t ucycom_probe; 111static device_attach_t ucycom_attach; 112static device_detach_t ucycom_detach; | 3 4/*- 5 * Copyright (c) 2004 Dag-Erling Co��dan Sm��rgrav 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: --- 94 unchanged lines hidden (view full) --- 105 uint8_t sc_temp_cfg[32]; 106}; 107 108/* prototypes */ 109 110static device_probe_t ucycom_probe; 111static device_attach_t ucycom_attach; 112static device_detach_t ucycom_detach; |
113static device_free_softc_t ucycom_free_softc; | 113static void ucycom_free_softc(struct ucycom_softc *); |
114 115static usb_callback_t ucycom_ctrl_write_callback; 116static usb_callback_t ucycom_intr_read_callback; 117 118static void ucycom_free(struct ucom_softc *); 119static void ucycom_cfg_open(struct ucom_softc *); 120static void ucycom_start_read(struct ucom_softc *); 121static void ucycom_stop_read(struct ucom_softc *); --- 36 unchanged lines hidden (view full) --- 158 .ucom_poll = &ucycom_poll, 159 .ucom_free = &ucycom_free, 160}; 161 162static device_method_t ucycom_methods[] = { 163 DEVMETHOD(device_probe, ucycom_probe), 164 DEVMETHOD(device_attach, ucycom_attach), 165 DEVMETHOD(device_detach, ucycom_detach), | 114 115static usb_callback_t ucycom_ctrl_write_callback; 116static usb_callback_t ucycom_intr_read_callback; 117 118static void ucycom_free(struct ucom_softc *); 119static void ucycom_cfg_open(struct ucom_softc *); 120static void ucycom_start_read(struct ucom_softc *); 121static void ucycom_stop_read(struct ucom_softc *); --- 36 unchanged lines hidden (view full) --- 158 .ucom_poll = &ucycom_poll, 159 .ucom_free = &ucycom_free, 160}; 161 162static device_method_t ucycom_methods[] = { 163 DEVMETHOD(device_probe, ucycom_probe), 164 DEVMETHOD(device_attach, ucycom_attach), 165 DEVMETHOD(device_detach, ucycom_detach), |
166 DEVMETHOD(device_free_softc, ucycom_free_softc), | |
167 DEVMETHOD_END 168}; 169 170static devclass_t ucycom_devclass; 171 172static driver_t ucycom_driver = { 173 .name = "ucycom", 174 .methods = ucycom_methods, --- 119 unchanged lines hidden (view full) --- 294static int 295ucycom_detach(device_t dev) 296{ 297 struct ucycom_softc *sc = device_get_softc(dev); 298 299 ucom_detach(&sc->sc_super_ucom, &sc->sc_ucom); 300 usbd_transfer_unsetup(sc->sc_xfer, UCYCOM_N_TRANSFER); 301 | 166 DEVMETHOD_END 167}; 168 169static devclass_t ucycom_devclass; 170 171static driver_t ucycom_driver = { 172 .name = "ucycom", 173 .methods = ucycom_methods, --- 119 unchanged lines hidden (view full) --- 293static int 294ucycom_detach(device_t dev) 295{ 296 struct ucycom_softc *sc = device_get_softc(dev); 297 298 ucom_detach(&sc->sc_super_ucom, &sc->sc_ucom); 299 usbd_transfer_unsetup(sc->sc_xfer, UCYCOM_N_TRANSFER); 300 |
301 device_claim_softc(dev); 302 303 ucycom_free_softc(sc); 304 |
|
302 return (0); 303} 304 305UCOM_UNLOAD_DRAIN(ucycom); 306 307static void | 305 return (0); 306} 307 308UCOM_UNLOAD_DRAIN(ucycom); 309 310static void |
308ucycom_free_softc(device_t dev, void *arg) | 311ucycom_free_softc(struct ucycom_softc *sc) |
309{ | 312{ |
310 struct ucycom_softc *sc = arg; 311 | |
312 if (ucom_unref(&sc->sc_super_ucom)) { | 313 if (ucom_unref(&sc->sc_super_ucom)) { |
313 if (mtx_initialized(&sc->sc_mtx)) 314 mtx_destroy(&sc->sc_mtx); 315 device_free_softc(dev, sc); | 314 mtx_destroy(&sc->sc_mtx); 315 device_free_softc(sc); |
316 } 317} 318 319static void 320ucycom_free(struct ucom_softc *ucom) 321{ | 316 } 317} 318 319static void 320ucycom_free(struct ucom_softc *ucom) 321{ |
322 ucycom_free_softc(NULL, ucom->sc_parent); | 322 ucycom_free_softc(ucom->sc_parent); |
323} 324 325static void 326ucycom_cfg_open(struct ucom_softc *ucom) 327{ 328 struct ucycom_softc *sc = ucom->sc_parent; 329 330 /* set default configuration */ --- 281 unchanged lines hidden --- | 323} 324 325static void 326ucycom_cfg_open(struct ucom_softc *ucom) 327{ 328 struct ucycom_softc *sc = ucom->sc_parent; 329 330 /* set default configuration */ --- 281 unchanged lines hidden --- |