From patchwork Wed Dec 6 11:44:29 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: 13481605 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 1D71CC10DC1 for ; Wed, 6 Dec 2023 11:50:39 +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=Z8JTIyroCbOhmkby3VqsLTvi4uwYIS6TAHCUZ6Ua5q0=; b=o4ActpjOMbxtOs v7y4gASeXl32UckyHmxGeTh2Nsof4qwsgb5nAZCBMclXLUfn3nBePxbgis2PwATDjnYHX1m88pveN jmh8Erz8x+PAZZzGWYD513vlblva2dl9yUo1rd/QGlBvx1wYpuvYbtci3qkaOFLRj0HQHt5ZM1RDX 8rGlVQtks6UWempt2QLv9i+rT04ova2jkMJT71Vlr9UyrNUHtVTNGVDnSUdhKHiPhjABvPpqc4aay 3KPaZCJ6kdCm/pDUSrM/3xNj3HieveYbPDQY51WaLzC3DVnR5FXe7VZjUrm0ja9atGWR7Z1gtCEAo f/82on/gK4LL7udXMWuQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rAqPw-00A7rb-0n; Wed, 06 Dec 2023 11:50:16 +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 1rAqOU-00A6Nl-1w for linux-amlogic@bombadil.infradead.org; Wed, 06 Dec 2023 11:48:46 +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=c9n4SEZCVPXQQDXyLWzJg3IUU8bz3KHBhLU2vHG3sPI=; b=jK5lLccem0zbbLw4zgIBquGC+W 1XPHOyayDodurGDYdjaIl6sDM1xlSO+LtyQgwCWcdriOeep8w4z0+ToLdv8b+z0Y1MITYcPOmE8vy 6tRSXR+3O6vOFIWqAyz71fClcvYog4rWjFZ29SryrX8h6wiC6gM0u3j1M53EAEpRPQQ3U25/27jwZ XHs2ZNtULsEm4v5t4gMoKVrDc4dpa/hHe/IbnlrII4tGuHuJiUaoBFeCaECi717NS1XRlobnvE7Cx qW3JpS1D93u8+06/PMu0dP5fRn0obTIhYJe5QWgWxEIgjPZAKzl/Zwk/vyN7AMU3kLxd/buA0RIQF HeFJa2eQ==; 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 1rAqOR-0059Wn-17 for linux-amlogic@lists.infradead.org; Wed, 06 Dec 2023 11:48:45 +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 1rAqOJ-00075H-KE; Wed, 06 Dec 2023 12:48:35 +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 1rAqOG-00Dww2-W1; Wed, 06 Dec 2023 12:48:33 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1rAqOG-00FR1R-MZ; Wed, 06 Dec 2023 12:48:32 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Thierry Reding Cc: kernel@pengutronix.de, Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , linux-pwm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org Subject: [PATCH v4 075/115] pwm: meson: Make use of devm_pwmchip_alloc() function Date: Wed, 6 Dec 2023 12:44:29 +0100 Message-ID: <513593a5a3d4169abfdabe36de966e5095edfd3b.1701860672.git.u.kleine-koenig@pengutronix.de> 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=2613; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=Ue7uTWHXrmzSMDoSz9IIRmhParo0m7noVVdhB3JyFFM=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlcF7vxeYCUx6b41zw71jBPl2OZ+JAcMvlG6qdo PQxFrMNnbSJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZXBe7wAKCRCPgPtYfRL+ TpQoB/9jwwrVemdukqMpPIKwElv1MMey4NJFPvPG1p0tIYmn+U/Z5Z3oV489iLR0av9F66/FnDO xbLWKh+pioz8cfA1T14ObcO+NG7FDxTIofmGuJJ7BzYf2+NMCn92IFjMHnzXbkAjo+w+lzMjeuG 3QGpJ3WakoDR3vwCcam1GShhWmR8AAUmTWh7PboEqBhVBOvrsE6nU57hsZtC3qm/NkrTKVtygtm LAu51/WUIMPiJveV6KFbstu247sEXwvNQQN1x5K0qh+ql699mwgA5/4W8L3WOUWrdIMHtstlpSP +LqUGZlG9XRJ76wm9xIOrwCHgxohWLky0FXG8FEbnbLGx15I 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-amlogic@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231206_114843_517889_AD96B0F2 X-CRM114-Status: GOOD ( 16.23 ) X-BeenThere: linux-amlogic@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-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org This prepares the pwm-meson 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-meson.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c index 640d6fe63799..187cd6f35cce 100644 --- a/drivers/pwm/pwm-meson.c +++ b/drivers/pwm/pwm-meson.c @@ -102,7 +102,6 @@ struct meson_pwm_data { }; struct meson_pwm { - struct pwm_chip chip; const struct meson_pwm_data *data; struct meson_pwm_channel channels[MESON_NUM_PWMS]; void __iomem *base; @@ -115,7 +114,7 @@ struct meson_pwm { static inline struct meson_pwm *to_meson_pwm(struct pwm_chip *chip) { - return container_of(chip, struct meson_pwm, chip); + return pwmchip_get_drvdata(chip); } static int meson_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm) @@ -449,7 +448,7 @@ static int meson_pwm_init_channels(struct pwm_chip *chip) mux_parent_data[i].name = meson->data->parent_names[i]; } - for (i = 0; i < meson->chip.npwm; i++) { + for (i = 0; i < chip->npwm; i++) { struct meson_pwm_channel *channel = &meson->channels[i]; struct clk_parent_data div_parent = {}, gate_parent = {}; struct clk_init_data init = {}; @@ -535,29 +534,29 @@ static int meson_pwm_init_channels(struct pwm_chip *chip) static int meson_pwm_probe(struct platform_device *pdev) { + struct pwm_chip *chip; struct meson_pwm *meson; int err; - meson = devm_kzalloc(&pdev->dev, sizeof(*meson), GFP_KERNEL); - if (!meson) - return -ENOMEM; + chip = devm_pwmchip_alloc(&pdev->dev, MESON_NUM_PWMS, sizeof(*meson)); + if (IS_ERR(chip)) + return PTR_ERR(chip); + meson = to_meson_pwm(chip); meson->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(meson->base)) return PTR_ERR(meson->base); spin_lock_init(&meson->lock); - meson->chip.dev = &pdev->dev; - meson->chip.ops = &meson_pwm_ops; - meson->chip.npwm = MESON_NUM_PWMS; + chip->ops = &meson_pwm_ops; meson->data = of_device_get_match_data(&pdev->dev); - err = meson_pwm_init_channels(&meson->chip); + err = meson_pwm_init_channels(chip); if (err < 0) return err; - err = devm_pwmchip_add(&pdev->dev, &meson->chip); + err = devm_pwmchip_add(&pdev->dev, chip); if (err < 0) { dev_err(&pdev->dev, "failed to register PWM chip: %d\n", err); return err;