From patchwork Wed Feb 14 09:30:55 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: 13556141 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 51B80C48BEB for ; Wed, 14 Feb 2024 09:35:32 +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=e+sxy9m+SeRJvl+oXLEqhJ8QvwBOBtTanEDEfW7w5MM=; b=q7v140Qgqf64lV yvj6+5cVPrkND4pPbhwKUxKajBAHHYl1vjgj8hJVKqpio3XauRLw4Ovtb+KOTXIUctPVp3mk5dxrL Jubcvm3wRG4g8P0ZFoVDRn1jm3QLWolEdouOKjliaFV8VQozJPxlMX1BglRDioL6XpIYsHbIswede BERq6EZ3ERREeOvAWsDZkkej4fe75LOx+/jv2V5SKzL8a57W7ULCEmfgIJBNtzlViuM6x13lGcZXs keegBadwRNENF9hjSZqqyCR9/D0PggUdQLNr7M1Zn0LAK+LD9m67/VFkJuSGoFMosItxiHZ7YKvxy Rqqj+a1BY8ep0Sh2CR+Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfi-0000000CL0r-2SC1; Wed, 14 Feb 2024 09:35:18 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBev-0000000CK9x-04LL for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:31 +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 1raBel-0004Ok-EF; Wed, 14 Feb 2024 10:34:19 +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 1raBel-000f71-18; Wed, 14 Feb 2024 10:34:19 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBek-004Y0B-34; Wed, 14 Feb 2024 10:34:18 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Claudiu Beznea , Nicolas Ferre , Alexandre Belloni , linux-pwm@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 008/164] pwm: atmel: Change prototype of a helper to prepare further changes Date: Wed, 14 Feb 2024 10:30:55 +0100 Message-ID: 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=2858; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=QIQRTGWYyMDDIqzmMspyZIZGmehbfXvdg62xGI/Tyy0=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIhU1jXvH4ESWAqWsDYttDHJM5uqvSf1HqTuN xSTBs4ZIvSJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyIVAAKCRCPgPtYfRL+ TnBsB/96dYVoGauzJJA7c5p/W7a1Y6fZ33BOsOLnX6EMLoSOJfgeDz8QhX3sl/McT59eBlPlaIM M9x5nubm1F4Hb/G5zDHO8/xVjWRiRHkZ0FYciOb8EvEO1hnyka/JsNrODbDdvhvtVgj0BUUWQJk k89FcLo8zmr2RcDCfUhOoDcme8RgPj4szJj8xGt7NoMNOMy8YaeKtzTMdI4h762FbQP1YzwabUA R5snKsGNJnnSdnC/TIawvIeOAHA79JC1bV2sZd7xc/vKYBYo2UGBscS4Y1mJbbZCU2HUwrZryRL FYzu5pOYiIVj2xfv7MKWHK1eP5H/GCg22jgFElzBj8cLIDL8 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_013429_197514_2FCE8D87 X-CRM114-Status: GOOD ( 16.48 ) 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 atmel_pwm_chip. To just not have to do that, rework atmel_pwm_enable_clk_if_on() to take a pwm_chip. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-atmel.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/pwm/pwm-atmel.c b/drivers/pwm/pwm-atmel.c index 47bcc8a3bf9d..2f7d6c43be85 100644 --- a/drivers/pwm/pwm-atmel.c +++ b/drivers/pwm/pwm-atmel.c @@ -462,8 +462,9 @@ static const struct of_device_id atmel_pwm_dt_ids[] = { }; MODULE_DEVICE_TABLE(of, atmel_pwm_dt_ids); -static int atmel_pwm_enable_clk_if_on(struct atmel_pwm_chip *atmel_pwm, bool on) +static int atmel_pwm_enable_clk_if_on(struct pwm_chip *chip, bool on) { + struct atmel_pwm_chip *atmel_pwm = to_atmel_pwm_chip(chip); unsigned int i, cnt = 0; unsigned long sr; int ret = 0; @@ -472,7 +473,7 @@ static int atmel_pwm_enable_clk_if_on(struct atmel_pwm_chip *atmel_pwm, bool on) if (!sr) return 0; - cnt = bitmap_weight(&sr, atmel_pwm->chip.npwm); + cnt = bitmap_weight(&sr, chip->npwm); if (!on) goto disable_clk; @@ -480,7 +481,7 @@ static int atmel_pwm_enable_clk_if_on(struct atmel_pwm_chip *atmel_pwm, bool on) for (i = 0; i < cnt; i++) { ret = clk_enable(atmel_pwm->clk); if (ret) { - dev_err(atmel_pwm->chip.dev, + dev_err(chip->dev, "failed to enable clock for pwm %pe\n", ERR_PTR(ret)); @@ -501,6 +502,7 @@ static int atmel_pwm_enable_clk_if_on(struct atmel_pwm_chip *atmel_pwm, bool on) static int atmel_pwm_probe(struct platform_device *pdev) { struct atmel_pwm_chip *atmel_pwm; + struct pwm_chip *chip; int ret; atmel_pwm = devm_kzalloc(&pdev->dev, sizeof(*atmel_pwm), GFP_KERNEL); @@ -521,15 +523,16 @@ static int atmel_pwm_probe(struct platform_device *pdev) return dev_err_probe(&pdev->dev, PTR_ERR(atmel_pwm->clk), "failed to get prepared PWM clock\n"); - atmel_pwm->chip.dev = &pdev->dev; - atmel_pwm->chip.ops = &atmel_pwm_ops; - atmel_pwm->chip.npwm = 4; + chip = &atmel_pwm->chip; + chip->dev = &pdev->dev; + chip->ops = &atmel_pwm_ops; + chip->npwm = 4; - ret = atmel_pwm_enable_clk_if_on(atmel_pwm, true); + ret = atmel_pwm_enable_clk_if_on(chip, true); if (ret < 0) return ret; - ret = devm_pwmchip_add(&pdev->dev, &atmel_pwm->chip); + ret = devm_pwmchip_add(&pdev->dev, chip); if (ret < 0) { dev_err_probe(&pdev->dev, ret, "failed to add PWM chip\n"); goto disable_clk; @@ -538,7 +541,7 @@ static int atmel_pwm_probe(struct platform_device *pdev) return 0; disable_clk: - atmel_pwm_enable_clk_if_on(atmel_pwm, false); + atmel_pwm_enable_clk_if_on(chip, false); return ret; }