From patchwork Wed Feb 14 09:32:42 2024 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: 13556212 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 5719FC48BC4 for ; Wed, 14 Feb 2024 09:41:56 +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=WgauqpzuUdYQaesTO71Z9HOJyPVTuWvkldYhhaZLEzg=; b=bayA7NRZl8f0iR jBjJOnXLw7Qb8LMqO1vUzL79gm31fo8mKcggq6GPLVPbbYcoXwmtEstnrMOZ24b6Y46BW1SaSVc2B 3qOKgeyDZ2hUYN8MI9E6DqnlvPTiIdsbfJkZWJ+x+g4AG+jPi5HYyBTsQamUV482Zakg3EwMGesMt aQNEO0gmaJbw9YHfH8B6KIvTQ+/UyNf+NcqDrcYsruE76+MuS9GtL3un6rOtdqvVd9cQE/s1Kv7hE O7VnLMPHmFo8iC5aMftorA2y2DjEzSd5ua2pz2zxtNday9nQ1zfrZSFa+huPCHUi0IUeg3QxzQ5bp VhImLS9Lz53869ReilpQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBlr-0000000CPTw-2M7G; Wed, 14 Feb 2024 09:41:39 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfd-0000000CKyF-0OBD for linux-arm-kernel@bombadil.infradead.org; Wed, 14 Feb 2024 09:35:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description; bh=pE41sGOmkufr+x+YNrOMJsY2syO5U8IpxRdCrMVyTtA=; b=euwj2DU6TG2q9gG8aygnhMhFpX CAOneNEH6LHlcQdP7J056Rgur7+5sa1+4h1aRPpLcYBQknNS1AUV0Ber8a1nExc9wqXBmY3vVYTw8 nqnQLpWY5JCerqSt0TYWb4nX7+keUIETZhW9MvsjUqJTbwB76SwoYna6YIdK9zy5PE/lRyL+sj5zA KNcCNpRfvDPDp+BCm6zeVgjNoGE1RHCeNEG7g9LsDgVf0kqen3faEh/IrNPNPow2ga9KH5flO2dv0 sGjI2wiOeKE14NDHK1DcPmizvnOnwQ0gPVGURCliexEIsccamGkOlQx6a/UQAk7Lae0UpRHzTfHsd 2Tb0TyRQ==; Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfT-0000000GDlB-03vW for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:35:12 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1raBf4-0005kE-MU; Wed, 14 Feb 2024 10:34:38 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raBf1-000fFr-Hl; Wed, 14 Feb 2024 10:34:35 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBf1-004Y7Z-1W; Wed, 14 Feb 2024 10:34:35 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Fabrice Gasnier , Maxime Coquelin , Alexandre Torgue , linux-pwm@vger.kernel.org Cc: linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 115/164] pwm: stm32: Prepare removing pwm_chip from driver data Date: Wed, 14 Feb 2024 10:32:42 +0100 Message-ID: <3db96cd915d9d8fc350a7193c0d55dd109b1f035.1707900770.git.u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2861; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=eAn5zF3jZjX3+BIQYFdyKESVmjjGkTa7aWulVHapXqA=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIjPJCfNH6vyPPPC9avsKPPfP5Ivo6fJsl5ri EkWkZwDeV6JATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyIzwAKCRCPgPtYfRL+ Ti8FB/49TDgXTFVxzSGv2wqrXOht+HhTFwO/+fq5SwdAa1NB0Vd+V2oRnUPUNqnvITBnGNZYUTc 50nI/TKddrey92Dw2XIPUXF+vDUSFz5Uo9sA9P/9caEPlNu9V6mSEPqeO1g+XytuZd7GJwFxsRi 7Ju6Jl3g++puBlegdyWdLeoByphzx33an6HLAn4kTPAxlU8R8r/wxXkHzdHwWiZvCmB1/8LdIig 3PyedNiS58IZ0D4d05fpEnk8dreVHah7ZIChpazCSfvdbVO6E/19LUUM4eiLl+49QEd6fWpn+gj JHgpaBITWpsN1J6c6HRLgpSW1G1KgbWoXoU0f9sa0GmYvSoj 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_093504_486530_AB4704F2 X-CRM114-Status: GOOD ( 13.85 ) 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 This prepares the driver for further changes that will drop struct pwm_chip chip from struct stm32_pwm. Use the pwm_chip as driver data instead of the stm32_pwm to get access to the pwm_chip in stm32_pwm_suspend() without using priv->chip. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-stm32.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/pwm/pwm-stm32.c b/drivers/pwm/pwm-stm32.c index ec15bc51d930..4d12f3d849cd 100644 --- a/drivers/pwm/pwm-stm32.c +++ b/drivers/pwm/pwm-stm32.c @@ -630,6 +630,7 @@ static int stm32_pwm_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct device_node *np = dev->of_node; struct stm32_timers *ddata = dev_get_drvdata(pdev->dev.parent); + struct pwm_chip *chip; struct stm32_pwm *priv; unsigned int num_enabled; unsigned int i; @@ -638,6 +639,7 @@ static int stm32_pwm_probe(struct platform_device *pdev) priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; + chip = &priv->chip; mutex_init(&priv->lock); priv->regmap = ddata->regmap; @@ -653,37 +655,38 @@ static int stm32_pwm_probe(struct platform_device *pdev) stm32_pwm_detect_complementary(priv); - priv->chip.dev = dev; - priv->chip.ops = &stm32pwm_ops; - priv->chip.npwm = stm32_pwm_detect_channels(priv, &num_enabled); + chip->dev = dev; + chip->ops = &stm32pwm_ops; + chip->npwm = stm32_pwm_detect_channels(priv, &num_enabled); /* Initialize clock refcount to number of enabled PWM channels. */ for (i = 0; i < num_enabled; i++) clk_enable(priv->clk); - ret = devm_pwmchip_add(dev, &priv->chip); + ret = devm_pwmchip_add(dev, chip); if (ret < 0) return ret; - platform_set_drvdata(pdev, priv); + platform_set_drvdata(pdev, chip); return 0; } static int stm32_pwm_suspend(struct device *dev) { - struct stm32_pwm *priv = dev_get_drvdata(dev); + struct pwm_chip *chip = dev_get_drvdata(dev); + struct stm32_pwm *priv = to_stm32_pwm_dev(chip); unsigned int i; u32 ccer, mask; /* Look for active channels */ ccer = active_channels(priv); - for (i = 0; i < priv->chip.npwm; i++) { + for (i = 0; i < chip->npwm; i++) { mask = TIM_CCER_CC1E << (i * 4); if (ccer & mask) { dev_err(dev, "PWM %u still in use by consumer %s\n", - i, priv->chip.pwms[i].label); + i, chip->pwms[i].label); return -EBUSY; } } @@ -693,7 +696,8 @@ static int stm32_pwm_suspend(struct device *dev) static int stm32_pwm_resume(struct device *dev) { - struct stm32_pwm *priv = dev_get_drvdata(dev); + struct pwm_chip *chip = dev_get_drvdata(dev); + struct stm32_pwm *priv = to_stm32_pwm_dev(chip); int ret; ret = pinctrl_pm_select_default_state(dev);