From owner-svn-src-head@freebsd.org Sun Oct 18 20:20:12 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C2480A18550; Sun, 18 Oct 2015 20:20:12 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::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 933C417A8; Sun, 18 Oct 2015 20:20:12 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9IKKBZ6092898; Sun, 18 Oct 2015 20:20:11 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9IKKBC8092897; Sun, 18 Oct 2015 20:20:11 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201510182020.t9IKKBC8092897@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: "Conrad E. Meyer" Date: Sun, 18 Oct 2015 20:20:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289541 - head/sys/dev/ntb/ntb_hw X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Oct 2015 20:20:13 -0000 Author: cem Date: Sun Oct 18 20:20:11 2015 New Revision: 289541 URL: https://svnweb.freebsd.org/changeset/base/289541 Log: NTB: Simplify ntb_map_pci_bars Skip using a function pointer for shared error logging. Sponsored by: EMC / Isilon Storage Division Modified: head/sys/dev/ntb/ntb_hw/ntb_hw.c Modified: head/sys/dev/ntb/ntb_hw/ntb_hw.c ============================================================================== --- head/sys/dev/ntb/ntb_hw/ntb_hw.c Sun Oct 18 20:20:02 2015 (r289540) +++ head/sys/dev/ntb/ntb_hw/ntb_hw.c Sun Oct 18 20:20:11 2015 (r289541) @@ -194,16 +194,12 @@ bus_space_write_8(bus_space_tag_t tag, b ntb_bar_write(SIZE, ntb_mw_to_bar(ntb, ntb->mw_count), \ offset, val) -typedef int (*bar_map_strategy)(struct ntb_softc *ntb, - struct ntb_pci_bar_info *bar); - static int ntb_probe(device_t device); static int ntb_attach(device_t device); static int ntb_detach(device_t device); static inline enum ntb_bar ntb_mw_to_bar(struct ntb_softc *, unsigned mw); static int ntb_map_pci_bars(struct ntb_softc *ntb); -static int map_pci_bar(struct ntb_softc *ntb, bar_map_strategy strategy, - struct ntb_pci_bar_info *bar); +static void print_map_success(struct ntb_softc *, struct ntb_pci_bar_info *); static int map_mmr_bar(struct ntb_softc *ntb, struct ntb_pci_bar_info *bar); static int map_memory_window_bar(struct ntb_softc *ntb, struct ntb_pci_bar_info *bar); @@ -388,53 +384,44 @@ ntb_map_pci_bars(struct ntb_softc *ntb) int rc; ntb->bar_info[NTB_CONFIG_BAR].pci_resource_id = PCIR_BAR(0); - rc = map_pci_bar(ntb, map_mmr_bar, &ntb->bar_info[NTB_CONFIG_BAR]); + rc = map_mmr_bar(ntb, &ntb->bar_info[NTB_CONFIG_BAR]); if (rc != 0) - return (rc); + goto out; ntb->bar_info[NTB_B2B_BAR_1].pci_resource_id = PCIR_BAR(2); - rc = map_pci_bar(ntb, map_memory_window_bar, - &ntb->bar_info[NTB_B2B_BAR_1]); + rc = map_memory_window_bar(ntb, &ntb->bar_info[NTB_B2B_BAR_1]); if (rc != 0) - return (rc); + goto out; ntb->bar_info[NTB_B2B_BAR_2].pci_resource_id = PCIR_BAR(4); if (HAS_FEATURE(NTB_SDOORBELL_LOCKUP) && !HAS_FEATURE(NTB_SPLIT_BAR)) - rc = map_pci_bar(ntb, map_mmr_bar, - &ntb->bar_info[NTB_B2B_BAR_2]); + rc = map_mmr_bar(ntb, &ntb->bar_info[NTB_B2B_BAR_2]); else - rc = map_pci_bar(ntb, map_memory_window_bar, - &ntb->bar_info[NTB_B2B_BAR_2]); + rc = map_memory_window_bar(ntb, &ntb->bar_info[NTB_B2B_BAR_2]); if (!HAS_FEATURE(NTB_SPLIT_BAR)) - return (rc); + goto out; ntb->bar_info[NTB_B2B_BAR_3].pci_resource_id = PCIR_BAR(5); if (HAS_FEATURE(NTB_SDOORBELL_LOCKUP)) - rc = map_pci_bar(ntb, map_mmr_bar, - &ntb->bar_info[NTB_B2B_BAR_3]); + rc = map_mmr_bar(ntb, &ntb->bar_info[NTB_B2B_BAR_3]); else - rc = map_pci_bar(ntb, map_memory_window_bar, - &ntb->bar_info[NTB_B2B_BAR_3]); - return (rc); -} + rc = map_memory_window_bar(ntb, &ntb->bar_info[NTB_B2B_BAR_3]); -static int -map_pci_bar(struct ntb_softc *ntb, bar_map_strategy strategy, - struct ntb_pci_bar_info *bar) -{ - int rc; - - rc = strategy(ntb, bar); +out: if (rc != 0) device_printf(ntb->device, "unable to allocate pci resource\n"); - else - device_printf(ntb->device, - "Bar size = %lx, v %p, p %p\n", - bar->size, bar->vbase, (void *)(bar->pbase)); return (rc); } +static void +print_map_success(struct ntb_softc *ntb, struct ntb_pci_bar_info *bar) +{ + + device_printf(ntb->device, "Bar size = %lx, v %p, p %p\n", + bar->size, bar->vbase, (void *)(bar->pbase)); +} + static int map_mmr_bar(struct ntb_softc *ntb, struct ntb_pci_bar_info *bar) { @@ -445,6 +432,7 @@ map_mmr_bar(struct ntb_softc *ntb, struc return (ENXIO); save_bar_parameters(bar); + print_map_success(ntb, bar); return (0); } @@ -505,6 +493,7 @@ map_memory_window_bar(struct ntb_softc * "unable to mark bar as WRITE_COMBINING\n"); return (rc); } + print_map_success(ntb, bar); return (0); }