ALSA: pci: Simplify with dma_set_mask_and_coherent()
authorTakashi Iwai <tiwai@suse.de>
Thu, 14 Jan 2021 12:54:11 +0000 (13:54 +0100)
committerTakashi Iwai <tiwai@suse.de>
Fri, 15 Jan 2021 10:17:00 +0000 (11:17 +0100)
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/20210114125412.993-2-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
18 files changed:
sound/pci/ad1889.c
sound/pci/ali5451/ali5451.c
sound/pci/als300.c
sound/pci/als4000.c
sound/pci/au88x0/au88x0.c
sound/pci/aw2/aw2-alsa.c
sound/pci/azt3328.c
sound/pci/ca0106/ca0106_main.c
sound/pci/cs5535audio/cs5535audio.c
sound/pci/ctxfi/cthw20k1.c
sound/pci/ctxfi/cthw20k2.c
sound/pci/es1938.c
sound/pci/es1968.c
sound/pci/hda/hda_intel.c
sound/pci/ice1712/ice1712.c
sound/pci/maestro3.c
sound/pci/sonicvibes.c
sound/pci/trident/trident_main.c

index 5d42c42491bf190582a908fc408e63b66597df44..5d835d2af0549068f927fe702b6253d31aed2154 100644 (file)
@@ -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;
index 4462375d2d826cb66192d62a5a0d489d4c3eddab..51f24796f03faebfce4a1224039f041878d4076f 100644 (file)
@@ -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);
index 8d2471ea090bf98cb4dfcbae8f618358de735bac..1dc8c4ed0592bd5c69322829e205ce4399360101 100644 (file)
@@ -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;
index ba6390e9a694f06d6d11d7cf90f1330a55c5c3ac..2edc7455285a47263f85845182fc3ab5bbd27a5a 100644 (file)
@@ -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;
index be276fb3f5afe4e0e2831d058c0dcbf44ae4c26c..5dd98e6ff34b9369c6ae232bd3091c5c93287c14 100644 (file)
@@ -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;
index f1865afedc59bb9a2880ff67b6859c7f36a2dc2b..43396849a01c27b5e03eaa96d7520e40bae7e2b0 100644 (file)
@@ -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;
index 77c7030ebbfa9e224b1f25e3fcef3df25d871d86..e3ea72a2116b87b628703f57a85d8bee13957359 100644 (file)
@@ -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"
                );
index c189f70c82cb9a1a9f98aef77ba4e861184e9195..ee20f9a1aae98d0188b355c7cebd5bf2e5132729 100644 (file)
@@ -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;
index 11ce3c4589faf52445287a19c742e3578412b165..359bc6af867085da309a4f436c8eb7b4e92ff5dd 100644 (file)
@@ -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;
index 108ab449c968d86b0402b89d715a18a268f689a1..0cea4982ed7dcc5aa9b49ed79a364bf789b2e1c4 100644 (file)
@@ -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");
index fc1bc18caee989ca3cf1ef15d7d915f187a427f3..a855fb8c58bd6a23bd9fafe6987cdbe38f5073ac 100644 (file)
@@ -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");
index 09704a78d799eb0a541d5d4bf89f230948b0e29a..3b5d68ce9dd55b877467baf253e4856b1b10b945 100644 (file)
@@ -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);
index c6be14c4f3113ff94f6153741ec81f355eaec57a..747fa69bb1c90c4454af94fe9cf0780ca42e0eda 100644 (file)
@@ -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);
index 694d95e3a46ea95916dc6013a2ee11e4f4f536a5..292d3ff447099312354da774e24f7aaa799c0c23 100644 (file)
@@ -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
index 73e1e5400506a82b5faf29fd2b29c9e8eb1b90b1..f814dbbec2a4316736e96676e00cf1b04a25d307 100644 (file)
@@ -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);
index f622c2a6f74654acb75ebbd6a1b4519041633633..d2c2cd6006f04711b7a782c133508c058610e3fc 100644 (file)
@@ -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);
index bd805e416e12f9a8ad18d9708d728c3ef017e0ae..26fd1d08c179fb86a5d9b34799db28dc3436b136 100644 (file)
@@ -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);
index 8d0d0d8335ecb22f21c2eeecae9f562cf9ab590b..20145143f6a67c5513454cd0cf5aaa82924d374e 100644 (file)
@@ -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);