Skip to content

Commit d145827

Browse files
committed
ALSA: Add snd_pci_quirk_lookup_id()
Added a new function to look up a quirk entry with the given PCI SSID instead of a pci device pointer. This can be used when the searched ID is overridden for debugging or such a purpose. Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 47e9134 commit d145827

2 files changed

Lines changed: 30 additions & 5 deletions

File tree

‎include/sound/core.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,5 +458,8 @@ struct snd_pci_quirk {
458458
const struct snd_pci_quirk *
459459
snd_pci_quirk_lookup(struct pci_dev *pci, const struct snd_pci_quirk *list);
460460

461+
const struct snd_pci_quirk *
462+
snd_pci_quirk_lookup_id(u16 vendor, u16 device,
463+
const struct snd_pci_quirk *list);
461464

462465
#endif /* __SOUND_CORE_H */

‎sound/core/misc.c‎

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,9 @@ EXPORT_SYMBOL_GPL(__snd_printk);
101101
#ifdef CONFIG_PCI
102102
#include <linux/pci.h>
103103
/**
104-
* snd_pci_quirk_lookup - look up a PCI SSID quirk list
105-
* @pci: pci_dev handle
104+
* snd_pci_quirk_lookup_id - look up a PCI SSID quirk list
105+
* @vendor: PCI SSV id
106+
* @device: PCI SSD id
106107
* @list: quirk list, terminated by a null entry
107108
*
108109
* Look through the given quirk list and finds a matching entry
@@ -112,18 +113,39 @@ EXPORT_SYMBOL_GPL(__snd_printk);
112113
* Returns the matched entry pointer, or NULL if nothing matched.
113114
*/
114115
const struct snd_pci_quirk *
115-
snd_pci_quirk_lookup(struct pci_dev *pci, const struct snd_pci_quirk *list)
116+
snd_pci_quirk_lookup_id(u16 vendor, u16 device,
117+
const struct snd_pci_quirk *list)
116118
{
117119
const struct snd_pci_quirk *q;
118120

119121
for (q = list; q->subvendor; q++) {
120-
if (q->subvendor != pci->subsystem_vendor)
122+
if (q->subvendor != vendor)
121123
continue;
122124
if (!q->subdevice ||
123-
(pci->subsystem_device & q->subdevice_mask) == q->subdevice)
125+
(device & q->subdevice_mask) == q->subdevice)
124126
return q;
125127
}
126128
return NULL;
127129
}
130+
EXPORT_SYMBOL(snd_pci_quirk_lookup_id);
131+
132+
/**
133+
* snd_pci_quirk_lookup - look up a PCI SSID quirk list
134+
* @pci: pci_dev handle
135+
* @list: quirk list, terminated by a null entry
136+
*
137+
* Look through the given quirk list and finds a matching entry
138+
* with the same PCI SSID. When subdevice is 0, all subdevice
139+
* values may match.
140+
*
141+
* Returns the matched entry pointer, or NULL if nothing matched.
142+
*/
143+
const struct snd_pci_quirk *
144+
snd_pci_quirk_lookup(struct pci_dev *pci, const struct snd_pci_quirk *list)
145+
{
146+
return snd_pci_quirk_lookup_id(pci->subsystem_vendor,
147+
pci->subsystem_device,
148+
list);
149+
}
128150
EXPORT_SYMBOL(snd_pci_quirk_lookup);
129151
#endif

0 commit comments

Comments
 (0)