From patchwork Thu Jan 25 12:09:35 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: 13530912 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 CF962C47258 for ; Thu, 25 Jan 2024 14:11:55 +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=id3Ro6DnstWvjlnRSCZQsDo2eyBssWaJdaVDZCHZwps=; b=29QDTwebHBqvlz FfRLfHaN7LKLYWjvzbCDb1Qv7W7b2IYAnYFRhs4ueRtJKlDTcAvRasDQfdui62MA5T1y5D0RAKKyf CtuB/pMX6TtEcfyv+LCduA5JqF41g37OzLw5/3vIIBxuBYxWA005UJt+RcdyZYzQQiUNj1QBIOoK3 PHw84+aaXbDJFa3jaQh2lOOSey3WVvobeUjxJsbU9yAd5TvWf1gmvIHuvJTPK7/uTL6b1lz/+ZYLR OF3qkxZBCazmRX5cPDPWgA4bEaXqIyrOBNOIWSd9OTMAJvcyFyoUMdCBolW8Fwy0alTaVSa+tTH7k vZXd3aoocfFaD6SS9giQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rT0SO-00000000Hac-0JZb; Thu, 25 Jan 2024 14:11:52 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rT0Ru-00000000HDy-0jM2 for linux-riscv@bombadil.infradead.org; Thu, 25 Jan 2024 14:11:22 +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=2mG3vRn+pDbvcg6MR3BIizdJfnx/etk+zu28sOcm6m4=; b=W78Pth4qH7dQUn5M5seH/cVxe3 RCvcCIee+5XHuUMUoaU8otIle+7A8WhJlkuuZ5ZJwtFIa3A1giZfqi4rNaGQ2ajAPC47PajO9RS9f bPSUbywwGKVMNrDZ9Scp4k9VohErCsZd5oTsbScefXLT0ICbzz78jUfIXu69Jljoq5nhhYQl0qFt/ A5y5MbDZo2i2IDzOLwYOnrefp5ue0Kxo7Fv39CD4OaFQj7wchf0CQtByxOZVuF3QUrcoZ+/MExkTX 7e0R0Woxphv+TVnzqwI8s5ibrSiQ91nS9lCgEz7vwJYtLJ7lYrZkMqXYjIHnO/nb0Z6+mK6HD8fd2 FQtRY50w==; Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rSybc-00000005Hfj-3MaI for linux-riscv@lists.infradead.org; Thu, 25 Jan 2024 12:13:20 +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 1rSyZL-0004Rd-Jv; Thu, 25 Jan 2024 13:10:55 +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 1rSyZK-002HTQ-Ef; Thu, 25 Jan 2024 13:10:54 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1rSyZK-007n32-1C; Thu, 25 Jan 2024 13:10:54 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Conor Dooley , Daire McNamara , linux-pwm@vger.kernel.org Cc: linux-riscv@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v5 073/111] pwm: microchip-core: Make use of devm_pwmchip_alloc() function Date: Thu, 25 Jan 2024 13:09:35 +0100 Message-ID: <42fb7450f73c1eb1aa33fb4d896eca75b526116f.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=2673; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=ZntXgTZI9dQH8TWQ+94AuqHDVkwvSRMP95xrnBIG4co=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlsk+Q1dKVs0JHErbbeNbC2+bO54n74VgU1f/GY j14HOAMR2aJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZbJPkAAKCRCPgPtYfRL+ TlbRB/0ZaybKGvcUCZ+JG/DCa1UFPNGyeluNTTtTGh6mZXqSh1Z8ish+tVSLumPbjayVPxhOEEQ FFpE3KnW5NXEaphs7vruX/l/1ZSAqKPlIsRFmkegWqnm1NQ68omVP82COMiZZ2d0BX+q/5vEeYO gbpDE42ms7UxbzRZ0LibcOme9MjXfdV7vpDwNGl3A/P4SILKwlyAzSOncRiPjmYopDU61AWk/tH r0Ffpj0Xei5NlPmHX8nWcDy7Lapz53DSAFSPJSMo//fm05oRot46ObG00Mwxx3e5WVV8kKIaVgt HrRtdbhDplrCx9TW6smjU97PYcEpRHCt3kKVPbxPIoDSRpyn 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-riscv@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240125_121316_965057_75B67DFC X-CRM114-Status: GOOD ( 13.47 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org This prepares the pwm-microchip-core 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. Acked-by: Conor Dooley Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-microchip-core.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/pwm/pwm-microchip-core.c b/drivers/pwm/pwm-microchip-core.c index c0c53968f3e9..c1f2287b8e97 100644 --- a/drivers/pwm/pwm-microchip-core.c +++ b/drivers/pwm/pwm-microchip-core.c @@ -54,7 +54,6 @@ #define MCHPCOREPWM_TIMEOUT_MS 100u struct mchp_core_pwm_chip { - struct pwm_chip chip; struct clk *clk; void __iomem *base; struct mutex lock; /* protects the shared period */ @@ -65,7 +64,7 @@ struct mchp_core_pwm_chip { static inline struct mchp_core_pwm_chip *to_mchp_core_pwm(struct pwm_chip *chip) { - return container_of(chip, struct mchp_core_pwm_chip, chip); + return pwmchip_get_drvdata(chip); } static void mchp_core_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm, @@ -447,13 +446,15 @@ MODULE_DEVICE_TABLE(of, mchp_core_of_match); static int mchp_core_pwm_probe(struct platform_device *pdev) { + struct pwm_chip *chip; struct mchp_core_pwm_chip *mchp_core_pwm; struct resource *regs; int ret; - mchp_core_pwm = devm_kzalloc(&pdev->dev, sizeof(*mchp_core_pwm), GFP_KERNEL); - if (!mchp_core_pwm) - return -ENOMEM; + chip = devm_pwmchip_alloc(&pdev->dev, 16, sizeof(*mchp_core_pwm)); + if (IS_ERR(chip)) + return PTR_ERR(chip); + mchp_core_pwm = to_mchp_core_pwm(chip); mchp_core_pwm->base = devm_platform_get_and_ioremap_resource(pdev, 0, ®s); if (IS_ERR(mchp_core_pwm->base)) @@ -470,9 +471,7 @@ static int mchp_core_pwm_probe(struct platform_device *pdev) mutex_init(&mchp_core_pwm->lock); - mchp_core_pwm->chip.dev = &pdev->dev; - mchp_core_pwm->chip.ops = &mchp_core_pwm_ops; - mchp_core_pwm->chip.npwm = 16; + chip->ops = &mchp_core_pwm_ops; mchp_core_pwm->channel_enabled = readb_relaxed(mchp_core_pwm->base + MCHPCOREPWM_EN(0)); mchp_core_pwm->channel_enabled |= @@ -485,7 +484,7 @@ static int mchp_core_pwm_probe(struct platform_device *pdev) writel_relaxed(1U, mchp_core_pwm->base + MCHPCOREPWM_SYNC_UPD); mchp_core_pwm->update_timestamp = ktime_get(); - ret = devm_pwmchip_add(&pdev->dev, &mchp_core_pwm->chip); + ret = devm_pwmchip_add(&pdev->dev, chip); if (ret) return dev_err_probe(&pdev->dev, ret, "Failed to add pwmchip\n");