svn commit: r251569 - in stable/9/sys/dev: msk sk

Marius Strobl marius at FreeBSD.org
Sun Jun 9 12:51:44 UTC 2013


Author: marius
Date: Sun Jun  9 12:51:42 2013
New Revision: 251569
URL: http://svnweb.freebsd.org/changeset/base/251569

Log:
  MFC: r251133
  
  - Merge from r249476: Ensure that PCI bus BUS_GET_DMA_TAG() method sees
    the actual PCI device which makes the request for DMA tag, instead of
    some descendant of the PCI device, by creating a pass-through trampoline.
  - Sprinkle const on tables.
  - Use NULL instead of 0 for pointers.
  - Take advantage of nitems().

Modified:
  stable/9/sys/dev/msk/if_msk.c
  stable/9/sys/dev/sk/if_sk.c
  stable/9/sys/dev/sk/if_skreg.h
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/9/sys/dev/msk/if_msk.c
==============================================================================
--- stable/9/sys/dev/msk/if_msk.c	Sun Jun  9 12:46:41 2013	(r251568)
+++ stable/9/sys/dev/msk/if_msk.c	Sun Jun  9 12:51:42 2013	(r251569)
@@ -162,7 +162,7 @@ TUNABLE_INT("hw.msk.jumbo_disable", &jum
 /*
  * Devices supported by this driver.
  */
-static struct msk_product {
+static const struct msk_product {
 	uint16_t	msk_vendorid;
 	uint16_t	msk_deviceid;
 	const char	*msk_name;
@@ -257,6 +257,7 @@ static int mskc_shutdown(device_t);
 static int mskc_setup_rambuffer(struct msk_softc *);
 static int mskc_suspend(device_t);
 static int mskc_resume(device_t);
+static bus_dma_tag_t mskc_get_dma_tag(device_t, device_t);
 static void mskc_reset(struct msk_softc *);
 
 static int msk_probe(device_t);
@@ -334,6 +335,8 @@ static device_method_t mskc_methods[] = 
 	DEVMETHOD(device_resume,	mskc_resume),
 	DEVMETHOD(device_shutdown,	mskc_shutdown),
 
+	DEVMETHOD(bus_get_dma_tag,	mskc_get_dma_tag),
+
 	DEVMETHOD_END
 };
 
@@ -368,9 +371,9 @@ static driver_t msk_driver = {
 
 static devclass_t msk_devclass;
 
-DRIVER_MODULE(mskc, pci, mskc_driver, mskc_devclass, 0, 0);
-DRIVER_MODULE(msk, mskc, msk_driver, msk_devclass, 0, 0);
-DRIVER_MODULE(miibus, msk, miibus_driver, miibus_devclass, 0, 0);
+DRIVER_MODULE(mskc, pci, mskc_driver, mskc_devclass, NULL, NULL);
+DRIVER_MODULE(msk, mskc, msk_driver, msk_devclass, NULL, NULL);
+DRIVER_MODULE(miibus, msk, miibus_driver, miibus_devclass, NULL, NULL);
 
 static struct resource_spec msk_res_spec_io[] = {
 	{ SYS_RES_IOPORT,	PCIR_BAR(1),	RF_ACTIVE },
@@ -1180,15 +1183,14 @@ msk_ioctl(struct ifnet *ifp, u_long comm
 static int
 mskc_probe(device_t dev)
 {
-	struct msk_product *mp;
+	const struct msk_product *mp;
 	uint16_t vendor, devid;
 	int i;
 
 	vendor = pci_get_vendor(dev);
 	devid = pci_get_device(dev);
 	mp = msk_products;
-	for (i = 0; i < sizeof(msk_products)/sizeof(msk_products[0]);
-	    i++, mp++) {
+	for (i = 0; i < nitems(msk_products); i++, mp++) {
 		if (vendor == mp->msk_vendorid && devid == mp->msk_deviceid) {
 			device_set_desc(dev, mp->msk_name);
 			return (BUS_PROBE_DEFAULT);
@@ -2119,6 +2121,13 @@ mskc_detach(device_t dev)
 	return (0);
 }
 
+static bus_dma_tag_t
+mskc_get_dma_tag(device_t bus, device_t child __unused)
+{
+
+	return (bus_get_dma_tag(bus));
+}
+
 struct msk_dmamap_arg {
 	bus_addr_t	msk_busaddr;
 };

Modified: stable/9/sys/dev/sk/if_sk.c
==============================================================================
--- stable/9/sys/dev/sk/if_sk.c	Sun Jun  9 12:46:41 2013	(r251568)
+++ stable/9/sys/dev/sk/if_sk.c	Sun Jun  9 12:51:42 2013	(r251569)
@@ -143,7 +143,7 @@ static const char rcsid[] =
   "$FreeBSD$";
 #endif
 
-static struct sk_type sk_devs[] = {
+static const struct sk_type sk_devs[] = {
 	{
 		VENDORID_SK,
 		DEVICEID_SK_V1,
@@ -193,6 +193,7 @@ static int skc_detach(device_t);
 static int skc_shutdown(device_t);
 static int skc_suspend(device_t);
 static int skc_resume(device_t);
+static bus_dma_tag_t skc_get_dma_tag(device_t, device_t);
 static int sk_detach(device_t);
 static int sk_probe(device_t);
 static int sk_attach(device_t);
@@ -296,6 +297,8 @@ static device_method_t skc_methods[] = {
 	DEVMETHOD(device_resume,	skc_resume),
 	DEVMETHOD(device_shutdown,	skc_shutdown),
 
+	DEVMETHOD(bus_get_dma_tag,	skc_get_dma_tag),
+
 	DEVMETHOD_END
 };
 
@@ -330,9 +333,9 @@ static driver_t sk_driver = {
 
 static devclass_t sk_devclass;
 
-DRIVER_MODULE(skc, pci, skc_driver, skc_devclass, 0, 0);
-DRIVER_MODULE(sk, skc, sk_driver, sk_devclass, 0, 0);
-DRIVER_MODULE(miibus, sk, miibus_driver, miibus_devclass, 0, 0);
+DRIVER_MODULE(skc, pci, skc_driver, skc_devclass, NULL, NULL);
+DRIVER_MODULE(sk, skc, sk_driver, sk_devclass, NULL, NULL);
+DRIVER_MODULE(miibus, sk, miibus_driver, miibus_devclass, NULL, NULL);
 
 static struct resource_spec sk_res_spec_io[] = {
 	{ SYS_RES_IOPORT,	PCIR_BAR(1),	RF_ACTIVE },
@@ -1186,7 +1189,7 @@ static int
 skc_probe(dev)
 	device_t		dev;
 {
-	struct sk_type		*t = sk_devs;
+	const struct sk_type	*t = sk_devs;
 
 	while(t->sk_name != NULL) {
 		if ((pci_get_vendor(dev) == t->sk_vid) &&
@@ -1889,6 +1892,13 @@ skc_detach(dev)
 	return(0);
 }
 
+static bus_dma_tag_t
+skc_get_dma_tag(device_t bus, device_t child __unused)
+{
+
+	return (bus_get_dma_tag(bus));
+}
+
 struct sk_dmamap_arg {
 	bus_addr_t	sk_busaddr;
 };
@@ -3186,7 +3196,7 @@ sk_init_xmac(sc_if)
 	struct sk_softc		*sc;
 	struct ifnet		*ifp;
 	u_int16_t		eaddr[(ETHER_ADDR_LEN+1)/2];
-	struct sk_bcom_hack	bhack[] = {
+	static const struct sk_bcom_hack bhack[] = {
 	{ 0x18, 0x0c20 }, { 0x17, 0x0012 }, { 0x15, 0x1104 }, { 0x17, 0x0013 },
 	{ 0x15, 0x0404 }, { 0x17, 0x8006 }, { 0x15, 0x0132 }, { 0x17, 0x8006 },
 	{ 0x15, 0x0232 }, { 0x17, 0x800D }, { 0x15, 0x000F }, { 0x18, 0x0420 },

Modified: stable/9/sys/dev/sk/if_skreg.h
==============================================================================
--- stable/9/sys/dev/sk/if_skreg.h	Sun Jun  9 12:46:41 2013	(r251568)
+++ stable/9/sys/dev/sk/if_skreg.h	Sun Jun  9 12:51:42 2013	(r251569)
@@ -1289,7 +1289,7 @@
 struct sk_type {
 	u_int16_t		sk_vid;
 	u_int16_t		sk_did;
-	char			*sk_name;
+	const char		*sk_name;
 };
 
 #define SK_ADDR_LO(x)	((u_int64_t) (x) & 0xffffffff)


More information about the svn-src-stable-9 mailing list