xref: /illumos-gate/usr/src/man/man9f/usb_register_hotplug_cbs.9f (revision 8119dad84d6416f13557b0ba8e2aaf9064cbcfd3)
te
Copyright (c) 2004, Sun Microsystems, Inc.,
All Rights Reserved
The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
USB_REGISTER_HOTPLUG_CBS 9F "Aug 17, 2004"
NAME
usb_register_hotplug_cbs, usb_unregister_hotplug_cbs - Register/unregister for notification of device hotplug events
SYNOPSIS
#include <sys/usb/usba.h>



int usb_register_hotplug_cbs(dev_info_t *dip,
 int (*disconnection_event_handler)(dev_info_t *dip,
 int (*reconnection_event_handler)(dev_info_t *dip);

 void usb_unregister_hotplug_cbs(dev_info_t *dip);
INTERFACE LEVEL
illumos DDI specific (illumos DDI)
PARAMETERS
For usb_register_hotplug_cbs() dip

Pointer to the device's dev_info structure.

disconnection_event_handler

Called when device is disconnected. This handler takes a dev_info_t as an argument (representing the device being disconnected) and always returns USB_SUCCESS.

reconnection_event_handler

Called when device is reconnected. This handler takes a dev_info_t as an argument (representing the device being reconnected) and always returns USB_SUCCESS.

For usb_unregister_hotplug_cbs(): dip

Pointer to the device's dev_info structure.

DESCRIPTION
The usb_register_hotplug_cbs() function registers callbacks to be executed when the USB device represented by dip is hotplugged or removed.

The usb_unregister_hotplug_cbs() function unregisters or disengages callbacks from executing when the USB device represented by dip is hotplugged or removed.

RETURN VALUES
For usb_register_hotplug_cbs(): USB_SUCCESS

Callbacks were successfully registered.

USB_FAILURE

One or more arguments were NULL. Callbacks could not be successfully registered.

For usb_unregister_hotplug_cbs(): None

CONTEXT
The usb_register_hotplug_cbs() function may be called only from attach(9E).

The usb_unregister_hotplug_cbs() function may be called only from detach(9E).

Registered callback handlers requiring the use of any DDI (section 9F) function (except ddi_taskq_* functions), should launch a separate thread using ddi_taskq_* routines for processing their event, to avoid deadlocks. The new thread can then safely call any DDI function it needs to handle the event.

The registered callback handlers execute in kernel context.

EXAMPLES

 int remove_device(dev_info_t *)
 {
 ...
 ...
 return (USB_SUCCESS);
 }

 int accommodate_device(dev_info_t *)
 {
 ...
 ...
 return (USB_SUCCESS);
 }

 if (usb_register_hotplug_cbs(
 dip, remove_device, accommodate_device) == USB_FAILURE) {
 cmn_err (CE_WARN,
 "%s%d: Could not register hotplug handlers.",
 ddi_driver_name(dip), ddi_get_instance(dip));
 }

ATTRIBUTES
See attributes(7) for descriptions of the following attributes:
ATTRIBUTE TYPE ATTRIBUTE VALUE
Architecture PCI-based systems
Interface stability Committed
SEE ALSO
attributes (7), attach (9E), detach (9E), usb_get_status (9F)