Deleted Added
full compact
1/*-
2 * Copyright (c) 1997,1998 Doug Rabson
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $Id: subr_bus.c,v 1.26 1999/05/22 14:57:15 dfr Exp $
26 * $Id: subr_bus.c,v 1.27 1999/05/27 07:18:41 dfr Exp $
27 */
28
29#include <sys/param.h>
30#include <sys/queue.h>
31#include <sys/malloc.h>
32#include <sys/kernel.h>
33#include <sys/module.h>
34#include <sys/sysctl.h>

--- 564 unchanged lines hidden (view full) ---

599 dev->ops = &null_ops;
600 dev->driver = NULL;
601 dev->devclass = NULL;
602 dev->unit = unit;
603 dev->nameunit = NULL;
604 dev->desc = NULL;
605 dev->busy = 0;
606 dev->flags = DF_ENABLED;
607 dev->order = 0;
608 if (unit == -1)
609 dev->flags |= DF_WILDCARD;
610 if (name) {
611 dev->flags |= DF_FIXEDCLASS;
612 devclass_add_device(dc, dev);
613 }
614 dev->ivars = ivars;
615 dev->softc = NULL;

--- 14 unchanged lines hidden (view full) ---

630 } else
631 printf(" not found");
632 printf("\n");
633}
634
635device_t
636device_add_child(device_t dev, const char *name, int unit, void *ivars)
637{
637 device_t child;
638
639 PDEBUG(("%s at %s as unit %d with%s ivars",
640 name, DEVICENAME(dev), unit, (ivars? "":"out")));
641
642 child = make_device(dev, name, unit, ivars);
643
644 if (child)
645 TAILQ_INSERT_TAIL(&dev->children, child, link);
646 else
647 PDEBUG(("%s failed", name));
648
649 return child;
638 return device_add_child_ordered(dev, 0, name, unit, ivars);
639}
640
641device_t
653device_add_child_after(device_t dev, device_t place, const char *name,
654 int unit, void *ivars)
642device_add_child_ordered(device_t dev, int order,
643 const char *name, int unit, void *ivars)
644{
645 device_t child;
646 device_t place;
647
658 PDEBUG(("%s at %s after %s as unit %d with%s ivars",
659 name, DEVICENAME(dev), DEVICENAME(place), unit, (ivars? "":"out")));
648 PDEBUG(("%s at %s with order %d as unit %d with%s ivars",
649 name, DEVICENAME(dev), order, unit, (ivars? "":"out")));
650
651 child = make_device(dev, name, unit, ivars);
652 if (child == NULL)
653 return child;
654 child->order = order;
655
656 TAILQ_FOREACH(place, &dev->children, link)
657 if (place->order > order)
658 break;
659
660 if (place) {
666 TAILQ_INSERT_AFTER(&dev->children, place, child, link);
661 /*
662 * The device 'place' is the first device whose order is
663 * greater than the new child.
664 */
665 TAILQ_INSERT_BEFORE(place, child, link);
666 } else {
668 TAILQ_INSERT_HEAD(&dev->children, child, link);
667 /*
668 * The new child's order is greater or equal to the order of
669 * any existing device. Add the child to the tail of the list.
670 */
671 TAILQ_INSERT_TAIL(&dev->children, child, link);
672 }
673
674 return child;
675}
676
677int
678device_delete_child(device_t dev, device_t child)
679{

--- 1672 unchanged lines hidden ---