diff -ur filo.orig/drivers/ide.c filo-0.5/drivers/ide.c
--- filo.orig/drivers/ide.c	2007-10-04 10:12:32.000000000 +0400
+++ filo-0.5/drivers/ide.c	2007-12-13 10:42:32.000000000 +0300
@@ -1089,7 +1089,7 @@
 #ifdef SUPPORT_PCI
 static int find_ide_controller(struct controller *ctrl, int ctrl_index)
 {
-	int pci_index;
+	int pci_index, skipped;
 	struct pci_dev *dev;
 	unsigned int mask;
 
@@ -1097,9 +1097,9 @@
 	pci_index = ctrl_index >> 1;
 
 	/* Find a IDE storage class device */
-	dev = pci_find_device(-1, -1, 0x0180, -1, pci_index); // S-ATA first.
+	dev = pci_find_device(-1, -1, 0x0101, -1, pci_index, &skipped);
 	if (!dev) {
-		dev = pci_find_device(-1, -1, 0x0101, -1, pci_index);
+		dev = pci_find_device(-1, -1, 0x0180, -1, pci_index-skipped, 0); // continue our search in S-ATA
 		if (!dev) {
 			debug("PCI IDE #%d not found\n", pci_index);
 			return -1;
diff -ur filo.orig/drivers/usb/usb.c filo-0.5/drivers/usb/usb.c
--- filo.orig/drivers/usb/usb.c	2006-05-06 23:09:23.000000000 +0400
+++ filo-0.5/drivers/usb/usb.c	2007-12-13 10:34:18.000000000 +0300
@@ -67,7 +67,7 @@
 	i=0;
 	num_controllers = 0;
 	while(num_controllers<MAX_CONTROLLERS) {
-	        dev = pci_find_device(-1, -1, 0x0c03, -1, i);
+	        dev = pci_find_device(-1, -1, 0x0c03, -1, i, 0);
 		if(!dev) break;
 		
 		//prog_if = ((dev->class>>8) & 0xff);
diff -ur filo.orig/include/pci.h filo-0.5/include/pci.h
--- filo.orig/include/pci.h	2005-11-15 12:37:30.000000000 +0300
+++ filo-0.5/include/pci.h	2007-12-13 10:33:38.000000000 +0300
@@ -31,6 +31,6 @@
 };
 
 void pci_init(void);
-struct pci_dev *pci_find_device(int vendor, int device, int devclass, int prog_if, int index);
+struct pci_dev *pci_find_device(int vendor, int device, int devclass, int prog_if, int index, int *skipped);
 
 #endif /* PCI_H */
diff -ur filo.orig/main/pci.c filo-0.5/main/pci.c
--- filo.orig/main/pci.c	2006-04-29 01:45:48.000000000 +0400
+++ filo-0.5/main/pci.c	2007-12-13 10:51:50.000000000 +0300
@@ -86,10 +86,11 @@
 #endif
 }
 
-struct pci_dev *pci_find_device(int vendor, int device, int devclass, int prog_if, int index)
+struct pci_dev *pci_find_device(int vendor, int device, int devclass, int prog_if, int index, int *skipped)
 {
     struct pci_dev *dev;
 
+    if(skipped)*skipped=0;
     for (dev = dev_list; dev < dev_list + n_devs; dev++) {
 	if (vendor < 0 || vendor==dev->vendor)
 	    if (device < 0 || device==dev->device)
@@ -98,6 +99,7 @@
 			if (index == 0)
 			    return dev;
 			index--;
+			if(skipped)*skipped++;
 		    }
     }
     return NULL;
diff -ur filo.orig/main/sound.c filo-0.5/main/sound.c
--- filo.orig/main/sound.c	2005-11-15 12:37:30.000000000 +0300
+++ filo-0.5/main/sound.c	2007-12-13 10:33:53.000000000 +0300
@@ -9,7 +9,7 @@
     struct pci_dev *dev;
 
     for (drv = sound_drivers_start; drv < sound_drivers_end; drv++) {
-	dev = pci_find_device(drv->vendor, drv->device, -1, -1, 0);
+	dev = pci_find_device(drv->vendor, drv->device, -1, -1, 0, 0);
 	if (dev) {
 	    if (drv->ops->init(dev) == 0) {
 		ops = drv->ops;
