Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3017929rwb; Mon, 15 Aug 2022 16:14:38 -0700 (PDT) X-Google-Smtp-Source: AA6agR62JmG6T2Of0ytUjmAqchlQLWVIe6M9+083IY4nO8jDp1C0UPUKmgVZ1OebPSgAiRLzHrH+ X-Received: by 2002:a17:907:c0d:b0:730:a85d:8300 with SMTP id ga13-20020a1709070c0d00b00730a85d8300mr11846589ejc.558.1660605278025; Mon, 15 Aug 2022 16:14:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660605278; cv=none; d=google.com; s=arc-20160816; b=PVbwRqhQR1w8qn9JRugx1IfsGRD067kdvG1QPG+zwm9aiYIYGJ8BshFWK4zJWSaL/J 7SguI+6khfLpBQAhZhNFt5kvvZxsbRlzzO/yDBU3sS/2EtgooZ3WkwUlXXAlw7I/MHzY rCko+oqA0Sfb+egA1W5nCsN+8tPIyt4iExUuEpMrBiv2kXk4pOktux0Sxjv0ylGmOlvY cOrdQ3xeOsPRVy41byrdsdbzTzLHfzo6/PvV3Xyf7IEKvUCywHfifcXjAQUgkmISLLRq 5Gu4wIL8OljLuqG19uQ6d9K1sJcQciAyiQce35EIH7nldxx65zVU3fr6S6rjvH47bGJ+ b+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=d35y6g3gEHhjjnOhAQ71lvr70JYlfzkhrp5/f6XDygE=; b=H2mjK+T0Uhwyu95I6MPHZzC0653vU1mcNwzadzpTbIESaYo1JtqPpO0PKPtg7fuLZh o3WTKdJPFyBTmFy3MyxvpeOtt1WRqnMELOCx415Fd5rNzknXDGWJIz3HpHug2ijRo29y Os8l3J2c7VgFBLKLHDpM0fg8/+WYXrK71ru6CDZS0wXaptLLBMdWX7bUsTzxhhUj+8tq xpHMfH7xB1WER+Je8IOZfVEWI71WShY+Wvr8m5yQCN02lejm18vzr/4UGbseOTXjoodb f0UOC1PfkQQoI/aAxViXRZoQ4RX/wfUbe6WcTZjwgJDAGNk0OOMBteQ2gi9Oe6B8CPSH 72UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=h+j2Ua2R; 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 v28-20020a50d09c000000b0043574c5a72fsi9356018edd.360.2022.08.15.16.14.12; Mon, 15 Aug 2022 16:14:38 -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=h+j2Ua2R; 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 S1348008AbiHOVyS (ORCPT + 99 others); Mon, 15 Aug 2022 17:54:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350514AbiHOVva (ORCPT ); Mon, 15 Aug 2022 17:51:30 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 573E3106F87; Mon, 15 Aug 2022 12:32:54 -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 E80CE6113B; Mon, 15 Aug 2022 19:32:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5176C433D6; Mon, 15 Aug 2022 19:32:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660591973; bh=DBRad9dbqdq+e/uv1W5NXDIrcSTwjsDMioE3f8hh+bc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h+j2Ua2RHDgqlmUokPdfH+5ZVsX0RQP80QrxwtxyiAuOTJNmWPqwqxkaHSJa1nWSm 7l+/HUVhZu51F+sL3z+0mVR3KJveMJaXnb3v8SgSQS/z6FUoeK5318boJDyfZF+SCE KOqd+04WfhzqfeGbSoqnWXJGVFFGsJlukv8lp3Ww= 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.18 0712/1095] clk: qcom: clk-rcg2: Fail Duty-Cycle configuration if MND divider is not enabled. Date: Mon, 15 Aug 2022 20:01:51 +0200 Message-Id: <20220815180458.859322603@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@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 e9c357309fd9..9611c9a7231f 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