Skip to contentSkip to conversation

: MIPS: PCI: Add pre_enable hook, minor readability fixes

PATCH Superseded Joshua Kinard 2 participants 3 messages May 25, 2015 MIPS

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 : MIPS: PCI: Add pre_enable hook, minor readability fixes

From: Joshua Kinard <[email protected]>

This patch adds a hook "pre_enable", to the core MIPS PCI code. It is used by the IP30 Port to setup the PCI resources prior to probing the BRIDGE and detecting available PCI devices. It also adds some minor whitespace to improve readability.

---
 arch/mips/include/asm/pci.h |    3 +++
 arch/mips/pci/pci.c         |   10 ++++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

linux-mips-pci-pre_enable.patch

arch/mips/include/asm/pci.h +3 -0
index d969299..b51ccbd 100644
@@ -43,6 +43,9 @@ struct pci_controller {
 	   and XFree86. Eventually will be removed. */
 	unsigned int need_domain_info;
 
+	/* called in pcibios_enable_resources */
+	int (*pre_enable)(struct pci_controller *, struct pci_dev *, int);
+
 	int iommu;
 
 	/* Optional access methods for reading/writing the bus number
arch/mips/pci/pci.c +8 -2
index b8a0bf5..af17c16 100644
@@ -261,14 +261,19 @@ static int pcibios_enable_resources(struct pci_dev *dev, int mask)
 	u16 cmd, old_cmd;
 	int idx;
 	struct resource *r;
+	struct pci_controller *hose = (struct pci_controller *)dev->sysdata;
 
 	pci_read_config_word(dev, PCI_COMMAND, &cmd);
 	old_cmd = cmd;
-	for (idx=0; idx < PCI_NUM_RESOURCES; idx++) {
+	for (idx = 0; idx < PCI_NUM_RESOURCES; idx++) {
 		/* Only set up the requested stuff */
-		if (!(mask & (1<<idx)))
+		if (!(mask & (1 << idx)))
 			continue;
 
+		if(hose->pre_enable)
+			if(hose->pre_enable(hose, dev, idx) < 0)
+				return -EINVAL;
+
 		r = &dev->resource[idx];
 		if (!(r->flags & (IORESOURCE_IO | IORESOURCE_MEM)))
 			continue;
@@ -291,6 +296,7 @@ static int pcibios_enable_resources(struct pci_dev *dev, int mask)
 		       pci_name(dev), old_cmd, cmd);
 		pci_write_config_word(dev, PCI_COMMAND, cmd);
 	}
+
 	return 0;
 }
 
#1 lore raw

Hello.

Quoted 8 lines · Joshua Kinard

From: Joshua Kinard <[email protected]>

This patch adds a hook "pre_enable", to the core MIPS PCI code. It is used by the IP30 Port to setup the PCI resources prior to probing the BRIDGE and detecting available PCI devices. It also adds some minor whitespace to improve readability.

[...]

Quoted 11 lines
arch/mips/pci/pci.c +1 -0
index b8a0bf5..af17c16 100644
@@ -261,14 +261,19 @@ static int pcibios_enable_resources(struct pci_dev *dev, int mask)
  	u16 cmd, old_cmd;
  	int idx;
  	struct resource *r;
+	struct pci_controller *hose = (struct pci_controller *)dev->sysdata;
 
  	pci_read_config_word(dev, PCI_COMMAND, &cmd);

arch/mips/pci/pci.c static int pcibios_enable_resources(struct pci_dev *dev, int mask) · line 274

Quoted 10 lines
arch/mips/pci/pci.c +4 -2
  	old_cmd = cmd;
-	for (idx=0; idx < PCI_NUM_RESOURCES; idx++) {
+	for (idx = 0; idx < PCI_NUM_RESOURCES; idx++) {
  		/* Only set up the requested stuff */
-		if (!(mask & (1<<idx)))
+		if (!(mask & (1 << idx)))
  			continue;
 
+		if(hose->pre_enable)
+			if(hose->pre_enable(hose, dev, idx) < 0)

Space required after *if*; please run your patches thru scripts/checkpatch.pl.

WBR, Sergei

#2 lore raw
Quoted 34 lines · Sergei Shtylyov

Hello.

Quoted 8 lines · Joshua Kinard

From: Joshua Kinard <[email protected]>

This patch adds a hook "pre_enable", to the core MIPS PCI code. It is used by the IP30 Port to setup the PCI resources prior to probing the BRIDGE and detecting available PCI devices. It also adds some minor whitespace to improve readability.

[...]

Quoted 20 lines
arch/mips/pci/pci.c +3 -2
index b8a0bf5..af17c16 100644
@@ -261,14 +261,19 @@ static int pcibios_enable_resources(struct pci_dev
 *dev, int mask)
      u16 cmd, old_cmd;
      int idx;
      struct resource *r;
+    struct pci_controller *hose = (struct pci_controller *)dev->sysdata;
 
      pci_read_config_word(dev, PCI_COMMAND, &cmd);
      old_cmd = cmd;
-    for (idx=0; idx < PCI_NUM_RESOURCES; idx++) {
+    for (idx = 0; idx < PCI_NUM_RESOURCES; idx++) {
          /* Only set up the requested stuff */
-        if (!(mask & (1<<idx)))
+        if (!(mask & (1 << idx)))
              continue;
 
Quoted 6 lines

arch/mips/pci/pci.c static int pcibios_enable_resources(struct pci_dev *dev, int mask) · line 274

Quoted 2 lines
arch/mips/pci/pci.c +2 -0
+        if(hose->pre_enable)
+            if(hose->pre_enable(hose, dev, idx) < 0)

Space required after *if*; please run your patches thru scripts/checkpatch.pl.

WBR, Sergei

Whoops, thanks for catching that! I cleaned up a lot of the original IP30 code and added a lot of the needed whitespace, but I apparently missed this bit. I'll send a v2 shortly.

--J