Received: by 10.192.165.148 with SMTP id m20csp4180751imm; Mon, 30 Apr 2018 13:19:34 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqnPo8SxNoU8/KFI3qODmXT4whaMXZdgNOno5wyQZHEa1GA3Vlvy3dUSlg8jx992hmlMvU/ X-Received: by 2002:a17:902:8692:: with SMTP id g18-v6mr13680283plo.152.1525119574834; Mon, 30 Apr 2018 13:19:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525119574; cv=none; d=google.com; s=arc-20160816; b=G29GGRb00OABOICDJi81HWR5kolDfXYDF87Bh1lvOTGDfJxO+lMZ9rwb8eb/qmpiZY Nx9DOBsq1yIkiGfkxWbH25/IK+2tzyHPzvmjqul0iWwfdfljp/hw/yRCFFQMaIZ6RjwU 61JRvSsfIBXh6a+iV9Zb2QnWMw+Svmk3Y8abgNceN81ATfKhzamwv3Hn4RN2D0RDo5gL GHrOUgbeDRcY9RggKyxsaHvoe4XGEfx3NMvQkdtP+uTPMd8iXFIIC1cD9jn4RWFHCj4n E1tr/GpDJF5bzDi4fQerY+OD8EuqWtkbkqWMZm6evziTrKt579zlfvHitL3JYD0ZUguM D0wA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dmarc-filter :arc-authentication-results; bh=9DHO31b4pT+Zi/d3f2x91r0bX7ORRtDboByZmyXAF1M=; b=w+MoXL7vk9jLbqEbUnXlLgUdTkfSvYQUMK0PovFTtU99dF6hnyl2u7xvCtxweuvfgW RNmQc53tz/BLn/vF/GjopbfLsOJtqwzJaS9YU9tZdu5zgo7IIo+zZD3zLi4sEV95l8vh sgBSRI4dcXhxIyWuGHkZZoo/nWOEvYUWjrHq0yf1y+m6pxgB4xfUSi56s9aphkaWwGvr e7YqqJeR+vS1oSQ1VqXwaAF1JCnSYA1tu2I1jKeRvGtOtnku44j2vWERZl5WCf3cGFk1 ViaOh+ScYby6gfLb6fLeLwyXttMvcez8VRVU/hddRdxhHTsnnYNuaMoknzA2Lw6QbU0r rQyg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f16si8175117pfe.291.2018.04.30.13.19.20; Mon, 30 Apr 2018 13:19:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755903AbeD3UTJ (ORCPT + 99 others); Mon, 30 Apr 2018 16:19:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:32822 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755805AbeD3T0x (ORCPT ); Mon, 30 Apr 2018 15:26:53 -0400 Received: from localhost (unknown [104.132.1.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2BDC022DBF; Mon, 30 Apr 2018 19:26:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2BDC022DBF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=fail smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marek Vasut , Nicolin Chen , Fabio Estevam , Mark Brown Subject: [PATCH 4.9 48/61] ASoC: fsl_esai: Fix divisor calculation failure at lower ratio Date: Mon, 30 Apr 2018 12:24:51 -0700 Message-Id: <20180430183955.410289974@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430183951.312721450@linuxfoundation.org> References: <20180430183951.312721450@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Nicolin Chen commit c656941df9bc80f7ec65b92ca73c42f8b0b62628 upstream. 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 Tested-by: Marek Vasut Reviewed-by: Fabio Estevam Signed-off-by: Mark Brown Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- sound/soc/fsl/fsl_esai.c | 7 +++++++ 1 file changed, 7 insertions(+) --- a/sound/soc/fsl/fsl_esai.c +++ b/sound/soc/fsl/fsl_esai.c @@ -145,6 +145,13 @@ static int fsl_esai_divisor_cal(struct s 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;