svn commit: r343819 - in stable: 11/sys/compat/ndis 11/sys/dev/if_ndis 12/sys/compat/ndis 12/sys/dev/if_ndis
Andriy Voskoboinyk
avos at FreeBSD.org
Wed Feb 6 02:06:02 UTC 2019
Author: avos
Date: Wed Feb 6 02:06:00 2019
New Revision: 343819
URL: https://svnweb.freebsd.org/changeset/base/343819
Log:
MFC r343574:
Fix compilation with 'option NDISAPI + device ndis' and
without 'device pccard' in the kernel config file.
PR: 171532
Reported by: Robert Bonomi <bonomi at host128.r-bonomi.com>
Modified:
stable/11/sys/compat/ndis/ndis_var.h
stable/11/sys/dev/if_ndis/if_ndis.c
stable/11/sys/dev/if_ndis/if_ndis_pccard.c
Directory Properties:
stable/11/ (props changed)
Changes in other areas also in this revision:
Modified:
stable/12/sys/compat/ndis/ndis_var.h
stable/12/sys/dev/if_ndis/if_ndis.c
stable/12/sys/dev/if_ndis/if_ndis_pccard.c
Directory Properties:
stable/12/ (props changed)
Modified: stable/11/sys/compat/ndis/ndis_var.h
==============================================================================
--- stable/11/sys/compat/ndis/ndis_var.h Wed Feb 6 01:53:01 2019 (r343818)
+++ stable/11/sys/compat/ndis/ndis_var.h Wed Feb 6 02:06:00 2019 (r343819)
@@ -1734,8 +1734,6 @@ extern int ndis_get_supported_oids(void *, ndis_oid **
extern int ndis_send_packets(void *, ndis_packet **, int);
extern int ndis_send_packet(void *, ndis_packet *);
extern int ndis_convert_res(void *);
-extern int ndis_alloc_amem(void *);
-extern void ndis_free_amem(void *);
extern void ndis_free_packet(ndis_packet *);
extern void ndis_free_bufs(ndis_buffer *);
extern int ndis_reset_nic(void *);
Modified: stable/11/sys/dev/if_ndis/if_ndis.c
==============================================================================
--- stable/11/sys/dev/if_ndis/if_ndis.c Wed Feb 6 01:53:01 2019 (r343818)
+++ stable/11/sys/dev/if_ndis/if_ndis.c Wed Feb 6 02:06:00 2019 (r343819)
@@ -566,15 +566,6 @@ ndis_attach(device_t dev)
callout_init(&sc->ndis_stat_callout, 1);
mbufq_init(&sc->ndis_rxqueue, INT_MAX); /* XXXGL: sane maximum */
- if (sc->ndis_iftype == PCMCIABus) {
- error = ndis_alloc_amem(sc);
- if (error) {
- device_printf(dev, "failed to allocate "
- "attribute memory\n");
- goto fail;
- }
- }
-
/* Create sysctl registry nodes */
ndis_create_sysctls(sc);
@@ -1095,9 +1086,6 @@ ndis_detach(device_t dev)
if (ifp != NULL)
if_free(ifp);
-
- if (sc->ndis_iftype == PCMCIABus)
- ndis_free_amem(sc);
if (sc->ndis_sc)
ndis_destroy_dma(sc);
Modified: stable/11/sys/dev/if_ndis/if_ndis_pccard.c
==============================================================================
--- stable/11/sys/dev/if_ndis/if_ndis_pccard.c Wed Feb 6 01:53:01 2019 (r343818)
+++ stable/11/sys/dev/if_ndis/if_ndis_pccard.c Wed Feb 6 02:06:00 2019 (r343819)
@@ -72,6 +72,7 @@ MODULE_DEPEND(ndis, pccard, 1, 1, 1);
static int ndis_probe_pccard (device_t);
static int ndis_attach_pccard (device_t);
+static int ndis_detach_pccard (device_t);
static struct resource_list *ndis_get_resource_list
(device_t, device_t);
static int ndis_devcompare (interface_type,
@@ -89,7 +90,7 @@ static device_method_t ndis_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, ndis_probe_pccard),
DEVMETHOD(device_attach, ndis_attach_pccard),
- DEVMETHOD(device_detach, ndis_detach),
+ DEVMETHOD(device_detach, ndis_detach_pccard),
DEVMETHOD(device_shutdown, ndis_shutdown),
DEVMETHOD(device_suspend, ndis_suspend),
DEVMETHOD(device_resume, ndis_resume),
@@ -173,6 +174,50 @@ ndis_probe_pccard(dev)
return(ENXIO);
}
+#define NDIS_AM_RID 3
+
+static int
+ndis_alloc_amem(struct ndis_softc *sc)
+{
+ int error, rid;
+
+ rid = NDIS_AM_RID;
+ sc->ndis_res_am = bus_alloc_resource_anywhere(sc->ndis_dev,
+ SYS_RES_MEMORY, &rid, 0x1000, RF_ACTIVE);
+
+ if (sc->ndis_res_am == NULL) {
+ device_printf(sc->ndis_dev,
+ "failed to allocate attribute memory\n");
+ return(ENXIO);
+ }
+ sc->ndis_rescnt++;
+ resource_list_add(&sc->ndis_rl, SYS_RES_MEMORY, rid,
+ rman_get_start(sc->ndis_res_am), rman_get_end(sc->ndis_res_am),
+ rman_get_size(sc->ndis_res_am));
+
+ error = CARD_SET_MEMORY_OFFSET(device_get_parent(sc->ndis_dev),
+ sc->ndis_dev, rid, 0, NULL);
+
+ if (error) {
+ device_printf(sc->ndis_dev,
+ "CARD_SET_MEMORY_OFFSET() returned 0x%x\n", error);
+ return(error);
+ }
+
+ error = CARD_SET_RES_FLAGS(device_get_parent(sc->ndis_dev),
+ sc->ndis_dev, SYS_RES_MEMORY, rid, PCCARD_A_MEM_ATTR);
+
+ if (error) {
+ device_printf(sc->ndis_dev,
+ "CARD_SET_RES_FLAGS() returned 0x%x\n", error);
+ return(error);
+ }
+
+ sc->ndis_am_rid = rid;
+
+ return(0);
+}
+
/*
* Attach the interface. Allocate softc structures, do ifmedia
* setup and ethernet/BPF attach.
@@ -249,88 +294,40 @@ ndis_attach_pccard(dev)
sc->ndis_devidx = devidx;
+ error = ndis_alloc_amem(sc);
+ if (error) {
+ device_printf(dev, "failed to allocate attribute memory\n");
+ goto fail;
+ }
+
error = ndis_attach(dev);
fail:
return(error);
}
-static struct resource_list *
-ndis_get_resource_list(dev, child)
- device_t dev;
- device_t child;
+static int
+ndis_detach_pccard(device_t dev)
{
- struct ndis_softc *sc;
+ struct ndis_softc *sc = device_get_softc(dev);
- sc = device_get_softc(dev);
- return (&sc->ndis_rl);
-}
+ (void) ndis_detach(dev);
-#define NDIS_AM_RID 3
+ if (sc->ndis_res_am != NULL)
+ bus_release_resource(sc->ndis_dev, SYS_RES_MEMORY,
+ sc->ndis_am_rid, sc->ndis_res_am);
+ resource_list_free(&sc->ndis_rl);
-int
-ndis_alloc_amem(arg)
- void *arg;
-{
- struct ndis_softc *sc;
- int error, rid;
-
- if (arg == NULL)
- return(EINVAL);
-
- sc = arg;
- rid = NDIS_AM_RID;
- sc->ndis_res_am = bus_alloc_resource_anywhere(sc->ndis_dev,
- SYS_RES_MEMORY, &rid, 0x1000, RF_ACTIVE);
-
- if (sc->ndis_res_am == NULL) {
- device_printf(sc->ndis_dev,
- "failed to allocate attribute memory\n");
- return(ENXIO);
- }
- sc->ndis_rescnt++;
- resource_list_add(&sc->ndis_rl, SYS_RES_MEMORY, rid,
- rman_get_start(sc->ndis_res_am), rman_get_end(sc->ndis_res_am),
- rman_get_size(sc->ndis_res_am));
-
- error = CARD_SET_MEMORY_OFFSET(device_get_parent(sc->ndis_dev),
- sc->ndis_dev, rid, 0, NULL);
-
- if (error) {
- device_printf(sc->ndis_dev,
- "CARD_SET_MEMORY_OFFSET() returned 0x%x\n", error);
- return(error);
- }
-
- error = CARD_SET_RES_FLAGS(device_get_parent(sc->ndis_dev),
- sc->ndis_dev, SYS_RES_MEMORY, rid, PCCARD_A_MEM_ATTR);
-
- if (error) {
- device_printf(sc->ndis_dev,
- "CARD_SET_RES_FLAGS() returned 0x%x\n", error);
- return(error);
- }
-
- sc->ndis_am_rid = rid;
-
- return(0);
+ return (0);
}
-void
-ndis_free_amem(arg)
- void *arg;
+static struct resource_list *
+ndis_get_resource_list(dev, child)
+ device_t dev;
+ device_t child;
{
struct ndis_softc *sc;
- if (arg == NULL)
- return;
-
- sc = arg;
-
- if (sc->ndis_res_am != NULL)
- bus_release_resource(sc->ndis_dev, SYS_RES_MEMORY,
- sc->ndis_am_rid, sc->ndis_res_am);
- resource_list_free(&sc->ndis_rl);
-
- return;
+ sc = device_get_softc(dev);
+ return (&sc->ndis_rl);
}
More information about the svn-src-stable-11
mailing list