Skip to contentSkip to conversation

PCMCIA bug fix

PATCH In review Andrey Ulanov 2 participants 3 messages Jun 29, 2004 – Jun 30, 2004 Pcmcia

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCMCIA bug fix

I tested with one of ieee1394+usb2.0 PCMCIA adapters. Worked fine. Without this patch only first device (ieee1394 controller) was detected.

Please apply.

Signature · 1 line
with best regards, Andrey Ulanov.
drivers/pcmcia/cardbus.c renamed from drivers/pcmcia/cardbus.c.pcmcia +12 -6
@@ -435,12 +435,12 @@
 	pci_readb(&tmp, PCI_HEADER_TYPE, &hdr);
 	fn = 1;
 	if (hdr & 0x80) {
-		do {
-			tmp.devfn = fn;
+		for (i = 0; i < 8; i++) {
+			tmp.devfn = i;
 			if (pci_readw(&tmp, PCI_VENDOR_ID, &v) || !v || v == 0xffff)
-				break;
+				continue;
 			fn++;
-		} while (fn < 8);
+		};
 	}
 	s->functions = fn;
 
@@ -450,11 +450,17 @@
 	memset(c, 0, fn * sizeof(struct cb_config_t));
 
 	irq = s->cap.pci_irq;
-	for (i = 0; i < fn; i++) {
-		struct pci_dev *dev = &c[i].dev;
+	for (i = 0, fn = 0; i < 8; i++) {
+		struct pci_dev *dev = &c[fn].dev;
 		u8 irq_pin;
 		int r;
 
+		tmp.devfn = i;
+		if(pci_readw(&tmp, PCI_VENDOR_ID, &v) || !v || v == 0xffff)
+		    continue;
+
+		fn++;
+
 		dev->bus = bus;
 		dev->sysdata = bus->sysdata;
 		dev->devfn = i;
#1 lore raw
Quoted 3 lines · Andrey Ulanov

I tested with one of ieee1394+usb2.0 PCMCIA adapters. Worked fine. Without this patch only first device (ieee1394 controller) was detected.

Can you provide the lspci output, and a better description of the problem you're trying to solve please?

Signature · 4 lines
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 PCMCIA      - http://pcmcia.arm.linux.org.uk/
                 2.6 Serial core
#2 lore raw

Hi, Russell!

Quoted 6 lines · Russell King
Quoted 3 lines · Andrey Ulanov

I tested with one of ieee1394+usb2.0 PCMCIA adapters. Worked fine. Without this patch only first device (ieee1394 controller) was detected.

Can you provide the lspci output, and a better description of the problem you're trying to solve please?

OK. Sorry.

This PCMCIA has four devices:

Bus 6, device 0, function 0:

    Class 0c00: PCI device 104c:8024 (rev 0).
      IRQ 10.
      Master Capable.  Latency=16.  
      Non-prefetchable 32 bit memory at 0x11000000 [0x110007ff].
      Non-prefetchable 32 bit memory at 0x11004000 [0x11007fff].
  Bus  6, device   0, function  4:
    Class 0c03: PCI device 104c:0035 (rev 67).
      IRQ 10.
      Master Capable.  Latency=64.  
      Non-prefetchable 32 bit memory at 0x11001000 [0x11001fff].
  Bus  6, device   0, function  5:
    Class 0c03: PCI device 104c:0035 (rev 67).
      IRQ 10.
      Master Capable.  Latency=64.  
      Non-prefetchable 32 bit memory at 0x11002000 [0x11002fff].
  Bus  6, device   0, function  6:
    Class 0c03: PCI device 104c:00e0 (rev 4).
      IRQ 10.
      Master Capable.  Latency=68.  
      Non-prefetchable 32 bit memory at 0x11000800 [0x110008ff].

As you can see functions numbers do not form continual sequence beginning with zero. That's why current implementation do not work for me. Here is the part of old code:

fn = 1;
if (hdr & 0x80) {

  do {
    tmp.devfn = fn;
    if (pci_readw(&tmp, PCI_VENDOR_ID, &v) || !v || v == 0xffff)
      break;
    fn++;

} while (fn < 8);
}
s->functions = fn;

I hope now it is obvious that it detects only first one in my case.

Signature · 1 line
with best regards, Andrey Ulanov.