kernel/eka/drivers/usbc/d_usbc.cpp
changeset 90 947f0dc9f7a8
parent 33 0173bcd7697c
child 253 d37db4dcc88d
--- a/kernel/eka/drivers/usbc/d_usbc.cpp	Tue Feb 02 01:24:03 2010 +0200
+++ b/kernel/eka/drivers/usbc/d_usbc.cpp	Fri Apr 16 16:24:37 2010 +0300
@@ -153,6 +153,7 @@
 	__KTRACE_OPT(KUSB, Kern::Printf("DLddUsbcChannel::~DLddUsbcChannel()"));
 	if (iController)
 		{
+		iController->DeRegisterClient(this);
 		iStatusCallbackInfo.Cancel();
 		iEndpointStatusCallbackInfo.Cancel();
         iOtgFeatureCallbackInfo.Cancel();
@@ -164,7 +165,6 @@
 			iController->ReleaseDeviceControl(this);
 			iOwnsDeviceControl = EFalse;
 			}
-		iController->DeRegisterClient(this);
 		DestroyEp0();
 		delete iStatusFifo;
 		Kern::DestroyClientRequest(iStatusChangeReq);
@@ -1959,7 +1959,12 @@
             // Parcel out the memory between endpoints
             TUint8* newAddr = reinterpret_cast<TUint8*>(chunk->LinearAddress());
             __KTRACE_OPT(KUSB, Kern::Printf("SetupInterfaceMemory alloc new chunk=0x%x, size=%d", newAddr,bufSizes[chunkInd]));
-            chunkChanged = (newAddr != oldAddr);
+            // The check is important to avoid chunkChanged to be corrupted.
+            // This code change is to fix the problem that one chunk is used by multiple interfaces.
+            if(!chunkChanged)
+            	{
+            	chunkChanged = (newAddr != oldAddr);
+            	}            
             aHwChunks[chunkInd] = chunk;
             }
         chunkInd++;