From patchwork Wed Feb 14 09:32:32 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: 13556181 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 7CDAAC48BC4 for ; Wed, 14 Feb 2024 09:39:56 +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=hwitHESY5vA/cpZUgOPWs+hiHplyV0s3ZLTe+XDE0tI=; b=aRJZX3TJk2eFRl 9foORU0YZ3XPgGAEVmmfwXGwOSY7jwkJ7oepgMdbWVWzk7P34uIudEo86Y1XoCAMaIXNfwMmrEneZ Z7gfvMGQB3tvEM5S1G5aAHhoLHrNS8bwALBqZ9qyI5xp6gG525KA1MhmNKU/xvW+vR0VZkpV1szxd 9EnOxr9T5dAFQ7mUw/P66ZZ2mnAUZY+VNVc6C2437qnbo+/3Uorjf4g/MKDvFmR+6yBRIcg+tM2M2 iU8uy+Vxil6icis7N+xpnbgSdY9aMDnIUg6mYvUECGzE+SesJHczAWFZeBjGCmqfHXlWmN4pZhAJO UlK0tok+Yegdm0tlxG4Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBk6-0000000CO75-2dgd; Wed, 14 Feb 2024 09:39:50 +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 1raBfW-0000000CKuM-1tpq for linux-riscv@bombadil.infradead.org; Wed, 14 Feb 2024 09:35:06 +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=i3eIb9BzQ77SWxMC1T0epndA/vP1rDDhxpiHKfwp8PI=; b=LHVaNxZGTwG/oxB8EFrTDGLgUb oavcKpSikcep9Y0ES+EAMqOOaFYuAWj2Q0Hy0qZvlV1MOaGsdDI7Ubjbdyz5dNoR242GsVVnWVsmP iLpt/Wg8CsqCxdL/C1Z90J48pvvQFC0SvpAb2lWELQLurkEaydgaq/55NTCNOnXtld9pSP7mprgdd A9uIU61rOSMnJ8ToPqGFmXklqumernKUIVRd1nv9LmzQCasLblHcc/P9wkVh+swgd/PM52ogW0re4 gCUodpvzyq+VaXrdYCcsy8YyJA0AOt010TE9cZT27wtDEDVP6dxXIFZhfILmE5euDvoWtY/GNY0fT BMAjOdFQ==; 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 1raBfE-0000000GAXN-2PYr for linux-riscv@lists.infradead.org; Wed, 14 Feb 2024 09:35:02 +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 1raBf4-0005bk-6m; Wed, 14 Feb 2024 10:34:38 +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 1raBf0-000fFD-1R; Wed, 14 Feb 2024 10:34:34 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBez-004Y6v-36; Wed, 14 Feb 2024 10:34:33 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Palmer Dabbelt , Paul Walmsley , linux-pwm@vger.kernel.org Cc: linux-riscv@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 105/164] pwm: sifive: Make use of devm_pwmchip_alloc() function Date: Wed, 14 Feb 2024 10:32:32 +0100 Message-ID: <30a4cacafe2c323f2531dd1c1126f0bf0fe5e03c.1707900770.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=1786; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=eEmGHdSWNvR4ed02g4CrTc8o2T2daS6ifGT2/J93aKM=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIjDMoEOaUlUw5z3jDQXxi7KNqSviZi6PZrRK BeNBj/P/qeJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyIwwAKCRCPgPtYfRL+ Tk+XCACssJN1hA87M/LHdxRNCalhRlvEl5FmPlHj26Mkixz2D1s2qdJ50LPNuA8QIiOZP+jWTPR Vxb+7McnUCI3h/dYWDycGmT5wRa5uVy6b9Js6eCAB8nbrlils5cTyzxE3WHMxOHmX2cLZYgBxW3 cl+wOhWEWDwCThY0zEv6QfM8iaTnb81UU4xMWmMqvOZ5VkByRQNf7YeMivaPZbx02Uq+v887swT x0L9rPySQCrUNbQPBmh+jjlyu97p3XaOI5qCOExcOcYIBO7CVpXaJ0h0F+WDzBuSXW8Qs/rCVMT XTcEAbJfZsqmr8CIW4rVUYClwFo1h6CTq/AAXFphdfbgtivq 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-20240214_093449_186480_428756D8 X-CRM114-Status: GOOD ( 13.00 ) 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 | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/pwm/pwm-sifive.c b/drivers/pwm/pwm-sifive.c index 6abe91d2f21c..ed7957cc51fd 100644 --- a/drivers/pwm/pwm-sifive.c +++ b/drivers/pwm/pwm-sifive.c @@ -41,7 +41,6 @@ #define PWM_SIFIVE_DEFAULT_PERIOD 10000000 struct pwm_sifive_ddata { - struct pwm_chip chip; struct device *parent; struct mutex lock; /* lock to protect user_count and approx_period */ struct notifier_block notifier; @@ -55,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_get_drvdata(chip); } static int pwm_sifive_request(struct pwm_chip *chip, struct pwm_device *pwm) @@ -231,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->parent = dev; mutex_init(&ddata->lock); - chip = &ddata->chip; - chip->dev = ddata->parent = dev; chip->ops = &pwm_sifive_ops; - chip->npwm = 4; ddata->regs = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(ddata->regs))