From patchwork Sun Apr 8 23:57:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 10328645 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 285EE60170 for ; Sun, 8 Apr 2018 23:58:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1921228A0A for ; Sun, 8 Apr 2018 23:58:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0D20128A0D; Sun, 8 Apr 2018 23:58:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0E62B28A0C for ; Sun, 8 Apr 2018 23:58:42 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id A52092673D4; Mon, 9 Apr 2018 01:58:40 +0200 (CEST) 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 E24172673D6; Mon, 9 Apr 2018 01:58:38 +0200 (CEST) Received: from mail-pf0-f194.google.com (mail-pf0-f194.google.com [209.85.192.194]) by alsa0.perex.cz (Postfix) with ESMTP id EA20D2673C7 for ; Mon, 9 Apr 2018 01:58:35 +0200 (CEST) Received: by mail-pf0-f194.google.com with SMTP id l27so4699602pfk.12 for ; Sun, 08 Apr 2018 16:58:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=a3J6iOQ7nhAxmfKIVEfWU//TEg5DjQ0ue1yjaejbuFo=; b=fbVlZEAld18MVeJxPsN3NETD01pVWyzeaZZ4A2b7mEo0XYj51UJdhsd2w2mPDJUBwm bAecIcdC37xzy4TbEDNuB9N3xSMRkKgyERLh74+5NoyYPOKAt8FkQghxkIC/OswLAXxM 9U6aS3cSYtJ8BLOteVXX5xfhhHyHOaK8RKb+FysEbtwPh/6alnWqezELM1kfzgOyn7kw m04JnyT4745RFarZKQb5BgqePXHfoheenQrMG2YdM1/DbYCO8bbkr+Uqk8lfXw1cV0Xz XWZhEC8qo3oRQ5y/MCti6Hcn9f/whk19D4MsPstU7T10352F+4AgZcj/lOeNAmfLFSiP MySg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=a3J6iOQ7nhAxmfKIVEfWU//TEg5DjQ0ue1yjaejbuFo=; b=VIoGEP/t/de3gQxJ+hVmFPovcCt15oVPUe7WV7bM28eoKlWN81ScvqCFIR0kbiUfim 94nxjlOhlhRvai24ZWfTuF/zGkKtZeWT6lY28o5o3BpEDkDvlM55cPVuLpBI4oQ0gZJd 2mqJ8NCMwrCBU7+2CO8I3BaSi1iH73eGrx21MxDYA5ugwu++HC2aCsy774CU5IEsGgau kmqOfPSMfdCIbPRWXeo1R78ZtuA2o8ypXDcjmaeyIG8ROs03Cr4dolUHivS+BBSFtTGH /6s5Zmt7KAhO2RSG7hq40l6a/nHHvHV5fGADK9LCJOTxLj42XMfuWrnDAHjAUdoazZro nH/A== X-Gm-Message-State: AElRT7E8M7hh1lOTJ6EmWvqXOduoh4+hQbO59NbX7ss4EmRbgiAxEwWv evDHKu96m0WHr9DSsxQTWvk= X-Google-Smtp-Source: AIpwx4+kLknQV5BTMdV1D/FOFBmIEp9UxkA1ugZpHm9itL0MI++Uxu7lnER9y2235+YiRa2WlCGETg== X-Received: by 10.101.96.65 with SMTP id b1mr23844799pgv.340.1523231913704; Sun, 08 Apr 2018 16:58:33 -0700 (PDT) Received: from Asurada-CZ80.localdomain (c-73-231-2-134.hsd1.ca.comcast.net. [73.231.2.134]) by smtp.gmail.com with ESMTPSA id o88sm30731064pfk.91.2018.04.08.16.58.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 08 Apr 2018 16:58:33 -0700 (PDT) From: Nicolin Chen To: broonie@kernel.org, marex@denx.de Date: Sun, 8 Apr 2018 16:57:35 -0700 Message-Id: <1523231855-7854-1-git-send-email-nicoleotsuka@gmail.com> X-Mailer: git-send-email 2.7.4 Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, tiwai@suse.com, lgirdwood@gmail.com, fabio.estevam@nxp.com, linuxppc-dev@lists.ozlabs.org Subject: [alsa-devel] [PATCH] ASoC: fsl_esai: Fix divisor calculation failure at lower ratio 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 When the desired ratio is less than 256, the savesub (tolerance) in the calculation would become 0. This will then fail the loop- search immediately without reporting any errors. But if the ratio is smaller enough, there is no need to calculate the tolerance because PM divisor alone is enough to get the ratio. So a simple fix could be just to set PM directly instead of going into the loop-search. Reported-by: Marek Vasut Signed-off-by: Nicolin Chen Cc: Marek Vasut Tested-by: Marek Vasut Reviewed-by: Fabio Estevam --- sound/soc/fsl/fsl_esai.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sound/soc/fsl/fsl_esai.c b/sound/soc/fsl/fsl_esai.c index 40a7004..da8fd98 100644 --- a/sound/soc/fsl/fsl_esai.c +++ b/sound/soc/fsl/fsl_esai.c @@ -144,6 +144,13 @@ static int fsl_esai_divisor_cal(struct snd_soc_dai *dai, bool tx, u32 ratio, psr = ratio <= 256 * maxfp ? ESAI_xCCR_xPSR_BYPASS : ESAI_xCCR_xPSR_DIV8; + /* Do not loop-search if PM (1 ~ 256) alone can serve the ratio */ + if (ratio <= 256) { + pm = ratio; + fp = 1; + goto out; + } + /* Set the max fluctuation -- 0.1% of the max devisor */ savesub = (psr ? 1 : 8) * 256 * maxfp / 1000;