summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authortmm <tmm@FreeBSD.org>2002-10-16 17:03:36 +0000
committertmm <tmm@FreeBSD.org>2002-10-16 17:03:36 +0000
commit04ced36540f738e227706ff123215a16a68d7cad (patch)
tree6f6a99843888152225dca361dbd56f19cc66a2fa /sys
parent0697960fd6b7997e015649dd5508c734cc02e67d (diff)
downloadFreeBSD-src-04ced36540f738e227706ff123215a16a68d7cad.zip
FreeBSD-src-04ced36540f738e227706ff123215a16a68d7cad.tar.gz
Use a linked list to keep the psycho softcs instead of a statically
sized array. While being there, deuglify the psycho pair detection loop which became quite awkward in a previous code reorganization.
Diffstat (limited to 'sys')
-rw-r--r--sys/sparc64/pci/psycho.c32
-rw-r--r--sys/sparc64/pci/psychovar.h2
2 files changed, 12 insertions, 22 deletions
diff --git a/sys/sparc64/pci/psycho.c b/sys/sparc64/pci/psycho.c
index 0da2e59..63b723f 100644
--- a/sys/sparc64/pci/psycho.c
+++ b/sys/sparc64/pci/psycho.c
@@ -177,8 +177,8 @@ static devclass_t psycho_devclass;
DRIVER_MODULE(psycho, nexus, psycho_driver, psycho_devclass, 0, 0);
-static int psycho_ndevs;
-static struct psycho_softc *psycho_softcs[4];
+SLIST_HEAD(, psycho_softc) psycho_softcs =
+ SLIST_HEAD_INITIALIZER(psycho_softcs);
struct psycho_clr {
struct psycho_softc *pci_sc;
@@ -361,21 +361,12 @@ psycho_attach(device_t dev)
* the base physical address. This will be the same for a
* pair of devices that share register space.
*/
- for (n = 0; n < psycho_ndevs && n < sizeof(psycho_softcs) /
- sizeof(psycho_softcs[0]); n++) {
- asc = (struct psycho_softc *)psycho_softcs[n];
-
- if (asc == NULL || asc == sc)
- /* This entry is not there or it is me */
- continue;
-
- if (asc->sc_basepaddr != sc->sc_basepaddr)
- /* This is an unrelated psycho */
- continue;
-
- /* Found partner */
- osc = asc;
- break;
+ SLIST_FOREACH(asc, &psycho_softcs, sc_link) {
+ if (asc->sc_basepaddr == sc->sc_basepaddr) {
+ /* Found partner */
+ osc = asc;
+ break;
+ }
}
if (osc == NULL) {
@@ -473,11 +464,8 @@ psycho_attach(device_t dev)
sparc64_root_dma_tag = sc->sc_dmat;
/* Register the softc, this is needed for paired psychos. */
- if (psycho_ndevs < sizeof(psycho_softcs) / sizeof(psycho_softcs[0]))
- psycho_softcs[psycho_ndevs] = sc;
- else
- device_printf(dev, "XXX: bump the number of psycho_softcs");
- psycho_ndevs++;
+ SLIST_INSERT_HEAD(&psycho_softcs, sc, sc_link);
+
/*
* And finally, if we're a sabre or the first of a pair of psycho's to
* arrive here, start up the IOMMU and get a config space tag.
diff --git a/sys/sparc64/pci/psychovar.h b/sys/sparc64/pci/psychovar.h
index cee7c77..d79ff18 100644
--- a/sys/sparc64/pci/psychovar.h
+++ b/sys/sparc64/pci/psychovar.h
@@ -87,6 +87,8 @@ struct psycho_softc {
struct rman sc_mem_rman;
struct rman sc_io_rman;
+
+ SLIST_ENTRY(psycho_softc) sc_link;
};
#endif /* _SPARC64_PCI_PSYCHOVAR_H_ */
OpenPOWER on IntegriCloud