From patchwork Mon Mar 18 16:09:49 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: 13595559 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 5F7B8C54E6A for ; Mon, 18 Mar 2024 16:28: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=C7Dv6NiK5h6T1V60qeKHU7+sNcG2DNRepiVhxr9DPZ8=; b=knSqXW67KlTjAa Q45y7kkrW7JgKJbkiq+9ERfbIkpcs/wNPRgJq8bXs6Z+nCJuIsSCgdDu3BjVhshQZVPE4B0b/WVRh /QRCY3Sc669q+euaGHVrtXn/8xro0bWJ6tnQ/n3UdgG7E7l4NEyMdjDLY3PT4Kv+3qpJtI9hjiSIL uA3K/OaL2gQUKBkz+1MGKoTsVo4GWvhM8lqxStqcIW0riZmCTrrGlPUgRUjgK30vTP0TUExPqljtb fPaZuyhoOh3tN9BuPv2Jw+5yDsvE71q1wyoxqM2qo+ZNKULjNSUkMo0I5jS9QOlQfJgTLzmcYStGm l28rb3B1so0NHBx35oAQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rmFqT-00000009Emd-2TpO; Mon, 18 Mar 2024 16:28:17 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rmFqP-00000009Ek7-3Z0H for linux-arm-kernel@lists.infradead.org; Mon, 18 Mar 2024 16:28: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 1rmFqA-0007vm-3z; Mon, 18 Mar 2024 17:27:58 +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 1rmFq7-00771K-3i; Mon, 18 Mar 2024 17:27:55 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1rmFq7-0084aB-04; Mon, 18 Mar 2024 17:27:55 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Jean Delvare , Guenter Roeck , Joel Stanley Cc: Andrew Jeffery , linux-hwmon@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-pwm@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH 1/2] hwmon: (aspeed-g6-pwm-tacho): Make use of pwmchip_parent() accessor Date: Mon, 18 Mar 2024 17:09:49 +0100 Message-ID: <5c6a11dd10cd29e0f7bfaa1fdef145523347cb58.1710777536.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=1715; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=0kwrQdVB9fHadW0zcs/zefkApf0unD8BGUorM1zzxmk=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBl+GdO3EeEUQ6nZ6pNdoQlPypXol9wo4WBc8brb /motAhELkWJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZfhnTgAKCRCPgPtYfRL+ TsW1B/4z18EWUeJw8wanzvuSJt/qMpj2oBXKwiEzs+LtnrnJley6qeMoySlIeJ5WW0nVSbG/J8x 49nH5bAVvuR/5lnNT5RxR95dy5lfuYeos4aUzW7/SpMgWmMOAu7XewYt5nl1EYdwFA2YweSM0l8 0VbVlsQubVnIUeb9ab19Y8u9SfvoQRQ2lGD2Ps6hFhPwRSalSVHme23YyDL3zsC0hpO7spSow/b qjCr/BoWYZ1bN8xRYQXqlhjUZF8OGinn2haV7XU7N0DIOlWl1foIDVJk94eO7ucCLQzgCqkhudF y8x+4Sd55CZSPS04U8/MZetP0J/uGr9gzp33ojHyNxVCLjJD 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-20240318_092814_145900_31809F4C X-CRM114-Status: GOOD ( 12.77 ) 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 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 accessor function provided for exactly this purpose. Signed-off-by: Uwe Kleine-König Acked-by: Guenter Roeck --- drivers/hwmon/aspeed-g6-pwm-tach.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/hwmon/aspeed-g6-pwm-tach.c b/drivers/hwmon/aspeed-g6-pwm-tach.c index 597b3b019d49..64def5e4cdf6 100644 --- a/drivers/hwmon/aspeed-g6-pwm-tach.c +++ b/drivers/hwmon/aspeed-g6-pwm-tach.c @@ -195,7 +195,7 @@ static int aspeed_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, expect_period = div64_u64(ULLONG_MAX, (u64)priv->clk_rate); expect_period = min(expect_period, state->period); - dev_dbg(chip->dev, "expect period: %lldns, duty_cycle: %lldns", + dev_dbg(pwmchip_parent(chip), "expect period: %lldns, duty_cycle: %lldns", expect_period, state->duty_cycle); /* * Pick the smallest value for div_h so that div_l can be the biggest @@ -218,12 +218,12 @@ static int aspeed_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, if (div_l > 255) div_l = 255; - dev_dbg(chip->dev, "clk source: %ld div_h %lld, div_l : %lld\n", + dev_dbg(pwmchip_parent(chip), "clk source: %ld div_h %lld, div_l : %lld\n", priv->clk_rate, div_h, div_l); /* duty_pt = duty_cycle * (PERIOD + 1) / period */ duty_pt = div64_u64(state->duty_cycle * priv->clk_rate, (u64)NSEC_PER_SEC * (div_l + 1) << div_h); - dev_dbg(chip->dev, "duty_cycle = %lld, duty_pt = %d\n", + dev_dbg(pwmchip_parent(chip), "duty_cycle = %lld, duty_pt = %d\n", state->duty_cycle, duty_pt); /* From patchwork Mon Mar 18 16:09:50 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: 13595560 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 CC8D9C54E5D for ; Mon, 18 Mar 2024 16:28:41 +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=gGXwcXxUjOXNwTCxemZ320IKxAthWxDcKe1F8uFUJQA=; b=bQVFKx7wklIxiY iFTPT/CLUUrDUZ7/2J8gKShmQUpQs1UUjO2y0xkWhEm5WLmThYc/2liDu/tHjncOmQBNEgJo8o0L1 jex/ngyYlkMIwBwZiGfwyDgGdk/StZk8aJLhyrddh5UIhwBinY3lJMc+aoarUujos5NuYpOqIFcRW 1Vtxqlf6k2B/HAYkeBOQRkWNfSiIP5tklhy9npWr8onYqe3E2VMD2lqc/xS27WNZM81C1ldG/N5Sv cnxsMhz4UQSeZckP34Vpwm8Rdfp79D/x6iGeecdO1G91X0vSTodT+Z+odJSSwrLB3QKUM+uyhmELC Wch42ZRbJkkm+HxkM4Cg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rmFqd-00000009Eqf-0S44; Mon, 18 Mar 2024 16:28:27 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rmFqP-00000009Ek6-3YkP for linux-arm-kernel@lists.infradead.org; Mon, 18 Mar 2024 16:28:17 +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 1rmFqA-0007vn-3z; Mon, 18 Mar 2024 17:27:58 +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 1rmFq7-00771N-B1; Mon, 18 Mar 2024 17:27:55 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1rmFq7-0084aK-0o; Mon, 18 Mar 2024 17:27:55 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Jean Delvare , Guenter Roeck , Joel Stanley Cc: Andrew Jeffery , linux-hwmon@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-pwm@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH 2/2] hwmon: (aspeed-g6-pwm-tacho): Make use of devm_pwmchip_alloc() function Date: Mon, 18 Mar 2024 17:09:50 +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=2016; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=sxjjnfKkYkaoM01hMvDCymVFNJG1Id02ALiMxmvvPbo=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBl+GdPmc9wc8K9hxy5Ng9vDwdtqZxaBjb9CTpYf Tijn2ND/PWJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZfhnTwAKCRCPgPtYfRL+ TsWGB/0VWpThd/3Z7VCJWJhy7lkvW+lLYQQOv3fW/k7u63Rs78a3iRHCeyEQHW5raCK7FTrDPWS zVrJ//f99TxO5qTBQxebilOzDFycu4eouXx2QTcRy+WgdggIAkakj+JQLIg93keGIUeR/NLqb5e niCxliwGuBAfAXa0a/gQH4dH9FVM5l78POWEfrK9Lf+LXG7EgalDaLnZGSGYjboZ2XKEyXaFfI5 g0L7+UcYO06WP7QN3LGjcft91lea5S9rfeQQWjeZ6Coqy1b6Is2lHKkDBiSatfkunnR6i4finQy 9UoazMLDz5S1r6Bsd2CqwA0h1YS7ausQcattsrUckPU2CmK1 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-20240318_092814_149491_3006FFC3 X-CRM114-Status: GOOD ( 14.57 ) 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 aspeed-g6-pwm-tacho 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: Guenter Roeck --- drivers/hwmon/aspeed-g6-pwm-tach.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/hwmon/aspeed-g6-pwm-tach.c b/drivers/hwmon/aspeed-g6-pwm-tach.c index 64def5e4cdf6..332c02216668 100644 --- a/drivers/hwmon/aspeed-g6-pwm-tach.c +++ b/drivers/hwmon/aspeed-g6-pwm-tach.c @@ -136,7 +136,6 @@ struct aspeed_pwm_tach_data { struct clk *clk; struct reset_control *reset; unsigned long clk_rate; - struct pwm_chip chip; bool tach_present[TACH_ASPEED_NR_TACHS]; u32 tach_divisor; }; @@ -144,7 +143,7 @@ struct aspeed_pwm_tach_data { static inline struct aspeed_pwm_tach_data * aspeed_pwm_chip_to_data(struct pwm_chip *chip) { - return container_of(chip, struct aspeed_pwm_tach_data, chip); + return pwmchip_get_drvdata(chip); } static int aspeed_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, @@ -459,6 +458,7 @@ static int aspeed_pwm_tach_probe(struct platform_device *pdev) int ret; struct device_node *child; struct aspeed_pwm_tach_data *priv; + struct pwm_chip *chip; priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) @@ -487,11 +487,14 @@ static int aspeed_pwm_tach_probe(struct platform_device *pdev) if (ret) return ret; - priv->chip.dev = dev; - priv->chip.ops = &aspeed_pwm_ops; - priv->chip.npwm = PWM_ASPEED_NR_PWMS; + chip = devm_pwmchip_alloc(dev, PWM_ASPEED_NR_PWMS, 0); + if (IS_ERR(chip)) + return PTR_ERR(chip); - ret = devm_pwmchip_add(dev, &priv->chip); + pwmchip_set_drvdata(chip, priv); + chip->ops = &aspeed_pwm_ops; + + ret = devm_pwmchip_add(dev, chip); if (ret) return dev_err_probe(dev, ret, "Failed to add PWM chip\n");