From patchwork Tue Nov 21 13:49:28 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: 13463235 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 60044C61D94 for ; Tue, 21 Nov 2023 13:52:15 +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=kSFBp4n6a25YF0tNX8VCkbpBLEbdGybfArmACSHddHE=; b=Hcmk+cEL1mmNAC NwHHDD/Hff/D8mDALLV4ydmiMvYOr8S6e2OlstUm5nbkgNXhEt2ndzKw2DGN1sM2pZ6ssE7dIgsqA KG6QHJ4Bx7wC/b7mTpnawrdXk+wQYFogQ9M7SLp1MoFVVVHKmBwy2F6S/C0rjwJo5V3Vzm/XilzMf sUsaJb9dN4c52FtogYOqHMMiS6NGmB7vNJMiCJ9f4ST4tv92+1ML0imZsMcq41Ro3uRuMzWEI90XZ C3pPILnuZU65CNDaRAFxCgLQ4svp7xYNzbpgLjJROPCGvRbm2VmWq0WiiCvm5XkhQ0GD4x1WQDSOT hQ5lv9aUB0H1CdAtKw4g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r5RAb-00GuLf-11; Tue, 21 Nov 2023 13:52:05 +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 1r5RAO-00GuAJ-2w for linux-riscv@lists.infradead.org; Tue, 21 Nov 2023 13:51:55 +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 1r5RAM-0005Kv-JO; Tue, 21 Nov 2023 14:51:50 +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 1r5RAM-00Aay1-4X; Tue, 21 Nov 2023 14:51:50 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1r5RAL-004xcN-Rl; Tue, 21 Nov 2023 14:51:49 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Thierry Reding , Palmer Dabbelt , Paul Walmsley Cc: linux-pwm@vger.kernel.org, linux-riscv@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v3 026/108] pwm: sifive: Make use of pwmchip_parent() macro Date: Tue, 21 Nov 2023 14:49:28 +0100 Message-ID: <20231121134901.208535-27-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.42.0.586.gbc5204569f7d.dirty In-Reply-To: <20231121134901.208535-1-u.kleine-koenig@pengutronix.de> References: <20231121134901.208535-1-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1222; i=u.kleine-koenig@pengutronix.de; h=from:subject; bh=ItlQpYUXEstYhNFNdEVbRgED9w4SaS6zldtNLGor7lI=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlXLVpzS9AHqndKJ3b8keNfZ49PWB8VdxmjiZs4 qJGkoAPhPWJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZVy1aQAKCRCPgPtYfRL+ TgObCACi5wtfu2xxH2gzWPdAlas2i1mShyDm6JBpQwmJFEBQZUyX/GW3aUWvOboaW/AcU8YPUvs 9EtoP+//Drk7dUns+l2HMuxIKEIao8awYFjkPec1o8znxQeXME9f2h71iDmUuBaQH/+gpTGLfBc WCpwJBO1zA3432hhxApHk3RMzSKCSpL0Eh8FUPbgrT+b8Ibkrq3Ngb4D0w6d6ZUl50F2QTK53iB /zzPUunjLHwCkWTr6eGNnqN+0GuZ+IMv7NbYMXG+vwyixseT/yOzd/CFwrAatjN2+vGuNk99ksE vlDTO77mKp7NKoGdufKMGcWHRXd9wFGHshbY9OaNqTK1YsfM 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-20231121_055152_971542_121DC2B4 X-CRM114-Status: GOOD ( 12.93 ) 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 struct pwm_chip::dev is about to change. To not have to touch this driver in the same commit as struct pwm_chip::dev, use the macro provided for exactly this purpose. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-sifive.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pwm/pwm-sifive.c b/drivers/pwm/pwm-sifive.c index 089e50bdbbf0..c1b412905d9e 100644 --- a/drivers/pwm/pwm-sifive.c +++ b/drivers/pwm/pwm-sifive.c @@ -102,7 +102,7 @@ static void pwm_sifive_update_clock(struct pwm_sifive_ddata *ddata, /* As scale <= 15 the shift operation cannot overflow. */ num = (unsigned long long)NSEC_PER_SEC << (PWM_SIFIVE_CMPWIDTH + scale); ddata->real_period = div64_ul(num, rate); - dev_dbg(ddata->chip.dev, + dev_dbg(pwmchip_parent(&ddata->chip), "New real_period = %u ns\n", ddata->real_period); } @@ -185,7 +185,7 @@ static int pwm_sifive_apply(struct pwm_chip *chip, struct pwm_device *pwm, if (!enabled) { ret = clk_enable(ddata->clk); if (ret) { - dev_err(ddata->chip.dev, "Enable clk failed\n"); + dev_err(pwmchip_parent(chip), "Enable clk failed\n"); return ret; } } From patchwork Tue Nov 21 13:50:12 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: 13463237 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 237EAC61D94 for ; Tue, 21 Nov 2023 13:53:29 +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=b9B416Eb06KygXILqWb6lJ/6QUbe+26Fq48L00Zpnqk=; b=qlvo37VkBZufy0 QwM4NE/hjF/T1tutFuETp4GQmbkHQlz4QlwkLJXD0siWYabR/GlJ2wXAiAe0273/5FFJw2vrJAy5u ey0OyaEO0ERsVNgbJtp++BerADZ4d7lFlY6vH1ATU2ZB5J0O1EFWdkEnvcjCeKVSUnVKk1o1p59LS WLxjYqfMuZzh6xSItgqbzbT7S36TpU/e27yGg5FsnLECi1CeD3dPoZ4V9UTaY5l/eJA8OzZY57K+I z/OM/l5z3oosKYv455UguI97DWLl2QD7lzs7k2kuhR4yLv/8Jl3dbQArfmSgyZ/FZeHaWvQqFe480 m1+JB86BvYMnyLc771lg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r5RBm-00GvfX-19; Tue, 21 Nov 2023 13:53:18 +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 1r5RAe-00GuOu-1e for linux-riscv@lists.infradead.org; Tue, 21 Nov 2023 13:52:13 +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 1r5RAY-000616-Ff; Tue, 21 Nov 2023 14:52:02 +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 1r5RAV-00Ab0i-An; Tue, 21 Nov 2023 14:51:59 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1r5RAV-004xfX-1t; Tue, 21 Nov 2023 14:51:59 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Conor Dooley , Daire McNamara , Thierry Reding Cc: linux-riscv@lists.infradead.org, linux-pwm@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH v3 070/108] pwm: microchip-core: Make use of devm_pwmchip_alloc() function Date: Tue, 21 Nov 2023 14:50:12 +0100 Message-ID: <20231121134901.208535-71-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.42.0.586.gbc5204569f7d.dirty In-Reply-To: <20231121134901.208535-1-u.kleine-koenig@pengutronix.de> References: <20231121134901.208535-1-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2613; i=u.kleine-koenig@pengutronix.de; h=from:subject; bh=m4GyQiFXFJaqNI6WOpp3CmU9hg+F8DEVlbs8fT7JIU0=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlXLWZSTYln9e9/w1RE6dBuatGQK2RNYSXM6EYF CszlHEPUGeJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZVy1mQAKCRCPgPtYfRL+ Tso6CACWEICz+Jh2/S6FDrY1o+5J7hFt6zyH2dcAUsmNBuWJ4ZqL4miE/SUO657rMaSUg9Wtkhy wrFk8QVsIS04DXx4wHU1gic30T/u/3U7GisM5aBAwGKZ4S+xZy1TMkLOM9rOZxTJ21uecn8GM8G CEe+cLYLMAGgAJg/bfJYd5VkX9zCifzLtblcuAghcXnJSLVuutfJ8b7BHD9Xw59lRGWMFmz6jV0 nasGBbYyqmfwI8i8evkJ/BZo5i0cK4cCbXUyUbqnVSoI8LpAPwoZDKwgwLxn3LrWfQ2jNWr4e5y MqOLZ/CXnwJhoh0PzYy7JvOglfnnUh/Bk8uFWxLds8X3iQ4Q 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-20231121_055208_586025_D56944D3 X-CRM114-Status: GOOD ( 14.38 ) 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. Signed-off-by: Uwe Kleine-König Acked-by: Conor Dooley --- 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..6e0c2cbfc120 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_priv(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"); From patchwork Tue Nov 21 13:50:25 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: 13463236 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 BFCA4C61D94 for ; Tue, 21 Nov 2023 13:53:18 +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=CZ7xwrhez45ayCRHWJGt0zcisKobRagC40biKRr4Fhg=; b=cdnCTAdNwEVwtu yBCz4dgpCBY7bdMMfsBKbBXHP1k1NwDdc3rp7pg2ZuEV3vOVl+CP9d5SODJpXc/GJNBUJxmJyBZ5d mVO57OTVUr7mv92vIU/1WaKPIPxspKPfa+w60p5sITt+MyW81Pr3fGA3o9tWxWiTff1qlh0c/RPiY wZ2T7C25xoXaD07gwUTNrkdWOYpzQ3F2tYQqO7SBgBQHI4GuPG9/IroFUU5N+5/9QhEvEBuEzNKUp lozr7O+WGZHnd24wYzjw4yeVBf16+JmOw2t/16cSqHxNuQx60zXs4D/RES3RjgvPWt1VIIJSQRcND 3VBVe+EuM29EdTHiXFrw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r5RBe-00GvY5-1C; Tue, 21 Nov 2023 13:53:10 +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 1r5RAe-00GuOp-1W for linux-riscv@lists.infradead.org; Tue, 21 Nov 2023 13:52:12 +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 1r5RAa-0006GG-Eo; Tue, 21 Nov 2023 14:52:04 +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 1r5RAY-00Ab1Y-0Y; Tue, 21 Nov 2023 14:52:02 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1r5RAX-004xgX-NS; Tue, 21 Nov 2023 14:52:01 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Thierry Reding , Palmer Dabbelt , Paul Walmsley Cc: linux-pwm@vger.kernel.org, linux-riscv@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v3 083/108] pwm: sifive: Make use of devm_pwmchip_alloc() function Date: Tue, 21 Nov 2023 14:50:25 +0100 Message-ID: <20231121134901.208535-84-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.42.0.586.gbc5204569f7d.dirty In-Reply-To: <20231121134901.208535-1-u.kleine-koenig@pengutronix.de> References: <20231121134901.208535-1-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3188; i=u.kleine-koenig@pengutronix.de; h=from:subject; bh=bq6oGUNw3twpEEw3Xxtv6KtBRgfpfqaTqcIAr/U12XQ=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlXLWo2/ckebPr78FuPrlhSlNEcRHW0SDFawSnu FE5IEuUHYSJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZVy1qAAKCRCPgPtYfRL+ Tm4yB/9Q2UkmyOd/IK3SHV3hc2ji0grQMmqPHrd1nXFf+/0joeIH/j2WitSRC8jg+0STOz/ZE89 dLqqsigfURL4IMWWRl6kwVTVb0Ne5S+cPTEaS+jqBLw21FssoixVIGRCKPe3Npzapl55/QqWfEP B7Yjv87a+Dcv+TNMRNTQaapwjniSNGqD+7tqVQXpIsBQIPKx3UZBoUMvZ6KKE/znmGu8JQgPz0O 0K2ZPRrwx7Ngo6QbVpgc3ri09XeZtFZwI6mYeQrnyT94RR12kf+Sc4dvpjsvrnXlVTCogioyuGm LLghtdhRebblOntpnhqc44Zu6vgCtdnu0Yk9dZKCHFGJNaOY 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-20231121_055208_557382_A9FE10A0 X-CRM114-Status: GOOD ( 15.71 ) 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-sifive 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-sifive.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/pwm/pwm-sifive.c b/drivers/pwm/pwm-sifive.c index c1b412905d9e..99b7e981cdd6 100644 --- a/drivers/pwm/pwm-sifive.c +++ b/drivers/pwm/pwm-sifive.c @@ -41,7 +41,7 @@ #define PWM_SIFIVE_DEFAULT_PERIOD 10000000 struct pwm_sifive_ddata { - struct pwm_chip chip; + struct pwm_chip *chip; struct mutex lock; /* lock to protect user_count and approx_period */ struct notifier_block notifier; struct clk *clk; @@ -54,7 +54,7 @@ struct pwm_sifive_ddata { static inline struct pwm_sifive_ddata *pwm_sifive_chip_to_ddata(struct pwm_chip *chip) { - return container_of(chip, struct pwm_sifive_ddata, chip); + return pwmchip_priv(chip); } static int pwm_sifive_request(struct pwm_chip *chip, struct pwm_device *pwm) @@ -102,7 +102,7 @@ static void pwm_sifive_update_clock(struct pwm_sifive_ddata *ddata, /* As scale <= 15 the shift operation cannot overflow. */ num = (unsigned long long)NSEC_PER_SEC << (PWM_SIFIVE_CMPWIDTH + scale); ddata->real_period = div64_ul(num, rate); - dev_dbg(pwmchip_parent(&ddata->chip), + dev_dbg(pwmchip_parent(ddata->chip), "New real_period = %u ns\n", ddata->real_period); } @@ -230,15 +230,14 @@ static int pwm_sifive_probe(struct platform_device *pdev) u32 val; unsigned int enabled_pwms = 0, enabled_clks = 1; - ddata = devm_kzalloc(dev, sizeof(*ddata), GFP_KERNEL); - if (!ddata) - return -ENOMEM; + chip = devm_pwmchip_alloc(dev, 4, sizeof(*ddata)); + if (IS_ERR(chip)) + return PTR_ERR(chip); + ddata = pwm_sifive_chip_to_ddata(chip); + ddata->chip = chip; mutex_init(&ddata->lock); - chip = &ddata->chip; - chip->dev = dev; chip->ops = &pwm_sifive_ops; - chip->npwm = 4; ddata->regs = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(ddata->regs)) @@ -296,7 +295,7 @@ static int pwm_sifive_probe(struct platform_device *pdev) goto unregister_clk; } - platform_set_drvdata(pdev, ddata); + platform_set_drvdata(pdev, chip); dev_dbg(dev, "SiFive PWM chip registered %d PWMs\n", chip->npwm); return 0; @@ -314,15 +313,16 @@ static int pwm_sifive_probe(struct platform_device *pdev) static void pwm_sifive_remove(struct platform_device *dev) { - struct pwm_sifive_ddata *ddata = platform_get_drvdata(dev); + struct pwm_chip *chip = platform_get_drvdata(dev); + struct pwm_sifive_ddata *ddata = pwm_sifive_chip_to_ddata(chip); struct pwm_device *pwm; int ch; - pwmchip_remove(&ddata->chip); + pwmchip_remove(chip); clk_notifier_unregister(ddata->clk, &ddata->notifier); - for (ch = 0; ch < ddata->chip.npwm; ch++) { - pwm = &ddata->chip.pwms[ch]; + for (ch = 0; ch < chip->npwm; ch++) { + pwm = &chip->pwms[ch]; if (pwm->state.enabled) clk_disable(ddata->clk); }