summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/dev/ata/atascsi.c33
-rw-r--r--sys/dev/ata/atascsi.h4
-rw-r--r--sys/dev/ic/sili.c13
3 files changed, 45 insertions, 5 deletions
diff --git a/sys/dev/ata/atascsi.c b/sys/dev/ata/atascsi.c
index 3e692b696fc..c7875568060 100644
--- a/sys/dev/ata/atascsi.c
+++ b/sys/dev/ata/atascsi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: atascsi.c,v 1.46 2007/11/23 16:01:47 dlg Exp $ */
+/* $OpenBSD: atascsi.c,v 1.47 2007/11/23 18:21:55 dlg Exp $ */
/*
* Copyright (c) 2007 David Gwynne <dlg@openbsd.org>
@@ -65,6 +65,7 @@ struct scsi_device atascsi_device = {
};
int atascsi_probe(struct atascsi *, int);
+void atascsi_unprobe(struct atascsi *, int);
struct ata_xfer *ata_setup_identify(struct ata_port *, int);
void ata_free_identify(struct ata_xfer *);
@@ -144,8 +145,20 @@ atascsi_attach(struct device *self, struct atascsi_attach_args *aaa)
}
int
-atascsi_detach(struct atascsi *as)
+atascsi_detach(struct atascsi *as, int flags)
{
+ int rv;
+ int i;
+
+ rv = config_detach((struct device *)as->as_scsibus, flags);
+ if (rv != 0)
+ return (rv);
+
+ for (i = 0; i < as->as_link.adapter_buswidth; i++)
+ atascsi_unprobe(as, i);
+
+ free(as, M_DEVBUF);
+
return (0);
}
@@ -201,6 +214,22 @@ atascsi_probe(struct atascsi *as, int port)
return (0);
}
+void
+atascsi_unprobe(struct atascsi *as, int port)
+{
+ struct ata_port *ap;
+
+ if (port > as->as_link.adapter_buswidth)
+ return;
+
+ ap = as->as_ports[port];
+ if (ap == NULL)
+ return;
+
+ free(ap, M_DEVBUF);
+ as->as_ports[port] = NULL;
+}
+
struct ata_xfer *
ata_setup_identify(struct ata_port *ap, int nosleep)
{
diff --git a/sys/dev/ata/atascsi.h b/sys/dev/ata/atascsi.h
index ffe2e882ff7..5245029ff23 100644
--- a/sys/dev/ata/atascsi.h
+++ b/sys/dev/ata/atascsi.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: atascsi.h,v 1.25 2007/04/12 13:08:34 jsg Exp $ */
+/* $OpenBSD: atascsi.h,v 1.26 2007/11/23 18:21:55 dlg Exp $ */
/*
* Copyright (c) 2007 David Gwynne <dlg@openbsd.org>
@@ -308,7 +308,7 @@ struct atascsi_attach_args {
};
struct atascsi *atascsi_attach(struct device *, struct atascsi_attach_args *);
-int atascsi_detach(struct atascsi *);
+int atascsi_detach(struct atascsi *, int);
int atascsi_probe_dev(struct atascsi *, int);
int atascsi_detach_dev(struct atascsi *, int);
diff --git a/sys/dev/ic/sili.c b/sys/dev/ic/sili.c
index 208c12a9334..99fb1166119 100644
--- a/sys/dev/ic/sili.c
+++ b/sys/dev/ic/sili.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sili.c,v 1.35 2007/10/09 05:43:37 ray Exp $ */
+/* $OpenBSD: sili.c,v 1.36 2007/11/23 18:21:55 dlg Exp $ */
/*
* Copyright (c) 2007 David Gwynne <dlg@openbsd.org>
@@ -205,6 +205,17 @@ sili_attach(struct sili_softc *sc)
int
sili_detach(struct sili_softc *sc, int flags)
{
+ int rv;
+
+ if (sc->sc_atascsi != NULL) {
+ rv = atascsi_detach(sc->sc_atascsi, flags);
+ if (rv != 0)
+ return (rv);
+ }
+
+ if (sc->sc_ports != NULL)
+ sili_ports_free(sc);
+
return (0);
}