Date:2013-03-22 14:12:13 (9 years 6 months ago)
Author:Lars C.
Commit:0b4b338e2a7be677ba82329d7b573b4b097cf070
Message:ASoC: mxs: Embed the mxs_dma_data struct in the mxs_pcm_dma_params struct

Currently the mxs_dma_data struct, which gets passed to the dmaengine driver, is
allocated in the pcm driver's open callback. The mxs_dma_data struct has exactly
one field which is initialized from the the same field in the mxs_pcm_dma_params
struct. The mxs_pcm_dma_params struct gets passed to the pcm driver from the dai
driver. Instead of taking this indirection embed the mxs_dma_data struct
directly in the mxs_pcm_dma_params struct. This allows us to simplify the pcm
driver quite a bit, since we don't have to care about memory managing the
mxs_dma_data struct anymore.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Tested-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Files: sound/soc/mxs/mxs-pcm.c (6 diffs)
sound/soc/mxs/mxs-pcm.h (1 diff)
sound/soc/mxs/mxs-saif.c (1 diff)

Change Details

sound/soc/mxs/mxs-pcm.c
2828#include <linux/platform_device.h>
2929#include <linux/slab.h>
3030#include <linux/dmaengine.h>
31#include <linux/fsl/mxs-dma.h>
3231
3332#include <sound/core.h>
3433#include <sound/initval.h>
...... 
3938
4039#include "mxs-pcm.h"
4140
42struct mxs_pcm_dma_data {
43    struct mxs_dma_data dma_data;
44    struct mxs_pcm_dma_params *dma_params;
45};
46
4741static struct snd_pcm_hardware snd_mxs_hardware = {
4842    .info = SNDRV_PCM_INFO_MMAP |
4943                  SNDRV_PCM_INFO_MMAP_VALID |
...... 
6660
6761static bool filter(struct dma_chan *chan, void *param)
6862{
69    struct mxs_pcm_dma_data *pcm_dma_data = param;
70    struct mxs_pcm_dma_params *dma_params = pcm_dma_data->dma_params;
63    struct mxs_pcm_dma_params *dma_params = param;
7164
7265    if (!mxs_dma_is_apbx(chan))
7366        return false;
...... 
7568    if (chan->chan_id != dma_params->chan_num)
7669        return false;
7770
78    chan->private = &pcm_dma_data->dma_data;
71    chan->private = &dma_params->dma_data;
7972
8073    return true;
8174}
...... 
9184static int snd_mxs_open(struct snd_pcm_substream *substream)
9285{
9386    struct snd_soc_pcm_runtime *rtd = substream->private_data;
94    struct mxs_pcm_dma_data *pcm_dma_data;
95    int ret;
96
97    pcm_dma_data = kzalloc(sizeof(*pcm_dma_data), GFP_KERNEL);
98    if (pcm_dma_data == NULL)
99        return -ENOMEM;
100
101    pcm_dma_data->dma_params = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
102    pcm_dma_data->dma_data.chan_irq = pcm_dma_data->dma_params->chan_irq;
103
104    ret = snd_dmaengine_pcm_open(substream, filter, pcm_dma_data);
105    if (ret) {
106        kfree(pcm_dma_data);
107        return ret;
108    }
10987
11088    snd_soc_set_runtime_hwparams(substream, &snd_mxs_hardware);
11189
112    snd_dmaengine_pcm_set_data(substream, pcm_dma_data);
113
114    return 0;
115}
116
117static int snd_mxs_close(struct snd_pcm_substream *substream)
118{
119    struct mxs_pcm_dma_data *pcm_dma_data = snd_dmaengine_pcm_get_data(substream);
120
121    snd_dmaengine_pcm_close(substream);
122    kfree(pcm_dma_data);
123
124    return 0;
90    return snd_dmaengine_pcm_open(substream, filter,
91        snd_soc_dai_get_dma_data(rtd->cpu_dai, substream));
12592}
12693
12794static int snd_mxs_pcm_mmap(struct snd_pcm_substream *substream,
...... 
137104
138105static struct snd_pcm_ops mxs_pcm_ops = {
139106    .open = snd_mxs_open,
140    .close = snd_mxs_close,
107    .close = snd_dmaengine_pcm_close,
141108    .ioctl = snd_pcm_lib_ioctl,
142109    .hw_params = snd_mxs_pcm_hw_params,
143110    .trigger = snd_dmaengine_pcm_trigger,
sound/soc/mxs/mxs-pcm.h
1919#ifndef _MXS_PCM_H
2020#define _MXS_PCM_H
2121
22#include <linux/fsl/mxs-dma.h>
23
2224struct mxs_pcm_dma_params {
23    int chan_irq;
25    struct mxs_dma_data dma_data;
2426    int chan_num;
2527};
2628
sound/soc/mxs/mxs-saif.c
753753        return ret;
754754    }
755755
756    saif->dma_param.chan_irq = platform_get_irq(pdev, 1);
757    if (saif->dma_param.chan_irq < 0) {
758        ret = saif->dma_param.chan_irq;
756    saif->dma_param.dma_data.chan_irq = platform_get_irq(pdev, 1);
757    if (saif->dma_param.dma_data.chan_irq < 0) {
758        ret = saif->dma_param.dma_data.chan_irq;
759759        dev_err(&pdev->dev, "failed to get dma irq resource: %d\n",
760760            ret);
761761        return ret;

Archive Download the corresponding diff file



interactive