Deleted Added
full compact
ng_ubt.c (249178) ng_ubt.c (253255)
1/*
2 * ng_ubt.c
3 */
4
5/*-
6 * Copyright (c) 2001-2009 Maksim Yevmenkin <m_evmenkin@yahoo.com>
7 * All rights reserved.
8 *

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

23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 *
30 * $Id: ng_ubt.c,v 1.16 2003/10/10 19:15:06 max Exp $
1/*
2 * ng_ubt.c
3 */
4
5/*-
6 * Copyright (c) 2001-2009 Maksim Yevmenkin <m_evmenkin@yahoo.com>
7 * All rights reserved.
8 *

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

23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 *
30 * $Id: ng_ubt.c,v 1.16 2003/10/10 19:15:06 max Exp $
31 * $FreeBSD: head/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c 249178 2013-04-05 23:41:38Z adrian $
31 * $FreeBSD: head/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c 253255 2013-07-12 08:03:10Z rodrigc $
32 */
33
34/*
35 * NOTE: ng_ubt2 driver has a split personality. On one side it is
36 * a USB device driver and on the other it is a Netgraph node. This
37 * driver will *NOT* create traditional /dev/ enties, only Netgraph
38 * node.
39 *

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

104#include <sys/lock.h>
105#include <sys/mutex.h>
106#include <sys/condvar.h>
107#include <sys/sysctl.h>
108#include <sys/sx.h>
109#include <sys/unistd.h>
110#include <sys/callout.h>
111#include <sys/malloc.h>
32 */
33
34/*
35 * NOTE: ng_ubt2 driver has a split personality. On one side it is
36 * a USB device driver and on the other it is a Netgraph node. This
37 * driver will *NOT* create traditional /dev/ enties, only Netgraph
38 * node.
39 *

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

104#include <sys/lock.h>
105#include <sys/mutex.h>
106#include <sys/condvar.h>
107#include <sys/sysctl.h>
108#include <sys/sx.h>
109#include <sys/unistd.h>
110#include <sys/callout.h>
111#include <sys/malloc.h>
112#include <sys/jail.h>
112#include <sys/priv.h>
113#include <sys/priv.h>
114#include <sys/proc.h>
113
114#include "usbdevs.h"
115#include <dev/usb/usb.h>
116#include <dev/usb/usbdi.h>
117#include <dev/usb/usbdi_util.h>
118
119#define USB_DEBUG_VAR usb_debug
120#include <dev/usb/usb_debug.h>
121#include <dev/usb/usb_busdma.h>
122
123#include <sys/mbuf.h>
124#include <sys/taskqueue.h>
125
115
116#include "usbdevs.h"
117#include <dev/usb/usb.h>
118#include <dev/usb/usbdi.h>
119#include <dev/usb/usbdi_util.h>
120
121#define USB_DEBUG_VAR usb_debug
122#include <dev/usb/usb_debug.h>
123#include <dev/usb/usb_busdma.h>
124
125#include <sys/mbuf.h>
126#include <sys/taskqueue.h>
127
128#include <net/vnet.h>
126#include <netgraph/ng_message.h>
127#include <netgraph/netgraph.h>
128#include <netgraph/ng_parse.h>
129#include <netgraph/bluetooth/include/ng_bluetooth.h>
130#include <netgraph/bluetooth/include/ng_hci.h>
131#include <netgraph/bluetooth/include/ng_ubt.h>
132#include <netgraph/bluetooth/drivers/ubt/ng_ubt_var.h>
133

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

482 uint16_t wMaxPacketSize;
483 uint8_t alt_index, i, j;
484 uint8_t iface_index[2] = { 0, 1 };
485
486 device_set_usb_desc(dev);
487
488 sc->sc_dev = dev;
489 sc->sc_debug = NG_UBT_WARN_LEVEL;
129#include <netgraph/ng_message.h>
130#include <netgraph/netgraph.h>
131#include <netgraph/ng_parse.h>
132#include <netgraph/bluetooth/include/ng_bluetooth.h>
133#include <netgraph/bluetooth/include/ng_hci.h>
134#include <netgraph/bluetooth/include/ng_ubt.h>
135#include <netgraph/bluetooth/drivers/ubt/ng_ubt_var.h>
136

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

485 uint16_t wMaxPacketSize;
486 uint8_t alt_index, i, j;
487 uint8_t iface_index[2] = { 0, 1 };
488
489 device_set_usb_desc(dev);
490
491 sc->sc_dev = dev;
492 sc->sc_debug = NG_UBT_WARN_LEVEL;
490
493 CURVNET_SET(TD_TO_VNET(curthread));
491 /*
492 * Create Netgraph node
493 */
494
495 if (ng_make_node_common(&typestruct, &sc->sc_node) != 0) {
496 UBT_ALERT(sc, "could not create Netgraph node\n");
494 /*
495 * Create Netgraph node
496 */
497
498 if (ng_make_node_common(&typestruct, &sc->sc_node) != 0) {
499 UBT_ALERT(sc, "could not create Netgraph node\n");
500 CURVNET_RESTORE();
497 return (ENXIO);
498 }
499
500 /* Name Netgraph node */
501 if (ng_name_node(sc->sc_node, device_get_nameunit(dev)) != 0) {
502 UBT_ALERT(sc, "could not name Netgraph node\n");
503 NG_NODE_UNREF(sc->sc_node);
501 return (ENXIO);
502 }
503
504 /* Name Netgraph node */
505 if (ng_name_node(sc->sc_node, device_get_nameunit(dev)) != 0) {
506 UBT_ALERT(sc, "could not name Netgraph node\n");
507 NG_NODE_UNREF(sc->sc_node);
508 CURVNET_RESTORE();
504 return (ENXIO);
505 }
506 NG_NODE_SET_PRIVATE(sc->sc_node, sc);
507 NG_NODE_FORCE_WRITER(sc->sc_node);
509 return (ENXIO);
510 }
511 NG_NODE_SET_PRIVATE(sc->sc_node, sc);
512 NG_NODE_FORCE_WRITER(sc->sc_node);
513 CURVNET_RESTORE();
508
509 /*
510 * Initialize device softc structure
511 */
512
513 /* initialize locks */
514 mtx_init(&sc->sc_ng_mtx, "ubt ng", NULL, MTX_DEF);
515 mtx_init(&sc->sc_if_mtx, "ubt if", NULL, MTX_DEF | MTX_RECURSE);

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

626ubt_detach(device_t dev)
627{
628 struct ubt_softc *sc = device_get_softc(dev);
629 node_p node = sc->sc_node;
630
631 /* Destroy Netgraph node */
632 if (node != NULL) {
633 sc->sc_node = NULL;
514
515 /*
516 * Initialize device softc structure
517 */
518
519 /* initialize locks */
520 mtx_init(&sc->sc_ng_mtx, "ubt ng", NULL, MTX_DEF);
521 mtx_init(&sc->sc_if_mtx, "ubt if", NULL, MTX_DEF | MTX_RECURSE);

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

632ubt_detach(device_t dev)
633{
634 struct ubt_softc *sc = device_get_softc(dev);
635 node_p node = sc->sc_node;
636
637 /* Destroy Netgraph node */
638 if (node != NULL) {
639 sc->sc_node = NULL;
640 CURVNET_SET(node->nd_vnet);
634 NG_NODE_REALLY_DIE(node);
635 ng_rmnode_self(node);
641 NG_NODE_REALLY_DIE(node);
642 ng_rmnode_self(node);
643 CURVNET_RESTORE();
636 }
637
638 /* Make sure ubt_task in gone */
639 taskqueue_drain(taskqueue_swi, &sc->sc_task);
640
641 /* Free USB transfers, if any */
642 usbd_transfer_unsetup(sc->sc_xfer, UBT_N_TRANSFER);
643

--- 1174 unchanged lines hidden ---
644 }
645
646 /* Make sure ubt_task in gone */
647 taskqueue_drain(taskqueue_swi, &sc->sc_task);
648
649 /* Free USB transfers, if any */
650 usbd_transfer_unsetup(sc->sc_xfer, UBT_N_TRANSFER);
651

--- 1174 unchanged lines hidden ---