Deleted Added
full compact
u3g.c (239182) u3g.c (239299)
1/*
2 * Copyright (c) 2008 AnyWi Technologies
3 * Author: Andrea Guzzo <aguzzo@anywi.com>
4 * * based on uark.c 1.1 2006/08/14 08:30:22 jsg *
5 * * parts from ubsa.c 183348 2008-09-25 12:00:56Z phk *
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.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 *
1/*
2 * Copyright (c) 2008 AnyWi Technologies
3 * Author: Andrea Guzzo <aguzzo@anywi.com>
4 * * based on uark.c 1.1 2006/08/14 08:30:22 jsg *
5 * * parts from ubsa.c 183348 2008-09-25 12:00:56Z phk *
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.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 *
19 * $FreeBSD: head/sys/dev/usb/serial/u3g.c 239182 2012-08-10 17:43:20Z hselasky $
19 * $FreeBSD: head/sys/dev/usb/serial/u3g.c 239299 2012-08-15 15:42:57Z hselasky $
20 */
21
22/*
23 * NOTE:
24 *
25 * - The detour through the tty layer is ridiculously expensive wrt
26 * buffering due to the high speeds.
27 *

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

113 uint8_t sc_lsr; /* local status register */
114 uint8_t sc_msr; /* U3G status register */
115 uint8_t sc_numports;
116};
117
118static device_probe_t u3g_probe;
119static device_attach_t u3g_attach;
120static device_detach_t u3g_detach;
20 */
21
22/*
23 * NOTE:
24 *
25 * - The detour through the tty layer is ridiculously expensive wrt
26 * buffering due to the high speeds.
27 *

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

113 uint8_t sc_lsr; /* local status register */
114 uint8_t sc_msr; /* U3G status register */
115 uint8_t sc_numports;
116};
117
118static device_probe_t u3g_probe;
119static device_attach_t u3g_attach;
120static device_detach_t u3g_detach;
121static device_free_softc_t u3g_free_softc;
121static void u3g_free_softc(struct u3g_softc *);
122
123static usb_callback_t u3g_write_callback;
124static usb_callback_t u3g_read_callback;
125
126static void u3g_free(struct ucom_softc *ucom);
127static void u3g_start_read(struct ucom_softc *ucom);
128static void u3g_stop_read(struct ucom_softc *ucom);
129static void u3g_start_write(struct ucom_softc *ucom);

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

164 .ucom_stop_write = &u3g_stop_write,
165 .ucom_free = &u3g_free,
166};
167
168static device_method_t u3g_methods[] = {
169 DEVMETHOD(device_probe, u3g_probe),
170 DEVMETHOD(device_attach, u3g_attach),
171 DEVMETHOD(device_detach, u3g_detach),
122
123static usb_callback_t u3g_write_callback;
124static usb_callback_t u3g_read_callback;
125
126static void u3g_free(struct ucom_softc *ucom);
127static void u3g_start_read(struct ucom_softc *ucom);
128static void u3g_stop_read(struct ucom_softc *ucom);
129static void u3g_start_write(struct ucom_softc *ucom);

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

164 .ucom_stop_write = &u3g_stop_write,
165 .ucom_free = &u3g_free,
166};
167
168static device_method_t u3g_methods[] = {
169 DEVMETHOD(device_probe, u3g_probe),
170 DEVMETHOD(device_attach, u3g_attach),
171 DEVMETHOD(device_detach, u3g_detach),
172 DEVMETHOD(device_free_softc, u3g_free_softc),
173 DEVMETHOD_END
174};
175
176static devclass_t u3g_devclass;
177
178static driver_t u3g_driver = {
179 .name = "u3g",
180 .methods = u3g_methods,

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

893 DPRINTF("sc=%p\n", sc);
894
895 /* NOTE: It is not dangerous to detach more ports than attached! */
896 ucom_detach(&sc->sc_super_ucom, sc->sc_ucom);
897
898 for (subunit = 0; subunit != U3G_MAXPORTS; subunit++)
899 usbd_transfer_unsetup(sc->sc_xfer[subunit], U3G_N_TRANSFER);
900
172 DEVMETHOD_END
173};
174
175static devclass_t u3g_devclass;
176
177static driver_t u3g_driver = {
178 .name = "u3g",
179 .methods = u3g_methods,

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

892 DPRINTF("sc=%p\n", sc);
893
894 /* NOTE: It is not dangerous to detach more ports than attached! */
895 ucom_detach(&sc->sc_super_ucom, sc->sc_ucom);
896
897 for (subunit = 0; subunit != U3G_MAXPORTS; subunit++)
898 usbd_transfer_unsetup(sc->sc_xfer[subunit], U3G_N_TRANSFER);
899
900 device_claim_softc(dev);
901
902 u3g_free_softc(sc);
903
901 return (0);
902}
903
904UCOM_UNLOAD_DRAIN(u3g);
905
906static void
904 return (0);
905}
906
907UCOM_UNLOAD_DRAIN(u3g);
908
909static void
907u3g_free_softc(device_t dev, void *arg)
910u3g_free_softc(struct u3g_softc *sc)
908{
911{
909 struct u3g_softc *sc = arg;
910
911 if (ucom_unref(&sc->sc_super_ucom)) {
912 if (ucom_unref(&sc->sc_super_ucom)) {
912 if (mtx_initialized(&sc->sc_mtx))
913 mtx_destroy(&sc->sc_mtx);
914 device_free_softc(dev, sc);
913 mtx_destroy(&sc->sc_mtx);
914 device_free_softc(sc);
915 }
916}
917
918static void
919u3g_free(struct ucom_softc *ucom)
920{
915 }
916}
917
918static void
919u3g_free(struct ucom_softc *ucom)
920{
921 u3g_free_softc(NULL, ucom->sc_parent);
921 u3g_free_softc(ucom->sc_parent);
922}
923
924static void
925u3g_start_read(struct ucom_softc *ucom)
926{
927 struct u3g_softc *sc = ucom->sc_parent;
928
929 /* start read endpoint */

--- 85 unchanged lines hidden ---
922}
923
924static void
925u3g_start_read(struct ucom_softc *ucom)
926{
927 struct u3g_softc *sc = ucom->sc_parent;
928
929 /* start read endpoint */

--- 85 unchanged lines hidden ---