From patchwork Fri Jun 28 06:35:23 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: 13715524 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 DF0CDC2BBCA for ; Fri, 28 Jun 2024 06:36:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:MIME-Version: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:In-Reply-To:References:List-Owner; bh=cxGk+4YqqsWozGTNKL2A0eZoKoj+wj1wN0F9i8w3Ggs=; b=TEJfqNo9rum0a0gp1fu5+YPVrM xHWwSfl+YL8Ad1KkTfH4duNYJ4VQ60ZZNhtPXHlz7bXCdQDgIiZet2cTWHu0JbtwKrWEQw1w8pF9a Iv6/N4gWfs+X8/dIejaWBHlYrq188ObduufhkApINaMcMUe/NuQSXqgQnloQciNM6BEof5aVLS4eJ Yyr2S93t809aXq/L83bEOx0pFNv6N4j9TdWR46kmJSqBaPm39fMaeH6aXOEg3hAAnzas9cQKdFmpm 2mrCb3R6J1gX7a8UmaW7MnerpFWKAUcIrpA3BQogBIsD3w7M2DvwRHhr2UweKz8Vaj1exxzlZErZb Fbl+Camw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sN5D2-0000000CmOy-2VsT; Fri, 28 Jun 2024 06:35:48 +0000 Received: from mail-ej1-x62c.google.com ([2a00:1450:4864:20::62c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sN5Ct-0000000CmO0-2xhu for linux-arm-kernel@lists.infradead.org; Fri, 28 Jun 2024 06:35:41 +0000 Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-a6fdd947967so24810066b.2 for ; Thu, 27 Jun 2024 23:35:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1719556538; x=1720161338; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=cxGk+4YqqsWozGTNKL2A0eZoKoj+wj1wN0F9i8w3Ggs=; b=BfUngqMTNNQRNEkEMvcwkgZ1Dix5KhG5RBnI4bqFSWGCAkXouSTqOcvVP39Us8un5k G0UC1+1L6yaGOngdpsl2mZ5cas5WLQRJ45pBmgMrjtpUNRDJVCN/W0NyE6ucKMP8cJ25 R5tnjZeP1rQljIcAG6hH0Lo448xxjbuulE0d1rqh/93/lwSSVPJN+VZtPSacNHnDs24I E3V0D9tk9pj2Nxiz7ibaW7d6x5yCdD8NAfVJEIlZzFGAyW0YtudsElZyrKXdPlnTUeww 9JmM8PrJabEAeXetHRvsmCDAa4YXHcz6MeLh8FyE7Rzz71jgCsxhsqrJ670Npdj6p0zw usXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719556538; x=1720161338; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=cxGk+4YqqsWozGTNKL2A0eZoKoj+wj1wN0F9i8w3Ggs=; b=ITHjoMWzH7/QPOALartWIoz9Dd7D1AGO3vL5PjtYP5ywZbUSRIuL36l1Ed6SExblyJ 330+W0Q4gV/YnU6dJTwyR1fEO5D+O6qZW82LYH1bwzBRQ6x9J/wBsPkrRpHLaBylppdy J37HbAefQEmBIcGrLt+SdJwLKD+hPy2AHafkFAxYaiPBOIdO0T0QF+JYNGJqLQ0RlT0W pZz0vQPCGTUsMO1Wlp+qbmSZwpBo+NokW90xOBhj0VmJhkIqcIxarkSIrhqkWBF4T064 qV27lKZgxOcRayZEy/FJ4fIvjLkCIdt1InwYD2xAlTXpDIl3l0vpAF0BUKCQIOLCcx3p AWbw== X-Forwarded-Encrypted: i=1; AJvYcCVJ/5uIFU+7YWPcorEcGlIhmMQl9A2dIUiBtmQK9av5FSyYDiXjwK/k1iZ4WS5oCpB4YYaN14RSxmtchL0DoWYw6NXrbjDP/leRYBxcRQcjVTJn1ws= X-Gm-Message-State: AOJu0YwwuOIqtO8gbID1CbvlG9dCFxOewcdnUb9Q7OMeGrZtT2XqioH+ K93obkOfyiCTzPf3dPIiJfBdz0AdaVvwN2bf4ooPxz9tUJuA4UARxNjaF/UqytU= X-Google-Smtp-Source: AGHT+IGNyT3nClEBTHYQMeDvWkm+Sfii1qsZ3JbUNupryrA2bafFHa28Vuxz44XUGZRQd87uAkJ1HQ== X-Received: by 2002:a17:907:104c:b0:a72:455f:e8b with SMTP id a640c23a62f3a-a724599a00cmr1154233166b.0.1719556538014; Thu, 27 Jun 2024 23:35:38 -0700 (PDT) Received: from localhost ([2a02:8071:b783:6940:2d35:3c3:59a:94a4]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a72aaf1bd30sm46024066b.12.2024.06.27.23.35.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 23:35:37 -0700 (PDT) From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Sean Anderson Cc: Michal Simek , linux-pwm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] pwm: xilinx: Simplify using devm_ functions Date: Fri, 28 Jun 2024 08:35:23 +0200 Message-ID: <20240628063524.92907-2-u.kleine-koenig@baylibre.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2725; i=u.kleine-koenig@baylibre.com; h=from:subject; bh=87/dG3jexQmz5+T0cC7pfhCQFwWDm3M0fKcLB+sF11w=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBmflmsZwEH0eEUQHX2tPaAjYOpHdyns2iHZP3nG QOQw2Xu71iJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZn5ZrAAKCRCPgPtYfRL+ TmniCAC4TiW6H0gfqvXle1C8o1sDN05IPP4qLm85XpsCRU9cFuopDd+00IAyZIL4mfNRW/P7G41 EY+KncVfp3XItAsYBADlOgTQ57JWcFntuhM3LWrU0Slo/pVdaAHyHN8H6S9+kEqBHHs6IBfKbxa Vv+/edBlUnJNoCAQz+n+jju0SD2pyPJcG/kySczLZEkWb1sY8eP+1rSKHejlj47zVD020q3sRAM o90cOOBjmwMfcLY8vnb1ZQNIDRwxS/FQuvyToZTg1cK40d+RTO6VjtB76PoVpIBBcXW+QjTtphm TG6vv4fzJ8UfsJT2iaViqStwOZmyJ2ztWQP6kuaaEWMxIly6 X-Developer-Key: i=u.kleine-koenig@baylibre.com; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240627_233539_768663_834C6234 X-CRM114-Status: GOOD ( 15.51 ) 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 There are devm variants for clk_prepare_enable() and pwmchip_add(); and clk_prepare_enable() can be done together with devm_clk_get(). This allows to simplify the error paths in .probe() and drop .remove() completely. With the remove callback gone, the last user of platform_get_drvdata() is gone and so the call to platform_set_drvdata() can be dropped, too. Signed-off-by: Uwe Kleine-König Reviewed-by: Sean Anderson --- drivers/pwm/pwm-xilinx.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) base-commit: 642a16ca7994a50d7de85715996a8ce171a5bdfb diff --git a/drivers/pwm/pwm-xilinx.c b/drivers/pwm/pwm-xilinx.c index 3a7deebb0d0c..52c241982807 100644 --- a/drivers/pwm/pwm-xilinx.c +++ b/drivers/pwm/pwm-xilinx.c @@ -224,7 +224,6 @@ static int xilinx_pwm_probe(struct platform_device *pdev) if (IS_ERR(chip)) return PTR_ERR(chip); priv = xilinx_pwm_chip_to_priv(chip); - platform_set_drvdata(pdev, chip); regs = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(regs)) @@ -263,37 +262,24 @@ static int xilinx_pwm_probe(struct platform_device *pdev) * alas, such properties are not allowed to be used. */ - priv->clk = devm_clk_get(dev, "s_axi_aclk"); + priv->clk = devm_clk_get_enabled(dev, "s_axi_aclk"); if (IS_ERR(priv->clk)) return dev_err_probe(dev, PTR_ERR(priv->clk), "Could not get clock\n"); - ret = clk_prepare_enable(priv->clk); + ret = devm_clk_rate_exclusive_get(dev, priv->clk); if (ret) - return dev_err_probe(dev, ret, "Clock enable failed\n"); - clk_rate_exclusive_get(priv->clk); + return dev_err_probe(dev, ret, + "Failed to lock clock rate\n"); chip->ops = &xilinx_pwm_ops; - ret = pwmchip_add(chip); - if (ret) { - clk_rate_exclusive_put(priv->clk); - clk_disable_unprepare(priv->clk); + ret = devm_pwmchip_add(dev, chip); + if (ret) return dev_err_probe(dev, ret, "Could not register PWM chip\n"); - } return 0; } -static void xilinx_pwm_remove(struct platform_device *pdev) -{ - struct pwm_chip *chip = platform_get_drvdata(pdev); - struct xilinx_timer_priv *priv = xilinx_pwm_chip_to_priv(chip); - - pwmchip_remove(chip); - clk_rate_exclusive_put(priv->clk); - clk_disable_unprepare(priv->clk); -} - static const struct of_device_id xilinx_pwm_of_match[] = { { .compatible = "xlnx,xps-timer-1.00.a", }, {}, @@ -302,7 +288,6 @@ MODULE_DEVICE_TABLE(of, xilinx_pwm_of_match); static struct platform_driver xilinx_pwm_driver = { .probe = xilinx_pwm_probe, - .remove_new = xilinx_pwm_remove, .driver = { .name = "xilinx-pwm", .of_match_table = of_match_ptr(xilinx_pwm_of_match),