/* * $Id: config_alloc.c,v 1.1 2008/08/08 12:37:11 nbrk Exp $ */ /* * Allocate and initialize new device structure. */ #include struct device *config_alloc_device(struct driver *drv) { struct device *devp; /* device itself */ devp = kmem_alloc(sizeof(struct device)); if (devp == NULL) panic("config: can't allocate memory for device"); /* device data */ if (drv->dr_datasize != 0) { /* XXX page_alloc() ? */ devp->dv_data = kmem_alloc(drv->dr_datasize); if (devp->dv_data == NULL) panic("config: can't allocate memory dor device data"); } devp->dv_xname = drv->dr_name; /* will be changed by config later */ devp->dv_unit = 0; devp->dv_flags = 0; /* XXX */ devp->dv_parent = NULL; return(devp); } void config_free_device(struct device *devp) { kmem_free(devp->dv_data); kmem_free(devp); }