My KEXT fails to unload, if USB device removed. Why?
site_archiver@lists.apple.com Delivered-To: darwin-kernel@lists.apple.com Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=FkYChMpOXX8CHzmT2N3mz+on5RVsy+pXYw1VqSEZU6nbFBR3hqK9tOMt73SL38Jdi9uo/uh9ewpYcqb1poXaPMrf2eA2fiz6bdcS6ysss7jxaByvniiEZPMdSZMl7dNwPOXMMHIuNdP+tt2qJ74mTPipVXCyD/13EucDfCcV5Qg= 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 (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists.a... This email sent to site_archiver@lists.apple.com
participants (1)
-
rohit dhamija