Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/scsipi Implement detaching of SCSI busses.



details:   https://anonhg.NetBSD.org/src/rev/be1e1cb88d72
branches:  trunk
changeset: 476272:be1e1cb88d72
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sat Sep 11 21:25:26 1999 +0000

description:
Implement detaching of SCSI busses.

diffstat:

 sys/dev/scsipi/scsiconf.c |  71 +++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 69 insertions(+), 2 deletions(-)

diffs (95 lines):

diff -r 47723044917a -r be1e1cb88d72 sys/dev/scsipi/scsiconf.c
--- a/sys/dev/scsipi/scsiconf.c Sat Sep 11 20:52:07 1999 +0000
+++ b/sys/dev/scsipi/scsiconf.c Sat Sep 11 21:25:26 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: scsiconf.c,v 1.125 1999/09/09 20:06:52 hwr Exp $       */
+/*     $NetBSD: scsiconf.c,v 1.126 1999/09/11 21:25:26 thorpej Exp $   */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -99,10 +99,14 @@
 
 int scsibusmatch __P((struct device *, struct cfdata *, void *));
 void scsibusattach __P((struct device *, struct device *, void *));
+int scsibusactivate __P((struct device *, enum devact));
+int scsibusdetach __P((struct device *, int flags));
+
 int scsibussubmatch __P((struct device *, struct cfdata *, void *));
 
 struct cfattach scsibus_ca = {
-       sizeof(struct scsibus_softc), scsibusmatch, scsibusattach
+       sizeof(struct scsibus_softc), scsibusmatch, scsibusattach,
+           scsibusdetach, scsibusactivate,
 };
 
 extern struct cfdriver scsibus_cd;
@@ -225,6 +229,69 @@
        return ((*cf->cf_attach->ca_match)(parent, cf, aux));
 }
 
+int
+scsibusactivate(self, act)
+       struct device *self;
+       enum devact act;
+{
+       struct scsibus_softc *sc = (struct scsibus_softc *) self;
+       struct scsipi_link *sc_link;
+       int target, lun, error = 0, s;
+
+       s = splbio();
+       switch (act) {
+       case DVACT_ACTIVATE:
+               error = EOPNOTSUPP;
+               break;
+
+       case DVACT_DEACTIVATE:
+               for (target = 0; target <= sc->sc_maxtarget; target++) {
+                       if (target ==
+                           sc->adapter_link->scsipi_scsi.adapter_target)
+                               continue;
+                       for (lun = 0; lun <= sc->sc_maxlun; lun++) {
+                               sc_link = sc->sc_link[target][lun];
+                               if (sc_link == NULL)
+                                       continue;
+                               error =
+                                   config_deactivate(sc_link->device_softc);
+                               if (error)
+                                       goto out;
+                       }
+               }
+               break;
+       }
+ out:
+       splx(s);
+       return (error);
+}
+
+int
+scsibusdetach(self, flags)
+       struct device *self;
+       int flags;
+{
+       struct scsibus_softc *sc = (struct scsibus_softc *) self;
+       struct scsipi_link *sc_link;
+       int target, lun, error;
+
+       for (target = 0; target <= sc->sc_maxtarget; target++) {
+               if (target == sc->adapter_link->scsipi_scsi.adapter_target)
+                       continue;
+               for (lun = 0; lun <= sc->sc_maxlun; lun++) {
+                       sc_link = sc->sc_link[target][lun];
+                       if (sc_link == NULL)
+                               continue;
+                       error = config_detach(sc_link->device_softc, flags);
+                       if (error)
+                               return (error);
+                       free(sc_link, M_DEVBUF);
+                       sc->sc_link[target][lun] = NULL;
+               }
+       }
+       return (0);
+}
+
 /*
  * Probe the requested scsi bus. It must be already set up.
  * -1 requests all set up scsi busses.



Home | Main Index | Thread Index | Old Index