From patchwork Mon Jun 6 08:12:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 9157389 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EF39760572 for ; Mon, 6 Jun 2016 08:15:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DFFF026907 for ; Mon, 6 Jun 2016 08:15:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CE67C2780C; Mon, 6 Jun 2016 08:15:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5E47926C9B for ; Mon, 6 Jun 2016 08:15:48 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b9pdv-0001Zg-CH; Mon, 06 Jun 2016 08:12:15 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b9pdt-0001Z0-TL for xen-devel@lists.xenproject.org; Mon, 06 Jun 2016 08:12:13 +0000 Received: from [193.109.254.147] by server-11.bemta-14.messagelabs.com id 9A/31-23272-D5035575; Mon, 06 Jun 2016 08:12:13 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrCIsWRWlGSWpSXmKPExsXS6fjDSzfGIDT c4MZiUYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNWPCwt1sBev4Kn7t28rcwNjI08XIySEkkCfR unIGYxcjBwevgJ3EhgNZIGEJAUOJffNXsYHYLAKqEmebOphBbDYBdYm2Z9tZuxi5OEQErjFKz L56mBUkwSwQKDF39k4WEFtYwFJi3t9nTBDz7SSW9r4HszkF7CWuvV3OBrFLUOLvDmGIVi2Jh7 9usUDY2hLLFr5mBilhFpCWWP6PYwIj3yyEhllIGmYhaZiF0LCAkWUVo3pxalFZapGukV5SUWZ 6RkluYmaOrqGhiV5uanFxYnpqTmJSsV5yfu4mRmDoMQDBDsaWOc6HGCU5mJREeWW/hoQL8SXl p1RmJBZnxBeV5qQWH2KU4eBQkuDV0A8NFxIsSk1PrUjLzAFGAUxagoNHSYT3hR5Qmre4IDG3O DMdInWKUVFKnFcApE8AJJFRmgfXBou8S4yyUsK8jECHCPEUpBblZpagyr9iFOdgVBLmvQIyni czrwRu+iugxUxAi5ddCwZZXJKIkJJqYHTbYMZ26/0HO/3mfJmZhrsVzv2N9Fv91mfNln+qFgc tBU/l5i7/lJEzdcX33A0bP87ZM2u31v9tfteffmvYp7LWevLfG84n2urUep7bOygKNq76tfvI oQvPpjzatn72iQB1L8bULuWXPbW7m9j9rddZaHUs7VV8u+WNyY6DaTWqycsmRQfd9c5SYinOS DTUYi4qTgQArKdHPLcCAAA= X-Env-Sender: JBeulich@suse.com X-Msg-Ref: server-13.tower-27.messagelabs.com!1465200730!45991616!1 X-Originating-IP: [137.65.248.74] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 51610 invoked from network); 6 Jun 2016 08:12:11 -0000 Received: from prv-mh.provo.novell.com (HELO prv-mh.provo.novell.com) (137.65.248.74) by server-13.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 6 Jun 2016 08:12:11 -0000 Received: from INET-PRV-MTA by prv-mh.provo.novell.com with Novell_GroupWise; Mon, 06 Jun 2016 02:12:09 -0600 Message-Id: <57554C7502000078000F1DF5@prv-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.2.0 Date: Mon, 06 Jun 2016 02:12:05 -0600 From: "Jan Beulich" To: "David Vrabel" , "Boris Ostrovsky" , "Konrad Rzeszutek Wilk" , "Jan Beulich" ,"Juergen Gross" References: <57554B8D02000078000F1DE4@prv-mh.provo.novell.com> In-Reply-To: <57554B8D02000078000F1DE4@prv-mh.provo.novell.com> Mime-Version: 1.0 Content-Disposition: inline Cc: xen-devel , linux-kernel@vger.kernel.org Subject: [Xen-devel] [PATCH 2/2] xen-pciback: clean up read_dev_bar() X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP - drop unused function parameter - simplify determination of 64-bit memory resource - use const and unsigned Signed-off-by: Jan Beulich Reviewed-by: Boris Ostrovsky --- drivers/xen/xen-pciback/conf_space_header.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) --- 4.7-rc2-xen-pciback-BAR.orig/drivers/xen/xen-pciback/conf_space_header.c +++ 4.7-rc2-xen-pciback-BAR/drivers/xen/xen-pciback/conf_space_header.c @@ -209,21 +209,18 @@ static int bar_read(struct pci_dev *dev, return 0; } -static inline void read_dev_bar(struct pci_dev *dev, - struct pci_bar_info *bar_info, int offset, - u32 len_mask) +static inline void read_dev_bar(const struct pci_dev *dev, + struct pci_bar_info *bar_info, + unsigned int offset) { - int pos; - struct resource *res = dev->resource; + unsigned int pos; + const struct resource *res = dev->resource; if (offset == PCI_ROM_ADDRESS || offset == PCI_ROM_ADDRESS1) pos = PCI_ROM_RESOURCE; else { pos = (offset - PCI_BASE_ADDRESS_0) / 4; - if (pos && ((res[pos - 1].flags & (PCI_BASE_ADDRESS_SPACE | - PCI_BASE_ADDRESS_MEM_TYPE_MASK)) == - (PCI_BASE_ADDRESS_SPACE_MEMORY | - PCI_BASE_ADDRESS_MEM_TYPE_64))) { + if (pos && (res[pos - 1].flags & IORESOURCE_MEM_64)) { bar_info->val = res[pos - 1].start >> 32; bar_info->len_val = -resource_size(&res[pos - 1]) >> 32; return; @@ -248,7 +245,7 @@ static void *bar_init(struct pci_dev *de if (!bar) return ERR_PTR(-ENOMEM); - read_dev_bar(dev, bar, offset, ~0); + read_dev_bar(dev, bar, offset); return bar; } @@ -260,7 +257,7 @@ static void *rom_init(struct pci_dev *de if (!bar) return ERR_PTR(-ENOMEM); - read_dev_bar(dev, bar, offset, ~PCI_ROM_ADDRESS_ENABLE); + read_dev_bar(dev, bar, offset); return bar; }