Skip to content

Commit

Permalink
ALSA: remove deprecated use of pci api
Browse files Browse the repository at this point in the history
Replace occurences of the pci api by appropriate call to the dma api.

A simplified version of the semantic patch that finds this problem is as
follows: (http://coccinelle.lip6.fr)

@deprecated@
idexpression id;
position p;
@@

(
  pci_dma_supported@p ( id, ...)
|
  pci_alloc_consistent@p ( id, ...)
)

@bad1@
idexpression id;
position deprecated.p;
@@
...when != &id->dev
   when != pci_get_drvdata ( id )
   when != pci_enable_device ( id )
(
  pci_dma_supported@p ( id, ...)
|
  pci_alloc_consistent@p ( id, ...)
)

@Depends on !bad1@
idexpression id;
expression direction;
position deprecated.p;
@@

(
- pci_dma_supported@p ( id,
+ dma_supported ( &id->dev,
...
+ , GFP_ATOMIC
  )
|
- pci_alloc_consistent@p ( id,
+ dma_alloc_coherent ( &id->dev,
...
+ , GFP_ATOMIC
  )
)

Signed-off-by: Quentin Lambert <[email protected]>
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
Quentin Lambert authored and tiwai committed Apr 16, 2015
1 parent 3047755 commit 412b979
Show file tree
Hide file tree
Showing 23 changed files with 48 additions and 48 deletions.
4 changes: 2 additions & 2 deletions sound/pci/ad1889.c
Original file line number Diff line number Diff line change
Expand Up @@ -898,8 +898,8 @@ snd_ad1889_create(struct snd_card *card,
return err;

/* check PCI availability (32bit DMA) */
if (pci_set_dma_mask(pci, DMA_BIT_MASK(32)) < 0 ||
pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(32)) < 0) {
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(32)) < 0 ||
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32)) < 0) {
dev_err(card->dev, "error setting 32-bit DMA mask.\n");
pci_disable_device(pci);
return -ENXIO;
Expand Down
4 changes: 2 additions & 2 deletions sound/pci/ali5451/ali5451.c
Original file line number Diff line number Diff line change
Expand Up @@ -2105,8 +2105,8 @@ static int snd_ali_create(struct snd_card *card,
if (err < 0)
return err;
/* check, if we can restrict PCI DMA transfers to 31 bits */
if (pci_set_dma_mask(pci, DMA_BIT_MASK(31)) < 0 ||
pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(31)) < 0) {
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(31)) < 0 ||
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(31)) < 0) {
dev_err(card->dev,
"architecture does not support 31bit PCI busmaster DMA\n");
pci_disable_device(pci);
Expand Down
4 changes: 2 additions & 2 deletions sound/pci/als300.c
Original file line number Diff line number Diff line change
Expand Up @@ -658,8 +658,8 @@ static int snd_als300_create(struct snd_card *card,
if ((err = pci_enable_device(pci)) < 0)
return err;

if (pci_set_dma_mask(pci, DMA_BIT_MASK(28)) < 0 ||
pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(28)) < 0) {
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(28)) < 0 ||
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(28)) < 0) {
dev_err(card->dev, "error setting 28bit DMA mask\n");
pci_disable_device(pci);
return -ENXIO;
Expand Down
4 changes: 2 additions & 2 deletions sound/pci/als4000.c
Original file line number Diff line number Diff line change
Expand Up @@ -871,8 +871,8 @@ static int snd_card_als4000_probe(struct pci_dev *pci,
return err;
}
/* check, if we can restrict PCI DMA transfers to 24 bits */
if (pci_set_dma_mask(pci, DMA_BIT_MASK(24)) < 0 ||
pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(24)) < 0) {
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(24)) < 0 ||
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(24)) < 0) {
dev_err(&pci->dev, "architecture does not support 24bit PCI busmaster DMA\n");
pci_disable_device(pci);
return -ENXIO;
Expand Down
4 changes: 2 additions & 2 deletions sound/pci/au88x0/au88x0.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ snd_vortex_create(struct snd_card *card, struct pci_dev *pci, vortex_t ** rchip)
// check PCI availability (DMA).
if ((err = pci_enable_device(pci)) < 0)
return err;
if (pci_set_dma_mask(pci, DMA_BIT_MASK(32)) < 0 ||
pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(32)) < 0) {
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(32)) < 0 ||
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32)) < 0) {
dev_err(card->dev, "error to set DMA mask\n");
pci_disable_device(pci);
return -ENXIO;
Expand Down
4 changes: 2 additions & 2 deletions sound/pci/aw2/aw2-alsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ static int snd_aw2_create(struct snd_card *card,
pci_set_master(pci);

/* check PCI availability (32bit DMA) */
if ((pci_set_dma_mask(pci, DMA_BIT_MASK(32)) < 0) ||
(pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(32)) < 0)) {
if ((dma_set_mask(&pci->dev, DMA_BIT_MASK(32)) < 0) ||
(dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32)) < 0)) {
dev_err(card->dev, "Impossible to set 32bit mask DMA\n");
pci_disable_device(pci);
return -ENXIO;
Expand Down
4 changes: 2 additions & 2 deletions sound/pci/azt3328.c
Original file line number Diff line number Diff line change
Expand Up @@ -2420,8 +2420,8 @@ snd_azf3328_create(struct snd_card *card,
chip->irq = -1;

/* check if we can restrict PCI DMA transfers to 24 bits */
if (pci_set_dma_mask(pci, DMA_BIT_MASK(24)) < 0 ||
pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(24)) < 0) {
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(24)) < 0 ||
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(24)) < 0) {
dev_err(card->dev,
"architecture does not support 24bit PCI busmaster DMA\n"
);
Expand Down
4 changes: 2 additions & 2 deletions sound/pci/ca0106/ca0106_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1676,8 +1676,8 @@ static int snd_ca0106_create(int dev, struct snd_card *card,
err = pci_enable_device(pci);
if (err < 0)
return err;
if (pci_set_dma_mask(pci, DMA_BIT_MASK(32)) < 0 ||
pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(32)) < 0) {
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(32)) < 0 ||
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32)) < 0) {
dev_err(card->dev, "error to set 32bit mask DMA\n");
pci_disable_device(pci);
return -ENXIO;
Expand Down
4 changes: 2 additions & 2 deletions sound/pci/cs5535audio/cs5535audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,8 @@ static int snd_cs5535audio_create(struct snd_card *card,
if ((err = pci_enable_device(pci)) < 0)
return err;

if (pci_set_dma_mask(pci, DMA_BIT_MASK(32)) < 0 ||
pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(32)) < 0) {
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(32)) < 0 ||
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32)) < 0) {
dev_warn(card->dev, "unable to get 32bit dma\n");
err = -ENXIO;
goto pcifail;
Expand Down
4 changes: 2 additions & 2 deletions sound/pci/ctxfi/cthw20k1.c
Original file line number Diff line number Diff line change
Expand Up @@ -1910,8 +1910,8 @@ static int hw_card_start(struct hw *hw)
return err;

/* Set DMA transfer mask */
if (pci_set_dma_mask(pci, CT_XFI_DMA_MASK) < 0 ||
pci_set_consistent_dma_mask(pci, CT_XFI_DMA_MASK) < 0) {
if (dma_set_mask(&pci->dev, CT_XFI_DMA_MASK) < 0 ||
dma_set_coherent_mask(&pci->dev, CT_XFI_DMA_MASK) < 0) {
dev_err(hw->card->dev,
"architecture does not support PCI busmaster DMA with mask 0x%llx\n",
CT_XFI_DMA_MASK);
Expand Down
4 changes: 2 additions & 2 deletions sound/pci/ctxfi/cthw20k2.c
Original file line number Diff line number Diff line change
Expand Up @@ -2035,8 +2035,8 @@ static int hw_card_start(struct hw *hw)
return err;

/* Set DMA transfer mask */
if (pci_set_dma_mask(pci, CT_XFI_DMA_MASK) < 0 ||
pci_set_consistent_dma_mask(pci, CT_XFI_DMA_MASK) < 0) {
if (dma_set_mask(&pci->dev, CT_XFI_DMA_MASK) < 0 ||
dma_set_coherent_mask(&pci->dev, CT_XFI_DMA_MASK) < 0) {
dev_err(hw->card->dev,
"architecture does not support PCI busmaster DMA with mask 0x%llx\n",
CT_XFI_DMA_MASK);
Expand Down
4 changes: 2 additions & 2 deletions sound/pci/emu10k1/emu10k1_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1904,8 +1904,8 @@ int snd_emu10k1_create(struct snd_card *card,

/* set the DMA transfer mask */
emu->dma_mask = is_audigy ? AUDIGY_DMA_MASK : EMU10K1_DMA_MASK;
if (pci_set_dma_mask(pci, emu->dma_mask) < 0 ||
pci_set_consistent_dma_mask(pci, emu->dma_mask) < 0) {
if (dma_set_mask(&pci->dev, emu->dma_mask) < 0 ||
dma_set_coherent_mask(&pci->dev, emu->dma_mask) < 0) {
dev_err(card->dev,
"architecture does not support PCI busmaster DMA with mask 0x%lx\n",
emu->dma_mask);
Expand Down
4 changes: 2 additions & 2 deletions sound/pci/es1938.c
Original file line number Diff line number Diff line change
Expand Up @@ -1580,8 +1580,8 @@ static int snd_es1938_create(struct snd_card *card,
if ((err = pci_enable_device(pci)) < 0)
return err;
/* check, if we can restrict PCI DMA transfers to 24 bits */
if (pci_set_dma_mask(pci, DMA_BIT_MASK(24)) < 0 ||
pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(24)) < 0) {
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(24)) < 0 ||
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(24)) < 0) {
dev_err(card->dev,
"architecture does not support 24bit PCI busmaster DMA\n");
pci_disable_device(pci);
Expand Down
4 changes: 2 additions & 2 deletions sound/pci/es1968.c
Original file line number Diff line number Diff line change
Expand Up @@ -2689,8 +2689,8 @@ static int snd_es1968_create(struct snd_card *card,
if ((err = pci_enable_device(pci)) < 0)
return err;
/* check, if we can restrict PCI DMA transfers to 28 bits */
if (pci_set_dma_mask(pci, DMA_BIT_MASK(28)) < 0 ||
pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(28)) < 0) {
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(28)) < 0 ||
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(28)) < 0) {
dev_err(card->dev,
"architecture does not support 28bit PCI busmaster DMA\n");
pci_disable_device(pci);
Expand Down
8 changes: 4 additions & 4 deletions sound/pci/hda/hda_intel.c
Original file line number Diff line number Diff line change
Expand Up @@ -1528,11 +1528,11 @@ static int azx_first_init(struct azx *chip)
/* allow 64bit DMA address if supported by H/W */
if (!(gcap & AZX_GCAP_64OK))
dma_bits = 32;
if (!pci_set_dma_mask(pci, DMA_BIT_MASK(dma_bits))) {
pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(dma_bits));
if (!dma_set_mask(&pci->dev, DMA_BIT_MASK(dma_bits))) {
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(dma_bits));
} else {
pci_set_dma_mask(pci, DMA_BIT_MASK(32));
pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(32));
dma_set_mask(&pci->dev, DMA_BIT_MASK(32));
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32));
}

/* read number of streams from GCAP register instead of using
Expand Down
4 changes: 2 additions & 2 deletions sound/pci/ice1712/ice1712.c
Original file line number Diff line number Diff line change
Expand Up @@ -2530,8 +2530,8 @@ static int snd_ice1712_create(struct snd_card *card,
if (err < 0)
return err;
/* check, if we can restrict PCI DMA transfers to 28 bits */
if (pci_set_dma_mask(pci, DMA_BIT_MASK(28)) < 0 ||
pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(28)) < 0) {
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(28)) < 0 ||
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(28)) < 0) {
dev_err(card->dev,
"architecture does not support 28bit PCI busmaster DMA\n");
pci_disable_device(pci);
Expand Down
2 changes: 1 addition & 1 deletion sound/pci/lx6464es/lx6464es.c
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ static int snd_lx6464es_create(struct snd_card *card,
pci_set_master(pci);

/* check if we can restrict PCI DMA transfers to 32 bits */
err = pci_set_dma_mask(pci, DMA_BIT_MASK(32));
err = dma_set_mask(&pci->dev, DMA_BIT_MASK(32));
if (err < 0) {
dev_err(card->dev,
"architecture does not support 32bit PCI busmaster DMA\n");
Expand Down
4 changes: 2 additions & 2 deletions sound/pci/maestro3.c
Original file line number Diff line number Diff line change
Expand Up @@ -2537,8 +2537,8 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci,
return -EIO;

/* check, if we can restrict PCI DMA transfers to 28 bits */
if (pci_set_dma_mask(pci, DMA_BIT_MASK(28)) < 0 ||
pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(28)) < 0) {
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(28)) < 0 ||
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(28)) < 0) {
dev_err(card->dev,
"architecture does not support 28bit PCI busmaster DMA\n");
pci_disable_device(pci);
Expand Down
2 changes: 1 addition & 1 deletion sound/pci/mixart/mixart.c
Original file line number Diff line number Diff line change
Expand Up @@ -1269,7 +1269,7 @@ static int snd_mixart_probe(struct pci_dev *pci,
pci_set_master(pci);

/* check if we can restrict PCI DMA transfers to 32 bits */
if (pci_set_dma_mask(pci, DMA_BIT_MASK(32)) < 0) {
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(32)) < 0) {
dev_err(&pci->dev,
"architecture does not support 32bit PCI busmaster DMA\n");
pci_disable_device(pci);
Expand Down
2 changes: 1 addition & 1 deletion sound/pci/pcxhr/pcxhr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1537,7 +1537,7 @@ static int pcxhr_probe(struct pci_dev *pci,
pci_set_master(pci);

/* check if we can restrict PCI DMA transfers to 32 bits */
if (pci_set_dma_mask(pci, DMA_BIT_MASK(32)) < 0) {
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(32)) < 0) {
dev_err(&pci->dev,
"architecture does not support 32bit PCI busmaster DMA\n");
pci_disable_device(pci);
Expand Down
10 changes: 5 additions & 5 deletions sound/pci/sis7019.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,9 @@ static void __sis_map_silence(struct sis7019 *sis)
{
/* Helper function: must hold sis->voice_lock on entry */
if (!sis->silence_users)
sis->silence_dma_addr = pci_map_single(sis->pci,
sis->silence_dma_addr = dma_map_single(&sis->pci->dev,
sis->suspend_state[0],
4096, PCI_DMA_TODEVICE);
4096, DMA_TO_DEVICE);
sis->silence_users++;
}

Expand All @@ -394,8 +394,8 @@ static void __sis_unmap_silence(struct sis7019 *sis)
/* Helper function: must hold sis->voice_lock on entry */
sis->silence_users--;
if (!sis->silence_users)
pci_unmap_single(sis->pci, sis->silence_dma_addr, 4096,
PCI_DMA_TODEVICE);
dma_unmap_single(&sis->pci->dev, sis->silence_dma_addr, 4096,
DMA_TO_DEVICE);
}

static void sis_free_voice(struct sis7019 *sis, struct voice *voice)
Expand Down Expand Up @@ -1325,7 +1325,7 @@ static int sis_chip_create(struct snd_card *card,
if (rc)
goto error_out;

rc = pci_set_dma_mask(pci, DMA_BIT_MASK(30));
rc = dma_set_mask(&pci->dev, DMA_BIT_MASK(30));
if (rc < 0) {
dev_err(&pci->dev, "architecture does not support 30-bit PCI busmaster DMA");
goto error_out_enabled;
Expand Down
4 changes: 2 additions & 2 deletions sound/pci/sonicvibes.c
Original file line number Diff line number Diff line change
Expand Up @@ -1259,8 +1259,8 @@ static int snd_sonicvibes_create(struct snd_card *card,
if ((err = pci_enable_device(pci)) < 0)
return err;
/* check, if we can restrict PCI DMA transfers to 24 bits */
if (pci_set_dma_mask(pci, DMA_BIT_MASK(24)) < 0 ||
pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(24)) < 0) {
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(24)) < 0 ||
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(24)) < 0) {
dev_err(card->dev,
"architecture does not support 24bit PCI busmaster DMA\n");
pci_disable_device(pci);
Expand Down
4 changes: 2 additions & 2 deletions sound/pci/trident/trident_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3551,8 +3551,8 @@ int snd_trident_create(struct snd_card *card,
if ((err = pci_enable_device(pci)) < 0)
return err;
/* check, if we can restrict PCI DMA transfers to 30 bits */
if (pci_set_dma_mask(pci, DMA_BIT_MASK(30)) < 0 ||
pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(30)) < 0) {
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(30)) < 0 ||
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(30)) < 0) {
dev_err(card->dev,
"architecture does not support 30bit PCI busmaster DMA\n");
pci_disable_device(pci);
Expand Down

0 comments on commit 412b979

Please sign in to comment.