[patch] Re: pci_find_class question

Tim Waugh (tim@cyberelk.demon.co.uk)
Sat, 31 Jul 1999 15:49:56 +0100 (GMT)


Here is a patch that alters the behaviour of pci_find_class; I think it
makes it more useful.

Now pci_find_class returns the next device that matches the request class
and has at least the programming interface specified (i.e. least
significant byte of class).

So, if someone wanted to look at all of the parallel communication
devices, they could use (PCI_CLASS_COMMUNICATION_PARALLEL << 8) as the
class argument to pci_find_class. If it needs to be at least programming
interface 2, just add 0x02 to that.

Tim.
*/

--- linux/drivers/pci/pci.c~ Sat Jul 31 10:30:49 1999
+++ linux/drivers/pci/pci.c Sat Jul 31 15:39:54 1999
@@ -74,7 +74,9 @@
from = pci_devices;
else
from = from->next;
- while (from && from->class != class)
+ while (from
+ && ((from->class & ~0xff) != (class & ~0xff)
+ || (from->class & 0xff) < (class & 0xff)))
from = from->next;
return from;
}
--- linux/include/linux/pci.h~ Sat Jul 31 00:24:22 1999
+++ linux/include/linux/pci.h Sat Jul 31 15:41:13 1999
@@ -1300,6 +1300,8 @@
int pci_proc_detach_device(struct pci_dev *dev);

struct pci_dev *pci_find_device (unsigned int vendor, unsigned int device, struct pci_dev *from);
+/* find class finds a device in that class with _at least_ the specified
+ * prog-if. */
struct pci_dev *pci_find_class (unsigned int class, struct pci_dev *from);
struct pci_dev *pci_find_slot (unsigned int bus, unsigned int devfn);

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/