From patchwork Wed Dec 6 11:44:01 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: 13481630 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 4A684C10DC1 for ; Wed, 6 Dec 2023 11:50:16 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Vkmd0vS9q5TH0ni8DObPLYJcG+2w3wu5EQpT5SsPtNs=; b=PvknHysGKwFdeI 0uhCIL69NK9mR6RiMkKXitt68r5fIM4v9kU+GNPhd6BQVtgvshViHYYDPDhH9hnkBWe9a+l4EZvZ9 i56wW0K/+4Gf1fKfEaWMOjLD/IWp73bKNw/SVRIAZVJxSWmArSF5TmZzOT6tbWZEg+zolDkrDzJ/s a/ZPLViStPXu+TCnm2zucrFW1qx3PK+otCAT8bc7rCKUj5DlyFQAaJl76ta0k3IUywSy2ZWs0obH1 pqhrlHha5aMMOBYmVVQ6yDZX/6pYztDzi9L2J84R3RAgz3JIa/Tc1V+jsOYhalnm073jNrcpzT4DU dPwfp7ukTZ11rAKt1Z8g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rAqPS-00A7Kg-35; Wed, 06 Dec 2023 11:49:46 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rAqOQ-00A6K8-1L for linux-arm-kernel@bombadil.infradead.org; Wed, 06 Dec 2023 11:48:42 +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=sJb1PFWDyOb4MLogmUqz5jgrAsyRdihnyS1KA/uCiC8=; b=N2JALHhSUWdz2nPp+94Ddcxc1k Th6c6W/m0wo34olSEsefw3iL5ReY2ZyX6OMXOkjUnUAaHU8BQuEB74hgeFrHU9fU++kS3KAfp00hh cSNcCf7nIEYncce3mIqhgKPLg+kqnSofJTuAv6imqhg7Da8mv332P0rPM9cW8KMS9tmqhQFPQaGMw kY4jBW819JtVFs6zynbw9uaAGUAaff8Xu69+vmIq+nVYceLiSwz255pYElsseiHw7d7ozcI7antpo FVdkzF+e1wkqhuKk90v5+dE5cGOF42qmcrpUrdNRfhE/pKbaX0hxtssnONERAGhxTDSa6B2Ld0bLO dHKvwgSg==; Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rAqOM-0059Un-1u for linux-arm-kernel@lists.infradead.org; Wed, 06 Dec 2023 11:48:41 +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 1rAqOD-0006VI-3n; Wed, 06 Dec 2023 12:48:29 +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 1rAqOC-00DwuK-Ey; Wed, 06 Dec 2023 12:48:28 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1rAqOC-00FQzY-5T; Wed, 06 Dec 2023 12:48:28 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Thierry Reding Subject: [PATCH v4 047/115] pwm: atmel: Make use of devm_pwmchip_alloc() function Date: Wed, 6 Dec 2023 12:44:01 +0100 Message-ID: X-Mailer: git-send-email 2.42.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=gcNSIr60z1Q6ew/5ykPPEZLeTTEjXIN4yXThU5Sem7I=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlcF6X6qRGg89hbyEc6Wt9rR70fC/9oKF0RUiZn HjJvy3q07OJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZXBelwAKCRCPgPtYfRL+ ThQNCACqGX5Ouvuy+KChK/rccIfYF0m8ij2ksq/HoEPFXBSLu5gNkdeKOXVuuWkygHNkGsTDwnc KUu8S4JjPHjboMdShNsmPlMFHga6n9TsSlpo8eaRrqHmPRg9zq5gpK6EWASlz9EtKCyShLjuOMi nPDqBZlAJCtp0si0jE62QVCkN3YsV+n0aIM3eOnDG72LQzGz6GS6MPraAVXkqy5DmLqG13sTinj uSukii6gpYAE6Zn3nq8L7SmwChKf/HToZH0Be9V7auOofd02jHFRUH3ERu6ZIWKsdEYh0SEPVZd 3DLYkvvUWRg0KBCmlkfmekmqQpWshoUByopRNuuJJsyVJTMS 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-20231206_114839_253163_E506DB12 X-CRM114-Status: GOOD ( 16.76 ) 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: , Cc: linux-pwm@vger.kernel.org, Alexandre Belloni , Claudiu Beznea , kernel@pengutronix.de, linux-arm-kernel@lists.infradead.org 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; }