Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2913054rwb; Mon, 15 Aug 2022 13:56:50 -0700 (PDT) X-Google-Smtp-Source: AA6agR5PEsYZ1Poy3mwLqJuSRHv/WS9OuL+yjk/Cc9bMvcEH7S4GKMNPvlgI6AVQjMG60wf2oaPU X-Received: by 2002:a63:d409:0:b0:429:8f3f:82fc with SMTP id a9-20020a63d409000000b004298f3f82fcmr2214489pgh.591.1660597010187; Mon, 15 Aug 2022 13:56:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660597010; cv=none; d=google.com; s=arc-20160816; b=DoGQMErYVNhYfpkt/Z4NNstEf1Swpuq9rbodFHQFDDzvyuyD2odtfp5bvYfl7RCQpQ hAPuGNCPRxGhRWlWmF51UP9xYpQseMctZoPJqB0WulOgISXSuJ/oX9jUcmGlkRJuks+O zlAdi+bEIrb/mTbmCy/ewzQh6yUVqJdms4hzw4Flc3zcHHbgGrdFsqSFYqeQgFFP8VjA Hy/CF2LZsM4W/toj1EKPGQvajl15QA8R1IIqEg/FhE9Yw1to2Vi3jKyCtiVy+RmY0ABi oLr86iza3ZDHT1mUck0Fyb8iS4H3k5vLjHwYIWnc2pyKIV27DUKkCNOzgYxB56kPFiiW 5ySQ== 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=CWwl6RKedpvzToJXwwb9LYKr4rkpkUYr+AO6u8qD9XQ=; b=wN4NK6rGors+9QALyvG8ity6NdW6riODIUa3rQh+pd0EjudSmiRCjm2CTrIfcJ4Jvw sVEQbmpCxxZeKcQh+MV3YGSetkfNz7HrfypGoreO2ALy1Mgb7UXECBvAzTDBu28XEN5O B8Zn2N249G8/KYcpUJEl8BsvpTa3oDx3GuAADWETsTduAM/mkj2WsnBxLb23oDMV4HUu yUcQqvDkr9ZzCIH8l2jjt8TL1/BcBNCVN040jsw4LS7zW4AcK5KjY0PqM7qQFW3tcySm MgrsH7Y1tZ/ffasyqN7MYQWTJc8h6pPNWPjIV700JFvgcqVpWGcDc50W0PhRMQtEktSI n9Zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DS53cLCA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lr1-20020a17090b4b8100b001f291c80d40si17307541pjb.12.2022.08.15.13.56.38; Mon, 15 Aug 2022 13:56:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DS53cLCA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1344024AbiHOTOh (ORCPT + 99 others); Mon, 15 Aug 2022 15:14:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344009AbiHOTLc (ORCPT ); Mon, 15 Aug 2022 15:11:32 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 735634F6B0; Mon, 15 Aug 2022 11:37:07 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 877EA61129; Mon, 15 Aug 2022 18:37:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 154D7C433C1; Mon, 15 Aug 2022 18:37:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660588625; bh=v64i6dmRBj8u32VbpRKaEevUZlvMU/3S5m501PN/vcQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DS53cLCAPXeWJ5nzHvT5ncptVOfBjOtIcDse9+Bwz7GCFBSIyDlDbqCxqBDDevKC/ yEXXlEHmVNtNdocMuwL/+AIn6XwBSoNx9L/zanKOEoPbDeK1PB+3M9hnTYKjTXMjWT g3ph5uxk8R7gzfQdqZn5wDsv1zi2QtS4C139ducY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nikita Travkin , Stephen Boyd , Bjorn Andersson , Sasha Levin Subject: [PATCH 5.15 456/779] clk: qcom: clk-rcg2: Fail Duty-Cycle configuration if MND divider is not enabled. Date: Mon, 15 Aug 2022 20:01:40 +0200 Message-Id: <20220815180356.768074660@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nikita Travkin [ Upstream commit bdafb609c3bb848d710ad9cd4debd2ee9d6a4049 ] In cases when MND is not enabled (e.g. when only Half Integer Divider is used), setting D registers makes no effect. Fail instead of making ineffective write. Fixes: 7f891faf596e ("clk: qcom: clk-rcg2: Add support for duty-cycle for RCG") Signed-off-by: Nikita Travkin Reviewed-by: Stephen Boyd Signed-off-by: Bjorn Andersson Link: https://lore.kernel.org/r/20220612145955.385787-2-nikita@trvn.ru Signed-off-by: Sasha Levin --- drivers/clk/qcom/clk-rcg2.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/clk/qcom/clk-rcg2.c b/drivers/clk/qcom/clk-rcg2.c index f675fd969c4d..ebdbc842b98a 100644 --- a/drivers/clk/qcom/clk-rcg2.c +++ b/drivers/clk/qcom/clk-rcg2.c @@ -405,7 +405,7 @@ static int clk_rcg2_get_duty_cycle(struct clk_hw *hw, struct clk_duty *duty) static int clk_rcg2_set_duty_cycle(struct clk_hw *hw, struct clk_duty *duty) { struct clk_rcg2 *rcg = to_clk_rcg2(hw); - u32 notn_m, n, m, d, not2d, mask, duty_per; + u32 notn_m, n, m, d, not2d, mask, duty_per, cfg; int ret; /* Duty-cycle cannot be modified for non-MND RCGs */ @@ -416,6 +416,11 @@ static int clk_rcg2_set_duty_cycle(struct clk_hw *hw, struct clk_duty *duty) regmap_read(rcg->clkr.regmap, RCG_N_OFFSET(rcg), ¬n_m); regmap_read(rcg->clkr.regmap, RCG_M_OFFSET(rcg), &m); + regmap_read(rcg->clkr.regmap, RCG_CFG_OFFSET(rcg), &cfg); + + /* Duty-cycle cannot be modified if MND divider is in bypass mode. */ + if (!(cfg & CFG_MODE_MASK)) + return -EINVAL; n = (~(notn_m) + m) & mask; -- 2.35.1