summaryrefslogtreecommitdiff
path: root/sys/dev/pci/mpii.c
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2014-04-09 05:00:29 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2014-04-09 05:00:29 +0000
commit5ac5bed3e7c7f040c4f871817be231197af20914 (patch)
treeb653d73fedec4ed3a5cd07e489a3c9f7d60b79d2 /sys/dev/pci/mpii.c
parent28ce423bcd89d53083b9db1743e0e11a86d4c1de (diff)
remove an abstraction that just wraps a straight malloc on attach for
the sc_devs array.
Diffstat (limited to 'sys/dev/pci/mpii.c')
-rw-r--r--sys/dev/pci/mpii.c27
1 files changed, 9 insertions, 18 deletions
diff --git a/sys/dev/pci/mpii.c b/sys/dev/pci/mpii.c
index 01632351fa0..335ab517136 100644
--- a/sys/dev/pci/mpii.c
+++ b/sys/dev/pci/mpii.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mpii.c,v 1.90 2014/04/09 03:59:28 dlg Exp $ */
+/* $OpenBSD: mpii.c,v 1.91 2014/04/09 05:00:28 dlg Exp $ */
/*
* Copyright (c) 2010, 2012 Mike Belopuhov
* Copyright (c) 2009 James Giannoules
@@ -290,7 +290,6 @@ void mpii_scsi_cmd_tmo(void *);
void mpii_scsi_cmd_tmo_handler(void *, void *);
void mpii_scsi_cmd_tmo_done(struct mpii_ccb *);
-int mpii_alloc_dev(struct mpii_softc *);
int mpii_insert_dev(struct mpii_softc *, struct mpii_device *);
int mpii_remove_dev(struct mpii_softc *, struct mpii_device *);
struct mpii_device *
@@ -554,7 +553,9 @@ mpii_attach(struct device *parent, struct device *self, void *aux)
}
}
- if (mpii_alloc_dev(sc) != 0) {
+ sc->sc_devs = malloc(sc->sc_max_devices *
+ sizeof(struct mpii_device *), M_DEVBUF, M_NOWAIT | M_ZERO);
+ if (sc->sc_devs == NULL) {
printf("%s: unable to allocate memory for mpii_device\n",
DEVNAME(sc));
goto free_queues;
@@ -562,7 +563,7 @@ mpii_attach(struct device *parent, struct device *self, void *aux)
if (mpii_portenable(sc) != 0) {
printf("%s: unable to enable port\n", DEVNAME(sc));
- goto free_dev;
+ goto free_devs;
}
/* we should be good to go now, attach scsibus */
@@ -580,7 +581,7 @@ mpii_attach(struct device *parent, struct device *self, void *aux)
sc->sc_ih = pci_intr_establish(sc->sc_pc, ih, IPL_BIO | IPL_MPSAFE,
mpii_intr, sc, sc->sc_dev.dv_xname);
if (sc->sc_ih == NULL)
- goto free_dev;
+ goto free_devs;
/* config_found() returns the scsibus attached to us */
sc->sc_scsibus = (struct scsibus_softc *) config_found(&sc->sc_dev,
@@ -607,9 +608,9 @@ mpii_attach(struct device *parent, struct device *self, void *aux)
return;
-free_dev:
- if (sc->sc_devs)
- free(sc->sc_devs, M_DEVBUF);
+free_devs:
+ free(sc->sc_devs, M_DEVBUF);
+ sc->sc_devs = NULL;
free_queues:
bus_dmamap_sync(sc->sc_dmat, MPII_DMA_MAP(sc->sc_reply_freeq),
@@ -2294,16 +2295,6 @@ mpii_dmamem_free(struct mpii_softc *sc, struct mpii_dmamem *mdm)
}
int
-mpii_alloc_dev(struct mpii_softc *sc)
-{
- sc->sc_devs = malloc(sc->sc_max_devices *
- sizeof(struct mpii_device *), M_DEVBUF, M_NOWAIT | M_ZERO);
- if (sc->sc_devs == NULL)
- return (1);
- return (0);
-}
-
-int
mpii_insert_dev(struct mpii_softc *sc, struct mpii_device *dev)
{
int slot = dev->slot; /* initial hint */