hpci_detach(D3hpci)
hpci_detach --
detach a hot plug controller driver from the hot plug controller interface
Synopsis
#include <sys/types.h>
#include <sys/hpci.h>
#include <sys/ddi.h>
int hpci_detach(int hpcid);
Description
hpci_detach( )
detaches a hot plug controller driver
from the kernel before the driver is unloaded.
Arguments
hpcid-
identifier of an
hpci_hpcd_t(D4hpci)
structure as returned by the
hpci_attach(D3hpci)
function.
Return values
hpci_detach( )
returns 0 if successful, or -1 if no such instance is currently registered
with the kernel.
Usage
The
hpci_detach( )
function is called from the CFG_REMOVE subfunction of the driver's
config(D2hpci)
entry point routine to unregister a hot plug controller driver instance
before unloading the driver.
Context and synchronization
Blockable
context
Hardware applicability
All
Version applicability
hpci:
1
References
config(D2hpci),
hpci_attach(D3hpci),
hpci_hpcd_t(D4hpci)
``Hotplug devices'' in HDK Technical Reference
``PCI'' in HDK Technical Reference
Examples
The following code example illustrates how the
hpci_detach( )
function is used in the CFG_REMOVE subfunction
of the driver's
config(D2hpci)
entry point routine.
1 int
2 xxx_config(cfg_func_t func, void *idata, rm_key_t key)
3 {
4 hpcd_t *hpcdp;
5 int err = -1;
6 switch(func)
7 {
8 case CFG_ADD:
/* see hpci_attach(D3hpci) for example */
9 break;
10 case CFG_REMOVE:
11 hpcdp=((hpcd_t *) idata);
/* unregister with hpci */
12 if ((err=hpci_detach(hpcdp->hpcid))<0)
13 {
14 cmn_err(CE_WARN, "hpci_detach() failed\n");
15 return -1;
16 }
/* detach interrupts, deallocate memory, locks, etc */
17 cleanup(hpcdp);
18 break;
19 case CFG_xxxx: /* handle other CFG_* cases here */
20 break;
21 default:
22 cmn_err(CE_WARN, "%s:
23 xxx_config: unexpected request 0x%x for rm_key=%d\n",
24 modname, func, key);
25 return(EINVAL);
26 }
27 return(0);
28 }
Line 2-
call the
config(D2hpci)
entry point routine
Line 11-
point to the correct driver instance
Line 12-
call
hpci_detach(D3hpci)
to unregister this HPCD with HPCI
and check the return value for errors
Line 17-
deallocate resources associated with this HPCD
19 June 2005
© 2005 The SCO Group, Inc. All rights reserved.
OpenServer 6 and UnixWare (SVR5) HDK - June 2005