From patchwork Sat Sep 2 06:32:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hari Prasath Gujulan Elango X-Patchwork-Id: 13373034 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 71E63CA0FF8 for ; Sat, 2 Sep 2023 06:33:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=XP+D1Vafyu59Tfj3vzwyI/oYQjrntJII+wL+PobXbAE=; b=y90TZt2g0J7vo3 P8r49NjFUxeFyde6x4Wu6YtK8oncfzzvJVOF4FnNIeYuYMWJH3cvK/wJzs+527idGwuK95sRos+AD gzQT+Ge/ClWP/GP/4hZ3Puhzb0ojsm9XHNZmkC/j3dGSJrXQdXFYTY2l9QKrH+30PEAj5HjmLZiPy fGAFKMSrMsbmZ+a59yk01gwHENSnSgRd52jgdwVaTa85C4g71ys30kDf9aeJd9AvobELVfiQ4LDXv iVoGC7he/4rQ4ccHsH7THoaJDbObeTiWQ3p9woTZ9cfsP+5NEXu+vs3M788LJfuU8YB3cVIpT6GQI yUWCa2UHEaiF3z7FdVzw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qcKBe-0017jP-1h; Sat, 02 Sep 2023 06:32:50 +0000 Received: from esa.microchip.iphmx.com ([68.232.153.233]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qcKBb-0017iz-02 for linux-arm-kernel@lists.infradead.org; Sat, 02 Sep 2023 06:32:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1693636367; x=1725172367; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=3bgN04HCBhGYUCnjps2teOWZvkuLkjNIxGd9f26pwBY=; b=qO+VcWTU6ZOpwQkwV3Qe97Iy0D5melBm+6Ph/WNt7h3sQywRdMBHJodr Jf66PShSqDmOhdJCdhOeLJ+MJudzlbs/2q8q5H8k45ImpMbZuLtNg/fAn fOpDb6tSqXA42xc7zzyXUMngoBO7ulkkyws9OPwk4d7c7x9yQDcy7LpGw lmwaiKjzD0c2tvHLYxwZbmMEwXu964zEN6SrUvSDFQFc9305OKWBzZxh7 xZE9qQ76cwVYBBjglvWaHn07zn6l6A0twSv0vqckDd7o+iQiaohGw47fD P/UTRHLVbo9/drHjCvRQzMtN03ednJn5EBtXchCXY6nhH/2WxEubAXn48 w==; X-IronPort-AV: E=Sophos;i="6.02,221,1688454000"; d="scan'208";a="2544931" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 01 Sep 2023 23:32:44 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Fri, 1 Sep 2023 23:32:39 -0700 Received: from che-lt-i63539.amer.actel.com (10.10.85.11) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.21 via Frontend Transport; Fri, 1 Sep 2023 23:32:35 -0700 From: Hari Prasath Gujulan Elango To: , , , , CC: , , , Hari Prasath Gujulan Elango Subject: [PATCH v2] pwm: atmel: add missing clk_disable_unprepare() Date: Sat, 2 Sep 2023 12:02:32 +0530 Message-ID: <20230902063232.22620-1-Hari.PrasathGE@microchip.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230901_233247_219280_5A0B049A X-CRM114-Status: GOOD ( 12.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Fix the below smatch warning: drivers/pwm/pwm-atmel-hlcdc.c:167 atmel_hlcdc_pwm_apply() warn: 'new_clk' from clk_prepare_enable() not released on lines: 112,137,142,149. 'Fixes: 2b4984bef47a5 ("pwm: atmel-hlcdc: Convert to the atomic PWM API")' Signed-off-by: Hari Prasath Gujulan Elango changelog of v2: - moved the clk_disable_unprepare to single point of return. - cur_clk set to NULL before return. --- drivers/pwm/pwm-atmel-hlcdc.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/pwm/pwm-atmel-hlcdc.c b/drivers/pwm/pwm-atmel-hlcdc.c index 96a709a9d49a..4d35b838203f 100644 --- a/drivers/pwm/pwm-atmel-hlcdc.c +++ b/drivers/pwm/pwm-atmel-hlcdc.c @@ -44,7 +44,7 @@ static int atmel_hlcdc_pwm_apply(struct pwm_chip *c, struct pwm_device *pwm, struct atmel_hlcdc_pwm *chip = to_atmel_hlcdc_pwm(c); struct atmel_hlcdc *hlcdc = chip->hlcdc; unsigned int status; - int ret; + int ret = 0; if (state->enabled) { struct clk *new_clk = hlcdc->slow_clk; @@ -109,7 +109,7 @@ static int atmel_hlcdc_pwm_apply(struct pwm_chip *c, struct pwm_device *pwm, ATMEL_HLCDC_CLKPWMSEL, gencfg); if (ret) - return ret; + goto disable_new_clk; } do_div(pwmcval, state->period); @@ -134,18 +134,20 @@ static int atmel_hlcdc_pwm_apply(struct pwm_chip *c, struct pwm_device *pwm, ATMEL_HLCDC_PWMPOL, pwmcfg); if (ret) - return ret; + goto disable_new_clk; ret = regmap_write(hlcdc->regmap, ATMEL_HLCDC_EN, ATMEL_HLCDC_PWM); if (ret) - return ret; + goto disable_new_clk; ret = regmap_read_poll_timeout(hlcdc->regmap, ATMEL_HLCDC_SR, status, status & ATMEL_HLCDC_PWM, 10, 0); - if (ret) +disable_new_clk: + clk_disable_unprepare(new_clk); + chip->cur_clk = NULL; return ret; } else { ret = regmap_write(hlcdc->regmap, ATMEL_HLCDC_DIS,