From patchwork Thu Sep 10 01:57:10 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Troy Kisky X-Patchwork-Id: 46694 Received: from bear.ext.ti.com (bear.ext.ti.com [192.94.94.41]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n8AMhHiT019833 for ; Thu, 10 Sep 2009 22:43:17 GMT Received: from dlep33.itg.ti.com ([157.170.170.112]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id n8A1vs00008062 for ; Wed, 9 Sep 2009 20:57:59 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by dlep33.itg.ti.com (8.13.7/8.13.7) with ESMTP id n8A1vr6m016288 for ; Wed, 9 Sep 2009 20:57:53 -0500 (CDT) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 0515280646 for ; Wed, 9 Sep 2009 20:57:52 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp53.itg.ti.com (dflp53.itg.ti.com [128.247.5.6]) by linux.omap.com (Postfix) with ESMTP id E5DF180626 for ; Wed, 9 Sep 2009 20:57:46 -0500 (CDT) Received: from medina.ext.ti.com (localhost [127.0.0.1]) by dflp53.itg.ti.com (8.13.8/8.13.8) with ESMTP id n8A1vkwQ008524 for ; Wed, 9 Sep 2009 20:57:46 -0500 (CDT) Received: from mail36-va3-R.bigfish.com (mail-va3.bigfish.com [216.32.180.111]) by medina.ext.ti.com (8.13.7/8.13.7) with ESMTP id n8A1vfYf020847 for ; Wed, 9 Sep 2009 20:57:46 -0500 Received: from mail36-va3 (localhost.localdomain [127.0.0.1]) by mail36-va3-R.bigfish.com (Postfix) with ESMTP id 0A9CCC202F9 for ; Thu, 10 Sep 2009 01:57:41 +0000 (UTC) X-SpamScore: 0 X-BigFish: vps0(zzzz1202hzzz2dh62h) X-Spam-TCS-SCL: 1:0 X-MS-Exchange-Organization-Antispam-Report: OrigIP: 63.231.195.115; Service: EHS Received: by mail36-va3 (MessageSwitch) id 1252547848727207_22173; Thu, 10 Sep 2009 01:57:28 +0000 (UCT) Received: from mpls-qmqp-04.inet.qwest.net (mpls-qmqp-04.inet.qwest.net [63.231.195.115]) by mail36-va3.bigfish.com (Postfix) with ESMTP id 05BA212C805C for ; Thu, 10 Sep 2009 01:56:55 +0000 (UTC) Received: from localhost (unknown [67.42.45.38]) by mpls-qmqp-04.inet.qwest.net (Postfix) with ESMTP id 4ED9F22DC68; Thu, 10 Sep 2009 01:56:50 +0000 (UTC) Received: by localhost (Postfix, from userid 1002) id 446A35886E8; Wed, 9 Sep 2009 18:57:10 -0700 (MST) From: Troy Kisky To: khilman@deeprootsystems.com, davinci-linux-open-source@linux.davincidsp.com Date: Wed, 9 Sep 2009 18:57:10 -0700 Message-Id: <1252547830-16585-1-git-send-email-troy.kisky@boundarydevices.com> X-Mailer: git-send-email 1.5.6.3 Cc: alsa-devel@alsa-project.org, broonie@sirena.org.uk Subject: [PATCH] RFC: ASoC: Davinci: Fix data_type divide by zero X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.4 Precedence: list List-Id: davinci-linux-open-source.linux.davincidsp.com List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: davinci-linux-open-source-bounces+patchwork-davinci=patchwork.kernel.org@linux.davincidsp.com Errors-To: davinci-linux-open-source-bounces+patchwork-davinci=patchwork.kernel.org@linux.davincidsp.com This is a proposed fix for the data_type divide by 0 error. Signed-off-by: Troy Kisky --- This applies on top of my last patchset to Kevin's temp/asoc branch sound/soc/davinci/davinci-i2s.c | 18 +++++++----------- sound/soc/davinci/davinci-mcasp.h | 7 ++++++- sound/soc/davinci/davinci-pcm.c | 14 ++++++-------- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/sound/soc/davinci/davinci-i2s.c b/sound/soc/davinci/davinci-i2s.c index 5f61016..252c3ea 100644 --- a/sound/soc/davinci/davinci-i2s.c +++ b/sound/soc/davinci/davinci-i2s.c @@ -123,13 +123,18 @@ static struct davinci_pcm_dma_params davinci_i2s_pcm_in = { }; struct davinci_mcbsp_dev { + /* + * dma_params must be first because rtd->dai->cpu_dai->private_data + * is cast to an array of struct davinci_pcm_dma_params ** in + * davinci_pcm_open. + */ + struct davinci_pcm_dma_params *dma_params[2]; void __iomem *base; #define MOD_DSP_A 0 #define MOD_DSP_B 1 int mode; u32 pcr; struct clk *clk; - struct davinci_pcm_dma_params *dma_params[2]; /* * Combining both channels into 1 element will at least double the * amount of time between servicing the dma channel, increase @@ -255,14 +260,6 @@ static void davinci_mcbsp_stop(struct davinci_mcbsp_dev *dev, int playback) toggle_clock(dev, playback); } -static int davinci_i2s_startup(struct snd_pcm_substream *substream, - struct snd_soc_dai *cpu_dai) -{ - struct davinci_mcbsp_dev *dev = cpu_dai->private_data; - cpu_dai->dma_data = dev->dma_params[substream->stream]; - return 0; -} - #define DEFAULT_BITPERSAMPLE 16 static int davinci_i2s_set_dai_fmt(struct snd_soc_dai *cpu_dai, @@ -393,7 +390,6 @@ static int davinci_i2s_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct davinci_pcm_dma_params *dma_params = dai->dma_data; struct davinci_mcbsp_dev *dev = dai->private_data; struct snd_soc_dai *codec_dai = dev->codec_dai; struct snd_interval *i = NULL; @@ -407,6 +403,7 @@ static int davinci_i2s_hw_params(struct snd_pcm_substream *substream, int right_first = 0; int convert_mono_stereo = 0; int playback = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ? 1 : 0; + struct davinci_pcm_dma_params *dma_params = dev->dma_params[substream->stream]; i = hw_param_interval(params, SNDRV_PCM_HW_PARAM_SAMPLE_BITS); bits_per_sample = snd_interval_value(i); @@ -529,7 +526,6 @@ static void davinci_i2s_shutdown(struct snd_pcm_substream *substream, #define DAVINCI_I2S_RATES SNDRV_PCM_RATE_8000_96000 static struct snd_soc_dai_ops davinci_i2s_dai_ops = { - .startup = davinci_i2s_startup, .shutdown = davinci_i2s_shutdown, .prepare = davinci_i2s_prepare, .trigger = davinci_i2s_trigger, diff --git a/sound/soc/davinci/davinci-mcasp.h b/sound/soc/davinci/davinci-mcasp.h index 554354c..c6ea04d 100644 --- a/sound/soc/davinci/davinci-mcasp.h +++ b/sound/soc/davinci/davinci-mcasp.h @@ -39,10 +39,15 @@ enum { }; struct davinci_audio_dev { + /* + * dma_params must be first because rtd->dai->cpu_dai->private_data + * is cast to an array of struct davinci_pcm_dma_params ** in + * davinci_pcm_open. + */ + struct davinci_pcm_dma_params *dma_params[2]; void __iomem *base; int sample_rate; struct clk *clk; - struct davinci_pcm_dma_params *dma_params[2]; unsigned int codec_fmt; /* McASP specific data */ diff --git a/sound/soc/davinci/davinci-pcm.c b/sound/soc/davinci/davinci-pcm.c index 2729a80..0bd3b2e 100644 --- a/sound/soc/davinci/davinci-pcm.c +++ b/sound/soc/davinci/davinci-pcm.c @@ -265,8 +265,7 @@ static int ping_pong_dma_setup(struct snd_pcm_substream *substream) struct davinci_runtime_data *prtd = runtime->private_data; struct snd_dma_buffer *iram_dma = (struct snd_dma_buffer *)substream->dma_buffer.private_data; - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct davinci_pcm_dma_params *dma_data = rtd->dai->cpu_dai->dma_data; + struct davinci_pcm_dma_params *dma_data = prtd->params; unsigned int data_type = dma_data->data_type; unsigned int acnt = dma_data->acnt; unsigned int convert_mono_stereo = dma_data->convert_mono_stereo; @@ -482,15 +481,12 @@ static int davinci_pcm_dma_request(struct snd_pcm_substream *substream) { struct snd_dma_buffer *iram_dma; struct davinci_runtime_data *prtd = substream->runtime->private_data; - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct davinci_pcm_dma_params *dma_data = rtd->dai->cpu_dai->dma_data; + struct davinci_pcm_dma_params *dma_data = prtd->params; int link; if (!dma_data) return -ENODEV; - prtd->params = dma_data; - /* Request asp master DMA channel */ link = prtd->asp_channel = edma_alloc_channel(dma_data->channel, davinci_pcm_dma_irq, substream, EVENTQ_0); @@ -660,7 +656,8 @@ davinci_pcm_pointer(struct snd_pcm_substream *substream) static int davinci_pcm_open(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct davinci_pcm_dma_params *dma_data = rtd->dai->cpu_dai->dma_data; + struct davinci_pcm_dma_params **pa = rtd->dai->cpu_dai->private_data; + struct davinci_pcm_dma_params *dma_params = pa[substream->stream]; struct snd_pcm_runtime *runtime = substream->runtime; struct davinci_runtime_data *prtd; struct snd_pcm_hardware *ppcm; @@ -668,7 +665,7 @@ static int davinci_pcm_open(struct snd_pcm_substream *substream) ppcm = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ? &pcm_hardware_playback : &pcm_hardware_capture; - allocate_sram(substream, dma_data->sram_size, ppcm); + allocate_sram(substream, dma_params->sram_size, ppcm); snd_soc_set_runtime_hwparams(substream, ppcm); /* ensure that buffer size is a multiple of period size */ ret = snd_pcm_hw_constraint_integer(runtime, @@ -681,6 +678,7 @@ static int davinci_pcm_open(struct snd_pcm_substream *substream) return -ENOMEM; spin_lock_init(&prtd->lock); + prtd->params = dma_params; prtd->asp_channel = -1; prtd->asp_link[0] = prtd->asp_link[1] = -1; prtd->ram_channel = -1;