From patchwork Mon Mar 23 14:46:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Kleine-Budde X-Patchwork-Id: 6073681 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A13099F399 for ; Mon, 23 Mar 2015 14:46:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D089C20274 for ; Mon, 23 Mar 2015 14:46:33 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 7166B2020F for ; Mon, 23 Mar 2015 14:46:32 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 8F1672606D7; Mon, 23 Mar 2015 15:46:30 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id AF343260695; Mon, 23 Mar 2015 15:46:22 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 4BBC626066D; Mon, 23 Mar 2015 15:46:21 +0100 (CET) Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [92.198.50.35]) by alsa0.perex.cz (Postfix) with ESMTP id 66F3A26066D for ; Mon, 23 Mar 2015 15:46:14 +0100 (CET) Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1Ya3cL-0000lp-UC; Mon, 23 Mar 2015 15:46:13 +0100 Received: from mkl by dude.hi.pengutronix.de with local (Exim 4.84) (envelope-from ) id 1Ya3cL-0001KH-3N; Mon, 23 Mar 2015 15:46:13 +0100 From: Marc Kleine-Budde To: alsa-devel@alsa-project.org Date: Mon, 23 Mar 2015 15:46:12 +0100 Message-Id: <1427121972-5059-1-git-send-email-mkl@pengutronix.de> X-Mailer: git-send-email 2.1.4 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: mkl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: alsa-devel@alsa-project.org Cc: Sascha Hauer , broonie@kernel.org, Marc Kleine-Budde , linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [alsa-devel] [PATCH resend] ASoC: fsl-ssi: Fix bitclock calculation for master mode X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP From: Sascha Hauer in fsl_ssi_set_bclk we are looking for the best divider by iterating over all possible dividers. The divider is in the range 1..256, so make this clear by using 'div' as name for the loop counter and iterate from 1 to 256 instead of 0 to 255. This makes obvious that tmprate is calculated wrong, it has to be freq * factor * div, not freq * factor * (i + 2). Signed-off-by: Sascha Hauer Signed-off-by: Marc Kleine-Budde --- sound/soc/fsl/fsl_ssi.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index b9fabbf69db6..b8af08e49085 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -578,7 +578,7 @@ static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream, struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(cpu_dai); struct regmap *regs = ssi_private->regs; int synchronous = ssi_private->cpu_dai_drv.symmetric_rates, ret; - u32 pm = 999, div2, psr, stccr, mask, afreq, factor, i; + u32 pm = 999, div2, psr, stccr, mask, afreq, factor, div; unsigned long clkrate, baudrate, tmprate; u64 sub, savesub = 100000; unsigned int freq; @@ -602,8 +602,8 @@ static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream, factor = (div2 + 1) * (7 * psr + 1) * 2; - for (i = 0; i < 255; i++) { - tmprate = freq * factor * (i + 2); + for (div = 1; div < 256; div++) { + tmprate = freq * factor * div; if (baudclk_is_used) clkrate = clk_get_rate(ssi_private->baudclk); @@ -618,7 +618,7 @@ static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream, continue; clkrate /= factor; - afreq = clkrate / (i + 1); + afreq = clkrate / div; if (freq == afreq) sub = 0; @@ -636,7 +636,7 @@ static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream, if (sub < savesub) { baudrate = tmprate; savesub = sub; - pm = i; + pm = div - 1; } /* We are lucky */