aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/davinci
diff options
context:
space:
mode:
authorTroy Kisky <troy.kisky@boundarydevices.com>2009-09-11 17:29:03 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2009-09-23 13:08:57 -0400
commit92e2a6f68219f8d4c862b1f29c653b05639e4c06 (patch)
tree2a6dedf5568554f1555478e2d6d43eefb692990e /sound/soc/davinci
parent81ac55aa14c863821248d9e82694c79bb556694d (diff)
ASoC: Davinci: Fix race with cpu_dai->dma_data
This patch removes references to cpu_dai->dma_data. It makes struct davinci_pcm_dma_params part of struct davinci_mcbsp_dev or struct davinci_audio_dev. It removes the unused name variable from davinci_pcm_dma_params. Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/davinci')
-rw-r--r--sound/soc/davinci/davinci-i2s.c36
-rw-r--r--sound/soc/davinci/davinci-mcasp.c44
-rw-r--r--sound/soc/davinci/davinci-mcasp.h7
-rw-r--r--sound/soc/davinci/davinci-pcm.c3
-rw-r--r--sound/soc/davinci/davinci-pcm.h1
5 files changed, 29 insertions, 62 deletions
diff --git a/sound/soc/davinci/davinci-i2s.c b/sound/soc/davinci/davinci-i2s.c
index d32e1974fdf2..4ae707048021 100644
--- a/sound/soc/davinci/davinci-i2s.c
+++ b/sound/soc/davinci/davinci-i2s.c
@@ -97,22 +97,19 @@ enum {
97 DAVINCI_MCBSP_WORD_32, 97 DAVINCI_MCBSP_WORD_32,
98}; 98};
99 99
100static struct davinci_pcm_dma_params davinci_i2s_pcm_out = {
101 .name = "I2S PCM Stereo out",
102};
103
104static struct davinci_pcm_dma_params davinci_i2s_pcm_in = {
105 .name = "I2S PCM Stereo in",
106};
107
108struct davinci_mcbsp_dev { 100struct davinci_mcbsp_dev {
101 /*
102 * dma_params must be first because rtd->dai->cpu_dai->private_data
103 * is cast to a pointer of an array of struct davinci_pcm_dma_params in
104 * davinci_pcm_open.
105 */
106 struct davinci_pcm_dma_params dma_params[2];
109 void __iomem *base; 107 void __iomem *base;
110#define MOD_DSP_A 0 108#define MOD_DSP_A 0
111#define MOD_DSP_B 1 109#define MOD_DSP_B 1
112 int mode; 110 int mode;
113 u32 pcr; 111 u32 pcr;
114 struct clk *clk; 112 struct clk *clk;
115 struct davinci_pcm_dma_params *dma_params[2];
116}; 113};
117 114
118static inline void davinci_mcbsp_write_reg(struct davinci_mcbsp_dev *dev, 115static inline void davinci_mcbsp_write_reg(struct davinci_mcbsp_dev *dev,
@@ -215,14 +212,6 @@ static void davinci_mcbsp_stop(struct davinci_mcbsp_dev *dev, int playback)
215 toggle_clock(dev, playback); 212 toggle_clock(dev, playback);
216} 213}
217 214
218static int davinci_i2s_startup(struct snd_pcm_substream *substream,
219 struct snd_soc_dai *cpu_dai)
220{
221 struct davinci_mcbsp_dev *dev = cpu_dai->private_data;
222 cpu_dai->dma_data = dev->dma_params[substream->stream];
223 return 0;
224}
225
226#define DEFAULT_BITPERSAMPLE 16 215#define DEFAULT_BITPERSAMPLE 16
227 216
228static int davinci_i2s_set_dai_fmt(struct snd_soc_dai *cpu_dai, 217static int davinci_i2s_set_dai_fmt(struct snd_soc_dai *cpu_dai,
@@ -355,7 +344,7 @@ static int davinci_i2s_hw_params(struct snd_pcm_substream *substream,
355{ 344{
356 struct davinci_mcbsp_dev *dev = dai->private_data; 345 struct davinci_mcbsp_dev *dev = dai->private_data;
357 struct davinci_pcm_dma_params *dma_params = 346 struct davinci_pcm_dma_params *dma_params =
358 dev->dma_params[substream->stream]; 347 &dev->dma_params[substream->stream];
359 struct snd_interval *i = NULL; 348 struct snd_interval *i = NULL;
360 int mcbsp_word_length; 349 int mcbsp_word_length;
361 unsigned int rcr, xcr, srgr; 350 unsigned int rcr, xcr, srgr;
@@ -473,7 +462,6 @@ static void davinci_i2s_shutdown(struct snd_pcm_substream *substream,
473#define DAVINCI_I2S_RATES SNDRV_PCM_RATE_8000_96000 462#define DAVINCI_I2S_RATES SNDRV_PCM_RATE_8000_96000
474 463
475static struct snd_soc_dai_ops davinci_i2s_dai_ops = { 464static struct snd_soc_dai_ops davinci_i2s_dai_ops = {
476 .startup = davinci_i2s_startup,
477 .shutdown = davinci_i2s_shutdown, 465 .shutdown = davinci_i2s_shutdown,
478 .prepare = davinci_i2s_prepare, 466 .prepare = davinci_i2s_prepare,
479 .trigger = davinci_i2s_trigger, 467 .trigger = davinci_i2s_trigger,
@@ -535,12 +523,10 @@ static int davinci_i2s_probe(struct platform_device *pdev)
535 523
536 dev->base = (void __iomem *)IO_ADDRESS(mem->start); 524 dev->base = (void __iomem *)IO_ADDRESS(mem->start);
537 525
538 dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK] = &davinci_i2s_pcm_out; 526 dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK].dma_addr =
539 dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK]->dma_addr =
540 (dma_addr_t)(io_v2p(dev->base) + DAVINCI_MCBSP_DXR_REG); 527 (dma_addr_t)(io_v2p(dev->base) + DAVINCI_MCBSP_DXR_REG);
541 528
542 dev->dma_params[SNDRV_PCM_STREAM_CAPTURE] = &davinci_i2s_pcm_in; 529 dev->dma_params[SNDRV_PCM_STREAM_CAPTURE].dma_addr =
543 dev->dma_params[SNDRV_PCM_STREAM_CAPTURE]->dma_addr =
544 (dma_addr_t)(io_v2p(dev->base) + DAVINCI_MCBSP_DRR_REG); 530 (dma_addr_t)(io_v2p(dev->base) + DAVINCI_MCBSP_DRR_REG);
545 531
546 /* first TX, then RX */ 532 /* first TX, then RX */
@@ -550,7 +536,7 @@ static int davinci_i2s_probe(struct platform_device *pdev)
550 ret = -ENXIO; 536 ret = -ENXIO;
551 goto err_free_mem; 537 goto err_free_mem;
552 } 538 }
553 dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK]->channel = res->start; 539 dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK].channel = res->start;
554 540
555 res = platform_get_resource(pdev, IORESOURCE_DMA, 1); 541 res = platform_get_resource(pdev, IORESOURCE_DMA, 1);
556 if (!res) { 542 if (!res) {
@@ -558,7 +544,7 @@ static int davinci_i2s_probe(struct platform_device *pdev)
558 ret = -ENXIO; 544 ret = -ENXIO;
559 goto err_free_mem; 545 goto err_free_mem;
560 } 546 }
561 dev->dma_params[SNDRV_PCM_STREAM_CAPTURE]->channel = res->start; 547 dev->dma_params[SNDRV_PCM_STREAM_CAPTURE].channel = res->start;
562 548
563 davinci_i2s_dai.private_data = dev; 549 davinci_i2s_dai.private_data = dev;
564 ret = snd_soc_register_dai(&davinci_i2s_dai); 550 ret = snd_soc_register_dai(&davinci_i2s_dai);
diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c
index 7a06c0a86665..3174d96d929f 100644
--- a/sound/soc/davinci/davinci-mcasp.c
+++ b/sound/soc/davinci/davinci-mcasp.c
@@ -332,14 +332,6 @@ static inline void mcasp_set_ctl_reg(void __iomem *regs, u32 val)
332 printk(KERN_ERR "GBLCTL write error\n"); 332 printk(KERN_ERR "GBLCTL write error\n");
333} 333}
334 334
335static int davinci_mcasp_startup(struct snd_pcm_substream *substream,
336 struct snd_soc_dai *cpu_dai)
337{
338 struct davinci_audio_dev *dev = cpu_dai->private_data;
339 cpu_dai->dma_data = dev->dma_params[substream->stream];
340 return 0;
341}
342
343static void mcasp_start_rx(struct davinci_audio_dev *dev) 335static void mcasp_start_rx(struct davinci_audio_dev *dev)
344{ 336{
345 mcasp_set_ctl_reg(dev->base + DAVINCI_MCASP_GBLCTLR_REG, RXHCLKRST); 337 mcasp_set_ctl_reg(dev->base + DAVINCI_MCASP_GBLCTLR_REG, RXHCLKRST);
@@ -720,7 +712,7 @@ static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream,
720{ 712{
721 struct davinci_audio_dev *dev = cpu_dai->private_data; 713 struct davinci_audio_dev *dev = cpu_dai->private_data;
722 struct davinci_pcm_dma_params *dma_params = 714 struct davinci_pcm_dma_params *dma_params =
723 dev->dma_params[substream->stream]; 715 &dev->dma_params[substream->stream];
724 int word_length; 716 int word_length;
725 u8 numevt; 717 u8 numevt;
726 718
@@ -798,7 +790,6 @@ static int davinci_mcasp_trigger(struct snd_pcm_substream *substream,
798} 790}
799 791
800static struct snd_soc_dai_ops davinci_mcasp_dai_ops = { 792static struct snd_soc_dai_ops davinci_mcasp_dai_ops = {
801 .startup = davinci_mcasp_startup,
802 .trigger = davinci_mcasp_trigger, 793 .trigger = davinci_mcasp_trigger,
803 .hw_params = davinci_mcasp_hw_params, 794 .hw_params = davinci_mcasp_hw_params,
804 .set_fmt = davinci_mcasp_set_dai_fmt, 795 .set_fmt = davinci_mcasp_set_dai_fmt,
@@ -849,20 +840,12 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
849 struct resource *mem, *ioarea, *res; 840 struct resource *mem, *ioarea, *res;
850 struct snd_platform_data *pdata; 841 struct snd_platform_data *pdata;
851 struct davinci_audio_dev *dev; 842 struct davinci_audio_dev *dev;
852 int count = 0;
853 int ret = 0; 843 int ret = 0;
854 844
855 dev = kzalloc(sizeof(struct davinci_audio_dev), GFP_KERNEL); 845 dev = kzalloc(sizeof(struct davinci_audio_dev), GFP_KERNEL);
856 if (!dev) 846 if (!dev)
857 return -ENOMEM; 847 return -ENOMEM;
858 848
859 dma_data = kzalloc(sizeof(struct davinci_pcm_dma_params) * 2,
860 GFP_KERNEL);
861 if (!dma_data) {
862 ret = -ENOMEM;
863 goto err_release_dev;
864 }
865
866 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 849 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
867 if (!mem) { 850 if (!mem) {
868 dev_err(&pdev->dev, "no mem resource?\n"); 851 dev_err(&pdev->dev, "no mem resource?\n");
@@ -897,11 +880,10 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
897 dev->txnumevt = pdata->txnumevt; 880 dev->txnumevt = pdata->txnumevt;
898 dev->rxnumevt = pdata->rxnumevt; 881 dev->rxnumevt = pdata->rxnumevt;
899 882
900 dma_data[count].name = "I2S PCM Stereo out"; 883 dma_data = &dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK];
901 dma_data[count].eventq_no = pdata->eventq_no; 884 dma_data->eventq_no = pdata->eventq_no;
902 dma_data[count].dma_addr = (dma_addr_t) (pdata->tx_dma_offset + 885 dma_data->dma_addr = (dma_addr_t) (pdata->tx_dma_offset +
903 io_v2p(dev->base)); 886 io_v2p(dev->base));
904 dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK] = &dma_data[count];
905 887
906 /* first TX, then RX */ 888 /* first TX, then RX */
907 res = platform_get_resource(pdev, IORESOURCE_DMA, 0); 889 res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
@@ -910,13 +892,12 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
910 goto err_release_region; 892 goto err_release_region;
911 } 893 }
912 894
913 dma_data[count].channel = res->start; 895 dma_data->channel = res->start;
914 count++; 896
915 dma_data[count].name = "I2S PCM Stereo in"; 897 dma_data = &dev->dma_params[SNDRV_PCM_STREAM_CAPTURE];
916 dma_data[count].eventq_no = pdata->eventq_no; 898 dma_data->eventq_no = pdata->eventq_no;
917 dma_data[count].dma_addr = (dma_addr_t)(pdata->rx_dma_offset + 899 dma_data->dma_addr = (dma_addr_t)(pdata->rx_dma_offset +
918 io_v2p(dev->base)); 900 io_v2p(dev->base));
919 dev->dma_params[SNDRV_PCM_STREAM_CAPTURE] = &dma_data[count];
920 901
921 res = platform_get_resource(pdev, IORESOURCE_DMA, 1); 902 res = platform_get_resource(pdev, IORESOURCE_DMA, 1);
922 if (!res) { 903 if (!res) {
@@ -924,7 +905,7 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
924 goto err_release_region; 905 goto err_release_region;
925 } 906 }
926 907
927 dma_data[count].channel = res->start; 908 dma_data->channel = res->start;
928 davinci_mcasp_dai[pdata->op_mode].private_data = dev; 909 davinci_mcasp_dai[pdata->op_mode].private_data = dev;
929 davinci_mcasp_dai[pdata->op_mode].dev = &pdev->dev; 910 davinci_mcasp_dai[pdata->op_mode].dev = &pdev->dev;
930 ret = snd_soc_register_dai(&davinci_mcasp_dai[pdata->op_mode]); 911 ret = snd_soc_register_dai(&davinci_mcasp_dai[pdata->op_mode]);
@@ -936,8 +917,6 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
936err_release_region: 917err_release_region:
937 release_mem_region(mem->start, (mem->end - mem->start) + 1); 918 release_mem_region(mem->start, (mem->end - mem->start) + 1);
938err_release_data: 919err_release_data:
939 kfree(dma_data);
940err_release_dev:
941 kfree(dev); 920 kfree(dev);
942 921
943 return ret; 922 return ret;
@@ -946,7 +925,6 @@ err_release_dev:
946static int davinci_mcasp_remove(struct platform_device *pdev) 925static int davinci_mcasp_remove(struct platform_device *pdev)
947{ 926{
948 struct snd_platform_data *pdata = pdev->dev.platform_data; 927 struct snd_platform_data *pdata = pdev->dev.platform_data;
949 struct davinci_pcm_dma_params *dma_data;
950 struct davinci_audio_dev *dev; 928 struct davinci_audio_dev *dev;
951 struct resource *mem; 929 struct resource *mem;
952 930
@@ -959,8 +937,6 @@ static int davinci_mcasp_remove(struct platform_device *pdev)
959 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 937 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
960 release_mem_region(mem->start, (mem->end - mem->start) + 1); 938 release_mem_region(mem->start, (mem->end - mem->start) + 1);
961 939
962 dma_data = dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK];
963 kfree(dma_data);
964 kfree(dev); 940 kfree(dev);
965 941
966 return 0; 942 return 0;
diff --git a/sound/soc/davinci/davinci-mcasp.h b/sound/soc/davinci/davinci-mcasp.h
index 554354c1cc2f..9d179cc88f7b 100644
--- a/sound/soc/davinci/davinci-mcasp.h
+++ b/sound/soc/davinci/davinci-mcasp.h
@@ -39,10 +39,15 @@ enum {
39}; 39};
40 40
41struct davinci_audio_dev { 41struct davinci_audio_dev {
42 /*
43 * dma_params must be first because rtd->dai->cpu_dai->private_data
44 * is cast to a pointer of an array of struct davinci_pcm_dma_params in
45 * davinci_pcm_open.
46 */
47 struct davinci_pcm_dma_params dma_params[2];
42 void __iomem *base; 48 void __iomem *base;
43 int sample_rate; 49 int sample_rate;
44 struct clk *clk; 50 struct clk *clk;
45 struct davinci_pcm_dma_params *dma_params[2];
46 unsigned int codec_fmt; 51 unsigned int codec_fmt;
47 52
48 /* McASP specific data */ 53 /* McASP specific data */
diff --git a/sound/soc/davinci/davinci-pcm.c b/sound/soc/davinci/davinci-pcm.c
index 002808b27f49..359e99ec7244 100644
--- a/sound/soc/davinci/davinci-pcm.c
+++ b/sound/soc/davinci/davinci-pcm.c
@@ -238,7 +238,8 @@ static int davinci_pcm_open(struct snd_pcm_substream *substream)
238 struct davinci_runtime_data *prtd; 238 struct davinci_runtime_data *prtd;
239 int ret = 0; 239 int ret = 0;
240 struct snd_soc_pcm_runtime *rtd = substream->private_data; 240 struct snd_soc_pcm_runtime *rtd = substream->private_data;
241 struct davinci_pcm_dma_params *params = rtd->dai->cpu_dai->dma_data; 241 struct davinci_pcm_dma_params *pa = rtd->dai->cpu_dai->private_data;
242 struct davinci_pcm_dma_params *params = &pa[substream->stream];
242 if (!params) 243 if (!params)
243 return -ENODEV; 244 return -ENODEV;
244 245
diff --git a/sound/soc/davinci/davinci-pcm.h b/sound/soc/davinci/davinci-pcm.h
index 63d96253c73a..8746606efc89 100644
--- a/sound/soc/davinci/davinci-pcm.h
+++ b/sound/soc/davinci/davinci-pcm.h
@@ -17,7 +17,6 @@
17 17
18 18
19struct davinci_pcm_dma_params { 19struct davinci_pcm_dma_params {
20 char *name; /* stream identifier */
21 int channel; /* sync dma channel ID */ 20 int channel; /* sync dma channel ID */
22 unsigned short acnt; 21 unsigned short acnt;
23 dma_addr_t dma_addr; /* device physical address for DMA */ 22 dma_addr_t dma_addr; /* device physical address for DMA */