From patchwork Thu Jan 25 12:09:07 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: 13530897 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 10CECC48260 for ; Thu, 25 Jan 2024 14:09:40 +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=QHpIBsgJOaJaeBuVZrKaFVhhAQXq3UTnztl7Q60LgV0=; b=wBS0U7lBqLAb5a qpTxcYnobm2Je2ZcRQmzaFsZJDXnkYY14S5g0FN9cCvayqLgJyotmzEiT8igKynaQSDvaUt6FtoPH 7xzU8sdj/dUIUh+vf7WNxT5AF+X/qz0jxAfAaKvt4O1G4WK/6xTp2lF0hmnjztva3DE8jNykPG+D9 rQEAA50Q8IMARnW6YCU04e2luIqRjn5eQqa/0Qa9Gf48m6wBibMWpUajidQqVa3QXtBrdYmDnwPlR tNJDyL1IWeyXoUELvTcR3tagILdI3honvSNlRrk/d5vjN+K3jJB89ZRwvEIUKnmY0qTM6qRUwTlbG aSlt89T7YH/dxin/4asw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rT0Q1-00000000FtQ-0lgm; Thu, 25 Jan 2024 14:09:25 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rT0P4-00000000FA2-3IGj for linux-arm-kernel@bombadil.infradead.org; Thu, 25 Jan 2024 14:08:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; 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=1UtYQ81IDzSphm6o/E15PsImLZcjbPSxsSzzpRNM73E=; b=uE0wQsM/D+ScT7eROmGwLymFnZ B1Caf5mX3fnEGi5Y1ABi2vOGxEIjOmVqLuXgBtS0vOfOHPOO25fOoDGPnI93LDKst/Scd6vRjdgeN etuy4gS2mQ5M1kgqzlR/j8XgWjt8TusRRZjejo2xSfBR6J6e+bh/WHImvTSCFWFD3X+g8yTnZauJy ZBGqPciW5/ZD7ss1hxbdX5fTdH+9Luj/ODLPJm2t0U2kDtZunQwxc+gK73VJXzRa/4Oimtvyoj+AF 4sLxTUmHjja9wSMgQlq1Lvj+Rw5iys+1HE1KRPvvc4z2DhqRA30O7xXw84ghGtnjf6yI5m7mhdvUK PXknKQNg==; Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rSybY-00000009sDZ-1DzK for linux-arm-kernel@lists.infradead.org; Thu, 25 Jan 2024 12:13: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 1rSyZF-0004DE-Rp; Thu, 25 Jan 2024 13:10:49 +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 1rSyZE-002HRZ-Vj; Thu, 25 Jan 2024 13:10:48 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1rSyZE-007n19-2u; Thu, 25 Jan 2024 13:10:48 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , linux-pwm@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v5 045/111] pwm: atmel-tcb: Make use of devm_pwmchip_alloc() function Date: Thu, 25 Jan 2024 13:09:07 +0100 Message-ID: <929bfbd2695535c73260647e16f44de17ec892af.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=2971; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=Qrt9vaeR4KUuMfztIWBoWRb0aAUfBcwyeUrVK67lMM4=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlsk9uVoZxZ932+hxCc1MLX7pX118ipIVmyxMd7 QEJ8McityaJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZbJPbgAKCRCPgPtYfRL+ TiGrB/9ietXPsxs0oMkY3xy79/6GRlF8x68TjvUWo6tC7zsKbLXZ53MwqX5oBPo7J+iuB6mRJZ/ uH9Sfi80JKlq0LaAc7SoFKRgkN9LrRlXv98D4Mes1pIRpQJ/bierH/KprkGEei5EBVXVlMESWa0 z/13bIk3NpzCGZSHUkhjBI74HIhwaxeH9m1mdCIilmE+yY6q1E9KPe0at0CSC0Sh3srV4R1aUoM kZc3i5S4C80ye/akqyniiltBU1cxNmGugVMF1RNiO3p9J0tsaiI4rYWf5RGNuqrPEepzBk9gPWX qHofFlXGd8ChFgWMoE8DbB+Cp4SYOYblw989mVo3JK0Gkho+ 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-20240125_121313_716192_46435A18 X-CRM114-Status: GOOD ( 14.29 ) 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-atmel-tcb 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-atmel-tcb.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/pwm/pwm-atmel-tcb.c b/drivers/pwm/pwm-atmel-tcb.c index 80121ab81a01..0663685532ec 100644 --- a/drivers/pwm/pwm-atmel-tcb.c +++ b/drivers/pwm/pwm-atmel-tcb.c @@ -47,7 +47,6 @@ struct atmel_tcb_channel { }; struct atmel_tcb_pwm_chip { - struct pwm_chip chip; spinlock_t lock; u8 channel; u8 width; @@ -63,7 +62,7 @@ static const u8 atmel_tcb_divisors[] = { 2, 8, 32, 128, 0, }; static inline struct atmel_tcb_pwm_chip *to_tcb_chip(struct pwm_chip *chip) { - return container_of(chip, struct atmel_tcb_pwm_chip, chip); + return pwmchip_get_drvdata(chip); } static int atmel_tcb_pwm_request(struct pwm_chip *chip, @@ -389,6 +388,7 @@ static const struct of_device_id atmel_tcb_of_match[] = { static int atmel_tcb_pwm_probe(struct platform_device *pdev) { const struct of_device_id *match; + struct pwm_chip *chip; struct atmel_tcb_pwm_chip *tcbpwm; const struct atmel_tcb_config *config; struct device_node *np = pdev->dev.of_node; @@ -396,9 +396,10 @@ static int atmel_tcb_pwm_probe(struct platform_device *pdev) int err; int channel; - tcbpwm = devm_kzalloc(&pdev->dev, sizeof(*tcbpwm), GFP_KERNEL); - if (tcbpwm == NULL) - return -ENOMEM; + chip = devm_pwmchip_alloc(&pdev->dev, NPWM, sizeof(*tcbpwm)); + if (IS_ERR(chip)) + return PTR_ERR(chip); + tcbpwm = to_tcb_chip(chip); err = of_property_read_u32(np, "reg", &channel); if (err < 0) { @@ -436,9 +437,7 @@ static int atmel_tcb_pwm_probe(struct platform_device *pdev) } } - tcbpwm->chip.dev = &pdev->dev; - tcbpwm->chip.ops = &atmel_tcb_pwm_ops; - tcbpwm->chip.npwm = NPWM; + chip->ops = &atmel_tcb_pwm_ops; tcbpwm->channel = channel; tcbpwm->width = config->counter_width; @@ -448,11 +447,11 @@ static int atmel_tcb_pwm_probe(struct platform_device *pdev) spin_lock_init(&tcbpwm->lock); - err = pwmchip_add(&tcbpwm->chip); + err = pwmchip_add(chip); if (err < 0) goto err_disable_clk; - platform_set_drvdata(pdev, tcbpwm); + platform_set_drvdata(pdev, chip); return 0; @@ -473,9 +472,10 @@ static int atmel_tcb_pwm_probe(struct platform_device *pdev) static void atmel_tcb_pwm_remove(struct platform_device *pdev) { - struct atmel_tcb_pwm_chip *tcbpwm = platform_get_drvdata(pdev); + struct pwm_chip *chip = platform_get_drvdata(pdev); + struct atmel_tcb_pwm_chip *tcbpwm = to_tcb_chip(chip); - pwmchip_remove(&tcbpwm->chip); + pwmchip_remove(chip); clk_disable_unprepare(tcbpwm->slow_clk); clk_put(tcbpwm->gclk);