subr_bus.c (54031) | subr_bus.c (54073) |
---|---|
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 * | 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 * $FreeBSD: head/sys/kern/subr_bus.c 54031 1999-12-02 16:30:21Z n_hibma $ | 26 * $FreeBSD: head/sys/kern/subr_bus.c 54073 1999-12-03 08:41:24Z mdodd $ |
27 */ 28 29#include "opt_bus.h" 30 31#include <sys/param.h> 32#include <sys/queue.h> 33#include <sys/malloc.h> 34#include <sys/kernel.h> --- 541 unchanged lines hidden (view full) --- 576#ifdef DEVICE_SYSCTLS 577 device_unregister_oids(dev); 578#endif 579 580 return 0; 581} 582 583static device_t | 27 */ 28 29#include "opt_bus.h" 30 31#include <sys/param.h> 32#include <sys/queue.h> 33#include <sys/malloc.h> 34#include <sys/kernel.h> --- 541 unchanged lines hidden (view full) --- 576#ifdef DEVICE_SYSCTLS 577 device_unregister_oids(dev); 578#endif 579 580 return 0; 581} 582 583static device_t |
584make_device(device_t parent, const char *name, 585 int unit, void *ivars) | 584make_device(device_t parent, const char *name, int unit) |
586{ 587 device_t dev; 588 devclass_t dc; 589 | 585{ 586 device_t dev; 587 devclass_t dc; 588 |
590 PDEBUG(("%s at %s as unit %d with%s ivars", 591 name, DEVICENAME(parent), unit, (ivars? "":"out"))); | 589 PDEBUG(("%s at %s as unit %d", name, DEVICENAME(parent), unit)); |
592 593 if (name) { 594 dc = devclass_find_internal(name, TRUE); 595 if (!dc) { 596 printf("make_device: can't find device class %s\n", name); 597 return NULL; 598 } 599 } else --- 17 unchanged lines hidden (view full) --- 617 dev->flags = DF_ENABLED; 618 dev->order = 0; 619 if (unit == -1) 620 dev->flags |= DF_WILDCARD; 621 if (name) { 622 dev->flags |= DF_FIXEDCLASS; 623 devclass_add_device(dc, dev); 624 } | 590 591 if (name) { 592 dc = devclass_find_internal(name, TRUE); 593 if (!dc) { 594 printf("make_device: can't find device class %s\n", name); 595 return NULL; 596 } 597 } else --- 17 unchanged lines hidden (view full) --- 615 dev->flags = DF_ENABLED; 616 dev->order = 0; 617 if (unit == -1) 618 dev->flags |= DF_WILDCARD; 619 if (name) { 620 dev->flags |= DF_FIXEDCLASS; 621 devclass_add_device(dc, dev); 622 } |
625 dev->ivars = ivars; | 623 dev->ivars = NULL; |
626 dev->softc = NULL; 627 628 dev->state = DS_NOTPRESENT; 629 630 return dev; 631} 632 633static int --- 5 unchanged lines hidden (view full) --- 639 retval += BUS_PRINT_CHILD(dev, child); 640 } else 641 retval += device_printf(child, " not found\n"); 642 643 return (retval); 644} 645 646device_t | 624 dev->softc = NULL; 625 626 dev->state = DS_NOTPRESENT; 627 628 return dev; 629} 630 631static int --- 5 unchanged lines hidden (view full) --- 637 retval += BUS_PRINT_CHILD(dev, child); 638 } else 639 retval += device_printf(child, " not found\n"); 640 641 return (retval); 642} 643 644device_t |
647device_add_child(device_t dev, const char *name, int unit, void *ivars) | 645device_add_child(device_t dev, const char *name, int unit) |
648{ | 646{ |
649 return device_add_child_ordered(dev, 0, name, unit, ivars); | 647 return device_add_child_ordered(dev, 0, name, unit); |
650} 651 652device_t | 648} 649 650device_t |
653device_add_child_ordered(device_t dev, int order, 654 const char *name, int unit, void *ivars) | 651device_add_child_ordered(device_t dev, int order, const char *name, int unit) |
655{ 656 device_t child; 657 device_t place; 658 | 652{ 653 device_t child; 654 device_t place; 655 |
659 PDEBUG(("%s at %s with order %d as unit %d with%s ivars", 660 name, DEVICENAME(dev), order, unit, (ivars? "":"out"))); | 656 PDEBUG(("%s at %s with order %d as unit %d", 657 name, DEVICENAME(dev), order, unit)); |
661 | 658 |
662 child = make_device(dev, name, unit, ivars); | 659 child = make_device(dev, name, unit); |
663 if (child == NULL) 664 return child; 665 child->order = order; 666 667 TAILQ_FOREACH(place, &dev->children, link) 668 if (place->order > order) 669 break; 670 --- 308 unchanged lines hidden (view full) --- 979} 980 981void * 982device_get_ivars(device_t dev) 983{ 984 return dev->ivars; 985} 986 | 660 if (child == NULL) 661 return child; 662 child->order = order; 663 664 TAILQ_FOREACH(place, &dev->children, link) 665 if (place->order > order) 666 break; 667 --- 308 unchanged lines hidden (view full) --- 976} 977 978void * 979device_get_ivars(device_t dev) 980{ 981 return dev->ivars; 982} 983 |
984void 985device_set_ivars(device_t dev, void * ivars) 986{ 987 if (!dev) 988 return; 989 990 dev->ivars = ivars; 991 992 return; 993} 994 |
|
987device_state_t 988device_get_state(device_t dev) 989{ 990 return dev->state; 991} 992 993void 994device_enable(device_t dev) --- 1457 unchanged lines hidden --- | 995device_state_t 996device_get_state(device_t dev) 997{ 998 return dev->state; 999} 1000 1001void 1002device_enable(device_t dev) --- 1457 unchanged lines hidden --- |