diff options
author | Warner Losh <imp@FreeBSD.org> | 2006-02-07 18:38:51 +0000 |
---|---|---|
committer | Warner Losh <imp@FreeBSD.org> | 2006-02-07 18:38:51 +0000 |
commit | 22293c3afb68c8a083ed787fb8b797a375978b26 (patch) | |
tree | b25ef061ac41a1042bb72aa464c25cce46a1787c /sys/dev/pccbb | |
parent | a35ebcc25daf480d611128e75674e96da4ecae32 (diff) | |
download | src-22293c3afb68c8a083ed787fb8b797a375978b26.tar.gz src-22293c3afb68c8a083ed787fb8b797a375978b26.zip |
Detach the children before we delete them. This is a little cleaner
than just deleting them. Also add comments about why we do this.
Given the current behavior of delete_child, I don't think this changes
anything. It just feels cleaner.
Notes
Notes:
svn path=/head/; revision=155434
Diffstat (limited to 'sys/dev/pccbb')
-rw-r--r-- | sys/dev/pccbb/pccbb.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/sys/dev/pccbb/pccbb.c b/sys/dev/pccbb/pccbb.c index f9940308beed..8f6d06ad5783 100644 --- a/sys/dev/pccbb/pccbb.c +++ b/sys/dev/pccbb/pccbb.c @@ -287,18 +287,26 @@ cbb_detach(device_t brdev) int tmp; int error; - device_get_children(brdev, &devlist, &numdevs); + /* + * Before we delete the children (which we have to do because + * attach doesn't check for children busses correctly), we have + * to detach the children. Even if we didn't need to delete the + * children, we have to detach them. + */ + error = bus_generic_detach(brdev); + if (error != 0) + return (error); - error = 0; - for (tmp = 0; tmp < numdevs; tmp++) { - if (device_detach(devlist[tmp]) == 0) - device_delete_child(brdev, devlist[tmp]); - else - error++; - } + /* + * Since the attach routine doesn't search for children before it + * attaches them to this device, we must delete them here in order + * for the kldload/unload case to work. If we failed to do that, then + * we'd get duplicate devices when cbb.ko was reloaded. + */ + device_get_children(brdev, &devlist, &numdevs); + for (tmp = 0; tmp < numdevs; tmp++) + device_delete_child(brdev, devlist[tmp]); free(devlist, M_TEMP); - if (error > 0) - return (ENXIO); /* Turn off the interrupts */ cbb_set(sc, CBB_SOCKET_MASK, 0); |