From patchwork Thu Jan 25 12:09:56 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: 13530889 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 38AD0C47258 for ; Thu, 25 Jan 2024 14:09:01 +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=3B4ySZuiDZ/GKRPZ+wajzL6r4XzY0uFnAuakrYSkLt0=; b=gOTb4rmiCwZTfo C72ijfqG+6dTyOs0nLwXgrMf7UmdhhmYOBdWE5dsTT75tLrI9UuPNtF2yC1PwHnChGf1O/BAJAqck n1dcccaRoofMyFYi337eiNTAPMrKL4JhKYQxIV0szTs1M6P4u8CQvf+4JSKGSkpSmm0Kzmpg+lq3F JfmA4ccJZv8/Lgdq0/miI0H9YvbgnIQdEuYFH/E5LF19QLfduXxfnfh/bMDVLVK3aQ+vZPz+wrede Gb+ACnZp5AUq0hbITpQt4oAsfGJVbM/Da1AZfChz58DriE5kpoPxq06/hyy0kozDT0E3xZncBqpWK M2N8FwwRVkWu7+ZriokQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rT0PM-00000000FHr-3ShD; Thu, 25 Jan 2024 14:08:44 +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 1rT0Og-00000000EzJ-3cZB for linux-arm-kernel@bombadil.infradead.org; Thu, 25 Jan 2024 14:08:02 +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=eMxgfpisafBWEop1cRsJLV56QkmXzJpKfSWtWJNjT6U=; b=NepU+LHaM4W0bAPIL7G+0ebiSs SBcNMDGyTPU74ZLIMY3z8L/WH1LWSXIh9uLI8JYyffxkZAA9kf6YufHvzaQbGyVjPHVD95yQxxr00 MsXkpTWb4IWQ0dgRchwaSHzeop5g0yaI1wxjEYqNMn7KgKCzL48JbMO/NPWrPWM1P+untJoKstEin hy0hHE++aEgxOhi1Wfv49jrbk8/62oPmiXQoi5NVZ/RdEcRQ3SrA1tnFSxqddJUyL0AtT0UCCd6Fc vP7bpFGURjtPbq4g5FLY/XcW2+OvMPhGXGzr8B7N77FgIarHhQ3rpYVfVAtsP/po5HS4EwFr/d5Tz nSwg08PA==; 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 1rSybb-00000009sDW-08wp for linux-arm-kernel@lists.infradead.org; Thu, 25 Jan 2024 12:13:22 +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 1rSyZP-0004ZA-E7; Thu, 25 Jan 2024 13:10:59 +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 1rSyZO-002HUk-37; Thu, 25 Jan 2024 13:10:58 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1rSyZO-007n4T-03; Thu, 25 Jan 2024 13:10:58 +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, Andre Przywara Subject: [PATCH v5 094/111] pwm: sun4i: Make use of devm_pwmchip_alloc() function Date: Thu, 25 Jan 2024 13:09:56 +0100 Message-ID: <3fbc44ec7f4a5b8c388ebddb8fc9c98d2eb04834.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=3137; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=pbimw4e1snhdJV1OL+Hd8nlXssUcoYI3zeJdziV6/04=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlsk+ovSOLzS0QBSxAO37SsCRl6WlZNV2yQM532 +KI5vxIZ1WJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZbJPqAAKCRCPgPtYfRL+ TmiTB/9RSOvADji5DhMKskrIzH8FgyRWsSbXa0Ivb77Apq8oM+u13NHEmx5xWmyspbmx4cG4Vy1 s36owWy4rycjf72wTGYzizrnTg/W4APlv+3sRGnYTS53zybIzA/0dp5lRrT7uZcxERbdEJlj04I j//7OLQoKzJKm5YP8qnrFqx1wDq+0JE/iFlhXGHaT0toVCvxxwaRx5ZXqSkTxqmwpzH9la9/azl ltZGMSOhARoKupbwp9CVHRQWxsNH34GDmFKTkJUcWkaLXEmPlEuuFTRmn3+DQ0K18HLg7pQmsGj cEiElqZzAuGlFUca/aI+f2vMOXAvyECx8z/RSQavqqBJXn8X 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_121316_485765_BD6AEB2B X-CRM114-Status: GOOD ( 13.86 ) 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. Reviewed-by: Andre Przywara Reviewed-by: Jernej Skrabec Signed-off-by: Uwe Kleine-König --- 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);