I'm very new to linux device drivers and currently working on USB driver currently. I need to make USB related drivers as loadable modules and remove/re-insert them on will. But I'm facing certain issues.I'm working on Dragonboard 820 based on Qualcomm Snapdragon 820 processor(APQ8096).
Linux Kernel Version: 3.18.20
Android Version: 6.0
Insertion of drivers work first time.Here is the order of insertion.
insmod dbm.ko
insmod dbm-1_4.ko
insmod dbm-1_5.ko
insmod dwc3.ko
insmod dwc3-msm.ko
insmod dwc3-pci.ko
insmod ehci-hcd.ko
insmod ehci-pci.ko
insmod xhci-hcd.ko
insmod xhci-pci.ko
insmod xhci-plat-hcd.ko
insmod phy-msm-ssusb-qmp.ko
insmod phy-msm-qusb.ko
insmod usb-storage.ko
'lsmod' gives the following output;
root@msm8996:/system/lib/modules # lsmod
Module Size Used by
usb_storage 55391 0
phy_msm_qusb 18820 4
phy_msm_ssusb_qmp 17033 2
xhci_plat_hcd 6509 0
xhci_pci 4916 0
xhci_hcd 158558 2 xhci_plat_hcd,xhci_pci,[permanent]
ehci_pci 4594 0
ehci_hcd 69125 1 ehci_pci
dwc3_pci 2890 0
dwc3_msm 50671 0
dwc3 237561 1 dwc3_msm
dbm_1_5 6526 0
dbm_1_4 6197 0
dbm 2119 3 dwc3_msm,dbm_1_5,dbm_1_4
USB works well after insertion.However while trying to remove the drivers (in the reverse order),three drivers -phy_msm_qusb,phy_msm_ssusb_qmp and xhci_hcd aren't removed and re-insertion of other drivers crashes (while re-inserting xhci_plat_hcd). If I do a forced removal of those drivers, it is highly unstable and crashes either at removal of remaining drivers or while re-inserting. So, if anyone has any input on this - that's highly appreciated.