From patchwork Wed Feb 14 09:32:54 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: 13556202 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 C2009C48BEB for ; Wed, 14 Feb 2024 09:40:25 +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=oDJJX6adaZ2sQokYKjb9BT+WC+hWCihErZxQ/8ZzShw=; b=CkW/mRqYqxeUPs MQ07NDShI4odB+ErRlhQWw/yTW2kosSAUIt0slNprLMwF8mENviN0eJybREKuxNe80iwqxMemHehm JdextOGK0IZw69JuSvZBGfsjg0yNdDNsVyIeuCVz2UiyNf847xGr8hoR21Uf6IZOcW+FKrCHL3dCU htpWtkYfIeLHXVQWTpJRrnhwbM1Gx22/UCtfLma70gMbB/MYs0YMwn5410z/5EBNxktwAkZlyZYfA KS22MrSBNHqWaxCDoAOXPj26WkzjFHYycVBGz0YrKKCTguC7tpi1E8ncHvyi3h00pSTjkp/CWNx1M yjExOziLgpNOKx2w0TwQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBkO-0000000COL0-3ySJ; Wed, 14 Feb 2024 09:40:08 +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 1raBfX-0000000CKvX-2PZg for linux-arm-kernel@bombadil.infradead.org; Wed, 14 Feb 2024 09:35:07 +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=haZuOvKd1ECeZAbsLg9a2Un9yW1uGt86GOF3EkoaPzI=; b=UZG5Zn6zw143yzvRYHT7pMEUN9 mk6IRSZUqfIfXys0H6lAlKju1kqezDiFxrM18xs9JZKuQAwuKLs59JH0wRul1pHFgl362+Jwowuml T0GBQDu+ZL/DIHGIPa4fcqQXGCzxUdblojS2jziW2YFQ9WcKaBOozaufuvdAqznLqGXLdYuMZS3fy zmEK8V7ihF7z82N2ylx1RiqAK39foFgI0nDi4Ujn1jPKBLkh0918aydqIQ6op8J7Lc4ykMDCI9BOA 0GhnFsQz3L8NQKZhw+ypDTSywFvpX2gaEtZzVmyPZWhYuNOYz2QrM7mvZIqwC2KaXOQs2KJ21lNQt KDl+K7gA==; 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 1raBfS-0000000GDl6-2iZ2 for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:35:06 +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 1raBf6-0005v0-Cx; Wed, 14 Feb 2024 10:34:40 +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 1raBf3-000fGb-Dp; Wed, 14 Feb 2024 10:34:37 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBf3-004Y8L-17; Wed, 14 Feb 2024 10:34:37 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , linux-pwm@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, kernel@pengutronix.de Subject: [PATCH v6 127/164] pwm: sun4i: Make use of devm_pwmchip_alloc() function Date: Wed, 14 Feb 2024 10:32:54 +0100 Message-ID: <9d175b4e27878618cef2e75b6ecbf01ad5d18164.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=2177; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=8grekMG/pnUPKM2MOLizyNA3Ftp35oinBr44kp2qzzM=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIjdIZpyNN9xsJ/83vD9zGceZKDFjTgjS+vFw giGgyurR2mJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyI3QAKCRCPgPtYfRL+ TpS0B/91FU88mXiefrP3J4rA4CGdSag6uBm5eO2sgfhRr4Y5m3b9MI4JyFbJ/WQ4h+3EVL+uS8U ktz9YZxmHu0X+OUlFsT8GxSVAvneu1cwDWIynXlXiHzFk2wz2ZJJ2mDjKLhHRTMPT3TDP8iPmqE t0h80+KjIv7S2CUVLjo4nv1oQ9xW6Am6bp437q2YT483DwnpYDhbnCXIl1604tOR/JmkRew28h3 k9QXL+nWjyNhQDXaMD7K3WMKigRZ+Vi0UJi8sfS/Q4nySkXxyqSUBPvL6g5w56XHRcQKP68IfKj VALUdkhZLAIwm79XrJwGdX3hEKtEiudv+4htab04pHWUZks/ 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_193403_4A77F63D X-CRM114-Status: GOOD ( 12.45 ) 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-sun4i 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 Reviewed-by: Jernej Skrabec --- drivers/pwm/pwm-sun4i.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/pwm/pwm-sun4i.c b/drivers/pwm/pwm-sun4i.c index 2437e5961f5e..5c29590d1821 100644 --- a/drivers/pwm/pwm-sun4i.c +++ b/drivers/pwm/pwm-sun4i.c @@ -81,7 +81,6 @@ struct sun4i_pwm_data { }; struct sun4i_pwm_chip { - struct pwm_chip chip; struct clk *bus_clk; struct clk *clk; struct reset_control *rst; @@ -92,7 +91,7 @@ struct sun4i_pwm_chip { static inline struct sun4i_pwm_chip *to_sun4i_pwm_chip(struct pwm_chip *chip) { - return container_of(chip, struct sun4i_pwm_chip, chip); + return pwmchip_get_drvdata(chip); } static inline u32 sun4i_pwm_readl(struct sun4i_pwm_chip *sun4ichip, @@ -385,18 +384,20 @@ MODULE_DEVICE_TABLE(of, sun4i_pwm_dt_ids); static int sun4i_pwm_probe(struct platform_device *pdev) { struct pwm_chip *chip; + const struct sun4i_pwm_data *data; struct sun4i_pwm_chip *sun4ichip; int ret; - sun4ichip = devm_kzalloc(&pdev->dev, sizeof(*sun4ichip), GFP_KERNEL); - if (!sun4ichip) - return -ENOMEM; - chip = &sun4ichip->chip; - - sun4ichip->data = of_device_get_match_data(&pdev->dev); - if (!sun4ichip->data) + data = of_device_get_match_data(&pdev->dev); + if (!data) return -ENODEV; + chip = devm_pwmchip_alloc(&pdev->dev, data->npwm, sizeof(*sun4ichip)); + if (IS_ERR(chip)) + return PTR_ERR(chip); + sun4ichip = to_sun4i_pwm_chip(chip); + + sun4ichip->data = data; sun4ichip->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(sun4ichip->base)) return PTR_ERR(sun4ichip->base); @@ -453,9 +454,7 @@ static int sun4i_pwm_probe(struct platform_device *pdev) goto err_bus; } - chip->dev = &pdev->dev; chip->ops = &sun4i_pwm_ops; - chip->npwm = sun4ichip->data->npwm; spin_lock_init(&sun4ichip->ctrl_lock);