From owner-svn-src-stable@FreeBSD.ORG Fri Apr 25 21:42:53 2014 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 0DCE0A0A; Fri, 25 Apr 2014 21:42:53 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CE2F01AEB; Fri, 25 Apr 2014 21:42:52 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s3PLgqUT057105; Fri, 25 Apr 2014 21:42:52 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s3PLgqof057103; Fri, 25 Apr 2014 21:42:52 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201404252142.s3PLgqof057103@svn.freebsd.org> From: Marius Strobl Date: Fri, 25 Apr 2014 21:42:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r264945 - stable/10/sys/dev/iwn X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Apr 2014 21:42:53 -0000 Author: marius Date: Fri Apr 25 21:42:52 2014 New Revision: 264945 URL: http://svnweb.freebsd.org/changeset/base/264945 Log: MFC: r260053 - There's no need to keep track of resource IDs. - Simplify MSI allocation and release. For a single one, we don't need to fiddle with the MSI count and pci_release_msi(9) is smart enough to just do nothing in case of INTx. - Don't allocate MSI as RF_SHAREABLE. - Use DEVMETHOD_END. - Use NULL instead of 0 for pointers. Modified: stable/10/sys/dev/iwn/if_iwn.c stable/10/sys/dev/iwn/if_iwnvar.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/iwn/if_iwn.c ============================================================================== --- stable/10/sys/dev/iwn/if_iwn.c Fri Apr 25 21:42:46 2014 (r264944) +++ stable/10/sys/dev/iwn/if_iwn.c Fri Apr 25 21:42:52 2014 (r264945) @@ -413,7 +413,8 @@ static device_method_t iwn_methods[] = { DEVMETHOD(device_shutdown, iwn_shutdown), DEVMETHOD(device_suspend, iwn_suspend), DEVMETHOD(device_resume, iwn_resume), - { 0, 0 } + + DEVMETHOD_END }; static driver_t iwn_driver = { @@ -423,7 +424,7 @@ static driver_t iwn_driver = { }; static devclass_t iwn_devclass; -DRIVER_MODULE(iwn, pci, iwn_driver, iwn_devclass, 0, 0); +DRIVER_MODULE(iwn, pci, iwn_driver, iwn_devclass, NULL, NULL); MODULE_VERSION(iwn, 1); @@ -453,7 +454,7 @@ iwn_attach(device_t dev) struct ieee80211com *ic; struct ifnet *ifp; uint32_t reg; - int i, error, result; + int i, error, rid; uint8_t macaddr[IEEE80211_ADDR_LEN]; sc->sc_dev = dev; @@ -494,8 +495,8 @@ iwn_attach(device_t dev) /* Enable bus-mastering. */ pci_enable_busmaster(dev); - sc->mem_rid = PCIR_BAR(0); - sc->mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->mem_rid, + rid = PCIR_BAR(0); + sc->mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); if (sc->mem == NULL) { device_printf(dev, "can't map mem space\n"); @@ -505,13 +506,13 @@ iwn_attach(device_t dev) sc->sc_st = rman_get_bustag(sc->mem); sc->sc_sh = rman_get_bushandle(sc->mem); - sc->irq_rid = 0; - if ((result = pci_msi_count(dev)) == 1 && - pci_alloc_msi(dev, &result) == 0) - sc->irq_rid = 1; + i = 1; + rid = 0; + if (pci_alloc_msi(dev, &i) == 0) + rid = 1; /* Install interrupt handler. */ - sc->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &sc->irq_rid, - RF_ACTIVE | RF_SHAREABLE); + sc->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE | + (rid != 0 ? 0 : RF_SHAREABLE)); if (sc->irq == NULL) { device_printf(dev, "can't map interrupt\n"); error = ENOMEM; @@ -976,9 +977,9 @@ iwn_detach(device_t dev) /* Uninstall interrupt handler. */ if (sc->irq != NULL) { bus_teardown_intr(dev, sc->irq, sc->sc_ih); - bus_release_resource(dev, SYS_RES_IRQ, sc->irq_rid, sc->irq); - if (sc->irq_rid == 1) - pci_release_msi(dev); + bus_release_resource(dev, SYS_RES_IRQ, rman_get_rid(sc->irq), + sc->irq); + pci_release_msi(dev); } /* Free DMA resources. */ @@ -992,7 +993,8 @@ iwn_detach(device_t dev) iwn_free_fwmem(sc); if (sc->mem != NULL) - bus_release_resource(dev, SYS_RES_MEMORY, sc->mem_rid, sc->mem); + bus_release_resource(dev, SYS_RES_MEMORY, + rman_get_rid(sc->mem), sc->mem); if (ifp != NULL) if_free(ifp); Modified: stable/10/sys/dev/iwn/if_iwnvar.h ============================================================================== --- stable/10/sys/dev/iwn/if_iwnvar.h Fri Apr 25 21:42:46 2014 (r264944) +++ stable/10/sys/dev/iwn/if_iwnvar.h Fri Apr 25 21:42:52 2014 (r264945) @@ -294,11 +294,9 @@ struct iwn_softc { struct iwn_tx_ring txq[IWN5000_NTXQUEUES]; struct iwn_rx_ring rxq; - int mem_rid; struct resource *mem; bus_space_tag_t sc_st; bus_space_handle_t sc_sh; - int irq_rid; struct resource *irq; void *sc_ih; bus_size_t sc_sz;