From: "Jan Beulich" <JBeulich@suse.com>
To: "David Vrabel" <david.vrabel@citrix.com>,
"Boris Ostrovsky" <boris.ostrovsky@oracle.com>,
"Konrad Rzeszutek Wilk" <konrad.wilk@oracle.com>,
"Juergen Gross" <JGross@suse.com>
Cc: "xen-devel" <xen-devel@lists.xenproject.org>,
<linux-kernel@vger.kernel.org>
Subject: [PATCH v2 2/2] xen-pciback: clean up {bar,rom}_init()
Date: Tue, 07 Jun 2016 00:31:43 -0600 [thread overview]
Message-ID: <5756866F02000078000F269D@prv-mh.provo.novell.com> (raw)
In-Reply-To: <5756857802000078000F268D@prv-mh.provo.novell.com>
- drop unused function parameter of read_dev_bar()
- drop rom_init() (now identical to bar_init())
- fold read_dev_bar() into its now single caller
- simplify determination of 64-bit memory resource
- use const and unsigned
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
v2: fold in 3rd patch and drop read_dev_bar() (as requested by Boris)
---
drivers/xen/xen-pciback/conf_space_header.c | 57 ++++++++--------------------
1 file changed, 17 insertions(+), 40 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,58 +209,35 @@ 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 void *bar_init(struct pci_dev *dev, int offset)
{
- int pos;
- struct resource *res = dev->resource;
+ unsigned int pos;
+ const struct resource *res = dev->resource;
+ struct pci_bar_info *bar = kzalloc(sizeof(*bar), GFP_KERNEL);
+
+ if (!bar)
+ return ERR_PTR(-ENOMEM);
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))) {
- bar_info->val = res[pos - 1].start >> 32;
- bar_info->len_val = -resource_size(&res[pos - 1]) >> 32;
- return;
+ if (pos && (res[pos - 1].flags & IORESOURCE_MEM_64)) {
+ bar->val = res[pos - 1].start >> 32;
+ bar->len_val = -resource_size(&res[pos - 1]) >> 32;
+ return bar;
}
}
if (!res[pos].flags ||
(res[pos].flags & (IORESOURCE_DISABLED | IORESOURCE_UNSET |
IORESOURCE_BUSY)))
- return;
-
- bar_info->val = res[pos].start |
- (res[pos].flags & PCI_REGION_FLAG_MASK);
- bar_info->len_val = -resource_size(&res[pos]) |
- (res[pos].flags & PCI_REGION_FLAG_MASK);
-}
+ return bar;
-static void *bar_init(struct pci_dev *dev, int offset)
-{
- struct pci_bar_info *bar = kzalloc(sizeof(*bar), GFP_KERNEL);
-
- if (!bar)
- return ERR_PTR(-ENOMEM);
-
- read_dev_bar(dev, bar, offset, ~0);
-
- return bar;
-}
-
-static void *rom_init(struct pci_dev *dev, int offset)
-{
- struct pci_bar_info *bar = kzalloc(sizeof(*bar), GFP_KERNEL);
-
- if (!bar)
- return ERR_PTR(-ENOMEM);
-
- read_dev_bar(dev, bar, offset, ~PCI_ROM_ADDRESS_ENABLE);
+ bar->val = res[pos].start |
+ (res[pos].flags & PCI_REGION_FLAG_MASK);
+ bar->len_val = -resource_size(&res[pos]) |
+ (res[pos].flags & PCI_REGION_FLAG_MASK);
return bar;
}
@@ -383,7 +360,7 @@ static const struct config_field header_
{ \
.offset = reg_offset, \
.size = 4, \
- .init = rom_init, \
+ .init = bar_init, \
.reset = bar_reset, \
.release = bar_release, \
.u.dw.read = bar_read, \
next prev parent reply other threads:[~2016-06-07 6:31 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-07 6:27 [PATCH v2 0/2] xen-pciback: correct and clean up BAR handling Jan Beulich
2016-06-07 6:30 ` [PATCH v2 1/2] xen-pciback: return proper values during BAR sizing Jan Beulich
2016-06-07 14:06 ` Boris Ostrovsky
2016-06-07 14:14 ` Jan Beulich
2016-06-24 9:13 ` [PATCH v3 " Jan Beulich
2016-06-24 14:08 ` [Xen-devel] " David Vrabel
2016-06-07 6:31 ` Jan Beulich [this message]
2016-06-07 14:06 ` [PATCH v2 2/2] xen-pciback: clean up {bar,rom}_init() Boris Ostrovsky
2016-06-24 15:01 ` [Xen-devel] " David Vrabel
2016-06-27 7:24 ` Jan Beulich
2016-06-29 12:42 ` [Xen-devel] [PATCH v2 2/2] xen-pciback: clean up {bar, rom}_init() David Vrabel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5756866F02000078000F269D@prv-mh.provo.novell.com \
--to=jbeulich@suse.com \
--cc=JGross@suse.com \
--cc=boris.ostrovsky@oracle.com \
--cc=david.vrabel@citrix.com \
--cc=konrad.wilk@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®