From patchwork Wed Dec 6 11:44:03 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: 13481625 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 698B1C4167B for ; Wed, 6 Dec 2023 11:50:02 +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=T+yYvXQItVH0xfhY710qsiuGLOz6+HmrsMBnw72hp20=; b=bOW7kSAWgNdR/c uty8fvW27hyiaqXBVPDWJANioSNbWYKT1c7tyjbT6/acRFXgQABMgEP9pLNm9Lbl5wAZOspEVAAWX Sfq/xVZMAGY2nb4SGf0L7oq8Wux7BXT3vxBSkzowMdDNyhk7saj2FOGJqKKWZYxrsAvUs4XihqYhE 14ZUOFK6qBG34VZ9SuJTrcpBD7fELg+PX2r2bXR7y3fdcgQ+mTbKPChykQ7tTwwp8fUdWeXebGRr8 Dllyp6T2Qz0G6WaEGrCq1pqZu+E0F5Mv5MqVgq4u1Y2GgH+QUXDrm5o+W2jPs9eXldwkCogl8MaYF ZAJdiZiWaKL4NCFm0i3Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rAqPC-00A75s-1X; Wed, 06 Dec 2023 11:49:30 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rAqOL-00A6E6-1A for linux-arm-kernel@lists.infradead.org; Wed, 06 Dec 2023 11:48:41 +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 1rAqOD-0006ZN-Ng; Wed, 06 Dec 2023 12:48:29 +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 1rAqOC-00DwuR-QS; Wed, 06 Dec 2023 12:48:28 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1rAqOC-00FQzg-H5; Wed, 06 Dec 2023 12:48:28 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Thierry Reding Cc: kernel@pengutronix.de, Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , linux-pwm@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 049/115] pwm: bcm2835: Make use of devm_pwmchip_alloc() function Date: Wed, 6 Dec 2023 12:44:03 +0100 Message-ID: <237e4923fbc4e78e30fb4103b584557ac43a2458.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=2030; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=3HJ0Pbjomc2qLgbU80jfmvd9E4mLKNQSk//ghXZNiWI=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlcF6aTJO42ldOoRbo7Qeurk5gIk5AyGFCqJ2lm Psn+nGMSXaJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZXBemgAKCRCPgPtYfRL+ ThZvB/4oB9tNHbpvjo3o7cnjwVrFsTwmTw1KPh5NzrI+LRFqgcH7RQc0I8egtDMqgideDjX7656 Zb+IkQk29py6rUBo71oWM6XvQPmlaFOa5leXnv/fN8+7r6ikQ5b2BeJRXlMa1HV4K6JwmEZZ3dq OrslI8+tluMDziyEmSClgKvlRQc2kwJyTslTH2qDma4YHV6PxEe7YQiGAUQAQZjZD6/10u6geWk BEKtM34ubXVyM+RKukyF707X5iIJLgNN3al1c9GINe0wHBQn9JKB81NmsCIyHh01V+YoSdCvygH rWd2dkYdOF3asc2DjHwcBTo3XXIlfZhk79TL8zdXwi7gIhjV 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_034837_408249_0AB81CE2 X-CRM114-Status: GOOD ( 15.71 ) 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 | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/pwm/pwm-bcm2835.c b/drivers/pwm/pwm-bcm2835.c index ab30667f4f95..826f0494dc5f 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; @@ -32,7 +31,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) @@ -133,12 +132,14 @@ static const struct pwm_ops bcm2835_pwm_ops = { 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; @@ -151,13 +152,11 @@ static int bcm2835_pwm_probe(struct platform_device *pdev) return dev_err_probe(&pdev->dev, PTR_ERR(pc->clk), "clock not found\n"); - pc->chip.dev = &pdev->dev; - pc->chip.ops = &bcm2835_pwm_ops; - pc->chip.npwm = 2; + 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");