Skip to content

Commit

Permalink
ALSA: pci: Simplify with dma_set_mask_and_coherent()
Browse files Browse the repository at this point in the history
Many PCI drivers still have two explicit calls of dma_set_mask() and
dma_set_coherent_mask().

Let's simplify with dma_set_mask_and_coherent().

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
tiwai committed Jan 15, 2021
1 parent 9a08676 commit 669f65e
Show file tree
Hide file tree
Showing 18 changed files with 21 additions and 48 deletions.
3 changes: 1 addition & 2 deletions sound/pci/ad1889.c
Original file line number Diff line number Diff line change
Expand Up @@ -857,8 +857,7 @@ snd_ad1889_create(struct snd_card *card,
return err;

/* check PCI availability (32bit DMA) */
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(32)) < 0 ||
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32)) < 0) {
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32))) {
dev_err(card->dev, "error setting 32-bit DMA mask.\n");
pci_disable_device(pci);
return -ENXIO;
Expand Down
3 changes: 1 addition & 2 deletions sound/pci/ali5451/ali5451.c
Original file line number Diff line number Diff line change
Expand Up @@ -2057,8 +2057,7 @@ 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 (dma_set_mask(&pci->dev, DMA_BIT_MASK(31)) < 0 ||
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(31)) < 0) {
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(31))) {
dev_err(card->dev,
"architecture does not support 31bit PCI busmaster DMA\n");
pci_disable_device(pci);
Expand Down
3 changes: 1 addition & 2 deletions sound/pci/als300.c
Original file line number Diff line number Diff line change
Expand Up @@ -625,8 +625,7 @@ static int snd_als300_create(struct snd_card *card,
if ((err = pci_enable_device(pci)) < 0)
return err;

if (dma_set_mask(&pci->dev, DMA_BIT_MASK(28)) < 0 ||
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(28)) < 0) {
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(28))) {
dev_err(card->dev, "error setting 28bit DMA mask\n");
pci_disable_device(pci);
return -ENXIO;
Expand Down
3 changes: 1 addition & 2 deletions sound/pci/als4000.c
Original file line number Diff line number Diff line change
Expand Up @@ -837,8 +837,7 @@ static int snd_card_als4000_probe(struct pci_dev *pci,
return err;
}
/* check, if we can restrict PCI DMA transfers to 24 bits */
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(24)) < 0 ||
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(24)) < 0) {
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(24))) {
dev_err(&pci->dev, "architecture does not support 24bit PCI busmaster DMA\n");
pci_disable_device(pci);
return -ENXIO;
Expand Down
3 changes: 1 addition & 2 deletions sound/pci/au88x0/au88x0.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,7 @@ 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 (dma_set_mask(&pci->dev, DMA_BIT_MASK(32)) < 0 ||
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32)) < 0) {
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32))) {
dev_err(card->dev, "error to set DMA mask\n");
pci_disable_device(pci);
return -ENXIO;
Expand Down
3 changes: 1 addition & 2 deletions sound/pci/aw2/aw2-alsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,7 @@ static int snd_aw2_create(struct snd_card *card,
pci_set_master(pci);

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

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

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

/* Set DMA transfer mask */
if (!dma_set_mask(&pci->dev, DMA_BIT_MASK(dma_bits))) {
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(dma_bits));
} else {
dma_set_mask(&pci->dev, DMA_BIT_MASK(32));
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32));
}
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(dma_bits)))
dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32));

if (!hw->io_base) {
err = pci_request_regions(pci, "XFi");
Expand Down
8 changes: 2 additions & 6 deletions sound/pci/ctxfi/cthw20k2.c
Original file line number Diff line number Diff line change
Expand Up @@ -2026,12 +2026,8 @@ static int hw_card_start(struct hw *hw)
return err;

/* Set DMA transfer mask */
if (!dma_set_mask(&pci->dev, DMA_BIT_MASK(dma_bits))) {
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(dma_bits));
} else {
dma_set_mask(&pci->dev, DMA_BIT_MASK(32));
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32));
}
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(dma_bits)))
dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32));

if (!hw->io_base) {
err = pci_request_regions(pci, "XFi");
Expand Down
3 changes: 1 addition & 2 deletions sound/pci/es1938.c
Original file line number Diff line number Diff line change
Expand Up @@ -1560,8 +1560,7 @@ 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 (dma_set_mask(&pci->dev, DMA_BIT_MASK(24)) < 0 ||
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(24)) < 0) {
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(24))) {
dev_err(card->dev,
"architecture does not support 24bit PCI busmaster DMA\n");
pci_disable_device(pci);
Expand Down
3 changes: 1 addition & 2 deletions sound/pci/es1968.c
Original file line number Diff line number Diff line change
Expand Up @@ -2668,8 +2668,7 @@ 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 (dma_set_mask(&pci->dev, DMA_BIT_MASK(28)) < 0 ||
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(28)) < 0) {
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(28))) {
dev_err(card->dev,
"architecture does not support 28bit PCI busmaster DMA\n");
pci_disable_device(pci);
Expand Down
8 changes: 2 additions & 6 deletions sound/pci/hda/hda_intel.c
Original file line number Diff line number Diff line change
Expand Up @@ -1967,12 +1967,8 @@ 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 (!dma_set_mask(&pci->dev, DMA_BIT_MASK(dma_bits))) {
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(dma_bits));
} else {
dma_set_mask(&pci->dev, DMA_BIT_MASK(32));
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32));
}
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(dma_bits)))
dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32));

/* read number of streams from GCAP register instead of using
* hardcoded value
Expand Down
3 changes: 1 addition & 2 deletions sound/pci/ice1712/ice1712.c
Original file line number Diff line number Diff line change
Expand Up @@ -2486,8 +2486,7 @@ 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 (dma_set_mask(&pci->dev, DMA_BIT_MASK(28)) < 0 ||
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(28)) < 0) {
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(28))) {
dev_err(card->dev,
"architecture does not support 28bit PCI busmaster DMA\n");
pci_disable_device(pci);
Expand Down
3 changes: 1 addition & 2 deletions sound/pci/maestro3.c
Original file line number Diff line number Diff line change
Expand Up @@ -2532,8 +2532,7 @@ 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 (dma_set_mask(&pci->dev, DMA_BIT_MASK(28)) < 0 ||
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(28)) < 0) {
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(28))) {
dev_err(card->dev,
"architecture does not support 28bit PCI busmaster DMA\n");
pci_disable_device(pci);
Expand Down
3 changes: 1 addition & 2 deletions sound/pci/sonicvibes.c
Original file line number Diff line number Diff line change
Expand Up @@ -1230,8 +1230,7 @@ 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 (dma_set_mask(&pci->dev, DMA_BIT_MASK(24)) < 0 ||
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(24)) < 0) {
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(24))) {
dev_err(card->dev,
"architecture does not support 24bit PCI busmaster DMA\n");
pci_disable_device(pci);
Expand Down
3 changes: 1 addition & 2 deletions sound/pci/trident/trident_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3497,8 +3497,7 @@ 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 (dma_set_mask(&pci->dev, DMA_BIT_MASK(30)) < 0 ||
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(30)) < 0) {
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(30))) {
dev_err(card->dev,
"architecture does not support 30bit PCI busmaster DMA\n");
pci_disable_device(pci);
Expand Down

0 comments on commit 669f65e

Please sign in to comment.