0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <linux/module.h>
0010 #include <linux/isapnp.h>
0011 #include <linux/string.h>
0012
0013 static void pnp_convert_id(char *buf, unsigned short vendor,
0014 unsigned short device)
0015 {
0016 sprintf(buf, "%c%c%c%x%x%x%x",
0017 'A' + ((vendor >> 2) & 0x3f) - 1,
0018 'A' + (((vendor & 3) << 3) | ((vendor >> 13) & 7)) - 1,
0019 'A' + ((vendor >> 8) & 0x1f) - 1,
0020 (device >> 4) & 0x0f, device & 0x0f,
0021 (device >> 12) & 0x0f, (device >> 8) & 0x0f);
0022 }
0023
0024 struct pnp_dev *pnp_find_dev(struct pnp_card *card, unsigned short vendor,
0025 unsigned short function, struct pnp_dev *from)
0026 {
0027 char id[8];
0028 char any[8];
0029
0030 pnp_convert_id(id, vendor, function);
0031 pnp_convert_id(any, ISAPNP_ANY_ID, ISAPNP_ANY_ID);
0032 if (card == NULL) {
0033 struct list_head *list;
0034
0035 list = pnp_global.next;
0036 if (from)
0037 list = from->global_list.next;
0038
0039 while (list != &pnp_global) {
0040 struct pnp_dev *dev = global_to_pnp_dev(list);
0041
0042 if (compare_pnp_id(dev->id, id) ||
0043 (memcmp(id, any, 7) == 0))
0044 return dev;
0045 list = list->next;
0046 }
0047 } else {
0048 struct list_head *list;
0049
0050 list = card->devices.next;
0051 if (from) {
0052 list = from->card_list.next;
0053 if (from->card != card)
0054 return NULL;
0055 }
0056 while (list != &card->devices) {
0057 struct pnp_dev *dev = card_to_pnp_dev(list);
0058
0059 if (compare_pnp_id(dev->id, id))
0060 return dev;
0061 list = list->next;
0062 }
0063 }
0064 return NULL;
0065 }
0066 EXPORT_SYMBOL(pnp_find_dev);