mirror of https://gitee.com/openkylin/linux.git
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/20210114125412.993-2-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
9a08676fc5
commit
669f65eaeb
|
@ -857,8 +857,7 @@ snd_ad1889_create(struct snd_card *card,
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
/* check PCI availability (32bit DMA) */
|
/* check PCI availability (32bit DMA) */
|
||||||
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(32)) < 0 ||
|
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32))) {
|
||||||
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32)) < 0) {
|
|
||||||
dev_err(card->dev, "error setting 32-bit DMA mask.\n");
|
dev_err(card->dev, "error setting 32-bit DMA mask.\n");
|
||||||
pci_disable_device(pci);
|
pci_disable_device(pci);
|
||||||
return -ENXIO;
|
return -ENXIO;
|
||||||
|
|
|
@ -2057,8 +2057,7 @@ static int snd_ali_create(struct snd_card *card,
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
/* check, if we can restrict PCI DMA transfers to 31 bits */
|
/* check, if we can restrict PCI DMA transfers to 31 bits */
|
||||||
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(31)) < 0 ||
|
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(31))) {
|
||||||
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(31)) < 0) {
|
|
||||||
dev_err(card->dev,
|
dev_err(card->dev,
|
||||||
"architecture does not support 31bit PCI busmaster DMA\n");
|
"architecture does not support 31bit PCI busmaster DMA\n");
|
||||||
pci_disable_device(pci);
|
pci_disable_device(pci);
|
||||||
|
|
|
@ -625,8 +625,7 @@ static int snd_als300_create(struct snd_card *card,
|
||||||
if ((err = pci_enable_device(pci)) < 0)
|
if ((err = pci_enable_device(pci)) < 0)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(28)) < 0 ||
|
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(28))) {
|
||||||
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(28)) < 0) {
|
|
||||||
dev_err(card->dev, "error setting 28bit DMA mask\n");
|
dev_err(card->dev, "error setting 28bit DMA mask\n");
|
||||||
pci_disable_device(pci);
|
pci_disable_device(pci);
|
||||||
return -ENXIO;
|
return -ENXIO;
|
||||||
|
|
|
@ -837,8 +837,7 @@ static int snd_card_als4000_probe(struct pci_dev *pci,
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
/* check, if we can restrict PCI DMA transfers to 24 bits */
|
/* check, if we can restrict PCI DMA transfers to 24 bits */
|
||||||
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(24)) < 0 ||
|
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(24))) {
|
||||||
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(24)) < 0) {
|
|
||||||
dev_err(&pci->dev, "architecture does not support 24bit PCI busmaster DMA\n");
|
dev_err(&pci->dev, "architecture does not support 24bit PCI busmaster DMA\n");
|
||||||
pci_disable_device(pci);
|
pci_disable_device(pci);
|
||||||
return -ENXIO;
|
return -ENXIO;
|
||||||
|
|
|
@ -151,8 +151,7 @@ snd_vortex_create(struct snd_card *card, struct pci_dev *pci, vortex_t ** rchip)
|
||||||
// check PCI availability (DMA).
|
// check PCI availability (DMA).
|
||||||
if ((err = pci_enable_device(pci)) < 0)
|
if ((err = pci_enable_device(pci)) < 0)
|
||||||
return err;
|
return err;
|
||||||
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(32)) < 0 ||
|
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32))) {
|
||||||
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32)) < 0) {
|
|
||||||
dev_err(card->dev, "error to set DMA mask\n");
|
dev_err(card->dev, "error to set DMA mask\n");
|
||||||
pci_disable_device(pci);
|
pci_disable_device(pci);
|
||||||
return -ENXIO;
|
return -ENXIO;
|
||||||
|
|
|
@ -236,8 +236,7 @@ static int snd_aw2_create(struct snd_card *card,
|
||||||
pci_set_master(pci);
|
pci_set_master(pci);
|
||||||
|
|
||||||
/* check PCI availability (32bit DMA) */
|
/* check PCI availability (32bit DMA) */
|
||||||
if ((dma_set_mask(&pci->dev, DMA_BIT_MASK(32)) < 0) ||
|
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32))) {
|
||||||
(dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32)) < 0)) {
|
|
||||||
dev_err(card->dev, "Impossible to set 32bit mask DMA\n");
|
dev_err(card->dev, "Impossible to set 32bit mask DMA\n");
|
||||||
pci_disable_device(pci);
|
pci_disable_device(pci);
|
||||||
return -ENXIO;
|
return -ENXIO;
|
||||||
|
|
|
@ -2379,8 +2379,7 @@ snd_azf3328_create(struct snd_card *card,
|
||||||
chip->irq = -1;
|
chip->irq = -1;
|
||||||
|
|
||||||
/* check if we can restrict PCI DMA transfers to 24 bits */
|
/* check if we can restrict PCI DMA transfers to 24 bits */
|
||||||
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(24)) < 0 ||
|
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(24))) {
|
||||||
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(24)) < 0) {
|
|
||||||
dev_err(card->dev,
|
dev_err(card->dev,
|
||||||
"architecture does not support 24bit PCI busmaster DMA\n"
|
"architecture does not support 24bit PCI busmaster DMA\n"
|
||||||
);
|
);
|
||||||
|
|
|
@ -1605,8 +1605,7 @@ static int snd_ca0106_create(int dev, struct snd_card *card,
|
||||||
err = pci_enable_device(pci);
|
err = pci_enable_device(pci);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(32)) < 0 ||
|
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32))) {
|
||||||
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32)) < 0) {
|
|
||||||
dev_err(card->dev, "error to set 32bit mask DMA\n");
|
dev_err(card->dev, "error to set 32bit mask DMA\n");
|
||||||
pci_disable_device(pci);
|
pci_disable_device(pci);
|
||||||
return -ENXIO;
|
return -ENXIO;
|
||||||
|
|
|
@ -269,8 +269,7 @@ static int snd_cs5535audio_create(struct snd_card *card,
|
||||||
if ((err = pci_enable_device(pci)) < 0)
|
if ((err = pci_enable_device(pci)) < 0)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(32)) < 0 ||
|
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32))) {
|
||||||
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32)) < 0) {
|
|
||||||
dev_warn(card->dev, "unable to get 32bit dma\n");
|
dev_warn(card->dev, "unable to get 32bit dma\n");
|
||||||
err = -ENXIO;
|
err = -ENXIO;
|
||||||
goto pcifail;
|
goto pcifail;
|
||||||
|
|
|
@ -1901,12 +1901,8 @@ static int hw_card_start(struct hw *hw)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
/* Set DMA transfer mask */
|
/* Set DMA transfer mask */
|
||||||
if (!dma_set_mask(&pci->dev, DMA_BIT_MASK(dma_bits))) {
|
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(dma_bits)))
|
||||||
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(dma_bits));
|
dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32));
|
||||||
} else {
|
|
||||||
dma_set_mask(&pci->dev, DMA_BIT_MASK(32));
|
|
||||||
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!hw->io_base) {
|
if (!hw->io_base) {
|
||||||
err = pci_request_regions(pci, "XFi");
|
err = pci_request_regions(pci, "XFi");
|
||||||
|
|
|
@ -2026,12 +2026,8 @@ static int hw_card_start(struct hw *hw)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
/* Set DMA transfer mask */
|
/* Set DMA transfer mask */
|
||||||
if (!dma_set_mask(&pci->dev, DMA_BIT_MASK(dma_bits))) {
|
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(dma_bits)))
|
||||||
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(dma_bits));
|
dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32));
|
||||||
} else {
|
|
||||||
dma_set_mask(&pci->dev, DMA_BIT_MASK(32));
|
|
||||||
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!hw->io_base) {
|
if (!hw->io_base) {
|
||||||
err = pci_request_regions(pci, "XFi");
|
err = pci_request_regions(pci, "XFi");
|
||||||
|
|
|
@ -1560,8 +1560,7 @@ static int snd_es1938_create(struct snd_card *card,
|
||||||
if ((err = pci_enable_device(pci)) < 0)
|
if ((err = pci_enable_device(pci)) < 0)
|
||||||
return err;
|
return err;
|
||||||
/* check, if we can restrict PCI DMA transfers to 24 bits */
|
/* check, if we can restrict PCI DMA transfers to 24 bits */
|
||||||
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(24)) < 0 ||
|
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(24))) {
|
||||||
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(24)) < 0) {
|
|
||||||
dev_err(card->dev,
|
dev_err(card->dev,
|
||||||
"architecture does not support 24bit PCI busmaster DMA\n");
|
"architecture does not support 24bit PCI busmaster DMA\n");
|
||||||
pci_disable_device(pci);
|
pci_disable_device(pci);
|
||||||
|
|
|
@ -2668,8 +2668,7 @@ static int snd_es1968_create(struct snd_card *card,
|
||||||
if ((err = pci_enable_device(pci)) < 0)
|
if ((err = pci_enable_device(pci)) < 0)
|
||||||
return err;
|
return err;
|
||||||
/* check, if we can restrict PCI DMA transfers to 28 bits */
|
/* check, if we can restrict PCI DMA transfers to 28 bits */
|
||||||
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(28)) < 0 ||
|
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(28))) {
|
||||||
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(28)) < 0) {
|
|
||||||
dev_err(card->dev,
|
dev_err(card->dev,
|
||||||
"architecture does not support 28bit PCI busmaster DMA\n");
|
"architecture does not support 28bit PCI busmaster DMA\n");
|
||||||
pci_disable_device(pci);
|
pci_disable_device(pci);
|
||||||
|
|
|
@ -1967,12 +1967,8 @@ static int azx_first_init(struct azx *chip)
|
||||||
/* allow 64bit DMA address if supported by H/W */
|
/* allow 64bit DMA address if supported by H/W */
|
||||||
if (!(gcap & AZX_GCAP_64OK))
|
if (!(gcap & AZX_GCAP_64OK))
|
||||||
dma_bits = 32;
|
dma_bits = 32;
|
||||||
if (!dma_set_mask(&pci->dev, DMA_BIT_MASK(dma_bits))) {
|
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(dma_bits)))
|
||||||
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(dma_bits));
|
dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32));
|
||||||
} else {
|
|
||||||
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
|
/* read number of streams from GCAP register instead of using
|
||||||
* hardcoded value
|
* hardcoded value
|
||||||
|
|
|
@ -2486,8 +2486,7 @@ static int snd_ice1712_create(struct snd_card *card,
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
/* check, if we can restrict PCI DMA transfers to 28 bits */
|
/* check, if we can restrict PCI DMA transfers to 28 bits */
|
||||||
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(28)) < 0 ||
|
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(28))) {
|
||||||
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(28)) < 0) {
|
|
||||||
dev_err(card->dev,
|
dev_err(card->dev,
|
||||||
"architecture does not support 28bit PCI busmaster DMA\n");
|
"architecture does not support 28bit PCI busmaster DMA\n");
|
||||||
pci_disable_device(pci);
|
pci_disable_device(pci);
|
||||||
|
|
|
@ -2532,8 +2532,7 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci,
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
|
||||||
/* check, if we can restrict PCI DMA transfers to 28 bits */
|
/* check, if we can restrict PCI DMA transfers to 28 bits */
|
||||||
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(28)) < 0 ||
|
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(28))) {
|
||||||
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(28)) < 0) {
|
|
||||||
dev_err(card->dev,
|
dev_err(card->dev,
|
||||||
"architecture does not support 28bit PCI busmaster DMA\n");
|
"architecture does not support 28bit PCI busmaster DMA\n");
|
||||||
pci_disable_device(pci);
|
pci_disable_device(pci);
|
||||||
|
|
|
@ -1230,8 +1230,7 @@ static int snd_sonicvibes_create(struct snd_card *card,
|
||||||
if ((err = pci_enable_device(pci)) < 0)
|
if ((err = pci_enable_device(pci)) < 0)
|
||||||
return err;
|
return err;
|
||||||
/* check, if we can restrict PCI DMA transfers to 24 bits */
|
/* check, if we can restrict PCI DMA transfers to 24 bits */
|
||||||
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(24)) < 0 ||
|
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(24))) {
|
||||||
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(24)) < 0) {
|
|
||||||
dev_err(card->dev,
|
dev_err(card->dev,
|
||||||
"architecture does not support 24bit PCI busmaster DMA\n");
|
"architecture does not support 24bit PCI busmaster DMA\n");
|
||||||
pci_disable_device(pci);
|
pci_disable_device(pci);
|
||||||
|
|
|
@ -3497,8 +3497,7 @@ int snd_trident_create(struct snd_card *card,
|
||||||
if ((err = pci_enable_device(pci)) < 0)
|
if ((err = pci_enable_device(pci)) < 0)
|
||||||
return err;
|
return err;
|
||||||
/* check, if we can restrict PCI DMA transfers to 30 bits */
|
/* check, if we can restrict PCI DMA transfers to 30 bits */
|
||||||
if (dma_set_mask(&pci->dev, DMA_BIT_MASK(30)) < 0 ||
|
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(30))) {
|
||||||
dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(30)) < 0) {
|
|
||||||
dev_err(card->dev,
|
dev_err(card->dev,
|
||||||
"architecture does not support 30bit PCI busmaster DMA\n");
|
"architecture does not support 30bit PCI busmaster DMA\n");
|
||||||
pci_disable_device(pci);
|
pci_disable_device(pci);
|
||||||
|
|
Loading…
Reference in New Issue