Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1524447ybl; Thu, 22 Aug 2019 16:24:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqz8IT1EAw12pcx5+QWpBF+XiVGHF5Gv9xn3Vv98kd4T6R31gXy+SrP5qc92JMBzhW0MjZET X-Received: by 2002:a63:eb56:: with SMTP id b22mr1424394pgk.355.1566516281858; Thu, 22 Aug 2019 16:24:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566516281; cv=none; d=google.com; s=arc-20160816; b=bnPVKlH2vSmXt8HOx0g8gER0E2D2ktkJ4UWvfU9cBIp8QAeaQmgruhyKxV7g+071ej OnLy1CH+sygTF8ZMJeszqXvbKTW3ytW0XnkETH3CcMVhpczQ2swVsTgk3Kv4oV+jMYDD X2X2ME629+KIuoh1IeFDbHWDIBj0FQGA4pzMX6CdOOqZcNREAvflIfDo5HxMbvDKooiT rv0PNAxlngesi9uXu9Ym2Xn0bcZcQLLa4MD5PelRTA1iPHndV+4XP+AivHAHR2JVUHh3 pfwzFa8K7ILkYuqyqFVMQWSftF+gG8QBEku42UQV3MJybblzu5v0/dikpzGUbXrn3yKS K/hA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=XBo8e55QcFN7pMRAQ8LqNxcgwqxPQ3K40ZSsZXfO7v0=; b=fX8sZUhq9/vUSXGv8KHLdFlFzjK1vcj8jnaqBmw04k0g+ZyE+SpORYkoZOvBOv0nUt ZoIheHnRbRwWyAdVddVW+7CODfUCTE9AV8SHNJ75gy3s1SceGsIcFwgdQ9amcROf4ABZ KfQ8GKZFHE+bqnQYc9tmNR9J0Pe0s/CvcuBWdT0t9kKjs154Rpqd/qmGDFl72ILzWySB tOmRmkEAt+3ANyAL57Thob2jkfaF/4tJJOrdcy/LSxZBret1Ak+dzgjYjyXfRRFLUgFt ADbkRQaQmFtSUlq9Xd9QcDq0HXQ1fjktQ54H8mA2wGagoQATd3t50J5stYxVFvn0V3nU jcUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ioNjq05I; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a95si812732pla.2.2019.08.22.16.24.26; Thu, 22 Aug 2019 16:24:41 -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; dkim=pass header.i=@kernel.org header.s=default header.b=ioNjq05I; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389144AbfHVRQX (ORCPT + 99 others); Thu, 22 Aug 2019 13:16:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:58290 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390393AbfHVRIg (ORCPT ); Thu, 22 Aug 2019 13:08:36 -0400 Received: from sasha-vm.mshome.net (wsip-184-188-36-2.sd.sd.cox.net [184.188.36.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 034D823404; Thu, 22 Aug 2019 17:08:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566493715; bh=4GU5q7MsdvdvSTWnNddo6ZLGYrzNXvh0owCnGABhq1o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ioNjq05IH7RKY0MjEbreBgHRYzdH4tGBDXphaaKnkVcJvKqqIbcbvMHMWI7xNBfjK S+ehqsKjan1XNG/x7e5veKowYE1WARQYDqvRiNPzYpB5lv1SfEo0askU3ODV54IuAk rMIMu66wtJiL7QV/Ekdg5xpJ9cr379CqObhmEWxM= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Codrin Ciubotariu , Nicolas Ferre , Ludovic Desroches , Stephen Boyd , Sasha Levin Subject: [PATCH 5.2 039/135] clk: at91: generated: Truncate divisor to GENERATED_MAX_DIV + 1 Date: Thu, 22 Aug 2019 13:06:35 -0400 Message-Id: <20190822170811.13303-40-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190822170811.13303-1-sashal@kernel.org> References: <20190822170811.13303-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.2.10-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.2.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.2.10-rc1 X-KernelTest-Deadline: 2019-08-24T17:07+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Codrin Ciubotariu [ Upstream commit 1573eebeaa8055777eb753f9b4d1cbe653380c38 ] In clk_generated_determine_rate(), if the divisor is greater than GENERATED_MAX_DIV + 1, then the wrong best_rate will be returned. If clk_generated_set_rate() will be called later with this wrong rate, it will return -EINVAL, so the generated clock won't change its value. Do no let the divisor be greater than GENERATED_MAX_DIV + 1. Fixes: 8c7aa6328947 ("clk: at91: clk-generated: remove useless divisor loop") Signed-off-by: Codrin Ciubotariu Acked-by: Nicolas Ferre Acked-by: Ludovic Desroches Signed-off-by: Stephen Boyd Signed-off-by: Sasha Levin --- drivers/clk/at91/clk-generated.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/clk/at91/clk-generated.c b/drivers/clk/at91/clk-generated.c index 44db83a6d01c2..44a46dcc0518b 100644 --- a/drivers/clk/at91/clk-generated.c +++ b/drivers/clk/at91/clk-generated.c @@ -141,6 +141,8 @@ static int clk_generated_determine_rate(struct clk_hw *hw, continue; div = DIV_ROUND_CLOSEST(parent_rate, req->rate); + if (div > GENERATED_MAX_DIV + 1) + div = GENERATED_MAX_DIV + 1; clk_generated_best_diff(req, parent, parent_rate, div, &best_diff, &best_rate); -- 2.20.1