From: Jaroslav Kysela <jkysela@redhat.com> Date: Thu, 23 Apr 2009 13:32:20 -0400 Subject: [alsa] handle subdevice_mask in snd_pci_quirk_lookup Message-id: 200904231732.n3NHWK3w031872@ns3.rdu.redhat.com O-Subject: [RHEL 5.4 PATCH] ALSA: Extend snd_pci_quirk_lookup() to handle subdevice_mask Bugzilla: 473949 483594 RH-Acked-by: Brian Maly <bmaly@redhat.com> RH-Acked-by: Pete Zaitcev <zaitcev@redhat.com> RH-Acked-by: John Feeney <jfeeney@redhat.com> Bugzilla ======== BZ#483594,BZ#473949 https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=483594 https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=473949 Description =========== The big HDA patch from BZ#483594 (3rd version) expects to handle subdevice_mask in the snd_pci_quirk_lookup() core function. This code extends the mentioned function and is in mainstream. diff --git a/include/sound/core.h b/include/sound/core.h index 72a3c1c..5f8601c 100644 --- a/include/sound/core.h +++ b/include/sound/core.h @@ -416,8 +416,8 @@ struct snd_pci_quirk { #define _SND_PCI_QUIRK_ID_MASK(vend, mask, dev) \ .subvendor = (vend), .subdevice = (dev), .subdevice_mask = (mask) -#define _SND_PCI_QUIRK_ID(vend,dev) \ - .subvendor = (vend), .subdevice = (dev) +#define _SND_PCI_QUIRK_ID(vend, dev) \ + _SND_PCI_QUIRK_ID_MASK(vend, 0xffff, dev) #define SND_PCI_QUIRK_ID(vend,dev) {_SND_PCI_QUIRK_ID(vend, dev)} #ifdef CONFIG_SND_DEBUG_DETECT #define SND_PCI_QUIRK(vend,dev,xname,val) \ diff --git a/sound/core/misc.c b/sound/core/misc.c index f78cd00..44ada9d 100644 --- a/sound/core/misc.c +++ b/sound/core/misc.c @@ -96,10 +96,13 @@ snd_pci_quirk_lookup(struct pci_dev *pci, const struct snd_pci_quirk *list) { const struct snd_pci_quirk *q; - for (q = list; q->subvendor; q++) - if (q->subvendor == pci->subsystem_vendor && - (!q->subdevice || q->subdevice == pci->subsystem_device)) + for (q = list; q->subvendor; q++) { + if (q->subvendor != pci->subsystem_vendor) + continue; + if (!q->subdevice || + (pci->subsystem_device & q->subdevice_mask) == q->subdevice) return q; + } return NULL; }