Date: Fri, 3 Aug 2007 17:37:30 GMT From: Maxim Zhuravlev <thioretic@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 124604 for review Message-ID: <200708031737.l73HbUlm045155@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=124604 Change 124604 by thioretic@thioretic on 2007/08/03 17:36:54 Propogate changes. Affected files ... .. //depot/projects/soc2007/thioretic_gidl2/kern/subr_bus.c#3 integrate .. //depot/projects/soc2007/thioretic_gidl2/sys/bus.h#2 integrate Differences ... ==== //depot/projects/soc2007/thioretic_gidl2/kern/subr_bus.c#3 (text+ko) ==== @@ -182,6 +182,8 @@ typedef struct devicelink* devicelink_t; struct devicelink { device_t device_ptr; +#define DLF_ANCHOR 1 + int flags; TAILQ(devicelink) link; }; @@ -2168,21 +2170,21 @@ static int device_add_to_dev_list (device_t addwhat, devicelink_list_t *addwhere, int incr_refs){ - devicelink_t pd; + devicelink_t dl; - TAILQ_FOREACH (pd, addwhere, link){ - if (pd->device_ptr == addwhat) + TAILQ_FOREACH (dl, addwhere, link){ + if (dl->device_ptr == addwhat) return (1); } - pd = malloc(sizeof(struct devicelink), M_BUS, M_NOWAIT|M_ZERO); - if (!pd) + dl = malloc(sizeof(struct devicelink), M_BUS, M_NOWAIT|M_ZERO); + if (!dl) return (0); - pd->device_ptr = addwhat; - TAILQ_INSERT_TAIL(addwhere, pd, link); + dl->device_ptr = addwhat; + TAILQ_INSERT_TAIL(addwhere, dl, link); if (incr_refs) - pd->device_ptr->refs++; + dl->device_ptr->refs++; bus_data_generation_update(); return (1); @@ -2205,7 +2207,17 @@ */ int device_add_existing_parent (device_t dev, device_t parent){ + int count = 0; + devicelink_t dl; + device_add_to_dev_list (parent, &dev->parents, FALSE); + + TAILQ_FOREACH (dl, &dev->parents, link){count++;} + if ((count == 2) && (dl = TAILQ_FIRST(&dev->parents)) && + (dl->flags & DLF_ANCHOR) && (dl->device_ptr == root_bus)){ + device_delete_existing_parent (dev, root_bus); + } + device_add_to_dev_list (dev, &parent->children, TRUE); } @@ -2268,7 +2280,7 @@ child->device_ptr->refs++; device_add_existing_parent (child->device_ptr, dev); - + bus_data_generation_update(); return (child); } @@ -2290,7 +2302,7 @@ return (destroy_recurse (devtodel, dev, CHILDREN)); /* remove children first */ - if (devtodel->refs > 1) goto deletefromparents; + if (devtodel->refs > 1) goto deletefromparent; while ( (grand = TAILQ_FIRST(&devtodel->children)) ) { error = destroy_recurse(devtodel, grand->device_ptr, direction); if (error) @@ -2303,7 +2315,7 @@ return (error); if (devtodel->devclass) devclass_delete_device(devtodel->devclass, devtodel); -deletefromparents: +deletefromparent: TAILQ_FOREACH_SAFE(pd, &devtodel->parents, link, pd2){ if (pd->device_ptr == dev){ TAILQ_REMOVE(&devtodel->parents, pd, link); @@ -2313,8 +2325,10 @@ } } - if (devtodel->flags & DF_PERSISTENT){ + if (!devtodel->refs && (devtodel->flags & DF_PERSISTENT)){ device_add_existing_parent(dev, root_bus); + pd = TAILQ_FIRST(&dev->parents); + pd->flags |= DLF_ANCHOR; return (0); } @@ -2329,14 +2343,14 @@ } -void +int device_delete_existing_child (device_t dev, device_t child){ - destroy_recurse (dev, child, CHILDREN); + return (destroy_recurse (dev, child, CHILDREN)); } -void +int device_delete_existing_parent (device_t dev, device_t parent){ - destroy_recurse (dev, parent, PARENTS); + return (destroy_recurse (dev, parent, PARENTS)); } /** @@ -2394,7 +2408,7 @@ * @returns the device with the given unit number or @c * NULL if there is no such device */ -device_t +static device_t device_find_relation(device_t dev, const char *classname, int unit, int direction) { devclass_t dc; @@ -2630,7 +2644,7 @@ * @retval 0 success * @retval ENOMEM the array allocation failed */ -int +static int device_get_relations(device_t dev, device_t **devlistp, int *devcountp, int direction) { int count; ==== //depot/projects/soc2007/thioretic_gidl2/sys/bus.h#2 (text+ko) ==== @@ -341,27 +341,38 @@ * Access functions for device. */ device_t device_add_child(device_t dev, const char *name, int unit); +int device_add_existing_child (device_t dev, device_t child); +int device_add_existing_parent (device_t dev, device_t parent); device_t device_add_child_ordered(device_t dev, int order, const char *name, int unit); void device_busy(device_t dev); int device_delete_child(device_t dev, device_t child); +int device_delete_existing_child (device_t dev, device_t child); +int device_delete_existing_parent (device_t dev, device_t parent); int device_attach(device_t dev); int device_detach(device_t dev); void device_disable(device_t dev); void device_enable(device_t dev); device_t device_find_child(device_t dev, const char *classname, int unit); +device_t device_find_parent(device_t dev, const char* classname, + int unit); const char *device_get_desc(device_t dev); devclass_t device_get_devclass(device_t dev); driver_t *device_get_driver(device_t dev); u_int32_t device_get_flags(device_t dev); device_t device_get_parent(device_t dev); int device_get_children(device_t dev, device_t **listp, int *countp); +int device_get_all_parents(device_t dev, device_t **listp, int *countp); void *device_get_ivars(device_t dev); +void *device_get_driver_ivars (device_t dev, driver_t *driver); void device_set_ivars(device_t dev, void *ivars); +void device_set_driver_ivars (device_t dev, driver_t *driver, + void* ivars); const char *device_get_name(device_t dev); const char *device_get_nameunit(device_t dev); void *device_get_softc(device_t dev); +void *device_get_driver_softc(device_t dev, driver_t *driver); device_state_t device_get_state(device_t dev); int device_get_unit(device_t dev); struct sysctl_ctx_list *device_get_sysctl_ctx(device_t dev); @@ -381,6 +392,8 @@ int device_set_driver(device_t dev, driver_t *driver); void device_set_flags(device_t dev, u_int32_t flags); void device_set_softc(device_t dev, void *softc); +void device_set_driver_softc(device_t dev, driver_t *driver, + void* softc); int device_set_unit(device_t dev, int unit); /* XXX DONT USE XXX */ int device_shutdown(device_t dev); void device_unbusy(device_t dev); @@ -397,6 +410,8 @@ const char *devclass_get_name(devclass_t dc); device_t devclass_get_device(devclass_t dc, int unit); void *devclass_get_softc(devclass_t dc, int unit); +void *devclass_get_driver_softc (devclass_t dc, int unit, driver_t *driver); + int devclass_get_devices(devclass_t dc, device_t **listp, int *countp); int devclass_get_drivers(devclass_t dc, driver_t ***listp, int *countp); int devclass_get_count(devclass_t dc);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200708031737.l73HbUlm045155>