From patchwork Thu Jan 25 12:09:24 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: 13530868 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 0461AC47258 for ; Thu, 25 Jan 2024 14:07:11 +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=lo7fkKAosxIOz0RG+V3kPG6J66ftEEh0lSVwIpzhXOA=; b=Z21J/VQhPsrgfZ 7DyB5vQE4mlO/Al9VJRqRJP/b64wfmLpx//Itm/OmQAcVrXCaOqvUtcJAiC9i32Cqf6Sq0d2R4EJ8 OAVYp7fAwawRp43KQ+KIaoUTg68YsMBdqAvvssZoXxZA1dusJP967Li6R/Kv5h8TgIF2z6QNWOSBG Yx47OaFVmTlHWfgvjLeuNu0JSxnPttKJqcFAovwP+K1Hwxg9rXkO1CWE7pHs54fJFhGAmpOzOEoYg +DYnuv96fenscxTAA84W/ZOlrx9V/8OkCdKiL/jINY+thxxyDoSTRqbec7GmmStH5ym6ItSRO7boC 6PvTnqDw0fzqMtsQ0Ftw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rT0Nb-00000000EFU-1zGe; Thu, 25 Jan 2024 14:06:55 +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 1rT0NZ-00000000EF1-2JaT for linux-arm-kernel@bombadil.infradead.org; Thu, 25 Jan 2024 14:06:53 +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=XpW93pgnbY5VPL7kaP5SHUdD88drdcAIxq3/xQLHYHQ=; b=IdCJskmMFQCInF5V/K7g3JfSOY M3f775ktRD3XkHEFlTkIHNsxOpwAvgmB+j+nYzVYpxcYVSNWCN8xARVt6gr6TF+g5A4AwZ63+8ImV vi7jSD0q4IzbIM6TMoSHtHJbSZpxRg10r/g9XCghLRGeeD6/RbYsH2QUhy77WYWpGargcXVaE34/9 4v99+VMN8jwpuWBfe0EH4/7JhTk9Db3hbxDMzFQIgrfaCzyoARsQLiS6AKjUy+hhXKnja+F9JplFS pdEBrlGWPRCOqzTRWiLZXie6rygyypz7JxjxX+E7oI7c6Y9OWmR5fjCILH8k2Cd6Sn4BJo0bgFbIA NAFdA6hg==; 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 1rSybW-00000005Hjc-3BjU for linux-arm-kernel@lists.infradead.org; Thu, 25 Jan 2024 12:13: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 1rSyZJ-0004Mi-5T; Thu, 25 Jan 2024 13:10:53 +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 1rSyZI-002HSk-86; Thu, 25 Jan 2024 13:10:52 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1rSyZI-007n2K-0X; Thu, 25 Jan 2024 13:10:52 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Shawn Guo , Sascha Hauer , linux-pwm@vger.kernel.org Cc: Fabio Estevam , NXP Linux Team , linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v5 062/111] pwm: imx-tpm: Make use of devm_pwmchip_alloc() function Date: Thu, 25 Jan 2024 13:09:24 +0100 Message-ID: <6144c4925c464cf677517c24701a8b36e80d6f6d.1706182805.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=2604; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=Zom3RCFrlpm+waz+6f5uIA5kXrRlXpCKoQzIGutQMZo=; b=owGbwMvMwMXY3/A7olbonx/jabUkhtRN/s0M4nFM010jPmd6LAq2PTd3tk/51dnvU8V2VqV92 8OcG3Stk9GYhYGRi0FWTJHFvnFNplWVXGTn2n+XYQaxMoFN4eIUgIlM/cr+P3PF66ylOnV+Cw41 nObJMq6I+nu/5cH0mxIZX4P37lM4dkR8zY8reXzCW0+y1jxlX9LCbXCa59//6095peUjlX0PZzz 3ztt+M+a+l/SW9Zomdu99RJa7v5zs9GXVriV/mC6Gz36UsmW+VOb8Am+ZyzYlN/h+rBBSuV7q1M Z42HjRqRA9w/WZnXcfOiy86XaNKav1X2xYuJKWRO0KpheuB6d4vU3jOcF94l/bftWcQ/8XMZUbT BP/7CN41n6TxcLDcVYWolXaDbFJ7itOJZv1iEhF+s3e6lxyzSCaoYQ7YWbf2v2sKxorfrhsNQ1M vWq6Zo8YX6NL8lUtiUS3lLrrrC9rkucvOnxoEYOP3A1NAA== 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-20240125_121310_855793_B6D6FFB9 X-CRM114-Status: GOOD ( 16.13 ) 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 pwm-tmp driver to further changes of the pwm core outlined in the commit introducing devm_pwmchip_alloc(). There is no intended semantical change and the driver should behave as before. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-imx-tpm.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/drivers/pwm/pwm-imx-tpm.c b/drivers/pwm/pwm-imx-tpm.c index 9fc290e647e1..04f8ab315748 100644 --- a/drivers/pwm/pwm-imx-tpm.c +++ b/drivers/pwm/pwm-imx-tpm.c @@ -57,7 +57,6 @@ #define PWM_IMX_TPM_MOD_MOD GENMASK(PWM_IMX_TPM_MOD_WIDTH - 1, 0) struct imx_tpm_pwm_chip { - struct pwm_chip chip; struct clk *clk; void __iomem *base; struct mutex lock; @@ -75,7 +74,7 @@ struct imx_tpm_pwm_param { static inline struct imx_tpm_pwm_chip * to_imx_tpm_pwm_chip(struct pwm_chip *chip) { - return container_of(chip, struct imx_tpm_pwm_chip, chip); + return pwmchip_get_drvdata(chip); } /* @@ -336,35 +335,40 @@ static const struct pwm_ops imx_tpm_pwm_ops = { static int pwm_imx_tpm_probe(struct platform_device *pdev) { + struct pwm_chip *chip; struct imx_tpm_pwm_chip *tpm; + void __iomem *base; int ret; + unsigned int npwm; u32 val; - tpm = devm_kzalloc(&pdev->dev, sizeof(*tpm), GFP_KERNEL); - if (!tpm) - return -ENOMEM; + base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(base)) + return PTR_ERR(base); + + /* get number of channels */ + val = readl(tpm->base + PWM_IMX_TPM_PARAM); + npwm = FIELD_GET(PWM_IMX_TPM_PARAM_CHAN, val); + + chip = devm_pwmchip_alloc(&pdev->dev, npwm, sizeof(*tpm)); + if (IS_ERR(chip)) + return PTR_ERR(chip); + tpm = to_imx_tpm_pwm_chip(chip); platform_set_drvdata(pdev, tpm); - tpm->base = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(tpm->base)) - return PTR_ERR(tpm->base); + tpm->base = base; tpm->clk = devm_clk_get_enabled(&pdev->dev, NULL); if (IS_ERR(tpm->clk)) return dev_err_probe(&pdev->dev, PTR_ERR(tpm->clk), "failed to get PWM clock\n"); - tpm->chip.dev = &pdev->dev; - tpm->chip.ops = &imx_tpm_pwm_ops; - - /* get number of channels */ - val = readl(tpm->base + PWM_IMX_TPM_PARAM); - tpm->chip.npwm = FIELD_GET(PWM_IMX_TPM_PARAM_CHAN, val); + chip->ops = &imx_tpm_pwm_ops; mutex_init(&tpm->lock); - ret = devm_pwmchip_add(&pdev->dev, &tpm->chip); + ret = devm_pwmchip_add(&pdev->dev, chip); if (ret) return dev_err_probe(&pdev->dev, ret, "failed to add PWM chip\n");