CONFIG_ATTACH(9) Kernel Developer's Manual CONFIG_ATTACH(9) NAME config_attach, config_detach, config_detach_children, config_deactivate attach and detach devices SYNOPSIS #include #include struct device * config_attach(struct device *parent, void *cf, void *aux, cfprint_t print); int config_detach(struct device *dev, int flags); int config_detach_children(struct device *parent, int flags); int config_deactivate(struct device *dev); DESCRIPTION The config_attach() function attaches a found device. Memory is allocated for the softc structure and the driver's attach function is called according to the configuration table. If successful, config_attach() returns the softc. If unsuccessful, it returns NULL. The config_detach() function is called by the parent to detach the child device. The second argument flags contains detachment flags: #define DETACH_FORCE 0x01 /* Force detachment; hardware gone */ #define DETACH_QUIET 0x02 /* Don't print a notice */ The config_deactivate() function is called by the parent to change the child device's operational state by calling the driver's activate function with a flags argument describing the targeted operational state: #define DVACT_DEACTIVATE 1 /* deactivate the device */ #define DVACT_QUIESCE 2 /* warn the device about suspend */ #define DVACT_SUSPEND 3 /* suspend the device */ #define DVACT_RESUME 4 /* resume the device */ #define DVACT_WAKEUP 5 /* tell device to recover after resume */ #define DVACT_POWERDOWN 6 /* power device down */ CONTEXT config_detach() is always called from process context, allowing tsleep(9) to be called while the device detaches itself (to deal with processes which have a device open). RETURN VALUES config_detach() and config_deactivate() return zero if successful and an error code otherwise. SEE ALSO config_found(9) OpenBSD 6.0 December 5, 2014 OpenBSD 6.0