static void r592_remove(struct pci_dev *pdev) { int error = 0; struct r592_device *dev = pci_get_drvdata(pdev); /* Stop the processing thread. That ensures that we won't take any more requests */ kthread_stop(dev->io_thread); r592_enable_device(dev, false); while (!error && dev->req) { dev->req->error = -ETIME; error = memstick_next_req(dev->host, &dev->req); } memstick_remove_host(dev->host); free_irq(dev->irq, dev); iounmap(dev->mmio); pci_release_regions(pdev); pci_disable_device(pdev); memstick_free_host(dev->host); if (dev->dummy_dma_page) pci_free_consistent(pdev, PAGE_SIZE, dev->dummy_dma_page, dev->dummy_dma_page_physical_address); }
static int rtsx_pci_ms_drv_remove(struct platform_device *pdev) { struct realtek_pci_ms *host = platform_get_drvdata(pdev); struct rtsx_pcr *pcr; struct memstick_host *msh; int rc; if (!host) return 0; pcr = host->pcr; pcr->slots[RTSX_MS_CARD].p_dev = NULL; pcr->slots[RTSX_MS_CARD].card_event = NULL; msh = host->msh; host->eject = true; mutex_lock(&host->host_mutex); if (host->req) { dev_dbg(&(pdev->dev), "%s: Controller removed during transfer\n", dev_name(&msh->dev)); rtsx_pci_complete_unfinished_transfer(pcr); host->req->error = -ENOMEDIUM; do { rc = memstick_next_req(msh, &host->req); if (!rc) host->req->error = -ENOMEDIUM; } while (!rc); } mutex_unlock(&host->host_mutex); memstick_remove_host(msh); memstick_free_host(msh); platform_set_drvdata(pdev, NULL); dev_dbg(&(pdev->dev), ": Realtek PCI-E Memstick controller has been removed\n"); return 0; }