drivers/network/pcnet: Only allocate a local softc in probe() if one isn't set.

This commit is contained in:
Augustin Cavalier
2025-01-27 12:46:08 -05:00
parent 1047530b8f
commit 84fb1209cd
@@ -504,26 +504,33 @@ pcn_probe(dev)
device_t dev; device_t dev;
{ {
const struct pcn_type *t; const struct pcn_type *t;
struct pcn_softc *sc; struct pcn_softc *sc, *local_sc;
int rid; int rid;
u_int32_t chip_id; u_int32_t chip_id;
#ifdef __HAIKU__
sc = __builtin_alloca(offsetof(struct pcn_softc, pcn_ldata));
device_set_softc(dev, sc);
#endif
t = pcn_match(pci_get_vendor(dev), pci_get_device(dev)); t = pcn_match(pci_get_vendor(dev), pci_get_device(dev));
if (t == NULL) if (t == NULL)
return (ENXIO); return (ENXIO);
sc = device_get_softc(dev); sc = device_get_softc(dev);
#ifdef __HAIKU__
local_sc = NULL;
if (sc == NULL) {
sc = local_sc = __builtin_alloca(offsetof(struct pcn_softc, pcn_ldata));
device_set_softc(dev, local_sc);
}
#endif
/* /*
* Temporarily map the I/O space so we can read the chip ID register. * Temporarily map the I/O space so we can read the chip ID register.
*/ */
rid = PCN_RID; rid = PCN_RID;
sc->pcn_res = bus_alloc_resource_any(dev, PCN_RES, &rid, RF_ACTIVE); sc->pcn_res = bus_alloc_resource_any(dev, PCN_RES, &rid, RF_ACTIVE);
if (sc->pcn_res == NULL) { if (sc->pcn_res == NULL) {
#ifdef __HAIKU__
if (local_sc != NULL)
device_set_softc(dev, NULL);
#endif
device_printf(dev, "couldn't map ports/memory\n"); device_printf(dev, "couldn't map ports/memory\n");
return(ENXIO); return(ENXIO);
} }
@@ -535,7 +542,8 @@ pcn_probe(dev)
bus_release_resource(dev, PCN_RES, PCN_RID, sc->pcn_res); bus_release_resource(dev, PCN_RES, PCN_RID, sc->pcn_res);
#ifdef __HAIKU__ #ifdef __HAIKU__
device_set_softc(dev, NULL); if (local_sc != NULL)
device_set_softc(dev, NULL);
#endif #endif
switch((chip_id >> 12) & PART_MASK) { switch((chip_id >> 12) & PART_MASK) {