From patchwork Thu Jan 25 12:09:06 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: 13530893 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 C8C25C47258 for ; Thu, 25 Jan 2024 14:09:24 +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=AZCkvJNUHt9WzNLSLqpP2CphaLspLKVGHYwst5Z/YPM=; b=RmahhedTitQqYc DycjRHB7qDLStBd065GXI60IJmMJzG3HazsDzf0ZbUinIcp+Hh2h8x2P9usOwT0AAO6T6MmqchwV4 d1JKchR+z9a6iSSrqntNhjLS8I/Ofy790Cum52Y9jlnF/Pk9zKY3rbIKcJ4edLcAlLPcBHJyRiJvP Y4C/ENUS+M0sTIqBFqzPCu8o4WhfspwV75zyRnagTrtfAtZALIqPPqHWsF1WEc5JBve+2LLc7vNKX p+/8/FkdNHtwSSS5uuDWSVEu8IFlNlulG/+yxpa44Bh5Xsb39ia5WRMUE9jLyEaT3Q8iW0gaWME6X nAhyet9rT0pB5pfVunmg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rT0Pm-00000000FhH-1MKv; Thu, 25 Jan 2024 14:09:10 +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 1rT0P3-00000000FA2-1jk5 for linux-arm-kernel@bombadil.infradead.org; Thu, 25 Jan 2024 14:08:25 +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=iiLNrI2fgyS4sfjxn+B34OIFQ6EgYyW7o7DF+5Uw2x8=; b=pLCceGoSq6AqITAFHALw9FRa5g YcSIn6yNwx+dBHVqdTlvb37vNaki8c41SCmxyC/qIJfWeKJwIDA4y+jpbgwPDRJqY9y83xePfpdM/ +KE0T2hA+7Kt7LUc47YH3kzLddvZQ0FI+bX+eMsnrgA5jC6a6SIaaCzMebz12n6ImbOuoIn5HXzvx O4V/KleXokBA/Rf+swfnkJdp0bYE2U4Ee/xo+wV8NgruzodWyQl+e+G3GAFzKxGJitFglrEbkhGVI rJWA2JqU/4bEj47UUnzPArLPTmyfRL6cViNZyvo/qpP3uowE6TgCd6KFLuAEPE53jeA0GMWcgEcjw zpLRt3Og==; 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-00000009sDe-25ef for linux-arm-kernel@lists.infradead.org; Thu, 25 Jan 2024 12:13:19 +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-0004CV-Bl; 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-002HRW-P9; 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-007n15-2G; Thu, 25 Jan 2024 13:10:48 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Claudiu Beznea , Nicolas Ferre , Alexandre Belloni , linux-pwm@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v5 044/111] pwm: atmel: Make use of devm_pwmchip_alloc() function Date: Thu, 25 Jan 2024 13:09:06 +0100 Message-ID: <3e8a8d3e493f473b02c5551b8185c285f5e3701b.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=3197; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=HqaMlO4bwz8FFPc9Sh9l7EOcdPN0NloTc6UjhKjzABE=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlsk9tTtw+Qm7qFLZSyjxnqBJVeWPjvL8bfTeFz XWo4e9QeSuJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZbJPbQAKCRCPgPtYfRL+ TvpmB/4448JtaJVVnSq1/4PrVO/LXyNG7PFSiGJEkrXeGHZNIkGAoUWHv4byXmsb231Cm9jRimj /EvAD/U07gUCDNW9Wh8jc+HvvR//6XhvJzVA6Oq8iEuhsS6W8wd1pF2ML9IEo9+3H+JabI3B1je aD5mS0zUm2emRS5r7E/BmHEdjSvr0l746f1ja4BW/4a7UMP3iPuQOlbsHmNPHeYx5vRjDlGmvIj 5PuV3epkJ6hLJVeN70jVPS0RQnuRU/Z6qJ7qvaNYFuHaxxPZnoNVbRt8Fk4Ox5k67TOvjcStiZS K265jPuiZjOVozA2tgU8FMAvYPFlaExHlN88Oyl4/0aGYOAW 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_934790_EE11D5AC X-CRM114-Status: GOOD ( 14.61 ) 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 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.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/drivers/pwm/pwm-atmel.c b/drivers/pwm/pwm-atmel.c index 4ef91fe6f147..ab84229161ef 100644 --- a/drivers/pwm/pwm-atmel.c +++ b/drivers/pwm/pwm-atmel.c @@ -77,7 +77,6 @@ struct atmel_pwm_data { }; struct atmel_pwm_chip { - struct pwm_chip chip; struct clk *clk; void __iomem *base; const struct atmel_pwm_data *data; @@ -99,7 +98,7 @@ struct atmel_pwm_chip { static inline struct atmel_pwm_chip *to_atmel_pwm_chip(struct pwm_chip *chip) { - return container_of(chip, struct atmel_pwm_chip, chip); + return pwmchip_get_drvdata(chip); } static inline u32 atmel_pwm_readl(struct atmel_pwm_chip *chip, @@ -473,7 +472,7 @@ static int atmel_pwm_enable_clk_if_on(struct pwm_chip *chip, bool on) if (!sr) return 0; - cnt = bitmap_weight(&sr, atmel_pwm->chip.npwm); + cnt = bitmap_weight(&sr, chip->npwm); if (!on) goto disable_clk; @@ -481,9 +480,8 @@ static int atmel_pwm_enable_clk_if_on(struct pwm_chip *chip, bool on) for (i = 0; i < cnt; i++) { ret = clk_enable(atmel_pwm->clk); if (ret) { - dev_err(pwmchip_parent(chip), - "failed to enable clock for pwm %pe\n", - ERR_PTR(ret)); + dev_err_probe(pwmchip_parent(chip), ret, + "failed to enable clock for pwm\n"); cnt = i; goto disable_clk; @@ -501,12 +499,14 @@ static int atmel_pwm_enable_clk_if_on(struct pwm_chip *chip, bool on) static int atmel_pwm_probe(struct platform_device *pdev) { + struct pwm_chip *chip; struct atmel_pwm_chip *atmel_pwm; int ret; - atmel_pwm = devm_kzalloc(&pdev->dev, sizeof(*atmel_pwm), GFP_KERNEL); - if (!atmel_pwm) - return -ENOMEM; + chip = devm_pwmchip_alloc(&pdev->dev, 4, sizeof(*atmel_pwm)); + if (IS_ERR(chip)) + return PTR_ERR(chip); + atmel_pwm = to_atmel_pwm_chip(chip); atmel_pwm->data = of_device_get_match_data(&pdev->dev); @@ -522,15 +522,13 @@ static int atmel_pwm_probe(struct platform_device *pdev) return dev_err_probe(&pdev->dev, PTR_ERR(atmel_pwm->clk), "failed to get prepared PWM clock\n"); - atmel_pwm->chip.dev = &pdev->dev; - atmel_pwm->chip.ops = &atmel_pwm_ops; - atmel_pwm->chip.npwm = 4; + chip->ops = &atmel_pwm_ops; - ret = atmel_pwm_enable_clk_if_on(&atmel_pwm->chip, true); + ret = atmel_pwm_enable_clk_if_on(chip, true); if (ret < 0) return ret; - ret = devm_pwmchip_add(&pdev->dev, &atmel_pwm->chip); + ret = devm_pwmchip_add(&pdev->dev, chip); if (ret < 0) { dev_err_probe(&pdev->dev, ret, "failed to add PWM chip\n"); goto disable_clk; @@ -539,7 +537,7 @@ static int atmel_pwm_probe(struct platform_device *pdev) return 0; disable_clk: - atmel_pwm_enable_clk_if_on(&atmel_pwm->chip, false); + atmel_pwm_enable_clk_if_on(chip, false); return ret; }