From patchwork Wed Dec 6 11:43:59 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: 13481639 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 9367FC46CA3 for ; Wed, 6 Dec 2023 11:50:37 +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=Mh/Y0j8kQr8B3ZgY9NjrKA0Qu3NymiqA7W5gNft/7vs=; b=WW5fZxdwvPMLyH FRrNGxJbyu6oMgn0VuzdzdkT/gNL+4v0q6xszmFPU9BDRCxiggOMoQBmKI3Mue2Z18mdz1GlzmLGL LYD9vzs0xnza1bN2CZ6HmK7u+8Ek6xFOoPRWnBgg18WAahTAJ8zfKk9x8XLWZ7QRR7lin2qz+Z2x1 ocnlbViB6zSVWzr24svQErJZu2fjb0qoweYW7aHd4lZ+MEceMbhOICMv+cEXVrt8OZGa6Ugz2j0iA hLLyNDUVdzbKWZqx1Q5kqdjg7v6PxN7IZGtDlFvzfyGP83VblNBhg0BLMxWNxrpqYVez5jN1/xlDP UqbD0gHbmJP2imcZINkA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rAqPm-00A7dS-05; Wed, 06 Dec 2023 11:50:06 +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 1rAqOT-00A6MK-01 for linux-arm-kernel@bombadil.infradead.org; Wed, 06 Dec 2023 11:48:45 +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=ZKlToSjiEGZ83xnXETQr/vi8fjJoUWRHcQeMMSMSW3o=; b=fgNaOxq5y+JvoqlG3tgz3Refri USjE15Js1ZTqIGc2koB0G8Fpz8JKNaBvJKiAcF47IQdSvicJy/tRidtE8J6UkmR1kbFwplgWLfMbI lBMYWQxkS+Af06zI4LeAM8XIU/MdshFFnOygd71obRPHTjyCTb2fQ2FA2ZTVo/HK5DjgCpA7XlIF4 DGsEknl/sbO6AqyoYyCvy7tgTzBb6BSyqblng9uXqsBFoIT0Gjb1UOY4jprYib/jC/SoTiHfkNbpR nHUNmvSWnpI5bFHkpOwZmpt3J6mpzRiU02i8rzwdIJCMIMDo/oGw88GLrs5nYa/6sewrLeU7EOceR ijGnSLqw==; 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 1rAqOP-0059Vq-2j for linux-arm-kernel@lists.infradead.org; Wed, 06 Dec 2023 11:48:43 +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 1rAqOC-0006SN-QW; Wed, 06 Dec 2023 12:48:28 +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-00DwuD-43; 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 1rAqOB-00FQzQ-RA; Wed, 06 Dec 2023 12:48:27 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Thierry Reding Cc: kernel@pengutronix.de, Hector Martin , Sven Peter , Alyssa Rosenzweig , asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-pwm@vger.kernel.org Subject: [PATCH v4 045/115] pwm: apple: Make use of devm_pwmchip_alloc() function Date: Wed, 6 Dec 2023 12:43:59 +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=2027; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=H/RSyrPQVoPBPHhFRtxTr/CSeZbddhD6RGCOV6q7+1A=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlcF6V1Epgti1xujvaXjqhsNLwQlW5a2CuH3bzA 3a0pavAjWaJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZXBelQAKCRCPgPtYfRL+ TtL0B/91sy7TDyXtcU0s0Gk4eKxqOcRdDqDh6/b1Q6vr2qYFALhXjW5VZAqx6ySvl5UD9FzhXMg d1xOqK9T5zCxaqvfRQEvKoV3tC8MrgTF09/S6OPQOLj7hjMx2DPg6XSmKZUw5Rf8/yMq0oiI/qx AsjeUnCYndlBlFggljlaxWX+N8DwH8JCfYcN4QQDzSfe7ebpMEbb8dMsR1b0WReff45qLYXu+qx +PPlFvEHN8Ul1xCfEUDHhdXtHxXCU+/MlatAn6v8CBED84+Ok+ZTQKm1QggXH5/gJ+fqQcUSm/b Ar+6qBj5S7TZGoZuYBWprVCw6TzjmH4ZxjucAeOnRI5S4sZm 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_114841_995265_5FE39A34 X-CRM114-Status: GOOD ( 15.08 ) 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-apple 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-apple.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/pwm/pwm-apple.c b/drivers/pwm/pwm-apple.c index 4d755b628d9e..6e58aca2f13c 100644 --- a/drivers/pwm/pwm-apple.c +++ b/drivers/pwm/pwm-apple.c @@ -32,14 +32,13 @@ #define APPLE_PWM_CTRL_OUTPUT_ENABLE BIT(14) struct apple_pwm { - struct pwm_chip chip; void __iomem *base; u64 clkrate; }; static inline struct apple_pwm *to_apple_pwm(struct pwm_chip *chip) { - return container_of(chip, struct apple_pwm, chip); + return pwmchip_get_drvdata(chip); } static int apple_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, @@ -103,13 +102,16 @@ static const struct pwm_ops apple_pwm_ops = { static int apple_pwm_probe(struct platform_device *pdev) { + struct pwm_chip *chip; struct apple_pwm *fpwm; struct clk *clk; int ret; - fpwm = devm_kzalloc(&pdev->dev, sizeof(*fpwm), GFP_KERNEL); - if (!fpwm) - return -ENOMEM; + chip = devm_pwmchip_alloc(&pdev->dev, 1, sizeof(*fpwm)); + if (IS_ERR(chip)) + return PTR_ERR(chip); + + fpwm = to_apple_pwm(chip); fpwm->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(fpwm->base)) @@ -129,11 +131,9 @@ static int apple_pwm_probe(struct platform_device *pdev) if (fpwm->clkrate > NSEC_PER_SEC) return dev_err_probe(&pdev->dev, -EINVAL, "pwm clock out of range"); - fpwm->chip.dev = &pdev->dev; - fpwm->chip.npwm = 1; - fpwm->chip.ops = &apple_pwm_ops; + chip->ops = &apple_pwm_ops; - ret = devm_pwmchip_add(&pdev->dev, &fpwm->chip); + ret = devm_pwmchip_add(&pdev->dev, chip); if (ret < 0) return dev_err_probe(&pdev->dev, ret, "unable to add pwm chip");