From patchwork Thu Jul 21 10:31:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 12924965 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 75FAFC433EF for ; Thu, 21 Jul 2022 10:32:04 +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:References:In-Reply-To: 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: List-Owner; bh=SLFcDvyDj/C++kpiwKomAuYVq5TURh5hNAseLt5iaPc=; b=1imBS1OwSfde7V o9A/+au7lpJkHRir2TUEETIbibBF+fNr17KODEB7c4jt0PtGyHsru95Nyh4dHyfJoZ8drFuNjt8QV YpRorqaHhAf2IxID9ex/K6TDJcDElo/tEmcZhPdNLPsNecnZZ1qcw+Dc9Ux50s71p4Rg8WmmPmXH7 IEDW7fqp9JEBQVESnWkcaWRYJ/6TI26jZq5Qb/7O3sgcGJRWbTl9iIyURcHUTfJeQZ1Mp6nowaep3 JKNjYI5kFHOovGzRooRmHSiU3lRhVvWuDYax4V6hSffcyvCaK8ibXln+M+qOVpFXCiSkZ2HmkMPMn 8svaX1WxP4T+XRtZXLhA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oETTG-003rn4-Pc; Thu, 21 Jul 2022 10:31:54 +0000 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oETT9-003rco-Ke for linux-riscv@lists.infradead.org; Thu, 21 Jul 2022 10:31:50 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oETSz-0002Vx-QO; Thu, 21 Jul 2022 12:31:38 +0200 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1oETSy-002IMg-FZ; Thu, 21 Jul 2022 12:31:36 +0200 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1oETSx-006ZIJ-Dh; Thu, 21 Jul 2022 12:31:35 +0200 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Thierry Reding Cc: Wan Jiabing , kernel@pengutronix.de, linux-pwm@vger.kernel.org, linux-riscv@lists.infradead.org, Palmer Dabbelt , Paul Walmsley , Yash Shah , Atish Patra , "Wesley W. Terpstra" Subject: [PATCH 2/7] pwm: sifive: Fold pwm_sifive_enable() into its only caller Date: Thu, 21 Jul 2022 12:31:24 +0200 Message-Id: <20220721103129.304697-2-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220721103129.304697-1-u.kleine-koenig@pengutronix.de> References: <20220721103129.304697-1-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1745; h=from:subject; bh=sKOWXDCL91kq58t0FdekJeukQkU6Bwjo3++M3hvFQls=; b=owEBbQGS/pANAwAKAcH8FHityuwJAcsmYgBi2Srv+TgOLs1G9g7euiKgebUIZ8RhD3suhSpXS9Vw WaUQQwiJATMEAAEKAB0WIQR+cioWkBis/z50pAvB/BR4rcrsCQUCYtkq7wAKCRDB/BR4rcrsCaQaB/ 0UHu0XNU/HMCeI8tIqAxgqTzAnvVsOD0HiVNK5OiNnKzTx5up6NUB1+1vZj5Jog1MjDfMpaBUTekek UYsWcQ4T/l21c0qoq1sKJZHDMFf0H/d/mdj8/1u5Oafi5Ky79GyIuUpzfaEDEppmH9SmwEjf72b3/T K1Q9AAW3+bQF3hpHfrgXgwYpuI7x2GQc4tbxSm3/KCbhnGogkdzkUf8dYc33zYfqcU3LBXVZGMsJuz Qu5JbIkJo3W8zmeKkOVROAtuhAwtJBRIlQFe2EWzZqD39MG2wojWy9R/m4GsutzgIIsXz0Qv7B+0LG WU/grNk7VedR5GloHAORBj5FJaibM2 X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-riscv@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220721_033147_714324_4F69E93A X-CRM114-Status: GOOD ( 11.94 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org There is only a single caller of pwm_sifive_enable() which only enables or disables the clk. Put this implementation directly into pwm_sifive_apply() which allows further simplification in the next change. There is no change in behaviour. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-sifive.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/drivers/pwm/pwm-sifive.c b/drivers/pwm/pwm-sifive.c index b7fc33b08d82..91cf90bd4083 100644 --- a/drivers/pwm/pwm-sifive.c +++ b/drivers/pwm/pwm-sifive.c @@ -124,24 +124,6 @@ static void pwm_sifive_get_state(struct pwm_chip *chip, struct pwm_device *pwm, state->polarity = PWM_POLARITY_INVERSED; } -static int pwm_sifive_enable(struct pwm_chip *chip, bool enable) -{ - struct pwm_sifive_ddata *ddata = pwm_sifive_chip_to_ddata(chip); - int ret; - - if (enable) { - ret = clk_enable(ddata->clk); - if (ret) { - dev_err(ddata->chip.dev, "Enable clk failed\n"); - return ret; - } - } else { - clk_disable(ddata->clk); - } - - return 0; -} - static int pwm_sifive_apply(struct pwm_chip *chip, struct pwm_device *pwm, const struct pwm_state *state) { @@ -192,8 +174,14 @@ static int pwm_sifive_apply(struct pwm_chip *chip, struct pwm_device *pwm, writel(frac, ddata->regs + PWM_SIFIVE_PWMCMP(pwm->hwpwm)); - if (state->enabled != enabled) - pwm_sifive_enable(chip, state->enabled); + if (state->enabled != enabled) { + if (state->enabled) { + if (clk_enable(ddata->clk)) + dev_err(ddata->chip.dev, "Enable clk failed\n"); + } else { + clk_disable(ddata->clk); + } + } exit: clk_disable(ddata->clk);