Make ldi_ev_remove_callbacks safe to use in LDI callbacks
LDI allows various events to be propagated from a device driver up to consumers of those devices. The functions ldi_invoke_finalize and ldi_invoke_notify will walk the list of subscriptions and call back into the function pointer to deliver the event.
Unfortunately, the notify phase of LDI event delivery can require the consumer to synchronously free resources and close their LDI handle before returning from the callback. Consumers are also required to invoke ldi_ev_remove_callbacks on all registered callbacks when doing so.
Even more unfortunately, you may have more than one callback registered for a particular LDI handle and the walk of the list is not removal safe. So, we must enlist the cooperation of ldi_ev_remove_callbacks to shift our walker along the list if we are unregistering the element at our current walk position.