Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 6 Feb 2019 02:07:37 +0000 (UTC)
From:      Andriy Voskoboinyk <avos@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r343820 - in stable/10/sys: compat/ndis dev/if_ndis
Message-ID:  <201902060207.x1627bcT000676@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: avos
Date: Wed Feb  6 02:07:37 2019
New Revision: 343820
URL: https://svnweb.freebsd.org/changeset/base/343820

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@host128.r-bonomi.com>

Modified:
  stable/10/sys/compat/ndis/ndis_var.h
  stable/10/sys/dev/if_ndis/if_ndis.c
  stable/10/sys/dev/if_ndis/if_ndis_pccard.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/compat/ndis/ndis_var.h
==============================================================================
--- stable/10/sys/compat/ndis/ndis_var.h	Wed Feb  6 02:06:00 2019	(r343819)
+++ stable/10/sys/compat/ndis/ndis_var.h	Wed Feb  6 02:07:37 2019	(r343820)
@@ -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/10/sys/dev/if_ndis/if_ndis.c
==============================================================================
--- stable/10/sys/dev/if_ndis/if_ndis.c	Wed Feb  6 02:06:00 2019	(r343819)
+++ stable/10/sys/dev/if_ndis/if_ndis.c	Wed Feb  6 02:07:37 2019	(r343820)
@@ -559,15 +559,6 @@ ndis_attach(dev)
 	InitializeListHead(&sc->ndisusb_xferdonelist);
 	callout_init(&sc->ndis_stat_callout, 1);
 
-	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);
 
@@ -1078,9 +1069,6 @@ ndis_detach(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/10/sys/dev/if_ndis/if_ndis_pccard.c
==============================================================================
--- stable/10/sys/dev/if_ndis/if_ndis_pccard.c	Wed Feb  6 02:06:00 2019	(r343819)
+++ stable/10/sys/dev/if_ndis/if_ndis_pccard.c	Wed Feb  6 02:07:37 2019	(r343820)
@@ -70,6 +70,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,
@@ -87,7 +88,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),
@@ -171,6 +172,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(sc->ndis_dev, SYS_RES_MEMORY,
+	    &rid, 0UL, ~0UL, 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.
@@ -247,88 +292,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(sc->ndis_dev, SYS_RES_MEMORY,
-	    &rid, 0UL, ~0UL, 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);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201902060207.x1627bcT000676>