Skip to content

Commit 0b6a2c9

Browse files
committed
ALSA: isa: Avoid passing NULL to memory allocators
We used to pass NULL to memory allocators for ISA devices due to historical reasons. But we prefer rather a proper device object to be assigned, so let's fix it by replacing snd_dma_isa_data() call with card->dev reference, and kill snd_dma_isa_data() definition. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 6a8125c commit 0b6a2c9

11 files changed

Lines changed: 18 additions & 18 deletions

File tree

‎Documentation/sound/kernel-api/writing-an-alsa-driver.rst‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3520,14 +3520,14 @@ allocator will try to get an area as large as possible within the
35203520
given size.
35213521

35223522
The second argument (type) and the third argument (device pointer) are
3523-
dependent on the bus. In the case of the ISA bus, pass
3524-
:c:func:`snd_dma_isa_data()` as the third argument with
3523+
dependent on the bus. For normal devices, pass the device pointer
3524+
(typically identical as ``card->dev``) to the third argument with
35253525
``SNDRV_DMA_TYPE_DEV`` type. For the continuous buffer unrelated to the
35263526
bus can be pre-allocated with ``SNDRV_DMA_TYPE_CONTINUOUS`` type and the
35273527
``snd_dma_continuous_data(GFP_KERNEL)`` device pointer, where
3528-
``GFP_KERNEL`` is the kernel allocation flag to use. For the PCI
3529-
scatter-gather buffers, use ``SNDRV_DMA_TYPE_DEV_SG`` with
3530-
``snd_dma_pci_data(pci)`` (see the `Non-Contiguous Buffers`_
3528+
``GFP_KERNEL`` is the kernel allocation flag to use. For the
3529+
scatter-gather buffers, use ``SNDRV_DMA_TYPE_DEV_SG`` with the device
3530+
pointer (see the `Non-Contiguous Buffers`_
35313531
section).
35323532

35333533
Once the buffer is pre-allocated, you can use the allocator in the

‎include/sound/memalloc.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ struct snd_dma_device {
3737
};
3838

3939
#define snd_dma_pci_data(pci) (&(pci)->dev)
40-
#define snd_dma_isa_data() NULL
4140
#define snd_dma_continuous_data(x) ((struct device *)(__force unsigned long)(x))
4241

4342

‎sound/isa/ad1816a/ad1816a_lib.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ int snd_ad1816a_pcm(struct snd_ad1816a *chip, int device)
693693
snd_ad1816a_init(chip);
694694

695695
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
696-
snd_dma_isa_data(),
696+
chip->card->dev,
697697
64*1024, chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024);
698698

699699
chip->pcm = pcm;

‎sound/isa/cmi8330.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ static int snd_cmi8330_pcm(struct snd_card *card, struct snd_cmi8330 *chip)
470470
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &chip->streams[SNDRV_PCM_STREAM_CAPTURE].ops);
471471

472472
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
473-
snd_dma_isa_data(),
473+
card->dev,
474474
64*1024, 128*1024);
475475
chip->pcm = pcm;
476476

‎sound/isa/es1688/es1688_lib.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ int snd_es1688_pcm(struct snd_card *card, struct snd_es1688 *chip, int device)
746746
chip->pcm = pcm;
747747

748748
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
749-
snd_dma_isa_data(),
749+
card->dev,
750750
64*1024, 64*1024);
751751
return 0;
752752
}

‎sound/isa/es18xx.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1717,7 +1717,7 @@ static int snd_es18xx_pcm(struct snd_card *card, int device)
17171717
chip->pcm = pcm;
17181718

17191719
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
1720-
snd_dma_isa_data(),
1720+
card->dev,
17211721
64*1024,
17221722
chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024);
17231723
return 0;

‎sound/isa/gus/gus_pcm.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,7 @@ int snd_gf1_pcm_new(struct snd_gus_card *gus, int pcm_dev, int control_index)
891891

892892
for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next)
893893
snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV,
894-
snd_dma_isa_data(),
894+
card->dev,
895895
64*1024, gus->gf1.dma1 > 3 ? 128*1024 : 64*1024);
896896

897897
pcm->info_flags = 0;
@@ -901,7 +901,7 @@ int snd_gf1_pcm_new(struct snd_gus_card *gus, int pcm_dev, int control_index)
901901
if (gus->gf1.dma2 == gus->gf1.dma1)
902902
pcm->info_flags |= SNDRV_PCM_INFO_HALF_DUPLEX;
903903
snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream,
904-
SNDRV_DMA_TYPE_DEV, snd_dma_isa_data(),
904+
SNDRV_DMA_TYPE_DEV, card->dev,
905905
64*1024, gus->gf1.dma2 > 3 ? 128*1024 : 64*1024);
906906
}
907907
strcpy(pcm->name, pcm->id);

‎sound/isa/sb/sb16_main.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ int snd_sb16dsp_pcm(struct snd_sb *chip, int device)
889889
}
890890

891891
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
892-
snd_dma_isa_data(),
892+
card->dev,
893893
64*1024, 128*1024);
894894
return 0;
895895
}

‎sound/isa/sb/sb8_main.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ int snd_sb8dsp_pcm(struct snd_sb *chip, int device)
610610
if (chip->dma8 > 3 || chip->dma16 >= 0)
611611
max_prealloc = 128 * 1024;
612612
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
613-
snd_dma_isa_data(),
613+
card->dev,
614614
64*1024, max_prealloc);
615615

616616
return 0;

‎sound/isa/sscape.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,13 @@ static inline struct soundscape *get_card_soundscape(struct snd_card *c)
167167
* I think this means that the memory has to map to
168168
* contiguous pages of physical memory.
169169
*/
170-
static struct snd_dma_buffer *get_dmabuf(struct snd_dma_buffer *buf,
170+
static struct snd_dma_buffer *get_dmabuf(struct soundscape *s,
171+
struct snd_dma_buffer *buf,
171172
unsigned long size)
172173
{
173174
if (buf) {
174175
if (snd_dma_alloc_pages_fallback(SNDRV_DMA_TYPE_DEV,
175-
snd_dma_isa_data(),
176+
s->chip->card->dev,
176177
size, buf) < 0) {
177178
snd_printk(KERN_ERR "sscape: Failed to allocate "
178179
"%lu bytes for DMA\n",
@@ -443,7 +444,7 @@ static int upload_dma_data(struct soundscape *s, const unsigned char *data,
443444
int ret;
444445
unsigned char val;
445446

446-
if (!get_dmabuf(&dma, PAGE_ALIGN(32 * 1024)))
447+
if (!get_dmabuf(s, &dma, PAGE_ALIGN(32 * 1024)))
447448
return -ENOMEM;
448449

449450
spin_lock_irqsave(&s->lock, flags);

0 commit comments

Comments
 (0)