Public Attributes | List of all members
usb_notify_hooks Struct Reference

Hooks that the USB stack can callback in case of events. More...

Public Attributes

status_t(* device_added )(usb_device device, void **cookie)
 Called by the stack in case a device is added. More...
 
status_t(* device_removed )(void *cookie)
 Called by the stack in case a device you are using is removed. More...
 

Detailed Description

Hooks that the USB stack can callback in case of events.

Member Data Documentation

◆ device_added

status_t(* usb_notify_hooks::device_added)(usb_device device, void **cookie)

Called by the stack in case a device is added.

Once you have registered hooks using the usb_module_info::install_notify() method, this hook will be called as soon as a device is inserted that matches your provided usb_support_descriptor.

Parameters
deviceA unique id that identifies this USB device.
[in]cookieYou can store a pointer to an object in this variable. When the device is removed, this cookie will be provided to you.
Returns
You should return B_OK in case of success. The USB stack will then request the kernel to republish your device names so that the new device will be shown in the /dev tree. If you return an error value, the device id will become invalid and you will not be notified if this device is removed.
See also
device_removed()

◆ device_removed

status_t(* usb_notify_hooks::device_removed)(void *cookie)

Called by the stack in case a device you are using is removed.

If you have accepted a device in the device_added() hook, this hook will be called as soon as the device is removed.

Parameters
cookieThe cookie you provided in the device_added() hook. Make sure that you free the cookie if necessary.
Returns
Currently the return value of this hook is ignored. It is recommended to return B_OK though.