From patchwork Wed Dec 6 11:44:51 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: 13481644 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 6FE2EC4167B for ; Wed, 6 Dec 2023 11:51:05 +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=rIyaobmyA6rH1AqTQIECyM9djckOYjuJ1DOQFHZNFpQ=; b=ZPow1b7nxEw+og 5pzc4/qC+PcoBRRSPtl2rIBHG1Lu3XNQeoIj58RS2klyavfSAOuoQq7Qf54Wmc3YYLdCY3ddEWiT3 WRS+5A10YMBBmxU+6h3sFxoASSdZwHFGg5WJtg0iRhJ0LJ75vr37q2Ddg1G4T4tbarOTDC1/zagHK GDVkv1W++ASOiaJW3aeGaJnV2Az/qQYJIeF9T/c63uWgB6b+78BD8vz/mXl3mtKOUG3Ick7L9LTOK C+Vvmnrs03jUCg9r5J0EkaBqJg3Vkunzol0/RFu1GppUrnpZN0mnxsBF3YWt+YERUKQoICFLBei0o kqxtcki74vTQPi9Xhfng==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rAqQB-00A8Bg-2j; Wed, 06 Dec 2023 11:50:31 +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 1rAqOW-00A6Pa-2F for linux-arm-kernel@bombadil.infradead.org; Wed, 06 Dec 2023 11:48:48 +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=vmucCxiPEvVCl5zK+InfuoxJOE96F2cDuQVFBVzn4n0=; b=ePmd+Wtm507VyaSt+mDmUeP/Gc aglWiIXgNj38BD+gYhpHxIelLMkCouIMfZ4F1o2qdIDjG3PBU6H0RNNNxv5ea38tj4JfMh5YLCG2t +8TOczKP4+zPHl0RqVUzLAb1XzjGUhrywct6cbGcxB5cY9jU5OVbDkLN97zD9NK7SNLzskoFQ+DZ9 ThlowrEOtQngWJm2Cu5ngarcHTbtt7ZhoI6V2F7f6c3LLWa5II/3hWaRXcHbpdSm7ds8FqsYoOXq0 XsuO+/BaOAZHOcpDYadejOKIM9Q0Y/oGU2MF8KlgtU81Bc6u4RdnG7QvrZynZXnKuhRKaO4lRAuy0 YbSxewIw==; 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 1rAqOT-0059Xh-1c for linux-arm-kernel@lists.infradead.org; Wed, 06 Dec 2023 11:48:47 +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 1rAqON-0007YP-TG; Wed, 06 Dec 2023 12:48:39 +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 1rAqOL-00DwxW-S3; Wed, 06 Dec 2023 12:48:37 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1rAqOL-00FR2w-J2; Wed, 06 Dec 2023 12:48:37 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Thierry Reding Cc: kernel@pengutronix.de, Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , linux-pwm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: [PATCH v4 097/115] pwm: sun4i: Make use of devm_pwmchip_alloc() function Date: Wed, 6 Dec 2023 12:44:51 +0100 Message-ID: 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=3027; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=cpvkAoawTIlpSQ6Qo5v1/quKLPAM9OKABQQO5PgeyoA=; b=owGbwMvMwMXY3/A7olbonx/jabUkhtSCeB1T5bJlP+U0V7n48uyQ636tVv9LsfKBqv2VGX28Y UwMbxQ6GY1ZGBi5GGTFFFnsG9dkWlXJRXau/XcZZhArE8gUBi5OAZiImTv7P1P9i4r9G3mzb0nI znV2bo6Mny581+83w9VMRV6RtilRK/6eDVjjUFfYqH/e/MfsVZc/Xzv03mx2dUvEpU/VTP8mXLK foVrY/OU5Q7zGd4vbF6efvJX708B2+UyZad1TBB76m8hELVL4USKx2e7fHl6LTpl2z4dHRdttX7 L859DpF1oRv8bUwe68aFXT0fU773Do9HbK8wutehzQHDufl4NX1VFmzud+jg0M0Q+3TsrsWpC2o nfn8UM9GTJvNr4KUq663JzotIV9zo0apb86hVxXlyVd12y7fWrDSqMThpLJqcujbpeHfn5tbH5w t4Ywi0jgf8uMVA2Lih7V6iJp9oxNlVrC63bfflSS7fYCAA== 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_114845_637093_F16DC231 X-CRM114-Status: GOOD ( 16.26 ) 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: Andre Przywara Reviewed-by: Jernej Skrabec --- drivers/pwm/pwm-sun4i.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/drivers/pwm/pwm-sun4i.c b/drivers/pwm/pwm-sun4i.c index 44edf1ce5739..36a8dc65b19c 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 *chip, @@ -384,17 +383,22 @@ MODULE_DEVICE_TABLE(of, sun4i_pwm_dt_ids); static int sun4i_pwm_probe(struct platform_device *pdev) { + struct pwm_chip *chip; struct sun4i_pwm_chip *sun4ichip; + const struct sun4i_pwm_data *data; int ret; - sun4ichip = devm_kzalloc(&pdev->dev, sizeof(*sun4ichip), GFP_KERNEL); - if (!sun4ichip) - return -ENOMEM; - - 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); @@ -451,19 +455,18 @@ static int sun4i_pwm_probe(struct platform_device *pdev) goto err_bus; } - sun4ichip->chip.dev = &pdev->dev; - sun4ichip->chip.ops = &sun4i_pwm_ops; - sun4ichip->chip.npwm = sun4ichip->data->npwm; + chip->ops = &sun4i_pwm_ops; + chip->npwm = sun4ichip->data->npwm; spin_lock_init(&sun4ichip->ctrl_lock); - ret = pwmchip_add(&sun4ichip->chip); + ret = pwmchip_add(chip); if (ret < 0) { dev_err(&pdev->dev, "failed to add PWM chip: %d\n", ret); goto err_pwm_add; } - platform_set_drvdata(pdev, sun4ichip); + platform_set_drvdata(pdev, chip); return 0; @@ -477,9 +480,10 @@ static int sun4i_pwm_probe(struct platform_device *pdev) static void sun4i_pwm_remove(struct platform_device *pdev) { - struct sun4i_pwm_chip *sun4ichip = platform_get_drvdata(pdev); + struct pwm_chip *chip = platform_get_drvdata(pdev); + struct sun4i_pwm_chip *sun4ichip = to_sun4i_pwm_chip(chip); - pwmchip_remove(&sun4ichip->chip); + pwmchip_remove(chip); clk_disable_unprepare(sun4ichip->bus_clk); reset_control_assert(sun4ichip->rst);