]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
ALSA: isa: Avoid passing NULL to memory allocators
authorTakashi Iwai <tiwai@suse.de>
Fri, 1 Feb 2019 11:14:53 +0000 (12:14 +0100)
committerTakashi Iwai <tiwai@suse.de>
Fri, 1 Feb 2019 16:16:40 +0000 (17:16 +0100)
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>
Documentation/sound/kernel-api/writing-an-alsa-driver.rst
include/sound/memalloc.h
sound/isa/ad1816a/ad1816a_lib.c
sound/isa/cmi8330.c
sound/isa/es1688/es1688_lib.c
sound/isa/es18xx.c
sound/isa/gus/gus_pcm.c
sound/isa/sb/sb16_main.c
sound/isa/sb/sb8_main.c
sound/isa/sscape.c
sound/isa/wss/wss_lib.c

index 7c2f2032d30a683a778235ec60d2a13040b3d847..6b154dbb02cc76eb991c809af4bec52528114c84 100644 (file)
@@ -3520,14 +3520,14 @@ allocator will try to get an area as large as possible within the
 given size.
 
 The second argument (type) and the third argument (device pointer) are
-dependent on the bus. In the case of the ISA bus, pass
-:c:func:`snd_dma_isa_data()` as the third argument with
+dependent on the bus. For normal devices, pass the device pointer
+(typically identical as ``card->dev``) to the third argument with
 ``SNDRV_DMA_TYPE_DEV`` type. For the continuous buffer unrelated to the
 bus can be pre-allocated with ``SNDRV_DMA_TYPE_CONTINUOUS`` type and the
 ``snd_dma_continuous_data(GFP_KERNEL)`` device pointer, where
-``GFP_KERNEL`` is the kernel allocation flag to use. For the PCI
-scatter-gather buffers, use ``SNDRV_DMA_TYPE_DEV_SG`` with
-``snd_dma_pci_data(pci)`` (see the `Non-Contiguous Buffers`_
+``GFP_KERNEL`` is the kernel allocation flag to use. For the
+scatter-gather buffers, use ``SNDRV_DMA_TYPE_DEV_SG`` with the device
+pointer (see the `Non-Contiguous Buffers`_
 section).
 
 Once the buffer is pre-allocated, you can use the allocator in the
index af3fa577fa066ae3aa0ed712e12d7c45eeac0b50..1ac0dd82a9163847dc5280aa55efbead4f671bdb 100644 (file)
@@ -37,7 +37,6 @@ struct snd_dma_device {
 };
 
 #define snd_dma_pci_data(pci)  (&(pci)->dev)
-#define snd_dma_isa_data()     NULL
 #define snd_dma_continuous_data(x)     ((struct device *)(__force unsigned long)(x))
 
 
index 61e8c7e524db609443b996641d913ed1278deab4..94b381a78e9e5a5850419476ae35007c2839fc0a 100644 (file)
@@ -693,7 +693,7 @@ int snd_ad1816a_pcm(struct snd_ad1816a *chip, int device)
        snd_ad1816a_init(chip);
 
        snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
-                                             snd_dma_isa_data(),
+                                             chip->card->dev,
                                              64*1024, chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024);
 
        chip->pcm = pcm;
index 7e5aa06414c45078d2901c8117d82e772bdf3d11..1868b73aa49cdbdc95d0a1d8691ee9db0e9d27c7 100644 (file)
@@ -470,7 +470,7 @@ static int snd_cmi8330_pcm(struct snd_card *card, struct snd_cmi8330 *chip)
        snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &chip->streams[SNDRV_PCM_STREAM_CAPTURE].ops);
 
        snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
-                                             snd_dma_isa_data(),
+                                             card->dev,
                                              64*1024, 128*1024);
        chip->pcm = pcm;
 
index 50cdce0e89468610349b853f62247795a075c98d..da341969e65083b80f72789e8e19145fa141a060 100644 (file)
@@ -746,7 +746,7 @@ int snd_es1688_pcm(struct snd_card *card, struct snd_es1688 *chip, int device)
        chip->pcm = pcm;
 
        snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
-                                             snd_dma_isa_data(),
+                                             card->dev,
                                              64*1024, 64*1024);
        return 0;
 }
index 77aa9a27fb3beb4dbe6e9fb33882770aa22b9964..07abc7f7840c22a6821f222447b1b63eee433b7d 100644 (file)
@@ -1717,7 +1717,7 @@ static int snd_es18xx_pcm(struct snd_card *card, int device)
         chip->pcm = pcm;
 
        snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
-                                             snd_dma_isa_data(),
+                                             card->dev,
                                              64*1024,
                                              chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024);
        return 0;
index 131b28997e1d1e1c097122770e1562d8cb13c7a9..b9efc6dff45dcd68657f3e89efad3f446e5a8c36 100644 (file)
@@ -891,7 +891,7 @@ int snd_gf1_pcm_new(struct snd_gus_card *gus, int pcm_dev, int control_index)
 
        for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next)
                snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV,
-                                             snd_dma_isa_data(),
+                                             card->dev,
                                              64*1024, gus->gf1.dma1 > 3 ? 128*1024 : 64*1024);
        
        pcm->info_flags = 0;
@@ -901,7 +901,7 @@ int snd_gf1_pcm_new(struct snd_gus_card *gus, int pcm_dev, int control_index)
                if (gus->gf1.dma2 == gus->gf1.dma1)
                        pcm->info_flags |= SNDRV_PCM_INFO_HALF_DUPLEX;
                snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream,
-                                             SNDRV_DMA_TYPE_DEV, snd_dma_isa_data(),
+                                             SNDRV_DMA_TYPE_DEV, card->dev,
                                              64*1024, gus->gf1.dma2 > 3 ? 128*1024 : 64*1024);
        }
        strcpy(pcm->name, pcm->id);
index 981d65d122b69e546670b1678cd2b8681e6c9fce..473ec74ae48ca359656d301884f739400734f9a4 100644 (file)
@@ -889,7 +889,7 @@ int snd_sb16dsp_pcm(struct snd_sb *chip, int device)
        }
 
        snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
-                                             snd_dma_isa_data(),
+                                             card->dev,
                                              64*1024, 128*1024);
        return 0;
 }
index 8288fae90085c8c4d36f793a5fb8791ca43076f4..97645a732a7104cba67844568a9767869299bd7d 100644 (file)
@@ -610,7 +610,7 @@ int snd_sb8dsp_pcm(struct snd_sb *chip, int device)
        if (chip->dma8 > 3 || chip->dma16 >= 0)
                max_prealloc = 128 * 1024;
        snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
-                                             snd_dma_isa_data(),
+                                             card->dev,
                                              64*1024, max_prealloc);
 
        return 0;
index 733adee5afbf94915b2460a82723e8cf9a1dcf19..8181db4db019d06a2539906482e9d9da1959d4e1 100644 (file)
@@ -167,12 +167,13 @@ static inline struct soundscape *get_card_soundscape(struct snd_card *c)
  * I think this means that the memory has to map to
  * contiguous pages of physical memory.
  */
-static struct snd_dma_buffer *get_dmabuf(struct snd_dma_buffer *buf,
+static struct snd_dma_buffer *get_dmabuf(struct soundscape *s,
+                                        struct snd_dma_buffer *buf,
                                         unsigned long size)
 {
        if (buf) {
                if (snd_dma_alloc_pages_fallback(SNDRV_DMA_TYPE_DEV,
-                                                snd_dma_isa_data(),
+                                                s->chip->card->dev,
                                                 size, buf) < 0) {
                        snd_printk(KERN_ERR "sscape: Failed to allocate "
                                            "%lu bytes for DMA\n",
@@ -443,7 +444,7 @@ static int upload_dma_data(struct soundscape *s, const unsigned char *data,
        int ret;
        unsigned char val;
 
-       if (!get_dmabuf(&dma, PAGE_ALIGN(32 * 1024)))
+       if (!get_dmabuf(s, &dma, PAGE_ALIGN(32 * 1024)))
                return -ENOMEM;
 
        spin_lock_irqsave(&s->lock, flags);
index b11ef97bce1bc139f9f33149d9613f7c2c6c3313..0dfb8065b4034fe5dbd1b10a30256fab28807c2f 100644 (file)
@@ -1942,7 +1942,7 @@ int snd_wss_pcm(struct snd_wss *chip, int device)
        strcpy(pcm->name, snd_wss_chip_id(chip));
 
        snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
-                                             snd_dma_isa_data(),
+                                             chip->card->dev,
                                              64*1024, chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024);
 
        chip->pcm = pcm;