MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / rt_ahci_host_unregister

Function rt_ahci_host_unregister

components/drivers/ata/ahci.c:854–896  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

852}
853
854rt_err_t rt_ahci_host_unregister(struct rt_ahci_host *host)
855{
856 rt_err_t err;
857 struct rt_scsi_host *scsi;
858
859 if (!host)
860 {
861 return -RT_EINVAL;
862 }
863
864 scsi = &host->parent;
865
866 if ((err = rt_scsi_host_unregister(scsi)))
867 {
868 return err;
869 }
870
871 rt_hw_interrupt_mask(host->irq);
872 rt_pic_detach_irq(host->irq, host);
873
874 for (int i = 0; i < host->ports_nr; ++i)
875 {
876 struct rt_ahci_port *port = &host->ports[i];
877
878 if (port->ataid)
879 {
880 rt_free(port->ataid);
881 }
882
883 HWREG32(port->regs) &= ~(RT_AHCI_PORT_CMD_ACTIVE | RT_AHCI_PORT_CMD_POWER_ON |
884 RT_AHCI_PORT_CMD_SPIN_UP | RT_AHCI_PORT_CMD_START);
885
886 if (port->dma)
887 {
888 rt_dma_free_coherent(host->parent.dev, RT_AHCI_DMA_SIZE, port->dma,
889 port->dma_handle);
890 }
891 }
892
893 HWREG32(host->regs + RT_AHCI_HBA_GHC) &= ~(RT_AHCI_GHC_AHCI_EN | RT_AHCI_GHC_IRQ_EN);
894
895 return RT_EOK;
896}

Callers 1

pci_ahci_removeFunction · 0.85

Calls 5

rt_scsi_host_unregisterFunction · 0.85
rt_pic_detach_irqFunction · 0.85
rt_freeFunction · 0.85
rt_dma_free_coherentFunction · 0.85
rt_hw_interrupt_maskFunction · 0.50

Tested by

no test coverage detected