From patchwork Thu Jul 21 10:31:29 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: 12924969 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 825C5CCA479 for ; Thu, 21 Jul 2022 10:32:08 +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=bV9hwGQ6zpAIpJ8e/rAoUHfMVQ7n9+l6BBsPLS0JbyY=; b=OQi4grF9s6u18o /bDb+ToE6uKT7IEkvejKNPHQpiui/E1ZwbWWUQWA0qcBm6GvFjDoSBwt8CNizyVdR7etFR3xB7KF6 0zOjB6A+Q4vq1adIXInrvzbdVJalzmfgOe8nMrFF1iRkp5YmzzzaptOa+/Hw7Cbmr7xy4vIblkMr+ TDSBjoc2UKrD0E88MnLKmdFB1mA645nkXClgXdvtTZ1P5VMvJTzhNO8Hc5FELtiKlUKRhAlSEGbz/ YhgU7nTktEPqYxOArZJu8SGQxGFOze6UwXtM4aOWhLUBarnjhSYOdkCYE46YfQK83s8zQUhoxTduv JCI9nOUbB7SrcMQPipzQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oETTJ-003roY-ML; Thu, 21 Jul 2022 10:31:57 +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-003rcj-MV for linux-riscv@lists.infradead.org; Thu, 21 Jul 2022 10:31:51 +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-0002W1-QS; Thu, 21 Jul 2022 12:31:37 +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-002IMt-Ti; 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 1oETSy-006ZIY-8Y; Thu, 21 Jul 2022 12:31:36 +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 7/7] pwm: sifive: Shut down hardware only after pwmchip_remove() completed Date: Thu, 21 Jul 2022 12:31:29 +0200 Message-Id: <20220721103129.304697-7-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=1079; h=from:subject; bh=zQLWxgV295stqWE/56SMfwXF5tRzx6Wmb0QC4HH8Cw8=; b=owEBbQGS/pANAwAKAcH8FHityuwJAcsmYgBi2Sr+XeA/kTOnz7lLWTP39p9qGkAtgJshtXu2A/vv Td2ybxGJATMEAAEKAB0WIQR+cioWkBis/z50pAvB/BR4rcrsCQUCYtkq/gAKCRDB/BR4rcrsCfIuB/ 4787jU2mMlX1tFBEAWmtDC1irHTvudx25tIFJeJWAZPkm9MasFS3qs8e2lDL3q4NXCOm49Z2IH4m6d rf9raH1+cAJxza7sO8LZnMp4YDaptnSFqKpJG6sqbPxwEKj0aZU1g2g+1Zg5AvrQGQgnwmptatgELU rAXNiH8Psm0aDLStJ5UHJtOBxlEIuQtw466jtcMF06/wMT3LfV36QKIYW8GXF+WwZOshuklCHu4xyS dMdvFn2RkGwyxwAM7fyLiOMDpMyxejx9cUHy3+KQN86EoJhAwHOtamHQAGqAGX8Xr8Bhq7RRSMZ8GA IHNDiElI3/fnq2H2oIyE6eJd9gMs7D 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_765238_1321C5AD X-CRM114-Status: GOOD ( 11.91 ) 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 The PWMs are expected to be functional until pwmchip_remove() is called. So disable the clks only afterwards. Fixes: 9e37a53eb051 ("pwm: sifive: Add a driver for SiFive SoC PWM") Signed-off-by: Uwe Kleine-König Tested-by: Emil Renner Berhing --- drivers/pwm/pwm-sifive.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/pwm/pwm-sifive.c b/drivers/pwm/pwm-sifive.c index da40ade0ebdf..2d4fa5e5fdd4 100644 --- a/drivers/pwm/pwm-sifive.c +++ b/drivers/pwm/pwm-sifive.c @@ -308,6 +308,9 @@ static int pwm_sifive_remove(struct platform_device *dev) struct pwm_device *pwm; int ch; + pwmchip_remove(&ddata->chip); + clk_notifier_unregister(ddata->clk, &ddata->notifier); + for (ch = 0; ch < ddata->chip.npwm; ch++) { pwm = &ddata->chip.pwms[ch]; if (pwm->state.enabled) @@ -315,8 +318,6 @@ static int pwm_sifive_remove(struct platform_device *dev) } clk_unprepare(ddata->clk); - pwmchip_remove(&ddata->chip); - clk_notifier_unregister(ddata->clk, &ddata->notifier); return 0; }