From a5c7e3bb704eca6794f27bc86253e86c56a26917 Mon Sep 17 00:00:00 2001 From: Guido van Rooij Date: Thu, 18 Mar 2004 21:10:11 +0000 Subject: [PATCH] Prevent the strange situation that after each load/unload of a ppbus device, the device is probed multiple times (so each device is detected N times after unloading/loading the module N-1 times). The real fix is (quote Doug and Warner): > : In an ideal world, there should be some kind of BUS_UNIDENTIFY method > : which a driver could use to delete the devices it created in > : BUS_IDENTIFY. > > Or the bus would have a driver deleted routine that got called and it > would remove all instances of the devclass attached to it. Reviewed by: Doug Rabson & Warner Losh --- sys/dev/ppbus/if_plip.c | 5 ++++- sys/dev/ppbus/lpbb.c | 6 +++++- sys/dev/ppbus/lpt.c | 6 +++++- sys/dev/ppbus/pcfclock.c | 6 +++++- sys/dev/ppbus/ppi.c | 6 +++++- sys/dev/ppbus/pps.c | 6 +++++- sys/dev/ppbus/vpo.c | 6 +++++- 7 files changed, 34 insertions(+), 7 deletions(-) diff --git a/sys/dev/ppbus/if_plip.c b/sys/dev/ppbus/if_plip.c index 32221c718f88..9805e0b05079 100644 --- a/sys/dev/ppbus/if_plip.c +++ b/sys/dev/ppbus/if_plip.c @@ -183,8 +183,11 @@ static devclass_t lp_devclass; static void lp_identify(driver_t *driver, device_t parent) { + device_t dev; - BUS_ADD_CHILD(parent, 0, "plip", -1); + dev = device_find_child(parent, "plip", 0); + if (!dev) + BUS_ADD_CHILD(parent, 0, "plip", -1); } /* * lpprobe() diff --git a/sys/dev/ppbus/lpbb.c b/sys/dev/ppbus/lpbb.c index 6516f503460f..a9b3667c4129 100644 --- a/sys/dev/ppbus/lpbb.c +++ b/sys/dev/ppbus/lpbb.c @@ -58,7 +58,11 @@ static void lpbb_identify(driver_t *driver, device_t parent) { - BUS_ADD_CHILD(parent, 0, "lpbb", -1); + device_t dev; + + dev = device_find_child(parent, "lpbb", 0); + if (!dev) + BUS_ADD_CHILD(parent, 0, "lpbb", -1); } static int diff --git a/sys/dev/ppbus/lpt.c b/sys/dev/ppbus/lpt.c index f0bdea72e3d0..7855e364cc18 100644 --- a/sys/dev/ppbus/lpt.c +++ b/sys/dev/ppbus/lpt.c @@ -340,7 +340,11 @@ static void lpt_identify(driver_t *driver, device_t parent) { - BUS_ADD_CHILD(parent, 0, LPT_NAME, -1); + device_t dev; + + dev = device_find_child(parent, LPT_NAME, 0); + if (!dev) + BUS_ADD_CHILD(parent, 0, LPT_NAME, -1); } /* diff --git a/sys/dev/ppbus/pcfclock.c b/sys/dev/ppbus/pcfclock.c index fd4c010d66f2..a47f304b5ecb 100644 --- a/sys/dev/ppbus/pcfclock.c +++ b/sys/dev/ppbus/pcfclock.c @@ -117,7 +117,11 @@ static void pcfclock_identify(driver_t *driver, device_t parent) { - BUS_ADD_CHILD(parent, 0, PCFCLOCK_NAME, -1); + device_t dev; + + dev = device_find_child(parent, PCFCLOCK_NAME, 0); + if (!dev) + BUS_ADD_CHILD(parent, 0, PCFCLOCK_NAME, -1); } static int diff --git a/sys/dev/ppbus/ppi.c b/sys/dev/ppbus/ppi.c index 7df5851ca03a..113448db5129 100644 --- a/sys/dev/ppbus/ppi.c +++ b/sys/dev/ppbus/ppi.c @@ -133,7 +133,11 @@ static void ppi_identify(driver_t *driver, device_t parent) { - BUS_ADD_CHILD(parent, 0, "ppi", -1); + device_t dev; + + dev = device_find_child(parent, "ppi", 0); + if (!dev) + BUS_ADD_CHILD(parent, 0, "ppi", -1); } /* diff --git a/sys/dev/ppbus/pps.c b/sys/dev/ppbus/pps.c index 20a8b02e7054..fef615769ea2 100644 --- a/sys/dev/ppbus/pps.c +++ b/sys/dev/ppbus/pps.c @@ -75,7 +75,11 @@ static void ppsidentify(driver_t *driver, device_t parent) { - BUS_ADD_CHILD(parent, 0, PPS_NAME, -1); + device_t dev; + + dev = device_find_child(parent, PPS_NAME, 0); + if (!dev) + BUS_ADD_CHILD(parent, 0, PPS_NAME, -1); } static int diff --git a/sys/dev/ppbus/vpo.c b/sys/dev/ppbus/vpo.c index 69d2870403da..50ebf8135438 100644 --- a/sys/dev/ppbus/vpo.c +++ b/sys/dev/ppbus/vpo.c @@ -90,7 +90,11 @@ static void vpo_identify(driver_t *driver, device_t parent) { - BUS_ADD_CHILD(parent, 0, "vpo", -1); + device_t dev; + + dev = device_find_child(parent, "vpo", 0); + if (!dev) + BUS_ADD_CHILD(parent, 0, "vpo", -1); } /*