From owner-svn-src-all@FreeBSD.ORG Thu May 30 12:16:56 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 18CF747B; Thu, 30 May 2013 12:16:56 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id EE6B1A60; Thu, 30 May 2013 12:16:55 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r4UCGt2C069557; Thu, 30 May 2013 12:16:55 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r4UCGtkk069554; Thu, 30 May 2013 12:16:55 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201305301216.r4UCGtkk069554@svn.freebsd.org> From: Marius Strobl Date: Thu, 30 May 2013 12:16:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r251133 - in head/sys/dev: msk sk X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 May 2013 12:16:56 -0000 Author: marius Date: Thu May 30 12:16:55 2013 New Revision: 251133 URL: http://svnweb.freebsd.org/changeset/base/251133 Log: - 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(). MFC after: 1 week Modified: head/sys/dev/msk/if_msk.c head/sys/dev/sk/if_sk.c head/sys/dev/sk/if_skreg.h Modified: head/sys/dev/msk/if_msk.c ============================================================================== --- head/sys/dev/msk/if_msk.c Thu May 30 11:10:42 2013 (r251132) +++ head/sys/dev/msk/if_msk.c Thu May 30 12:16:55 2013 (r251133) @@ -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); @@ -2118,6 +2120,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: head/sys/dev/sk/if_sk.c ============================================================================== --- head/sys/dev/sk/if_sk.c Thu May 30 11:10:42 2013 (r251132) +++ head/sys/dev/sk/if_sk.c Thu May 30 12:16:55 2013 (r251133) @@ -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) && @@ -1888,6 +1891,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; }; @@ -3185,7 +3195,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: head/sys/dev/sk/if_skreg.h ============================================================================== --- head/sys/dev/sk/if_skreg.h Thu May 30 11:10:42 2013 (r251132) +++ head/sys/dev/sk/if_skreg.h Thu May 30 12:16:55 2013 (r251133) @@ -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)