The ldi_add_event_handler() function adds a callback handler to be invoked at the
occurance of the event specified by the cookie. Adding a callback handler
is also known as subscribing to an event. Upon successful subscription, the
handler is invoked when the event occurs. You can unregister the handler by
using ldi_remove_event_handler(9F).

An instance of a layered driver can register multiple handlers for an
event or a single handler for multiple events. Callback order is not
defined and should be assumed to be random.

The routine handler is invoked with the following arguments:

ldi_handle_tlh

Layered handle representing the device for which the event notification is requested.

ddi_eventcookie_tec

Structure describing event that occurred.

void *arg

Opaque data pointer provided by the driver during callback registration.

void *impl_data

Pointer to event specific data defined by the framework that invokes the callback function.

Return Values

DDI_SUCCESS

Callback handler registered successfully.

DDI_FAILURE

Failed to register callback handler. Possible reasons include lack of resources or a bad cookie.

Context

The ldi_add_event_handler() function can be called from user and kernel contexts only.

See Also

Notes

Layered drivers must remove all registered callback handlers for a device instance,
represented by the layered handle, by calling ldi_remove_event_handler(9F) before the layered driver's
detach(9E) routine completes.