subr_bus.c (42734) | subr_bus.c (43301) |
---|---|
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 * $Id: subr_bus.c,v 1.13 1999/01/10 22:04:05 n_hibma Exp $ | 26 * $Id: subr_bus.c,v 1.14 1999/01/16 17:44:09 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/bus_private.h> --- 225 unchanged lines hidden (view full) --- 260 * Disassociate from any devices. We iterate through all the 261 * devices in the devclass of the driver and detach any which are 262 * using the driver. 263 */ 264 for (i = 0; i < dc->maxunit; i++) { 265 if (dc->devices[i]) { 266 dev = dc->devices[i]; 267 if (dev->driver == driver) { | 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/bus_private.h> --- 225 unchanged lines hidden (view full) --- 260 * Disassociate from any devices. We iterate through all the 261 * devices in the devclass of the driver and detach any which are 262 * using the driver. 263 */ 264 for (i = 0; i < dc->maxunit; i++) { 265 if (dc->devices[i]) { 266 dev = dc->devices[i]; 267 if (dev->driver == driver) { |
268 if (error = device_detach(dev)) | 268 if ((error = device_detach(dev)) != 0) |
269 return error; 270 device_set_driver(dev, NULL); 271 } 272 } 273 } 274 275 TAILQ_REMOVE(&busclass->drivers, driver, link); 276 return 0; --- 129 unchanged lines hidden (view full) --- 406 407static int 408devclass_add_device(devclass_t dc, device_t dev) 409{ 410 int error; 411 412 PDEBUG(("%s in devclass %s", DEVICENAME(dev), DEVCLANAME(dc))); 413 | 269 return error; 270 device_set_driver(dev, NULL); 271 } 272 } 273 } 274 275 TAILQ_REMOVE(&busclass->drivers, driver, link); 276 return 0; --- 129 unchanged lines hidden (view full) --- 406 407static int 408devclass_add_device(devclass_t dc, device_t dev) 409{ 410 int error; 411 412 PDEBUG(("%s in devclass %s", DEVICENAME(dev), DEVCLANAME(dc))); 413 |
414 if (error = devclass_alloc_unit(dc, &dev->unit)) | 414 if ((error = devclass_alloc_unit(dc, &dev->unit)) != 0) |
415 return error; 416 dc->devices[dev->unit] = dev; 417 dev->devclass = dc; 418 return 0; 419} 420 421static int 422devclass_delete_device(devclass_t dc, device_t dev) --- 28 unchanged lines hidden (view full) --- 451 452 if (name) { 453 dc = devclass_find_internal(name, TRUE); 454 if (!dc) { 455 printf("make_device: can't find device class %s\n", name); 456 return NULL; 457 } 458 | 415 return error; 416 dc->devices[dev->unit] = dev; 417 dev->devclass = dc; 418 return 0; 419} 420 421static int 422devclass_delete_device(devclass_t dc, device_t dev) --- 28 unchanged lines hidden (view full) --- 451 452 if (name) { 453 dc = devclass_find_internal(name, TRUE); 454 if (!dc) { 455 printf("make_device: can't find device class %s\n", name); 456 return NULL; 457 } 458 |
459 if (error = devclass_alloc_unit(dc, &unit)) | 459 if ((error = devclass_alloc_unit(dc, &unit)) != 0) |
460 return NULL; 461 } else 462 dc = NULL; 463 464 dev = malloc(sizeof(struct device), M_DEVBUF, M_NOWAIT); 465 if (!dev) 466 return 0; 467 --- 82 unchanged lines hidden (view full) --- 550 551 /* remove children first */ 552 while ( (grandchild = TAILQ_FIRST(&child->children)) ) { 553 error = device_delete_child(child, grandchild); 554 if (error) 555 return error; 556 } 557 | 460 return NULL; 461 } else 462 dc = NULL; 463 464 dev = malloc(sizeof(struct device), M_DEVBUF, M_NOWAIT); 465 if (!dev) 466 return 0; 467 --- 82 unchanged lines hidden (view full) --- 550 551 /* remove children first */ 552 while ( (grandchild = TAILQ_FIRST(&child->children)) ) { 553 error = device_delete_child(child, grandchild); 554 if (error) 555 return error; 556 } 557 |
558 if (error = device_detach(child)) | 558 if ((error = device_detach(child)) != 0) |
559 return error; 560 if (child->devclass) 561 devclass_delete_device(child->devclass, child); 562 TAILQ_REMOVE(&dev->children, child, link); 563 free(child, M_DEVBUF); 564 565 return 0; 566} --- 311 unchanged lines hidden (view full) --- 878 int error; 879 880 PDEBUG(("%s", DEVICENAME(dev))); 881 if (dev->state == DS_BUSY) 882 return EBUSY; 883 if (dev->state != DS_ATTACHED) 884 return 0; 885 | 559 return error; 560 if (child->devclass) 561 devclass_delete_device(child->devclass, child); 562 TAILQ_REMOVE(&dev->children, child, link); 563 free(child, M_DEVBUF); 564 565 return 0; 566} --- 311 unchanged lines hidden (view full) --- 878 int error; 879 880 PDEBUG(("%s", DEVICENAME(dev))); 881 if (dev->state == DS_BUSY) 882 return EBUSY; 883 if (dev->state != DS_ATTACHED) 884 return 0; 885 |
886 if (error = DEVICE_DETACH(dev)) | 886 if ((error = DEVICE_DETACH(dev)) != 0) |
887 return error; 888 889 if (!(dev->flags & DF_FIXEDCLASS)) 890 devclass_delete_device(dev->devclass, dev); 891 892 dev->state = DS_NOTPRESENT; 893 device_set_driver(dev, NULL); 894 --- 152 unchanged lines hidden (view full) --- 1047 device_t child; 1048 int error; 1049 1050 if (dev->state != DS_ATTACHED) 1051 return EBUSY; 1052 1053 for (child = TAILQ_FIRST(&dev->children); 1054 child; child = TAILQ_NEXT(child, link)) | 887 return error; 888 889 if (!(dev->flags & DF_FIXEDCLASS)) 890 devclass_delete_device(dev->devclass, dev); 891 892 dev->state = DS_NOTPRESENT; 893 device_set_driver(dev, NULL); 894 --- 152 unchanged lines hidden (view full) --- 1047 device_t child; 1048 int error; 1049 1050 if (dev->state != DS_ATTACHED) 1051 return EBUSY; 1052 1053 for (child = TAILQ_FIRST(&dev->children); 1054 child; child = TAILQ_NEXT(child, link)) |
1055 if (error = device_detach(child)) | 1055 if ((error = device_detach(child)) != 0) |
1056 return error; 1057 1058 return 0; 1059} 1060 1061int 1062bus_generic_shutdown(device_t dev) 1063{ --- 509 unchanged lines hidden --- | 1056 return error; 1057 1058 return 0; 1059} 1060 1061int 1062bus_generic_shutdown(device_t dev) 1063{ --- 509 unchanged lines hidden --- |