From patchwork Wed Feb 14 09:32:41 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: 13556169 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 2440FC48BEC for ; Wed, 14 Feb 2024 09:39: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: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=OpEAbqIpXtR/9foHwEhpulXj1h1VS82t8JHXQvnznhI=; b=qEfHAVwMf8pIfB rOX4AAoK5bEoa38nmm3Cs8sa263BAGDZOORZ5KAywzaiAbTw7emiwzRD+ZAFaCBxyqm/FGevEAlN2 vfcmJN6UqOdbTG9OM7+aYkC7rhuL7IyStX/tF2xMhq3oNleLkKpQ+sX1t6pxgMT06pqu7QiCQFyEc uSrPyiWCNaqqCNKDxvr1DoFaFdl/skijPsG6Lhn1n2V10QbBFq+vnbrJr1Uql5rUXkdojMfX91k2y 7wJ+5KgtX5yP9sHU0Ii3lM78yOBdOAkpgOCCpL/hWTxl0hCvi1o3VUITL76xNaCxwhO0UZW102wNI G7tEfKVold6kUCgs9YJg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBjQ-0000000CNTy-3znR; Wed, 14 Feb 2024 09:39:08 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfM-0000000CKhZ-2s5b for linux-arm-kernel@bombadil.infradead.org; Wed, 14 Feb 2024 09:34:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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=PqZePcoM/DDHqOJc9Du3h/04VGrW5erzkVV2Rmz14E4=; b=IZ+boRpW4GGLIGpvr2L9rcfa9k isPhVrLSWTGuSJtIvi1+nVE10ASxB7JmvffBfjzzh5hxJy3udIQce8LR9ouHRsV8v5GAPprclUtuv mi9MTOhuPvAp6vUAz/RnUmaukd3PUiThxPiJV3mCgJuX+MjJk3K16y872HtFfd6zdI6yJhZMUW+f+ T0U1X5wOU9jmrO3SqWcICU3ojgSSjhMztqcsKwqrcX8DvgEdS2Cl6cylqW2A7vrGWhTnEszjMRL4P Tfk6aOpPi4z8hOB0NcHNsIQdy5p2Q37TW/WwMORcD3kRYx+CZYjvSukU8KZebNMeD0rRiXNxDYAPO VpEQ9sAA==; Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfE-0000000GAXR-22jh for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:55 +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-0005jX-9X; 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-000fFl-Cn; 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-004Y7U-11; 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 114/164] pwm: stm32: Change prototype of a helper to prepare further changes Date: Wed, 14 Feb 2024 10:32:41 +0100 Message-ID: <33790c64563cb0434d7156d96f189c6037b3eb0b.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=2549; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=14MfV+FXrX/aTvW2MLXTLmHT0CglDRMiyFAOzxxibSU=; b=owGbwMvMwMXY3/A7olbonx/jabUkhtQzHecu1gXPzzUPOtNe/yIl7YvfP489k+6fn3urYYJ15 ESPbguGTkZjFgZGLgZZMUUW+8Y1mVZVcpGda/9dhhnEygQyhYGLUwAmUriJ/Z9N2r1LBXrmkyQM XoRdENM9Kjy188Bit1n3zZVObvRhm2/68MHk31tj926Qe9z0b6PvhpbIU1nqhUbKViveypS5sXc nTlLfuEN01hQNzrDl4Qa1TpI86v0Xc7YcaLnxqtZYcYuqzbTPsd7vLU6+kfx5LtW4qeRi2/kGQ6 dAoQg32yrpKdKcBzIfTSlPNOy/PYsvkE+2NE38FqdxTPMR5rO5JrMcFpQp9DtV/5aQf/XzRHxsK e9d67jy3++a37z9kj9zeofR+8eik+asVTTolJzX+ZLN9r5al1jTAUVfva/FhS4nWlLUJIPjmz/Z MFfERWwqeiAhto/hIWO1A9uE0P5nTPxv8v6VeVjyrD0NAA== 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_093448_876299_30998A55 X-CRM114-Status: GOOD ( 13.41 ) 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 make it harder to determine the pwm_chip from a given stm32_pwm. To just not have to do that, rework stm32_pwm_raw_capture() to take a pwm_chip. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-stm32.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/pwm/pwm-stm32.c b/drivers/pwm/pwm-stm32.c index 202114c00ad3..ec15bc51d930 100644 --- a/drivers/pwm/pwm-stm32.c +++ b/drivers/pwm/pwm-stm32.c @@ -90,11 +90,12 @@ static u32 active_channels(struct stm32_pwm *dev) * - Period = t2 - t0 * - Duty cycle = t1 - t0 */ -static int stm32_pwm_raw_capture(struct stm32_pwm *priv, struct pwm_device *pwm, +static int stm32_pwm_raw_capture(struct pwm_chip *chip, struct pwm_device *pwm, unsigned long tmo_ms, u32 *raw_prd, u32 *raw_dty) { - struct device *parent = priv->chip.dev->parent; + struct stm32_pwm *priv = to_stm32_pwm_dev(chip); + struct device *parent = pwmchip_parent(chip)->parent; enum stm32_timers_dmas dma_id; u32 ccen, ccr; int ret; @@ -170,7 +171,7 @@ static int stm32_pwm_capture(struct pwm_chip *chip, struct pwm_device *pwm, ret = clk_enable(priv->clk); if (ret) { - dev_err(chip->dev, "failed to enable counter clock\n"); + dev_err(pwmchip_parent(chip), "failed to enable counter clock\n"); goto unlock; } @@ -208,7 +209,7 @@ static int stm32_pwm_capture(struct pwm_chip *chip, struct pwm_device *pwm, TIM_CCER_CC12P : TIM_CCER_CC34P, pwm->hwpwm < 2 ? TIM_CCER_CC2P : TIM_CCER_CC4P); - ret = stm32_pwm_raw_capture(priv, pwm, tmo_ms, &raw_prd, &raw_dty); + ret = stm32_pwm_raw_capture(chip, pwm, tmo_ms, &raw_prd, &raw_dty); if (ret) goto stop; @@ -229,7 +230,7 @@ static int stm32_pwm_capture(struct pwm_chip *chip, struct pwm_device *pwm, /* 2nd measure with new scale */ psc /= scale; regmap_write(priv->regmap, TIM_PSC, psc); - ret = stm32_pwm_raw_capture(priv, pwm, tmo_ms, &raw_prd, + ret = stm32_pwm_raw_capture(chip, pwm, tmo_ms, &raw_prd, &raw_dty); if (ret) goto stop; @@ -257,7 +258,7 @@ static int stm32_pwm_capture(struct pwm_chip *chip, struct pwm_device *pwm, FIELD_PREP(TIM_CCMR_IC1PSC, icpsc) | FIELD_PREP(TIM_CCMR_IC2PSC, icpsc)); - ret = stm32_pwm_raw_capture(priv, pwm, tmo_ms, &raw_prd, &raw_dty); + ret = stm32_pwm_raw_capture(chip, pwm, tmo_ms, &raw_prd, &raw_dty); if (ret) goto stop;