From patchwork Wed Feb 14 09:32:50 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: 13556215 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 552CFC48BEB for ; Wed, 14 Feb 2024 09:42:15 +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=WfHKmOY8NJ+UrMWHOw+AMN1G7K5OA0fJDutDxHeSMN0=; b=dxrR90NEuFJtoO l5wC293MPbJrHOB9XSUa3ErztJUHxnC9vVjx7uT2oTLrt97I1/n5bNHX/d5/M08v4VQSoOJqlmPvr BU8He+5tu2R/PAwubRY2tdIqcphUbW4SZnxPAwB1Dj/48PLUW9sGL0JyGYGNgqSgX6mD5h77KaNpa sJpmNsImghXezvDxZ+Jnmz0rX5QV58zKOcECgXVjK5deIMryMe5mhTHTn2t62Ycy8QgBjN2AqG3OV FYTTqGQSy/bVZZNC++xuCTz05ZgWaxvUWPTLsBiifp+meCdWYlyhEZ03/Kd5aZb3KFrPnN36wP6lj zSeFILOR2MgKrr5gDEgA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBmE-0000000CPn7-2bBV; Wed, 14 Feb 2024 09:42:02 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBfB-0000000CKVJ-1uNm for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:34:53 +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 1raBf5-0005rI-Mh; Wed, 14 Feb 2024 10:34:39 +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 1raBf2-000fGK-QI; Wed, 14 Feb 2024 10:34:36 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1raBf2-004Y85-2N; Wed, 14 Feb 2024 10:34:36 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Maxime Coquelin , Alexandre Torgue , linux-pwm@vger.kernel.org Cc: linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Subject: [PATCH v6 123/164] pwm: stmpe: Make use of devm_pwmchip_alloc() function Date: Wed, 14 Feb 2024 10:32:50 +0100 Message-ID: <7e3dbf3b70126038c0ba16331ca8c07cab575bd3.1707900770.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=2455; i=u.kleine-koenig@pengutronix.de; h=from:subject:message-id; bh=Bb8YBorqx+bVzwUkLBbdXoJMd39BE0M+Jl5c4roRp5w=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzIjYOMQ8tTWUOYAVYGSFAA+Yj0Hz+F/f4oxBl Rnfs+qAKOGJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZcyI2AAKCRCPgPtYfRL+ Th1jB/0fMrZDxTfd7Yt+yAj4BDFhl1L44RtBqZZzcd1IUYVMTqIwcgf76dzxY1D879k4DWMYWnH 4Qm4c4MoBoAhwFS7b9es8RzCCxmNZqwHGYASw8WyyaWHsexjOTvI3n436eZzN6KOk5HVrUNfLU4 7CU4WRiFuAUiT8h4DMuJsdqAkFC7Eju+QqYLX4BDITHtibkh58JrxaYobxYvAADm3Q9oNs1V4gc Fb4TFuw69uGkZ4Pv43Z0BBebpEdEi++I9Vr92rIvhxG9UWPDoZ4la0/jkcJOpMA5dkdmE/djM9v xBq2hV0PAPuPFd06QXzl6mQeCCU8+n+7m6mvMjR3bozH6tlO 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-20240214_013445_863158_D5AFE260 X-CRM114-Status: GOOD ( 15.69 ) 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-stmpe 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-stmpe.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/drivers/pwm/pwm-stmpe.c b/drivers/pwm/pwm-stmpe.c index 05f3f38031ee..bb91062d5f1d 100644 --- a/drivers/pwm/pwm-stmpe.c +++ b/drivers/pwm/pwm-stmpe.c @@ -27,13 +27,12 @@ struct stmpe_pwm { struct stmpe *stmpe; - struct pwm_chip chip; u8 last_duty; }; static inline struct stmpe_pwm *to_stmpe_pwm(struct pwm_chip *chip) { - return container_of(chip, struct stmpe_pwm, chip); + return pwmchip_get_drvdata(chip); } static int stmpe_24xx_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) @@ -292,33 +291,36 @@ static const struct pwm_ops stmpe_24xx_pwm_ops = { static int __init stmpe_pwm_probe(struct platform_device *pdev) { struct stmpe *stmpe = dev_get_drvdata(pdev->dev.parent); + struct pwm_chip *chip; struct stmpe_pwm *stmpe_pwm; int ret; - stmpe_pwm = devm_kzalloc(&pdev->dev, sizeof(*stmpe_pwm), GFP_KERNEL); - if (!stmpe_pwm) - return -ENOMEM; + switch (stmpe->partnum) { + case STMPE2401: + case STMPE2403: + break; + case STMPE1601: + return dev_err_probe(&pdev->dev, -ENODEV, + "STMPE1601 not yet supported\n"); + default: + return dev_err_probe(&pdev->dev, -ENODEV, + "Unknown STMPE PWM\n"); + } + + chip = devm_pwmchip_alloc(&pdev->dev, 3, sizeof(*stmpe_pwm)); + if (IS_ERR(chip)) + return PTR_ERR(chip); + stmpe_pwm = to_stmpe_pwm(chip); stmpe_pwm->stmpe = stmpe; - stmpe_pwm->chip.dev = &pdev->dev; - if (stmpe->partnum == STMPE2401 || stmpe->partnum == STMPE2403) { - stmpe_pwm->chip.ops = &stmpe_24xx_pwm_ops; - stmpe_pwm->chip.npwm = 3; - } else { - if (stmpe->partnum == STMPE1601) - dev_err(&pdev->dev, "STMPE1601 not yet supported\n"); - else - dev_err(&pdev->dev, "Unknown STMPE PWM\n"); - - return -ENODEV; - } + chip->ops = &stmpe_24xx_pwm_ops; ret = stmpe_enable(stmpe, STMPE_BLOCK_PWM); if (ret) return ret; - ret = pwmchip_add(&stmpe_pwm->chip); + ret = pwmchip_add(chip); if (ret) { stmpe_disable(stmpe, STMPE_BLOCK_PWM); return ret;