Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751796AbdFII60 (ORCPT ); Fri, 9 Jun 2017 04:58:26 -0400 Received: from regular1.263xmail.com ([211.150.99.140]:33564 "EHLO regular1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751577AbdFII5C (ORCPT ); Fri, 9 Jun 2017 04:57:02 -0400 X-263anti-spam: KSV:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ABS-CHECKED: 4 X-RL-SENDER: sugar.zhang@rock-chips.com X-FST-TO: heiko@sntech.de X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: sugar.zhang@rock-chips.com X-UNIQUE-TAG: <9ac5126e5129fdf37cbeeeab712c3463> X-ATTACHMENT-NUM: 0 X-DNS-TYPE: 0 From: Sugar Zhang To: heiko@sntech.de, broonie@kernel.org Cc: linux-rockchip@lists.infradead.org, Sugar Zhang , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 4/4] ASoC: rockchip: i2s: fixup clk div Date: Fri, 9 Jun 2017 16:52:49 +0800 Message-Id: <1496998369-30556-5-git-send-email-sugar.zhang@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1496998369-30556-1-git-send-email-sugar.zhang@rock-chips.com> References: <1496998369-30556-1-git-send-email-sugar.zhang@rock-chips.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1090 Lines: 32 we found mclk maybe not precise as required because of PLL, but it still can be used and no side effect. for example, if we require mclk 11289600, but get 11289598, it doesn't matter. so using DIV_ROUND_CLOSEST to fix it. Signed-off-by: Sugar Zhang --- sound/soc/rockchip/rockchip_i2s.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s.c index 2a15a00..b56e00d 100644 --- a/sound/soc/rockchip/rockchip_i2s.c +++ b/sound/soc/rockchip/rockchip_i2s.c @@ -282,10 +282,10 @@ static int rockchip_i2s_hw_params(struct snd_pcm_substream *substream, if (i2s->is_master_mode) { mclk_rate = clk_get_rate(i2s->mclk); bclk_rate = i2s->bclk_fs * params_rate(params); - if (bclk_rate && mclk_rate % bclk_rate) + if (!bclk_rate) return -EINVAL; - div_bclk = mclk_rate / bclk_rate; + div_bclk = DIV_ROUND_CLOSEST(mclk_rate, bclk_rate); div_lrck = bclk_rate / params_rate(params); regmap_update_bits(i2s->regmap, I2S_CKR, I2S_CKR_MDIV_MASK, -- 1.9.1