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 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> |
112#include <sys/jail.h> |
113#include <sys/priv.h> |
114#include <sys/proc.h> |
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> |
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; |
493 CURVNET_SET(TD_TO_VNET(curthread)); |
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(); |
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(); |
509 return (ENXIO); 510 } 511 NG_NODE_SET_PRIVATE(sc->sc_node, sc); 512 NG_NODE_FORCE_WRITER(sc->sc_node); |
513 CURVNET_RESTORE(); |
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); |
641 NG_NODE_REALLY_DIE(node); 642 ng_rmnode_self(node); |
643 CURVNET_RESTORE(); |
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 --- |