Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1699467pxb; Thu, 16 Sep 2021 13:19:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBe0Hvnx8TzaedtI8x1MYZWqhAfxFHWQ9ms8rcMmA83/XjkTvffk0plnGTIKEjDMvXnnAK X-Received: by 2002:a17:906:d1d6:: with SMTP id bs22mr8355041ejb.554.1631823549151; Thu, 16 Sep 2021 13:19:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631823549; cv=none; d=google.com; s=arc-20160816; b=fkWQ742M3NzqQO2jlp0qvH/yp0CsfIpPsn5a0D68WRfsWgB3sn6mPPCRQwxqltmjXA vCXQwL1QVY4MSl7qZKMLBibDKdVDLceW45rdB7AW/JhvHTr/BZZ7sncW3aqEj6Oas62n LoNMDUiDwn9kNJv1SpH/OgAxqUICJlrkuEPP/ia++EDX8YTADA9ah1Hm8uzgY9vMCqtW jlgpUFP5jDv/zo5qy50jxN+23SqVo/fE62C1CIRqg1MeRmELlMOEo1z0MEkGAdOuPOIL 1vzsZBb5h4HQUJNChISAtQ7k5vAGKn167vbtJ4Zk4XPSE8opOvLwfZzeIW2UjLrNeQcb J/Gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=tHI2s7XKy/CieQDwquSOAG9nkDymBAfa2nKPFg758No=; b=IWYapWeNfeaH8k5CkB0rTjz+A5VUWGnV6+PnE79eKwSO+1WavExVXqJY7aUTYG/eOo wEeVfeVRVWiZx6BbU8hLzBMt0IRus1CjQj9K7Shz9KooXJfjwqv78ElUNxPf7j6YkNE2 /OG63U6vmRgPa86yFo7ZOhFLsIhaxyiX+5d5OPMa9k3g/ehKgKz9HR307IoCfBp6lJGW 5Z/cRTYQ1B3hgIbr5zrqE5m4YjR9mV9R8ujAR8QVacBlI8vgs7EKlDvtNqUkv1TvGfGC XdhBsh23UTMOz+kZLZJSy/ZLB1Iqg8HFWxUpBvFJW08XOxIiqew+SLTozzk85fBwcbNc 8fEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="i1Z9M3/E"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v5si4705510edl.424.2021.09.16.13.18.28; Thu, 16 Sep 2021 13:19:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="i1Z9M3/E"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241326AbhIPQP2 (ORCPT + 99 others); Thu, 16 Sep 2021 12:15:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:48410 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236019AbhIPQJN (ORCPT ); Thu, 16 Sep 2021 12:09:13 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 755416128B; Thu, 16 Sep 2021 16:07:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631808464; bh=oWRUCAFDJYgHIjgHuS3unULmVDpG7sU3d4EIncw7RW8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i1Z9M3/ESm9VL3M97HGSrcTgxqEjHjYaWn85AjEur444nBhllhpTv/3QQhQRAXC7z gNzmI1r/arQKo3rI5Xr5BM3aZa1LGKycVSiFjMDdj3NtADucjDbfxB+TeGgeKZdBtN Au7H0CkCT4rVaqUWYEFvq1wIaA02KeA5l1gDqPGA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Codrin Ciubotariu , Nicolas Ferre , Stephen Boyd , Sasha Levin Subject: [PATCH 5.10 099/306] clk: at91: clk-generated: Limit the requested rate to our range Date: Thu, 16 Sep 2021 17:57:24 +0200 Message-Id: <20210916155757.448562794@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155753.903069397@linuxfoundation.org> References: <20210916155753.903069397@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Codrin Ciubotariu [ Upstream commit af7651e67b9d5f7e63ea23b118e3672ac662244a ] On clk_generated_determine_rate(), the requested rate could be outside of clk's range. Limit the rate to the clock's range to not return an error. Fixes: df70aeef6083 ("clk: at91: add generated clock driver") Signed-off-by: Codrin Ciubotariu Link: https://lore.kernel.org/r/20210707131213.3283509-1-codrin.ciubotariu@microchip.com Acked-by: Nicolas Ferre Signed-off-by: Stephen Boyd Signed-off-by: Sasha Levin --- drivers/clk/at91/clk-generated.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/clk/at91/clk-generated.c b/drivers/clk/at91/clk-generated.c index b4fc8d71daf2..b656d25a9767 100644 --- a/drivers/clk/at91/clk-generated.c +++ b/drivers/clk/at91/clk-generated.c @@ -128,6 +128,12 @@ static int clk_generated_determine_rate(struct clk_hw *hw, int i; u32 div; + /* do not look for a rate that is outside of our range */ + if (gck->range.max && req->rate > gck->range.max) + req->rate = gck->range.max; + if (gck->range.min && req->rate < gck->range.min) + req->rate = gck->range.min; + for (i = 0; i < clk_hw_get_num_parents(hw); i++) { if (gck->chg_pid == i) continue; -- 2.30.2