Skip to content

Commit 669f65e

Browse files
committed
ALSA: pci: Simplify with dma_set_mask_and_coherent()
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]>
1 parent 9a08676 commit 669f65e

File tree

18 files changed

+21
-48
lines changed

18 files changed

+21
-48
lines changed

sound/pci/ad1889.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -857,8 +857,7 @@ snd_ad1889_create(struct snd_card *card,
857857
return err;
858858

859859
/* check PCI availability (32bit DMA) */
860-
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(32)) < 0 ||
861-
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32)) < 0) {
860+
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32))) {
862861
dev_err(card->dev, "error setting 32-bit DMA mask.\n");
863862
pci_disable_device(pci);
864863
return -ENXIO;

sound/pci/ali5451/ali5451.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2057,8 +2057,7 @@ static int snd_ali_create(struct snd_card *card,
20572057
if (err < 0)
20582058
return err;
20592059
/* check, if we can restrict PCI DMA transfers to 31 bits */
2060-
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(31)) < 0 ||
2061-
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(31)) < 0) {
2060+
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(31))) {
20622061
dev_err(card->dev,
20632062
"architecture does not support 31bit PCI busmaster DMA\n");
20642063
pci_disable_device(pci);

sound/pci/als300.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -625,8 +625,7 @@ static int snd_als300_create(struct snd_card *card,
625625
if ((err = pci_enable_device(pci)) < 0)
626626
return err;
627627

628-
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(28)) < 0 ||
629-
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(28)) < 0) {
628+
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(28))) {
630629
dev_err(card->dev, "error setting 28bit DMA mask\n");
631630
pci_disable_device(pci);
632631
return -ENXIO;

sound/pci/als4000.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -837,8 +837,7 @@ static int snd_card_als4000_probe(struct pci_dev *pci,
837837
return err;
838838
}
839839
/* check, if we can restrict PCI DMA transfers to 24 bits */
840-
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(24)) < 0 ||
841-
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(24)) < 0) {
840+
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(24))) {
842841
dev_err(&pci->dev, "architecture does not support 24bit PCI busmaster DMA\n");
843842
pci_disable_device(pci);
844843
return -ENXIO;

sound/pci/au88x0/au88x0.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,7 @@ snd_vortex_create(struct snd_card *card, struct pci_dev *pci, vortex_t ** rchip)
151151
// check PCI availability (DMA).
152152
if ((err = pci_enable_device(pci)) < 0)
153153
return err;
154-
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(32)) < 0 ||
155-
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32)) < 0) {
154+
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32))) {
156155
dev_err(card->dev, "error to set DMA mask\n");
157156
pci_disable_device(pci);
158157
return -ENXIO;

sound/pci/aw2/aw2-alsa.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,7 @@ static int snd_aw2_create(struct snd_card *card,
236236
pci_set_master(pci);
237237

238238
/* check PCI availability (32bit DMA) */
239-
if ((dma_set_mask(&pci->dev, DMA_BIT_MASK(32)) < 0) ||
240-
(dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32)) < 0)) {
239+
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32))) {
241240
dev_err(card->dev, "Impossible to set 32bit mask DMA\n");
242241
pci_disable_device(pci);
243242
return -ENXIO;

sound/pci/azt3328.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2379,8 +2379,7 @@ snd_azf3328_create(struct snd_card *card,
23792379
chip->irq = -1;
23802380

23812381
/* check if we can restrict PCI DMA transfers to 24 bits */
2382-
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(24)) < 0 ||
2383-
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(24)) < 0) {
2382+
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(24))) {
23842383
dev_err(card->dev,
23852384
"architecture does not support 24bit PCI busmaster DMA\n"
23862385
);

sound/pci/ca0106/ca0106_main.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,8 +1605,7 @@ static int snd_ca0106_create(int dev, struct snd_card *card,
16051605
err = pci_enable_device(pci);
16061606
if (err < 0)
16071607
return err;
1608-
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(32)) < 0 ||
1609-
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32)) < 0) {
1608+
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32))) {
16101609
dev_err(card->dev, "error to set 32bit mask DMA\n");
16111610
pci_disable_device(pci);
16121611
return -ENXIO;

sound/pci/cs5535audio/cs5535audio.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,7 @@ static int snd_cs5535audio_create(struct snd_card *card,
269269
if ((err = pci_enable_device(pci)) < 0)
270270
return err;
271271

272-
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(32)) < 0 ||
273-
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32)) < 0) {
272+
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32))) {
274273
dev_warn(card->dev, "unable to get 32bit dma\n");
275274
err = -ENXIO;
276275
goto pcifail;

sound/pci/ctxfi/cthw20k1.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1901,12 +1901,8 @@ static int hw_card_start(struct hw *hw)
19011901
return err;
19021902

19031903
/* Set DMA transfer mask */
1904-
if (!dma_set_mask(&pci->dev, DMA_BIT_MASK(dma_bits))) {
1905-
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(dma_bits));
1906-
} else {
1907-
dma_set_mask(&pci->dev, DMA_BIT_MASK(32));
1908-
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32));
1909-
}
1904+
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(dma_bits)))
1905+
dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32));
19101906

19111907
if (!hw->io_base) {
19121908
err = pci_request_regions(pci, "XFi");

sound/pci/ctxfi/cthw20k2.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2026,12 +2026,8 @@ static int hw_card_start(struct hw *hw)
20262026
return err;
20272027

20282028
/* Set DMA transfer mask */
2029-
if (!dma_set_mask(&pci->dev, DMA_BIT_MASK(dma_bits))) {
2030-
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(dma_bits));
2031-
} else {
2032-
dma_set_mask(&pci->dev, DMA_BIT_MASK(32));
2033-
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32));
2034-
}
2029+
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(dma_bits)))
2030+
dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32));
20352031

20362032
if (!hw->io_base) {
20372033
err = pci_request_regions(pci, "XFi");

sound/pci/es1938.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,8 +1560,7 @@ static int snd_es1938_create(struct snd_card *card,
15601560
if ((err = pci_enable_device(pci)) < 0)
15611561
return err;
15621562
/* check, if we can restrict PCI DMA transfers to 24 bits */
1563-
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(24)) < 0 ||
1564-
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(24)) < 0) {
1563+
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(24))) {
15651564
dev_err(card->dev,
15661565
"architecture does not support 24bit PCI busmaster DMA\n");
15671566
pci_disable_device(pci);

sound/pci/es1968.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2668,8 +2668,7 @@ static int snd_es1968_create(struct snd_card *card,
26682668
if ((err = pci_enable_device(pci)) < 0)
26692669
return err;
26702670
/* check, if we can restrict PCI DMA transfers to 28 bits */
2671-
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(28)) < 0 ||
2672-
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(28)) < 0) {
2671+
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(28))) {
26732672
dev_err(card->dev,
26742673
"architecture does not support 28bit PCI busmaster DMA\n");
26752674
pci_disable_device(pci);

sound/pci/hda/hda_intel.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1967,12 +1967,8 @@ static int azx_first_init(struct azx *chip)
19671967
/* allow 64bit DMA address if supported by H/W */
19681968
if (!(gcap & AZX_GCAP_64OK))
19691969
dma_bits = 32;
1970-
if (!dma_set_mask(&pci->dev, DMA_BIT_MASK(dma_bits))) {
1971-
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(dma_bits));
1972-
} else {
1973-
dma_set_mask(&pci->dev, DMA_BIT_MASK(32));
1974-
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32));
1975-
}
1970+
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(dma_bits)))
1971+
dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32));
19761972

19771973
/* read number of streams from GCAP register instead of using
19781974
* hardcoded value

sound/pci/ice1712/ice1712.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2486,8 +2486,7 @@ static int snd_ice1712_create(struct snd_card *card,
24862486
if (err < 0)
24872487
return err;
24882488
/* check, if we can restrict PCI DMA transfers to 28 bits */
2489-
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(28)) < 0 ||
2490-
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(28)) < 0) {
2489+
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(28))) {
24912490
dev_err(card->dev,
24922491
"architecture does not support 28bit PCI busmaster DMA\n");
24932492
pci_disable_device(pci);

sound/pci/maestro3.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2532,8 +2532,7 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci,
25322532
return -EIO;
25332533

25342534
/* check, if we can restrict PCI DMA transfers to 28 bits */
2535-
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(28)) < 0 ||
2536-
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(28)) < 0) {
2535+
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(28))) {
25372536
dev_err(card->dev,
25382537
"architecture does not support 28bit PCI busmaster DMA\n");
25392538
pci_disable_device(pci);

sound/pci/sonicvibes.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,8 +1230,7 @@ static int snd_sonicvibes_create(struct snd_card *card,
12301230
if ((err = pci_enable_device(pci)) < 0)
12311231
return err;
12321232
/* check, if we can restrict PCI DMA transfers to 24 bits */
1233-
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(24)) < 0 ||
1234-
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(24)) < 0) {
1233+
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(24))) {
12351234
dev_err(card->dev,
12361235
"architecture does not support 24bit PCI busmaster DMA\n");
12371236
pci_disable_device(pci);

sound/pci/trident/trident_main.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3497,8 +3497,7 @@ int snd_trident_create(struct snd_card *card,
34973497
if ((err = pci_enable_device(pci)) < 0)
34983498
return err;
34993499
/* check, if we can restrict PCI DMA transfers to 30 bits */
3500-
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(30)) < 0 ||
3501-
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(30)) < 0) {
3500+
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(30))) {
35023501
dev_err(card->dev,
35033502
"architecture does not support 30bit PCI busmaster DMA\n");
35043503
pci_disable_device(pci);

0 commit comments

Comments
 (0)