Received: by 10.192.165.148 with SMTP id m20csp4145170imm; Mon, 30 Apr 2018 12:36:14 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpB1ztO6NxaV7bJ2iyilkFLObJGwEzjPVKxWcCqRnQsnIQxgCTuTIm8JFjNmPYKKUzUiBJR X-Received: by 2002:a17:902:8d8c:: with SMTP id v12-v6mr13527574plo.366.1525116974038; Mon, 30 Apr 2018 12:36:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525116974; cv=none; d=google.com; s=arc-20160816; b=BnLhbsPVhuu0wSNn4de4GqwARoLs0gQRWNQ4TiqXc7QxM0edl3ylIwV48eNnbUjhac LISjLGn+v8h/qNlNt6bO/AqbVdSX1Fk2fonMKVOpAu7UnZWlBRytujASydUu6fdUGwgg bjlOSgjDuJ8fgLVXUsM5udIIledVdheqAAv8+KU6cdPUqVF5hLcHf2UVUBj0jQ+WtWVj t8t6y6YBQbtbq6r3mnrGDkxXTlxi/CLR0VkoYE+0rLiPhWt41F2x2qmrPaJtkHdfJc5g 3zoNyGFj6afHKzPmeOSBcX4KCN164NM77WR5IT/mtZMVr+gdC1hN+azXK0mT7/qLEsxA dHng== 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=ceYz1JbNhL6lM7xNcjqZIY/lmu4tL+ZxGCudMZDTAPw=; b=QHJKa+AT4Tej8PKy7cZryjDptY8dHXMfuMjg7NsdsGhiqEyYQXLqRuihE38gKYI7TC 6VLAPB6FAF88xI1wFIcDchA+DgmUjrFmbA0fL5BBTXm2Ytmaz65YbeLqxs3CTuOawzLv Eg7CIVSdiXLkeBkaj6vDgslM0e03w2FL4HrU8aZvRKToFx9kohEsXzQ0229JYQkpYdL8 A1FCFfpNUOQBSm9FWzuqmm/TAOEr9LuZSseDsH3w1rCi9LVwY9kHjAu5cqDcsM3vcy57 KS9u8EsN7v01GyZESjTrffkNzpCK5qmAtfnlYF2bB1wxVdm7NTBbXcZaFD1MWt8wMt3d P4NA== 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 f35-v6si7845826plh.193.2018.04.30.12.36.00; Mon, 30 Apr 2018 12:36:14 -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 S932353AbeD3T2s (ORCPT + 99 others); Mon, 30 Apr 2018 15:28:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:36640 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755343AbeD3T2j (ORCPT ); Mon, 30 Apr 2018 15:28:39 -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 49F2722E01; Mon, 30 Apr 2018 19:28:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 49F2722E01 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.16 085/113] ASoC: fsl_esai: Fix divisor calculation failure at lower ratio Date: Mon, 30 Apr 2018 12:24:56 -0700 Message-Id: <20180430184018.786859422@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430184015.043892819@linuxfoundation.org> References: <20180430184015.043892819@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.16-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 @@ -144,6 +144,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;