diff -r 55a0a1279a7e -r 206a6eaaeb71 kernel/eka/drivers/iic/iic_channel.cpp --- a/kernel/eka/drivers/iic/iic_channel.cpp Wed Oct 13 13:34:03 2010 +0100 +++ b/kernel/eka/drivers/iic/iic_channel.cpp Mon Oct 18 15:31:10 2010 +0100 @@ -443,6 +443,8 @@ if(r == KErrNone) { + // Use placement new to re-initialise the iClientTimeoutDfc callback object (don't re-allocate the memory) + new (iClientTimeoutDfc) TDfc(SlaveStaticCB,(TAny*)this, 7); // Highest Dfc priority iClient->Open(); aCallback->iChannel=this; iNotif = aCallback; @@ -456,7 +458,6 @@ } else r=DoRequest(ESyncConfigPwrUp); - if(r == KErrNone) { if(!aAsynch) // For asynchronous version there is nothing more to do until the callback is invoked @@ -477,6 +478,7 @@ return r; } + TInt DIicBusChannelSlave::ReleaseChannel() { __KTRACE_OPT(KIIC, Kern::Printf("DIicBusChannelSlave::ReleaseChannel\n")); @@ -494,6 +496,10 @@ r=DoRequest(EPowerDown); if(r == KErrNone) { + if(iClientTimeoutDfc != NULL) + { + iClientTimeoutDfc->~TDfc(); // call destructor directly, ie don't free the memory + } TInt intState=__SPIN_LOCK_IRQSAVE(iSpinLock); iClient=NULL; iChannelInUse=0; // Channel now available for capture by other clients @@ -802,7 +808,7 @@ DIicBusChannelSlave::DIicBusChannelSlave(TBusType aBusType, TChannelDuplex aChanDuplex, TInt16 aChannelId) : DIicBusChannel(DIicBusChannel::ESlave, aBusType, aChanDuplex), - iChannelId(aChannelId), iTimerState(EInactive), + iChannelId(aChannelId), iClientTimeoutDfc(NULL), iTimerState(EInactive), iMasterWaitTime(KSlaveDefMWaitTime), iClientWaitTime(KSlaveDefCWaitTime), iSpinLock(TSpinLock::EOrderGenericIrqLow2) // Semi-arbitrary, low priority value { @@ -813,7 +819,12 @@ DIicBusChannelSlave::~DIicBusChannelSlave() { - delete iClientTimeoutDfc; + if(iClientTimeoutDfc != NULL) + { + delete iClientTimeoutDfc; + iClientTimeoutDfc = NULL; + } + return; } void DIicBusChannelSlave::SlaveStaticCB(TAny* aPtr) @@ -1139,9 +1150,7 @@ TInt DIicBusChannelMasterSlave::ReleaseChannel() { - iMasterChannel->Lock(); TInt r=iSlaveChannel->ReleaseChannel(); - iMasterChannel->Unlock(); return r; };