From patchwork Wed Dec 6 11:44:59 2023 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: 13481645 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 E426CC4167B for ; Wed, 6 Dec 2023 11:51:07 +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=KbPaR52TW9WY+wrok+SGU90vUzKEq+5ydtB5sBs7JzQ=; b=temaY981J6jw+r erjnaaaipvW/z98t7UL+RO/QoZPX066H5nSF95bhi9o+s8OxI8aDlKOaJEa1pVpsoQ/sXVZcfBafY sKI0xbpVA50goYFNDs7kp6cvlSmINKwahB03fOwUdYdULNzijt/crP45LYlimoEWkzXFJEtd/tmnt YXwB1GFlJgE5RkyI4nyDWql/4YbU3TJvFhk+onZIU2xwj23Fp0g0n/Wh+ArE/t8vdrYE4smb9eZBZ rC9QCtbGDQqIM3/pYzSN64CpkFplZS5+t+ee1ysxB7AaDRope8oQjN1N/f7N6YVlSHzvaF8+BjRiO vSVz29BFbXykRpMBmohQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rAqQH-00A8Jy-15; Wed, 06 Dec 2023 11:50:37 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rAqOX-00A6Qf-2q for linux-arm-kernel@bombadil.infradead.org; Wed, 06 Dec 2023 11:48:49 +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=86xuuIuo2GaIAdEMci4YwJvAwIF3+4iyjNPg+8fJElw=; b=dpftKMtBwr3EzyujkRRBVpw++U s6QUKlB8ga0HB2Qat4K0Dp7pDijxS5biLZw9qRrSyLm8pkSb04wxe1CYWyDIx4shFY7Sc5vpVJgMO CUaM4QKZVkIE3uGJ4B/dZqQlCIkIiPXjVyPX4fyWrSD8iV28DaV3KZKRHv5ZKh9aS7dPS5fu/f7D5 drjE0V9KVRutHna0rt4UKF8FTwLE/gOQkon8XZeRdggW0WH8FKbefm/MhqYdW4tC2amiEUurmGRYd cYJNHQxIDHL8vQJV+b5M4i4/2xX/+j4H6aAkzKCiTwdDNz7uutGspJIXZftu0/3Dy69U3c10G9e+6 bgp+iDeg==; Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rAqOU-0059Y8-2d for linux-arm-kernel@lists.infradead.org; Wed, 06 Dec 2023 11:48:48 +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 1rAqOQ-0007hP-08; Wed, 06 Dec 2023 12:48:42 +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 1rAqON-00Dwxz-Ag; Wed, 06 Dec 2023 12:48:39 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1rAqON-00FR3S-1f; Wed, 06 Dec 2023 12:48:39 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Thierry Reding Cc: kernel@pengutronix.de, Sean Anderson , Michal Simek , linux-pwm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 105/115] pwm: xilinx: Make use of devm_pwmchip_alloc() function Date: Wed, 6 Dec 2023 12:44:59 +0100 Message-ID: <9accf9867f66b90166aa52ff28d0634f917a73d1.1701860672.git.u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.42.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3206; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=FB/YK65khXm3EsyBDoGHdndZz8ILIfgWPODYwCRtGQc=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlcF9JkGrI5AyIEdQHEs/IA9bJSZqWDupNiEK06 RbPX+lYmJ6JATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZXBfSQAKCRCPgPtYfRL+ TlwqCACajquvFhZVECkfE6Zqh4o444tynVnqkXhT2B+qF3soUOO9nsWRc97dSsvfogCGd7+b2jW kyg6qwvUvUms5zzk+H2Wr15b9KiLiPW7d50eaqikNIXWcWLtgx0iPGiQ62sCcLvR2sFbWFNCOjG L1xfQzqcHZy44dwW+aLDBfS+nSTkD22c2cAhKdRa7wT8P+4cSjDK0d1OiTaXeRJ2W9WC6UmpMXq 7vihoCI4x5xBkepxCnK3OCIPOAY6n0z9o2rqAU671geqIFFISCGsoCnzSmFGtUX50MvA9d/DOqu L1d+7yUdtMqNr6lAr6oMQNuhB6Sdo2Zjs9f/hE83ZYZyX9e/ 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-20231206_114846_979630_F644B0EC X-CRM114-Status: GOOD ( 15.53 ) 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-xilinx 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-xilinx.c | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/drivers/pwm/pwm-xilinx.c b/drivers/pwm/pwm-xilinx.c index 5f3c2a6fed11..465ac9617256 100644 --- a/drivers/pwm/pwm-xilinx.c +++ b/drivers/pwm/pwm-xilinx.c @@ -80,15 +80,10 @@ unsigned int xilinx_timer_get_period(struct xilinx_timer_priv *priv, #define TCSR_PWM_CLEAR (TCSR_MDT | TCSR_LOAD) #define TCSR_PWM_MASK (TCSR_PWM_SET | TCSR_PWM_CLEAR) -struct xilinx_pwm_device { - struct pwm_chip chip; - struct xilinx_timer_priv priv; -}; - static inline struct xilinx_timer_priv *xilinx_pwm_chip_to_priv(struct pwm_chip *chip) { - return &container_of(chip, struct xilinx_pwm_device, chip)->priv; + return pwmchip_get_drvdata(chip); } static bool xilinx_timer_pwm_enabled(u32 tcsr0, u32 tcsr1) @@ -213,8 +208,8 @@ static int xilinx_pwm_probe(struct platform_device *pdev) int ret; struct device *dev = &pdev->dev; struct device_node *np = dev->of_node; + struct pwm_chip *chip; struct xilinx_timer_priv *priv; - struct xilinx_pwm_device *xilinx_pwm; u32 pwm_cells, one_timer, width; void __iomem *regs; @@ -225,11 +220,11 @@ static int xilinx_pwm_probe(struct platform_device *pdev) if (ret) return dev_err_probe(dev, ret, "could not read #pwm-cells\n"); - xilinx_pwm = devm_kzalloc(dev, sizeof(*xilinx_pwm), GFP_KERNEL); - if (!xilinx_pwm) - return -ENOMEM; - platform_set_drvdata(pdev, xilinx_pwm); - priv = &xilinx_pwm->priv; + chip = devm_pwmchip_alloc(dev, 1, sizeof(*priv)); + if (IS_ERR(chip)) + return PTR_ERR(chip); + priv = xilinx_pwm_chip_to_priv(chip); + platform_set_drvdata(pdev, chip); regs = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(regs)) @@ -278,10 +273,8 @@ static int xilinx_pwm_probe(struct platform_device *pdev) return dev_err_probe(dev, ret, "Clock enable failed\n"); clk_rate_exclusive_get(priv->clk); - xilinx_pwm->chip.dev = dev; - xilinx_pwm->chip.ops = &xilinx_pwm_ops; - xilinx_pwm->chip.npwm = 1; - ret = pwmchip_add(&xilinx_pwm->chip); + chip->ops = &xilinx_pwm_ops; + ret = pwmchip_add(chip); if (ret) { clk_rate_exclusive_put(priv->clk); clk_disable_unprepare(priv->clk); @@ -293,11 +286,12 @@ static int xilinx_pwm_probe(struct platform_device *pdev) static void xilinx_pwm_remove(struct platform_device *pdev) { - struct xilinx_pwm_device *xilinx_pwm = platform_get_drvdata(pdev); + struct pwm_chip *chip = platform_get_drvdata(pdev); + struct xilinx_timer_priv *priv = xilinx_pwm_chip_to_priv(chip); - pwmchip_remove(&xilinx_pwm->chip); - clk_rate_exclusive_put(xilinx_pwm->priv.clk); - clk_disable_unprepare(xilinx_pwm->priv.clk); + pwmchip_remove(chip); + clk_rate_exclusive_put(priv->clk); + clk_disable_unprepare(priv->clk); } static const struct of_device_id xilinx_pwm_of_match[] = {