- // Try to register the original consumer on the shared controller.
- error = vector->sharedController->registerInterrupt(originalNub,
- originalSource,
- vector->target,
- vector->handler,
- vector->refCon);
- // If the original consumer could not be moved to the shared controller,
- // put the original consumor's interrupt back to normal and
- // get rid of whats left of the shared controller.
- if (error != kIOReturnSuccess) {
- enableInterrupt(originalNub, originalSource);
- vector->sharedController->release();
- vector->sharedController = 0;
- IOUnlock(vector->interruptLock);
- return error;
+ // If there was an original consumer try to register it on the shared controller.
+ if (wasAlreadyRegisterd) {
+ error = vector->sharedController->registerInterrupt(originalNub,
+ originalSource,
+ vector->target,
+ vector->handler,
+ vector->refCon);
+ // If the original consumer could not be moved to the shared controller,
+ // put the original consumor's interrupt back to normal and
+ // get rid of whats left of the shared controller.
+ if (error != kIOReturnSuccess) {
+ // Save the driver's interrupt enablement state.
+ wasDisabledSoft = vector->interruptDisabledSoft;
+
+ // Make the interrupt really hard disabled.
+ vector->interruptDisabledSoft = 1;
+ vector->interruptDisabledHard = 1;
+
+ // Enable the original consumer's interrupt if needed.
+ if (!wasDisabledSoft) originalNub->enableInterrupt(originalSource);
+ enableInterrupt(originalNub, originalSource);
+
+ vector->sharedController->release();
+ vector->sharedController = 0;
+ IOUnlock(vector->interruptLock);
+ return error;
+ }