My KEXT fails to unload, if USB device removed. Why?
My KEXT fails to unload, if USB device removed. Why?
- Subject: My KEXT fails to unload, if USB device removed. Why?
- From: "rohit dhamija" <email@hidden>
- Date: Thu, 8 Jun 2006 23:07:43 +0530
Dear All,
I am developing kernel extension , KEXT for my USB bulk type and
control type devices for Mac OS 10.4 PowerPC and Intel Mac.
I am encountering some issues while unloading the kext. The kext fails
to unload in a situation if I first remove the USB device and then try
to unload the KEXT.
Below are the two different scenerios:
Scene 1) I attach my USB Device, perform the operations on the device
and then unload the kext , (sudo kextunload -v myDriver.kext).
In the above case, the kext gets unloaded successfully without issues.
ioclasscount myDriver = 1 , before unloading the kext
and
ioclasscount myDriver = 0, after unloading the kext.
So this works perfectly. Now comes the next scenerio (the main issue )
Scene 2) I attach my USB device, perform some operations, and DETACH
the USB device and then try to "unload the kext". But this time the
kext fails to unload
ioclasscount myDriver = 1 before unloading
after detach and attach
ioclasscount myDriver = 2
and after trying to unload my kext, the class count remains the same.
//////
At implementation level ,
1. At probe::
IOService *myDriver::probe(IOService *provider, SInt32 *score)
I have implemented a singleton class that maintains list of IOUSBDevice*
and IOUSBInterface* correspoding to each device ( i did it because i
have multiple usb devices to support)
2. In order to receive message from my provider, myDriver implement message
IOReturn Sentinel::message(UInt32 type, IOService *provider, void *argument)
Under this, i capture the device removal situation,
kIOMessageServiceIsTerminated case,get called up when the device has
been removed. So I close and release the IOUSBDevice* and
IOUSBInterface* under this case corresponding to each device removed.
/////
Is this the correct way to detect whether my USB device has been removed ?
Or
Is it advisable to release the allocated memory (i.e.IOUSBDevice*,
IOUSBInterface* ) at service stop rather than doing it at message()?
Or
Am I missing something ?
Please suggest. Any pointers, suggestions, comments, are most welcome.
Regards,
Rohit Dhamija
--
Rohit Dhamija(M) 9818446545
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden