From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 1/4] pci: rename variable mask -> barval
Date: Sat, 14 Apr 2018 01:30:50 +0200 [thread overview]
Message-ID: <20180413233053.15570-1-u.kleine-koenig@pengutronix.de> (raw)
The variable isn't really a mask. And it is irritating that this "mask"
value is passed as parameter "maxbase" to the function pci_size() which
also has a parameter "mask". So rename it to a more generic term.
The main reason for this patch is that the next patch introduces another
variable with name "mask" and so this original is in the way.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/pci/pci.c | 29 +++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index b2570eb15181..538903ee6607 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -170,25 +170,26 @@ static void setup_device(struct pci_dev *dev, int max_bar)
for (bar = 0; bar < max_bar; bar++) {
resource_size_t last_addr;
- u32 orig, mask, size;
+ u32 orig, barval, size;
pci_read_config_dword(dev, PCI_BASE_ADDRESS_0 + bar * 4, &orig);
pci_write_config_dword(dev, PCI_BASE_ADDRESS_0 + bar * 4, 0xfffffffe);
- pci_read_config_dword(dev, PCI_BASE_ADDRESS_0 + bar * 4, &mask);
+ pci_read_config_dword(dev, PCI_BASE_ADDRESS_0 + bar * 4, &barval);
pci_write_config_dword(dev, PCI_BASE_ADDRESS_0 + bar * 4, orig);
- if (mask == 0 || mask == 0xffffffff) {
+ if (barval == 0 || barval == 0xffffffff) {
pr_debug("pbar%d set bad mask\n", bar);
continue;
}
- if (mask & 0x01) { /* IO */
- size = pci_size(orig, mask, 0xfffffffe);
+ if (barval & 0x01) { /* IO */
+ size = pci_size(orig, barval, 0xfffffffe);
if (!size) {
pr_debug("pbar%d bad IO mask\n", bar);
continue;
}
- pr_debug("pbar%d: mask=%08x io %d bytes\n", bar, mask, size);
+ pr_debug("pbar%d: barval=%08x io %d bytes\n",
+ bar, barval, size);
if (ALIGN(last_io, size) + size >
dev->bus->resource[PCI_BUS_RESOURCE_IO]->end) {
pr_debug("BAR does not fit within bus IO res\n");
@@ -200,15 +201,15 @@ static void setup_device(struct pci_dev *dev, int max_bar)
dev->resource[bar].flags = IORESOURCE_IO;
last_addr = last_io;
last_io += size;
- } else if ((mask & PCI_BASE_ADDRESS_MEM_PREFETCH) &&
+ } else if ((barval & PCI_BASE_ADDRESS_MEM_PREFETCH) &&
last_mem_pref) /* prefetchable MEM */ {
- size = pci_size(orig, mask, 0xfffffff0);
+ size = pci_size(orig, barval, 0xfffffff0);
if (!size) {
pr_debug("pbar%d bad P-MEM mask\n", bar);
continue;
}
- pr_debug("pbar%d: mask=%08x P memory %d bytes\n",
- bar, mask, size);
+ pr_debug("pbar%d: barval=%08x P memory %d bytes\n",
+ bar, barval, size);
if (ALIGN(last_mem_pref, size) + size >
dev->bus->resource[PCI_BUS_RESOURCE_MEM_PREF]->end) {
pr_debug("BAR does not fit within bus p-mem res\n");
@@ -222,13 +223,13 @@ static void setup_device(struct pci_dev *dev, int max_bar)
last_addr = last_mem_pref;
last_mem_pref += size;
} else { /* non-prefetch MEM */
- size = pci_size(orig, mask, 0xfffffff0);
+ size = pci_size(orig, barval, 0xfffffff0);
if (!size) {
pr_debug("pbar%d bad NP-MEM mask\n", bar);
continue;
}
- pr_debug("pbar%d: mask=%08x NP memory %d bytes\n",
- bar, mask, size);
+ pr_debug("pbar%d: barval=%08x NP memory %d bytes\n",
+ bar, barval, size);
if (ALIGN(last_mem, size) + size >
dev->bus->resource[PCI_BUS_RESOURCE_MEM]->end) {
pr_debug("BAR does not fit within bus np-mem res\n");
@@ -245,7 +246,7 @@ static void setup_device(struct pci_dev *dev, int max_bar)
dev->resource[bar].start = last_addr;
dev->resource[bar].end = last_addr + size - 1;
- if ((mask & PCI_BASE_ADDRESS_MEM_TYPE_64)) {
+ if ((barval & PCI_BASE_ADDRESS_MEM_TYPE_64)) {
dev->resource[bar].flags |= IORESOURCE_MEM_64;
pci_write_config_dword(dev,
PCI_BASE_ADDRESS_1 + bar * 4, 0);
--
2.16.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next reply other threads:[~2018-04-13 23:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-13 23:30 Uwe Kleine-König [this message]
2018-04-13 23:30 ` [PATCH 2/4] pci: refactor bar configuration Uwe Kleine-König
2018-04-13 23:30 ` [PATCH 3/4] pci: improve debug output Uwe Kleine-König
2018-04-13 23:58 ` Uwe Kleine-König
2018-04-13 23:30 ` [PATCH 4/4] pci: don't hide hard to understand sanity check in size calculation Uwe Kleine-König
2018-04-14 16:25 ` Andrey Smirnov
2018-04-15 18:27 ` Uwe Kleine-König
2018-04-16 13:42 ` Andrey Smirnov
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=20180413233053.15570-1-u.kleine-koenig@pengutronix.de \
--to=u.kleine-koenig@pengutronix.de \
--cc=barebox@lists.infradead.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