Received: by 2002:a05:6520:4d:b0:139:a872:a4c9 with SMTP id i13csp2566339lkm; Mon, 20 Sep 2021 18:53:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxznQwnwNVIepOyQwExSeYX4Ro4BPEo3tlr7/JnWVPUk31jGRzRextuvTCoZsjDdcyklfer X-Received: by 2002:a5d:9c89:: with SMTP id p9mr21015689iop.13.1632189192050; Mon, 20 Sep 2021 18:53:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632189192; cv=none; d=google.com; s=arc-20160816; b=j6RkatdH3uZkbJqxKEyy7atBt1XM7ebj4PDSHazVMpA7DfgDWEbDCKw8Cxfmz7BeG/ iZuq+ciuHkDkeRKHuQRkWMrfQi7Lxnvb3buSZIn05OUgmA5So3DgZkV1dosWEbO302bt YOnSBo3lv52AZ4uufl6NXCVXZBhrTYtGZg57XKELt8sspLtuiDezx/4B2C19+wUeC6wf cNhEP8gxKZ8Frkn+j7J64arXwi+iQ2oJZsr8CmJR3+yDhrDvLC3ULQvb3u0SXDZrCynO icW2MEy9OmwvHO6ePudiTETs/pLrE0cpkdxm6kCXKwvx4wrxXXc5XnAyQ2wOnFCZw60O yr1A== 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=mcoh5l2TBCpJNcDKW3CuWbxf/YZAmEXbAxj8j+WbvdQ=; b=uFBwRMR+2zkQOP29SONKzre7nWsmHDlex33vkulMggT2o3fhfJmTDCuDinZAUdE4sJ /Rgoku0Nou8GLoKNuGd8m7fDkFod+LbztSVviOOMfa7D+EBs3r0VAXaDg1TGanE1NiRK kVBiEwEOkv9qol4vkZ/WHHpp7xEXh9yktFmi+eoNdgCfEz5NQNUn4KI88KcL7O0SOH4G 7TMiqn8vvKCs4lyzCIeuZAq7LCOcK1LaHqnT8Jsa1Hte7lv61BF8lDrEMJXZGf5ixTv0 UaWXp+vpA3uZFCvkCW1zFHtih1ON7ER8To2mzEzs0HhT9GXzmNLAmddK8VHIqzl/8MjV tnwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LoHvQof3; 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 j26si12193141ila.62.2021.09.20.18.53.00; Mon, 20 Sep 2021 18:53:12 -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=LoHvQof3; 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 S1359855AbhITSKx (ORCPT + 99 others); Mon, 20 Sep 2021 14:10:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:33262 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357698AbhITSEp (ORCPT ); Mon, 20 Sep 2021 14:04:45 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7588263242; Mon, 20 Sep 2021 17:17:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632158236; bh=H6EkSblXFQSVOVxQUfoJvoAgWaZVRuI4sRREVmvO8JI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LoHvQof3KwDfRgkaU6SCbCTA32Wjai6Z7VW6ux79e9jHoDFfYPdm5wSJui4WH3BXl +XJzBLalOGtFMycSUCPMUtEQh7gMIjAfKSidwwRhA6CtVLFEHC5zmmHKsRuqslTefc nuvhLkEO50vBCfexVLo4+HoEg7UWnlUUseGVLX10= 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.4 064/260] clk: at91: clk-generated: Limit the requested rate to our range Date: Mon, 20 Sep 2021 18:41:22 +0200 Message-Id: <20210920163933.308817275@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163931.123590023@linuxfoundation.org> References: <20210920163931.123590023@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 273d0447d727..d7fe1303f79d 100644 --- a/drivers/clk/at91/clk-generated.c +++ b/drivers/clk/at91/clk-generated.c @@ -127,6 +127,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