static void brcmf_usb_disconnect_cb(struct brcmf_usbdev_info *devinfo) { if (!devinfo) return; brcmf_dbg(USB, "Enter, bus_pub %p\n", devinfo); brcmf_detach(devinfo->dev); kfree(devinfo->bus_pub.bus); brcmf_usb_detach(devinfo); }
static void brcmf_usb_disconnect_cb(struct brcmf_usbdev *bus_pub) { if (!bus_pub) return; brcmf_dbg(TRACE, "enter: bus_pub %p\n", bus_pub); brcmf_detach(bus_pub->devinfo->dev); kfree(bus_pub->bus); brcmf_usb_detach(bus_pub); }
static int brcmf_usb_probe_cb(struct device *dev, const char *desc, u32 bustype, u32 hdrlen) { struct brcmf_bus *bus = NULL; struct brcmf_usbdev *bus_pub = NULL; int ret; bus_pub = brcmf_usb_attach(BRCMF_USB_NRXQ, BRCMF_USB_NTXQ, dev); if (!bus_pub) { ret = -ENODEV; goto fail; } bus = kzalloc(sizeof(struct brcmf_bus), GFP_ATOMIC); if (!bus) { ret = -ENOMEM; goto fail; } bus_pub->bus = bus; bus->brcmf_bus_txdata = brcmf_usb_tx; bus->brcmf_bus_init = brcmf_usb_up; bus->brcmf_bus_stop = brcmf_usb_down; bus->brcmf_bus_txctl = brcmf_usb_tx_ctlpkt; bus->brcmf_bus_rxctl = brcmf_usb_rx_ctlpkt; bus->type = bustype; bus->bus_priv.usb = bus_pub; dev_set_drvdata(dev, bus); /* Attach to the common driver interface */ ret = brcmf_attach(hdrlen, dev); if (ret) { brcmf_dbg(ERROR, "dhd_attach failed\n"); goto fail; } ret = brcmf_bus_start(dev); if (ret == -ENOLINK) { brcmf_dbg(ERROR, "dongle is not responding\n"); brcmf_detach(dev); goto fail; } return 0; fail: /* Release resources in reverse order */ if (bus_pub) brcmf_usb_detach(bus_pub); kfree(bus); return ret; }
/* * only need to signal the bus being down and update the state. */ static int brcmf_usb_suspend(struct usb_interface *intf, pm_message_t state) { struct usb_device *usb = interface_to_usbdev(intf); struct brcmf_usbdev_info *devinfo = brcmf_usb_get_businfo(&usb->dev); brcmf_dbg(USB, "Enter\n"); devinfo->bus_pub.state = BRCMFMAC_USB_STATE_SLEEP; if (devinfo->wowl_enabled) brcmf_cancel_all_urbs(devinfo); else brcmf_detach(&usb->dev); return 0; }
int brcmf_attach(struct device *dev, struct brcmf_mp_device *settings) { struct brcmf_pub *drvr = NULL; int ret = 0; int i; brcmf_dbg(TRACE, "Enter\n"); /* Allocate primary brcmf_info */ drvr = kzalloc(sizeof(struct brcmf_pub), GFP_ATOMIC); if (!drvr) return -ENOMEM; for (i = 0; i < ARRAY_SIZE(drvr->if2bss); i++) drvr->if2bss[i] = BRCMF_BSSIDX_INVALID; mutex_init(&drvr->proto_block); /* Link to bus module */ drvr->hdrlen = 0; drvr->bus_if = dev_get_drvdata(dev); drvr->bus_if->drvr = drvr; drvr->settings = settings; /* attach debug facilities */ brcmf_debug_attach(drvr); /* Attach and link in the protocol */ ret = brcmf_proto_attach(drvr); if (ret != 0) { brcmf_err("brcmf_prot_attach failed\n"); goto fail; } /* attach firmware event handler */ brcmf_fweh_attach(drvr); return ret; fail: brcmf_detach(dev); return ret; }
static void brcmf_pcie_remove(struct pci_dev *pdev) { struct brcmf_pciedev_info *devinfo; struct brcmf_bus *bus; brcmf_dbg(PCIE, "Enter\n"); bus = dev_get_drvdata(&pdev->dev); if (bus == NULL) return; devinfo = bus->bus_priv.pcie->devinfo; devinfo->state = BRCMFMAC_PCIE_STATE_DOWN; if (devinfo->ci) brcmf_pcie_intr_disable(devinfo); brcmf_detach(&pdev->dev); kfree(bus->bus_priv.pcie); kfree(bus->msgbuf->flowrings); kfree(bus->msgbuf); kfree(bus); brcmf_pcie_release_irq(devinfo); brcmf_pcie_release_scratchbuffers(devinfo); brcmf_pcie_release_ringbuffers(devinfo); brcmf_pcie_reset_device(devinfo); brcmf_pcie_release_resource(devinfo); if (devinfo->ci) brcmf_chip_detach(devinfo->ci); kfree(devinfo); dev_set_drvdata(&pdev->dev, NULL); }
static int brcmf_usb_bus_setup(struct brcmf_usbdev_info *devinfo) { int ret; /* Attach to the common driver interface */ ret = brcmf_attach(devinfo->dev); if (ret) { brcmf_err("brcmf_attach failed\n"); return ret; } ret = brcmf_usb_up(devinfo->dev); if (ret) goto fail; ret = brcmf_bus_start(devinfo->dev); if (ret) goto fail; return 0; fail: brcmf_detach(devinfo->dev); return ret; }