From patchwork Thu Jan 25 12:09:08 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: 13530898 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 42BD4C47258 for ; Thu, 25 Jan 2024 14:10:44 +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=oqEkhGjjU9n9wqq+8Yw9WwbJ65BtFNKqRuyCzMCiATM=; b=MrYbkwUuNSUmUe T9mfR8gsL/sTqrfVF3hkpTRn72VrNzslOOAaXFeXcAy4wcSIggj5rNgy0tgzTbV7s391rWofbxeHc xUiFPGfYEnYJ5onudwb2Eb8b2nDz6CjFfg90TQ2hb4PHowrfNe4enQ6ecKuJ4orFmGYfOkGjEv7/V gcnvqq+mAwvdlnKVt56O3kgW387b3V+MhjQSoCaNDR8m1CrU3p49cZAmBWlAmWZbJKxpInjNWCfqX ErxgvvjW+e7jfpgVLFX66HmKU2hvPOOvsLSBO5h8/P5Rj1fgJvYVNsLtCty/6aziu3QA3NTJ+oWzp wSU/Gz6/PYI83q2osu3g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rT0R7-00000000GX9-2bIi; Thu, 25 Jan 2024 14:10:33 +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 1rT0Pg-00000000FbC-3APx for linux-arm-kernel@bombadil.infradead.org; Thu, 25 Jan 2024 14:09:04 +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=V1mtQEUhF1Ve5IJnhZAiJk92SCG45naY1Ozfd0bT2BA=; b=XvNG09P08dAHJJS78C96WOP3tB YqCNlf0NxZn34RpG83Xyfpy40Uirw11W+tOyscu3kqToZb5hIB7k3JCx9Ewv1Z+oAcaKMu/Stc9JF IZAJvmCHB7cvFtfo+/qB8HE0WO8yOQH2Df/OjeTv5nbzS6blO7MY71RwyeTgpjTTkijSXb3/C8KFI D/zCE3YNR7ejGulGoxPwd845IG+MEhpOigEFeDO7Mhx6JlzLymJwE6IdnHzEtJb7oPogSpuUhdM2Y QYiLxeRgCJ6MW3eH+WfukjDJVjTsonx/zzeh0J1tAwjxcUPS55VSTJe3oOyZVNU9iBh1dlolpOjFJ qtKazCfQ==; 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 1rSybU-00000009sDg-380j for linux-arm-kernel@lists.infradead.org; Thu, 25 Jan 2024 12:13:16 +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 1rSyZF-0004Dw-RI; Thu, 25 Jan 2024 13:10:49 +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 1rSyZF-002HRc-5v; Thu, 25 Jan 2024 13:10:49 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1rSyZF-007n1D-0K; Thu, 25 Jan 2024 13:10:49 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Florian Fainelli , Ray Jui , Scott Branden , linux-pwm@vger.kernel.org Cc: Broadcom internal kernel review list , linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v5 046/111] pwm: bcm2835: Make use of devm_pwmchip_alloc() function Date: Thu, 25 Jan 2024 13:09:08 +0100 Message-ID: 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=2088; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=neQkkkXDHUEM9dSo5MAWe6moa15OMaMntAJ6c9xCReQ=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlsk9vN3MiJgOE+8YM2JmyCFJtFosL4WRveO87u BWJ/eitXHuJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZbJPbwAKCRCPgPtYfRL+ TqLxB/9YKXtEWsPi9SVOPdPwSqXSRyHuCh8NojbANO7EqjpTT1pGQVTVnb5qnW1DJSRvdotYx5h Mr6vqdqqjQ5S6HzBmSq3uZuBMT9BLE2nbJnERTyOqnV8fJY0Y2ZLn5o7PPWrTgsLBt6j1KJDndX 3vs1gGuLXp3WzKuV1kWYRLVIbx0j+tdXX1grM6bdDKVHzPfH9/lPlI0IchuqbvPPqlXfPE316dS 6ZjQKW0G3GfLrR3ZGfLUiTmDLAyTjeUaVNs0YXE2bu4NCXBiKKSOfI48DzdycrU76p8vl2Jr9um jtbN+O/wFriJPdEwRNSqG90zFVLqgDILuUSA+zhZFebM74Sm 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_157970_A17AEECD X-CRM114-Status: GOOD ( 12.72 ) 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-bcm2835 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-bcm2835.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/pwm/pwm-bcm2835.c b/drivers/pwm/pwm-bcm2835.c index 283cf27f25ba..a7450c98368d 100644 --- a/drivers/pwm/pwm-bcm2835.c +++ b/drivers/pwm/pwm-bcm2835.c @@ -24,7 +24,6 @@ #define PERIOD_MIN 0x2 struct bcm2835_pwm { - struct pwm_chip chip; struct device *dev; void __iomem *base; struct clk *clk; @@ -33,7 +32,7 @@ struct bcm2835_pwm { static inline struct bcm2835_pwm *to_bcm2835_pwm(struct pwm_chip *chip) { - return container_of(chip, struct bcm2835_pwm, chip); + return pwmchip_get_drvdata(chip); } static int bcm2835_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm) @@ -135,12 +134,14 @@ static void devm_clk_rate_exclusive_put(void *data) static int bcm2835_pwm_probe(struct platform_device *pdev) { + struct pwm_chip *chip; struct bcm2835_pwm *pc; int ret; - pc = devm_kzalloc(&pdev->dev, sizeof(*pc), GFP_KERNEL); - if (!pc) - return -ENOMEM; + chip = devm_pwmchip_alloc(&pdev->dev, 2, sizeof(*pc)); + if (IS_ERR(chip)) + return PTR_ERR(chip); + pc = to_bcm2835_pwm(chip); pc->dev = &pdev->dev; @@ -168,14 +169,12 @@ static int bcm2835_pwm_probe(struct platform_device *pdev) return dev_err_probe(&pdev->dev, -EINVAL, "failed to get clock rate\n"); - pc->chip.dev = &pdev->dev; - pc->chip.ops = &bcm2835_pwm_ops; - pc->chip.atomic = true; - pc->chip.npwm = 2; + chip->atomic = true; + chip->ops = &bcm2835_pwm_ops; platform_set_drvdata(pdev, pc); - ret = devm_pwmchip_add(&pdev->dev, &pc->chip); + ret = devm_pwmchip_add(&pdev->dev, chip); if (ret < 0) return dev_err_probe(&pdev->dev, ret, "failed to add pwmchip\n");