[ALSA] pci_find_device remove

Memalloc module,CS46xx driver,VIA82xx driver,ALI5451 driver
au88x0 driver
Replace pci_find_device() with pci_get_device() and pci_dev_put().

Signed-off-by: Jiri Slaby <xslaby@fi.muni.cz>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Jiri Slaby 2005-09-07 14:28:33 +02:00 committed by Jaroslav Kysela
parent 8cdfd2519c
commit 0dd119f703
6 changed files with 38 additions and 24 deletions

View File

@ -1702,7 +1702,6 @@ struct _snd_cs46xx {
void (*active_ctrl)(cs46xx_t *, int); void (*active_ctrl)(cs46xx_t *, int);
void (*mixer_init)(cs46xx_t *); void (*mixer_init)(cs46xx_t *);
struct pci_dev *acpi_dev;
int acpi_port; int acpi_port;
snd_kcontrol_t *eapd_switch; /* for amplifier hack */ snd_kcontrol_t *eapd_switch; /* for amplifier hack */
int accept_valid; /* accept mmap valid (for OSS) */ int accept_valid; /* accept mmap valid (for OSS) */

View File

@ -590,7 +590,7 @@ static int snd_mem_proc_write(struct file *file, const char __user *buffer,
alloced = 0; alloced = 0;
pci = NULL; pci = NULL;
while ((pci = pci_find_device(vendor, device, pci)) != NULL) { while ((pci = pci_get_device(vendor, device, pci)) != NULL) {
if (mask > 0 && mask < 0xffffffff) { if (mask > 0 && mask < 0xffffffff) {
if (pci_set_dma_mask(pci, mask) < 0 || if (pci_set_dma_mask(pci, mask) < 0 ||
pci_set_consistent_dma_mask(pci, mask) < 0) { pci_set_consistent_dma_mask(pci, mask) < 0) {
@ -604,6 +604,7 @@ static int snd_mem_proc_write(struct file *file, const char __user *buffer,
if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
size, &dmab) < 0) { size, &dmab) < 0) {
printk(KERN_ERR "snd-page-alloc: cannot allocate buffer pages (size = %d)\n", size); printk(KERN_ERR "snd-page-alloc: cannot allocate buffer pages (size = %d)\n", size);
pci_dev_put(pci);
return (int)count; return (int)count;
} }
snd_dma_reserve_buf(&dmab, snd_dma_pci_buf_id(pci)); snd_dma_reserve_buf(&dmab, snd_dma_pci_buf_id(pci));

View File

@ -318,13 +318,12 @@ static void ali_read_regs(ali_t *codec, int channel)
static void ali_read_cfg(unsigned int vendor, unsigned deviceid) static void ali_read_cfg(unsigned int vendor, unsigned deviceid)
{ {
unsigned int dwVal; unsigned int dwVal;
struct pci_dev *pci_dev = NULL; struct pci_dev *pci_dev;
int i,j; int i,j;
pci_dev = pci_get_device(vendor, deviceid, NULL);
pci_dev = pci_find_device(vendor, deviceid, pci_dev); if (pci_dev == NULL)
if (pci_dev == NULL) return ;
return ;
printk("\nM%x PCI CFG\n", deviceid); printk("\nM%x PCI CFG\n", deviceid);
printk(" "); printk(" ");
@ -341,6 +340,7 @@ static void ali_read_cfg(unsigned int vendor, unsigned deviceid)
} }
printk("\n"); printk("\n");
} }
pci_dev_put(pci_dev);
} }
static void ali_read_ac97regs(ali_t *codec, int secondary) static void ali_read_ac97regs(ali_t *codec, int secondary)
{ {
@ -2108,6 +2108,8 @@ static int snd_ali_free(ali_t * codec)
#ifdef CONFIG_PM #ifdef CONFIG_PM
kfree(codec->image); kfree(codec->image);
#endif #endif
pci_dev_put(codec->pci_m1533);
pci_dev_put(codec->pci_m7101);
kfree(codec); kfree(codec);
return 0; return 0;
} }
@ -2297,7 +2299,7 @@ static int __devinit snd_ali_create(snd_card_t * card,
codec->chregs.data.ainten = 0x00; codec->chregs.data.ainten = 0x00;
/* M1533: southbridge */ /* M1533: southbridge */
pci_dev = pci_find_device(0x10b9, 0x1533, NULL); pci_dev = pci_get_device(0x10b9, 0x1533, NULL);
codec->pci_m1533 = pci_dev; codec->pci_m1533 = pci_dev;
if (! codec->pci_m1533) { if (! codec->pci_m1533) {
snd_printk(KERN_ERR "ali5451: cannot find ALi 1533 chip.\n"); snd_printk(KERN_ERR "ali5451: cannot find ALi 1533 chip.\n");
@ -2305,7 +2307,7 @@ static int __devinit snd_ali_create(snd_card_t * card,
return -ENODEV; return -ENODEV;
} }
/* M7101: power management */ /* M7101: power management */
pci_dev = pci_find_device(0x10b9, 0x7101, NULL); pci_dev = pci_get_device(0x10b9, 0x7101, NULL);
codec->pci_m7101 = pci_dev; codec->pci_m7101 = pci_dev;
if (! codec->pci_m7101 && codec->revision == ALI_5451_V02) { if (! codec->pci_m7101 && codec->revision == ALI_5451_V02) {
snd_printk(KERN_ERR "ali5451: cannot find ALi 7101 chip.\n"); snd_printk(KERN_ERR "ali5451: cannot find ALi 7101 chip.\n");

View File

@ -79,19 +79,21 @@ static void vortex_fix_agp_bridge(struct pci_dev *via)
static void __devinit snd_vortex_workaround(struct pci_dev *vortex, int fix) static void __devinit snd_vortex_workaround(struct pci_dev *vortex, int fix)
{ {
struct pci_dev *via; struct pci_dev *via = NULL;
/* autodetect if workarounds are required */ /* autodetect if workarounds are required */
if (fix == 255) { if (fix == 255) {
/* VIA KT133 */ /* VIA KT133 */
via = pci_find_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8365_1, NULL); via = pci_get_device(PCI_VENDOR_ID_VIA,
PCI_DEVICE_ID_VIA_8365_1, NULL);
/* VIA Apollo */ /* VIA Apollo */
if (via == NULL) { if (via == NULL) {
via = pci_find_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C598_1, NULL); via = pci_get_device(PCI_VENDOR_ID_VIA,
} PCI_DEVICE_ID_VIA_82C598_1, NULL);
/* AMD Irongate */ /* AMD Irongate */
if (via == NULL) { if (via == NULL)
via = pci_find_device(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_FE_GATE_7007, NULL); via = pci_get_device(PCI_VENDOR_ID_AMD,
PCI_DEVICE_ID_AMD_FE_GATE_7007, NULL);
} }
if (via) { if (via) {
printk(KERN_INFO CARD_NAME ": Activating latency workaround...\n"); printk(KERN_INFO CARD_NAME ": Activating latency workaround...\n");
@ -101,13 +103,17 @@ static void __devinit snd_vortex_workaround(struct pci_dev *vortex, int fix)
} else { } else {
if (fix & 0x1) if (fix & 0x1)
vortex_fix_latency(vortex); vortex_fix_latency(vortex);
if ((fix & 0x2) && (via = pci_find_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8365_1, NULL))) if ((fix & 0x2) && (via = pci_get_device(PCI_VENDOR_ID_VIA,
PCI_DEVICE_ID_VIA_8365_1, NULL)))
vortex_fix_agp_bridge(via); vortex_fix_agp_bridge(via);
if ((fix & 0x4) && (via = pci_find_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C598_1, NULL))) if ((fix & 0x4) && (via = pci_get_device(PCI_VENDOR_ID_VIA,
PCI_DEVICE_ID_VIA_82C598_1, NULL)))
vortex_fix_agp_bridge(via); vortex_fix_agp_bridge(via);
if ((fix & 0x8) && (via = pci_find_device(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_FE_GATE_7007, NULL))) if ((fix & 0x8) && (via = pci_get_device(PCI_VENDOR_ID_AMD,
PCI_DEVICE_ID_AMD_FE_GATE_7007, NULL)))
vortex_fix_agp_bridge(via); vortex_fix_agp_bridge(via);
} }
pci_dev_put(via);
} }
// component-destructor // component-destructor

View File

@ -3537,7 +3537,7 @@ static void clkrun_hack(cs46xx_t *chip, int change)
{ {
u16 control, nval; u16 control, nval;
if (chip->acpi_dev == NULL) if (!chip->acpi_port)
return; return;
chip->amplifier += change; chip->amplifier += change;
@ -3560,15 +3560,20 @@ static void clkrun_hack(cs46xx_t *chip, int change)
*/ */
static void clkrun_init(cs46xx_t *chip) static void clkrun_init(cs46xx_t *chip)
{ {
struct pci_dev *pdev;
u8 pp; u8 pp;
chip->acpi_dev = pci_find_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_3, NULL); chip->acpi_port = 0;
if (chip->acpi_dev == NULL)
pdev = pci_get_device(PCI_VENDOR_ID_INTEL,
PCI_DEVICE_ID_INTEL_82371AB_3, NULL);
if (pdev == NULL)
return; /* Not a thinkpad thats for sure */ return; /* Not a thinkpad thats for sure */
/* Find the control port */ /* Find the control port */
pci_read_config_byte(chip->acpi_dev, 0x41, &pp); pci_read_config_byte(pdev, 0x41, &pp);
chip->acpi_port = pp << 8; chip->acpi_port = pp << 8;
pci_dev_put(pdev);
} }

View File

@ -1927,11 +1927,12 @@ static int snd_via82xx_chip_init(via82xx_t *chip)
* DXS channels don't work properly with VRA if MC97 is disabled. * DXS channels don't work properly with VRA if MC97 is disabled.
*/ */
struct pci_dev *pci; struct pci_dev *pci;
pci = pci_find_device(0x1106, 0x3068, NULL); /* MC97 */ pci = pci_get_device(0x1106, 0x3068, NULL); /* MC97 */
if (pci) { if (pci) {
unsigned char data; unsigned char data;
pci_read_config_byte(pci, 0x44, &data); pci_read_config_byte(pci, 0x44, &data);
pci_write_config_byte(pci, 0x44, data | 0x40); pci_write_config_byte(pci, 0x44, data | 0x40);
pci_dev_put(pci);
} }
} }