From patchwork Sun Aug 25 14:14:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13776781 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 6739EC5321E for ; Sun, 25 Aug 2024 14:16:17 +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:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=3V39aJFJWv5Ox+8nMTcg04luiBvVyWT65eor5O85K80=; b=eRrh2epgJleZrFKk0UKA99zMq5 Gx5fv7U7xJTm3S8sTMiOuALbAS905bu8NoZySRxoFo7qFTSpz6/iqbAMUbspVPuc5OWZUBVy9+TDQ WaTVLuWNDJqa1TW2TzZ/80LQt575jtdW61gOw4Xk+De3UncEBpah9u1xR3ofVpPUObOGIsWtqTTwa 6fQADnoRPbmts/g3hD3z/lcGVBSFE8Gw4gjnu24XZyaJI7D2v+yh3KBeh5Q7p0wJVsjY1vTI5tM2+ XDT/0UZ4qopdHcz7Fjvz0hWnj96doBxLFVcNNnd0XuFvmJvsgkmFhqT1u8yziIFBWs2IBZtfJN2Iw Kueolf4w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1siE2K-00000004Sja-3ASX; Sun, 25 Aug 2024 14:16:08 +0000 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1siE0p-00000004SGp-2c84 for linux-arm-kernel@lists.infradead.org; Sun, 25 Aug 2024 14:14:37 +0000 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-4290075c7e1so4344895e9.0 for ; Sun, 25 Aug 2024 07:14:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724595274; x=1725200074; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=3V39aJFJWv5Ox+8nMTcg04luiBvVyWT65eor5O85K80=; b=RUmoLr72UQgXesvBIfd/CoGwtlkO+DeOXRhZvl3pZvt5H0rA2OrBPLtOpDoLCqe65M zNkoL8x2zZQWganiM9nx2RXQTwCp6auADEUZ6eQ5rFyZxNvJCViij0u3ASYqHeSQX2CW wAeB3Q0fbI9CNGnSIzKfa9TFta5RaL8r/brWUrVMwxb8zyhOeNC4SSzXHYFuBXygsRly TxzaMXE1tJIy5eTQbREn5netPusEeq5YtF2KMUoLnkXSKw/3HMWDk9stsGHTaNNp6YH5 pdVekEyYDk4k6cws1SWOKPGVxVSW5AxuPNfctz9gV3PUW/4M/KGIsvmsIBE5Zzr5NI4j b6kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724595274; x=1725200074; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3V39aJFJWv5Ox+8nMTcg04luiBvVyWT65eor5O85K80=; b=gq2eqIf1p+vTyKSOC1F/MncxqxjY3YxEB00G63h+lWrgVUoWVlKoPzXKnVrlKYZqsJ d4NYg1Z9E/mO2iQb8gQKJWzWgh00Yx9acpfvChvaeepJ8550RNlQf53mx6dItPqK5Mgx IfOOciwsvl+19ueCX220HXqTHsB18tNrwm0uvsO7VFFJYQ+cTUGpXIDGuU2aXhl3W9Iz DHazGocwTfY6potXNStIymAIOL+Zvzmj84z75kLYOTENvbJuKpZIbQJEtuYp0Iszg/2I f3BN9EreeLMK+j4dZHhcb0KTx8u3tFyxzCVmvcYqzO/1v2qlPGBRNM8NgBPm2SZIQUDb 9FMQ== X-Forwarded-Encrypted: i=1; AJvYcCXsFazg9eLpezT0J3Ufb09JQTUi/SXyAAvPL9EqhmuFhc25wGUUuBIgsKA7unS52CQE6OnlKEO2QN5psde3nQQC@lists.infradead.org X-Gm-Message-State: AOJu0YzGbJDMq1LDDhC6Q+TYecRd6roKKuhPsiqa7jLVhSShVEzBTa6j jXe8Dj3YWaoPbTGh1ZzYieyHoy9Md+GVr4aO14hpUADQ2mn/I2zzF6oZ83HXXno= X-Google-Smtp-Source: AGHT+IGxaU5SPPeM8id8GkXJPuRmYySTf3YFVPhWqsLL0MARUSWhix2AIa7U5LEypfPKdiEqh4SA5A== X-Received: by 2002:a05:600c:3b8b:b0:426:67e0:3aa with SMTP id 5b1f17b1804b1-42acc8d50f1mr32658585e9.1.1724595273921; Sun, 25 Aug 2024 07:14:33 -0700 (PDT) Received: from [127.0.1.1] ([178.197.222.82]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42ac5162347sm122556045e9.23.2024.08.25.07.14.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Aug 2024 07:14:33 -0700 (PDT) From: Krzysztof Kozlowski Date: Sun, 25 Aug 2024 16:14:24 +0200 Subject: [PATCH 1/5] reset: berlin: fix OF node leak in probe() error path MIME-Version: 1.0 Message-Id: <20240825-reset-cleanup-scoped-v1-1-03f6d834f8c0@linaro.org> References: <20240825-reset-cleanup-scoped-v1-0-03f6d834f8c0@linaro.org> In-Reply-To: <20240825-reset-cleanup-scoped-v1-0-03f6d834f8c0@linaro.org> To: Philipp Zabel , Antoine Tenart , Sebastian Hesselbarth , Damien Le Moal , Palmer Dabbelt , Vladimir Zapolskiy Cc: linux-kernel@vger.kernel.org, Damien Le Moal , linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1147; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=joVnS8DmY0g4Y+2gErHi2Nv91aaUMO657tgyX7t8ZFA=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmyzxCjY77hkWpo20MJfyjjnVxsKR95SKAeU/iu Y3zJ4/suN+JAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZss8QgAKCRDBN2bmhouD 1/knD/9qX7o6/PZtVNH2lJW8W33eM3FNJFkdfkdS5NFkRnuq3XXEzDEAZLSSv6V/pWOYUEuiS0n OO6zl+0bae9XYGJi++SiuGPQBh8B6+5oRMSq2NNF+xcAkq18NJzU7HMi1wR2G6O9qauYQfvL+UD JR8TFFHdo+8DEObsVCOEA2ODYNY1+T4ABgXQqfOICeeQyWedx3g7BQ+Wn1ixGEQtvOjACRMjJ6H bKo3D7lFjZQ4sMrVTvkRv5UDVx82kBcS+g7QaTMefWaT6V4//kJojlV9rB3XmoOPSxHb1SEbdkr /+O5k2BFjG6wnjIwZhEKCBw5l25Y3IHD+ocwkt12CnOffinirDqQOiZ3yQlq2vQdLYxO9dT9hJl cysTeZ4B5BSfg2PpfjKB0ItoTeUldc2ZF+5CrO/8AgCxvyvumSAslG0SGGbpjeyX8bdx60Dxkxt iy843maH30+bYknaIMDKuY0lwb6p+fCtPR5/fnDhZp2j1wagrZmfZqux4PR3Cs8SUWAcyzH3/bR GwOdyZKbYs3Gqgt3kKrUdRs4rOpOhVHA2lsf846AVXufeF7FDtpYav5WtOTno+vngsU5cDeD1n7 FV0UCpBnyGd61GcPxxbr1VvPpn+WnqXlRmZ4eCApcxWKPsDCn1TdmUg9Ib0+TTu7rEZ9/BJMBpH xTPG14fHg7JSC/Q== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240825_071435_700331_AD82494B X-CRM114-Status: GOOD ( 12.88 ) 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 Driver is leaking OF node reference on memory allocation failure. Acquire the OF node reference after memory allocation to fix this and keep it simple. Fixes: aed6f3cadc86 ("reset: berlin: convert to a platform driver") Signed-off-by: Krzysztof Kozlowski Reviewed-by: Damien Le Moal --- drivers/reset/reset-berlin.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/reset/reset-berlin.c b/drivers/reset/reset-berlin.c index 2537ec05ecee..578fe867080c 100644 --- a/drivers/reset/reset-berlin.c +++ b/drivers/reset/reset-berlin.c @@ -68,13 +68,14 @@ static int berlin_reset_xlate(struct reset_controller_dev *rcdev, static int berlin2_reset_probe(struct platform_device *pdev) { - struct device_node *parent_np = of_get_parent(pdev->dev.of_node); + struct device_node *parent_np; struct berlin_reset_priv *priv; priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; + parent_np = of_get_parent(pdev->dev.of_node); priv->regmap = syscon_node_to_regmap(parent_np); of_node_put(parent_np); if (IS_ERR(priv->regmap)) From patchwork Sun Aug 25 14:14:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13776782 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 E0AC1C5320E for ; Sun, 25 Aug 2024 14:17:07 +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:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=+vyI734cRrZFj0A/p/jgke1T1ninVILNTlfgxfQSwKE=; b=zpCpilrTlLl70+Mk7R5OuYqOq5 xv+yBxBCCRV9nRRxch7Ud4NSJkuIlSDP48S1kl2ga0jgRYxjWeKj3v8701IcnAHQjU0WQzLZN/iBG WOZ3hV5hVsKdPr9k5uUJupjZULkqYDEGcx/DZqm1iJMlXhqa/HPB4JptbZeOdowOjDjx5ExIROFDX naZGGUt1cZhoI1kT+AZ34MOpfdvDGHOrV8RdkDWWr4QCbLrhUHf3HGUu3g7QIxEBWq+qy2OpYWnqb Rh5kNbbFp4tYs7jU9zL7a082+M/WOFrlT8Jv9y2AzjnSwc6lT7ZLg1BxSVxMWOINbK1nJcktASMg+ C6U4/eqQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1siE34-00000004Svh-3Svk; Sun, 25 Aug 2024 14:16:54 +0000 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1siE0r-00000004SHr-09RZ for linux-arm-kernel@lists.infradead.org; Sun, 25 Aug 2024 14:14:38 +0000 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4280772333eso5433865e9.0 for ; Sun, 25 Aug 2024 07:14:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724595275; x=1725200075; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=+vyI734cRrZFj0A/p/jgke1T1ninVILNTlfgxfQSwKE=; b=uY2C2CIq+AkR79a18RDC5srSsUyZMLlyhfG2f+od0VEhn+2kfnMeYltAYwn4Fm0YDf MqUzQ4yE2ijHGWGv1/UcswFzxVVZq/JDoNNAhJmn3R7rSYZdnd8yFXjxmYMWjokpWdSg ghBXJ7FJYE+CPlO+cGPbvPUf8mvW+waouEhFDV9jJxpChKN2Mx1rwcQ6apFZwagyh53T K6auAJyiwZl01zzBe8EqOKgu4gmm/7m0GrSF3J8YwocnACBRYAzN3yFriuXJQta38GAC XtDCF6F8ieByqgf0poJPWbcbDKEzv/AmGa8rKf6aqKLlzmpxH4adUMc4xaD8bNOxl3gM VnrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724595275; x=1725200075; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+vyI734cRrZFj0A/p/jgke1T1ninVILNTlfgxfQSwKE=; b=YFWFzrMAoFWdM1sI9RTtrKabIiGOqjUXceX5aosmg+7zU0U4aZuK7iyDqkAdxhPMUz kVuRaZwpzu1ETMUH5qpjMSV6oMcQvtbfqjfoo7JRNSoRWYu9RtCShJAKY2vC9XvOYpkW /uqsnG73/S/pVTkDK+nW+6TXEjV0dtZ8DP8J0FCqOkiXtwBVqzBafcuJvaqgWC+Kl6ee 4WElrn/T8zoEZ/aap8DCune94zDKWdzwUh7Vptos5VciY7ESmv7k2oQ+h5W1Pu5dW+Vx PHbakZkTbgnKFJTxdM2lBQKzMtId+Xr8NxoBRvZSplwzVbTrUaT70U9mrhxeYMWK4O+k 1q4w== X-Forwarded-Encrypted: i=1; AJvYcCURaDK6tiRZdLe9t+gf/o68tWIG5qP61RRjuFg1qt4sbUQ2Tw9KTx+k2AJwlMinjSeoNbPMvyz1CD32gJhO7ARc@lists.infradead.org X-Gm-Message-State: AOJu0YwbgOftBMYYEMRtIMNmS7kYE7n0hJW7ZD2pSv/rBvP2O+nZkjp/ ME25DFz6OZ1+Uo646s45Mpk53+z1B/Z761788KCklKJlyQ4GkYGcGlykI4c6s1E= X-Google-Smtp-Source: AGHT+IFak5e9TgxMwRV1VQC3TmD/nC7hYru8uGqId4jYQGfP92V0mB5tath7X71OxrZX1Y6HIUhsVA== X-Received: by 2002:a05:600c:1d25:b0:426:6ecc:e5c4 with SMTP id 5b1f17b1804b1-42acca0c727mr34083495e9.4.1724595275253; Sun, 25 Aug 2024 07:14:35 -0700 (PDT) Received: from [127.0.1.1] ([178.197.222.82]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42ac5162347sm122556045e9.23.2024.08.25.07.14.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Aug 2024 07:14:34 -0700 (PDT) From: Krzysztof Kozlowski Date: Sun, 25 Aug 2024 16:14:25 +0200 Subject: [PATCH 2/5] reset: k210: fix OF node leak in probe() error path MIME-Version: 1.0 Message-Id: <20240825-reset-cleanup-scoped-v1-2-03f6d834f8c0@linaro.org> References: <20240825-reset-cleanup-scoped-v1-0-03f6d834f8c0@linaro.org> In-Reply-To: <20240825-reset-cleanup-scoped-v1-0-03f6d834f8c0@linaro.org> To: Philipp Zabel , Antoine Tenart , Sebastian Hesselbarth , Damien Le Moal , Palmer Dabbelt , Vladimir Zapolskiy Cc: linux-kernel@vger.kernel.org, Damien Le Moal , linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1185; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=9pgusit1pxrr+A2/sS7UfW0KAIyXH2HmTDW6oahLzho=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmyzxD9ZG4S/H4bpvV+Ch6/rnPSqPk9mJsU/Jxb DPFQLvB6+KJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZss8QwAKCRDBN2bmhouD 19lyD/4x8fa4AOkKyveVLnoZhsiOq4/EM63MPkrJMxfB9Vfm/yTnK2uzctxkuWPgDgB076mY76k SaMnFfbFkK8VdlwXcAX/zFm0PBTyRXcbKk7Nv4u01b8rHPx9IAHCFOM8hIwGIa03i6XNmsL5Uko t42t2QmGdu6UFGT4kC9GKB5YbpDuZVYys8UZdPTYbwFScrCa3qRrMkZFZJZ8KP2YPGNtRR/F/Ua NqmT68ych37x5XciGnCF23o31YCm6nU5COwcDG6I/N7hWjqMt6f8ur/bRKEJeV/BJWFlK+Y2VHj 2zhkkrX7jC/eVXDm8L/zrU+aIn68h7lrDNgOtp53fekgqoPoQ6VXqmXGzYpChSl8atweHp1gDBr Q0/uc0DWw/Nheal0uryPSodVR2zQ1iqMoCxEPIa/wPHNqOcPOxjFC4OLs2tBViG6jaTrsWuRQBm zpVBbKkvEGSsf9sPZoNLWnyG6k9DnsXaaNoJPRC6EFXmpGJPnCIFAFW1BLmK02AWvLJ1IfZmIv6 Dem+z3xlw1HPDUIc1VjoTAXgLqUVqUFiSWXjd4jYqUtCtbvsNqp8+3iMCsvZAKJuK7RMKQGLwOs l3/2GQjQD7VfbOVodIn3WKUknAfKn67Gdhj0ML4V9Fk3gIyBj93OX8kSoSyTxq2vYb91N1LAfbb 6ZR51YIOEl0TDoA== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240825_071437_114231_93E681B4 X-CRM114-Status: GOOD ( 13.39 ) 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 Driver is leaking OF node reference on memory allocation failure. Acquire the OF node reference after memory allocation to fix this and keep it simple. Fixes: 5a2308da9f60 ("riscv: Add Canaan Kendryte K210 reset controller") Signed-off-by: Krzysztof Kozlowski Reviewed-by: Damien Le Moal --- drivers/reset/reset-k210.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/reset/reset-k210.c b/drivers/reset/reset-k210.c index b62a2fd44e4e..e77e4cca377d 100644 --- a/drivers/reset/reset-k210.c +++ b/drivers/reset/reset-k210.c @@ -90,7 +90,7 @@ static const struct reset_control_ops k210_rst_ops = { static int k210_rst_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct device_node *parent_np = of_get_parent(dev->of_node); + struct device_node *parent_np; struct k210_rst *ksr; dev_info(dev, "K210 reset controller\n"); @@ -99,6 +99,7 @@ static int k210_rst_probe(struct platform_device *pdev) if (!ksr) return -ENOMEM; + parent_np = of_get_parent(dev->of_node); ksr->map = syscon_node_to_regmap(parent_np); of_node_put(parent_np); if (IS_ERR(ksr->map)) From patchwork Sun Aug 25 14:14:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13776788 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 AEC38C5320E for ; Sun, 25 Aug 2024 14:17:50 +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:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=RgnZ6ZqZdmNcLaioI4ubaYNngOpE05oWSti+DXvBHck=; b=b5Py/JQqiteC+I9pkqKrRx/8qM JmdHcEaGf98qW7nhJamkB7zrYSfiXywnJJADOBchwGDFaUTEKuhX2RTv81+IaevHvwWwi0AF8UYfE zT1VPjWuYbKnTW4P1EpW6zZZ2/PjTTxaZvOeGdr2j3Ue/43FVcwB/XDivtRuvD/GBvuZfmG0/eF1r VXwcRXvZZdr27XatXJGMd+CIlJdlX6yat6l5+CDpVhF2PlRhLk8aVx8Hc+KTXoePdjIyP6r4haRy6 uxijN/wik3e131fOo3p7m7kBmklb8a7ca9wQI09oKGxozxNPwAhJAZA3juwbKrdcNBlDNzwC1oH7J kPAg/WLQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1siE3p-00000004T9a-1TMQ; Sun, 25 Aug 2024 14:17:41 +0000 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1siE0s-00000004SID-12Uo for linux-arm-kernel@lists.infradead.org; Sun, 25 Aug 2024 14:14:39 +0000 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4280772333eso5433895e9.0 for ; Sun, 25 Aug 2024 07:14:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724595276; x=1725200076; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=RgnZ6ZqZdmNcLaioI4ubaYNngOpE05oWSti+DXvBHck=; b=UnpXj9sMkUlalAg4cWJ6hJFo/WwRYxSlGRTR0tQlh9UA3l64C559QEPeZELzxt1Hrp kE18GA4cslHI3a+6YlUvQoNDQQXZC9rH8T9gqcUiH8e3paqVdEmudYVmT04YJThC6XRi TVsOtdYwK0mNIckuKhyGpDcwo42fmWI3FNXChrLFGPv5m5M5LCl4xLndZpSK/vCFGDNX tn32N/FQYzOm9+NTuJkOA2HcmSPs6C6XfRKZvMV1MpMoT573ncjxfdOdfj/kJhqWJqhE rn88ITkR5NO/PQcGFWLDm4vcoF8Z1XVQT1WiMnOAPD238UqjtPnV6r8YfkdaVIOZCP++ Y4Bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724595276; x=1725200076; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RgnZ6ZqZdmNcLaioI4ubaYNngOpE05oWSti+DXvBHck=; b=fAg/0a1Z4yL62dc8mLRbE4k8KkB0RHbBqVc3BrM0gJ5oEP2+WJBTmS+QNya+WndDeo uH3KIeJqsIHN/toVdbsCTddRQuo4vZei7vQUmN9ROAsx8TEjGT25R/ErtTRp55j/M4x2 lrAa+dAEugBw21ASvX362kbOf8LyMGitF29aiQqohY1lwk2odrtt1gSMWcDv14QbD02j TZrbZIG+4CnP086s7Bayr3jklbKAhiwS7eDuoUY5UJDKBe62yWYuYxgxB50olOUjIhW3 wAbhmGGIXdmkwsU9IHEyvMKMhotMn3ToMbJUmzdPiLBUSwiabzqpYaVo7ISGFq+zFPdo 9mYg== X-Forwarded-Encrypted: i=1; AJvYcCWN4Wh+bMPRj8MvibPpng41CGBjrrB6e2dOjspvzoGaGtwQFiK563HThshXjO7S/qYjb7E7UP7GDnFk0AizWTmZ@lists.infradead.org X-Gm-Message-State: AOJu0Yx9c0kUS/YGHebFI7kCaiKNf/iiw/jQIII47JlRvxxZbravaG8M T83ah3MQsnknvJCpbGLUdKe0Cmw2KdY7y4uscjQ0yyvMsTwXxzaomNqgU2Rj2fI= X-Google-Smtp-Source: AGHT+IFuxALm/fRk7IdAEl9tHnqRf3lkS/IQePpSj6npJhpr82rrpicyYF4ug/0SBMzTwrc8Ul4eLw== X-Received: by 2002:a05:600c:46d4:b0:424:8b08:26aa with SMTP id 5b1f17b1804b1-42acca01063mr34147235e9.3.1724595276499; Sun, 25 Aug 2024 07:14:36 -0700 (PDT) Received: from [127.0.1.1] ([178.197.222.82]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42ac5162347sm122556045e9.23.2024.08.25.07.14.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Aug 2024 07:14:36 -0700 (PDT) From: Krzysztof Kozlowski Date: Sun, 25 Aug 2024 16:14:26 +0200 Subject: [PATCH 3/5] reset: simplify locking with guard() MIME-Version: 1.0 Message-Id: <20240825-reset-cleanup-scoped-v1-3-03f6d834f8c0@linaro.org> References: <20240825-reset-cleanup-scoped-v1-0-03f6d834f8c0@linaro.org> In-Reply-To: <20240825-reset-cleanup-scoped-v1-0-03f6d834f8c0@linaro.org> To: Philipp Zabel , Antoine Tenart , Sebastian Hesselbarth , Damien Le Moal , Palmer Dabbelt , Vladimir Zapolskiy Cc: linux-kernel@vger.kernel.org, Damien Le Moal , linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1684; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=Ytuccfgs9TsHyxm9hDxL6CEbdGnLEij+BN4ZXAevank=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmyzxEEiERshJp4P/O36tRaMG3GnkMMvYxJ9g39 bFAc2IS7BSJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZss8RAAKCRDBN2bmhouD 104EEACHYXj9r8WaYp2o9fRW7dCF85yE11j+zp1IjAWosumCqGUSVtaVcJW0o6mKFDOTGul1Wmo MGE7W1EzVXd2ZyZNNLAWa51uznABmwL5ZSkg+AyjwrZx1lfZXEzPZb+MKhf46k1xFZ9zoi0Onam AbtiaiV/t2b4em83210TuqxSqsc3eSpkq/AXPN82gw1cHeCNA2H46wvTQ8/rQnBB+nBvPwiaocj nmyC7d3OlrR/xjr7T1ulZN9Or0ze+vm1Y1EVBZ4j84sz/fwmxtFQBNmC6/81lInJ4OScRLCjQvp wlCsXhPQKhluGr0r2UOgtXk84h1kdik+M6u3yL5HNMK1QomVKwfFkFJaHe3UKbnedEJ1DhmJY6v /M1aagcB3QnKmvBfK4XUsgDMJldJs0jQgOxJp0dgd4oY4sK9hgojSs2m3lVpAe/YHT788A876/k C9gRgcuxs8Y2lK6ktL71UuVKnLQwHAOWimTwIDcp8rNJ6naGB5/iITiRkdBh1EC8VRiYrIK3CyS GXP0khpho7KVDnNld4Vu7c1kYdbGqm21HiJnuMCgPl/tX60dfG/NDMu0WxUNKYWnjz6Zd8OWvm4 viMP4fPY4NQ+9emd1ZPd+/JbZEcBj3++KrIc7DKp/Ylzn1+ckWQHIdd/1yATfUUliOQ/kShZjZ3 6L2Gi0ciWufsHyQ== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240825_071438_302454_531D594F X-CRM114-Status: GOOD ( 13.13 ) 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 Simplify error handling (less gotos) over locks with guard(). Signed-off-by: Krzysztof Kozlowski Reviewed-by: Philipp Zabel --- drivers/reset/core.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/reset/core.c b/drivers/reset/core.c index dba74e857be6..c9074810306c 100644 --- a/drivers/reset/core.c +++ b/drivers/reset/core.c @@ -916,20 +916,18 @@ static int __reset_add_reset_gpio_device(const struct of_phandle_args *args) */ lockdep_assert_not_held(&reset_list_mutex); - mutex_lock(&reset_gpio_lookup_mutex); + guard(mutex)(&reset_gpio_lookup_mutex); list_for_each_entry(rgpio_dev, &reset_gpio_lookup_list, list) { if (args->np == rgpio_dev->of_args.np) { if (of_phandle_args_equal(args, &rgpio_dev->of_args)) - goto out; /* Already on the list, done */ + return 0; /* Already on the list, done */ } } id = ida_alloc(&reset_gpio_ida, GFP_KERNEL); - if (id < 0) { - ret = id; - goto err_unlock; - } + if (id < 0) + return id; /* Not freed on success, because it is persisent subsystem data. */ rgpio_dev = kzalloc(sizeof(*rgpio_dev), GFP_KERNEL); @@ -959,9 +957,6 @@ static int __reset_add_reset_gpio_device(const struct of_phandle_args *args) list_add(&rgpio_dev->list, &reset_gpio_lookup_list); -out: - mutex_unlock(&reset_gpio_lookup_mutex); - return 0; err_put: @@ -970,8 +965,6 @@ static int __reset_add_reset_gpio_device(const struct of_phandle_args *args) kfree(rgpio_dev); err_ida_free: ida_free(&reset_gpio_ida, id); -err_unlock: - mutex_unlock(&reset_gpio_lookup_mutex); return ret; } From patchwork Sun Aug 25 14:14:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13776789 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 0011FC5321E for ; Sun, 25 Aug 2024 14:18:38 +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:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=LjmDAWPerVk/U3QbJF8rREKJaY7hIybSzXq0JV4YLzI=; b=DOt/gN6rZmThpJDjKQDUsx32rS f65aP7J/Xn4Fy308LyazX/8FQdZhAFmjaH2Pt9syZ76PUCuVPR/PIqyXCmikY7c0KxHvQUViPk9Eq f5Eh7I7aEsrJPPEaXJJ3Vh3Wq01tW6YsEKK0l497oM8MoXz6I4CBAmJ1ThaVZPm7eHNqFvc/OMS/W IXIL/mvapMuEUV5QvVQFbCsSLWCC/oWRmnnkhP+HYg5IJ2OQAdyIXBLiUqXtE/g6mJWAbRiyflN9Y Vf8oI9W7ry8NEpSc5xRA4ZUbcyYwFxE+mD4rXf2QnHAnHuZwFRtIgwQz8VwO+bsrqqoCxUpg/Mhk6 Lgf7c/PQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1siE4Z-00000004TMG-01uc; Sun, 25 Aug 2024 14:18:27 +0000 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1siE0t-00000004SJC-3CIA for linux-arm-kernel@lists.infradead.org; Sun, 25 Aug 2024 14:14:41 +0000 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4290075c7e1so4344965e9.0 for ; Sun, 25 Aug 2024 07:14:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724595278; x=1725200078; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=LjmDAWPerVk/U3QbJF8rREKJaY7hIybSzXq0JV4YLzI=; b=uiXdqABsSW2c0Prmx6QzKg6snwOOLgLS9XYF1S5JJrFQRHMw5D+IfeNDSt5LOcAqTX +oQJtj6LqImpBJn1i6ATevufPndjcXHdaFGkPa9sjlrVAGt0VytOGFr709/rhzvQdwF2 WrPO1RjYI1a4HH6ty02cqNyt+nwle73dt3x6QIByiNpl2O/I+tqCA/JEjDcjaWcI1WCI zwB6xcwk7FGuh462rko35jHAQhAJ/1WxBBnF1IT5s9TnqBOMdR9eU1NMNaWgiRpNiuUy nl8AU47BHW5XnukmRD277ajiGu7roKN1i9y+UsA61EV90LB6hX6KNeaZOSpf1Ffr/1dJ htJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724595278; x=1725200078; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LjmDAWPerVk/U3QbJF8rREKJaY7hIybSzXq0JV4YLzI=; b=CvOlskUfyevQSSYUai8g+8+O38oKwN3cgSQfzRuGfe9LfhcrSFGhc2gZtECfOtS3/T /qSGvnliZGTONd0j1k9m+5CsG1mUEUQk5wLuKTjfVT/JSBwDr5xIVY5YHnago6QsCTgj DxzWAagbTiTGE4boBHNVQx2Oy7C16MzuYHwUka3dTb6Qyg5F70UHxorhcQBPfWNgYSgi bnRlrZvgWFYtZ+Sn4jQddReir/+XTJKTvax8106s05WCIUNbL/hyQgxWLKo0DFtIKtB6 MII6Hif/SySxMYcOUtvN+zcIcX2l9Vn5fdyj6y7zlinjkUsoxshqPoWG8bC+vJwJoJhA w6UQ== X-Forwarded-Encrypted: i=1; AJvYcCVGMvbGCM0I9OhYIJpoYzty7EkkW3PtKlBLTe/LjslAeF4OD2IZPf/WfyzMaqZWCGnp7ldvi/f79Tv0u/mz3iqg@lists.infradead.org X-Gm-Message-State: AOJu0YydOa9Fh9UG4+GCVmcYzU71vPibmdbfy1ASG+FjAZnAT3UoRDI+ LBU1wC7tKi21hXKUb4D7cYhImrzT85GInqzudWazxAUzEPtIMFkgwGfAucAXJPs= X-Google-Smtp-Source: AGHT+IH4oX5sMG/q4v+zj6KRXeT4WvXHszuUwi0hhOxdOeHlPtcZUnDMGObVsUyIcqEn+TKymiOIXQ== X-Received: by 2002:a05:600c:511a:b0:427:9f71:16bb with SMTP id 5b1f17b1804b1-42acca17489mr32308195e9.6.1724595278034; Sun, 25 Aug 2024 07:14:38 -0700 (PDT) Received: from [127.0.1.1] ([178.197.222.82]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42ac5162347sm122556045e9.23.2024.08.25.07.14.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Aug 2024 07:14:37 -0700 (PDT) From: Krzysztof Kozlowski Date: Sun, 25 Aug 2024 16:14:27 +0200 Subject: [PATCH 4/5] reset: lpc18xx: simplify with dev_err_probe() MIME-Version: 1.0 Message-Id: <20240825-reset-cleanup-scoped-v1-4-03f6d834f8c0@linaro.org> References: <20240825-reset-cleanup-scoped-v1-0-03f6d834f8c0@linaro.org> In-Reply-To: <20240825-reset-cleanup-scoped-v1-0-03f6d834f8c0@linaro.org> To: Philipp Zabel , Antoine Tenart , Sebastian Hesselbarth , Damien Le Moal , Palmer Dabbelt , Vladimir Zapolskiy Cc: linux-kernel@vger.kernel.org, Damien Le Moal , linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1258; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=Y2ICy6i8eJmrbEAyf3hyy7lpPTY6kTvT6Il6a4okjDE=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmyzxFI6hGTgYTOceLNliLoQr+EYniA1tKa5FfQ hePW63+vNOJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZss8RQAKCRDBN2bmhouD 17zzEACJcEdPayjkZvjjh2zSab3uEfc5NqZ4zTN6mSFqJoL5NzpvECKDgVsGtZwP2ra2wuQgDbc B5dfhfLe3E+Y735zsz4tHVXpY+PxkNZC8GSEVyl2Ox48Jz0reWf17m199ANdf30Wx2GXs/VKvit S/2SwK7rwLXJIVYEWADM6VMNbyGQjVfM6H1fVzpkCwEFWyuofywykuRlPszFT7wWwAOYhiWd57d m3PZjW4FICPbwLWDnwidm1cWe3dkeZrg46zVHTgP4JOiZHTca6a016dcRh63UjzG6TtbgUsltCg eIfyqzmHVS3ncCxx7uayrxoMcFQdKEXk5DmpX5oYotPp54PF8v5wFDw4sXuDfghny98AMwrer0x h4y/OoviFaO/wVVPLGeyQIA8/LnYdCqaYN9B6axrS3Lb4I/5hEWi7vh24Sf8DfhfGysMBwNPfX8 XzUuRkxphPFewdQp0RF+EfNbrFYOCViaHdlcQFEOrz6PkIzUC8Z2yoQPCNPJgmS8K+Cu53oYSBL mqmyD0U+++0K4lJSG7D6spDq/ClqaWE+PwwzR43K5HU6oY8gPAJlmIroZ/wZy8OZVG9Kl+bPapY iGzqFEFYtnXXO/IY9yhxytGqXD6lKeruYOwmy6JWYrFLDvOxQz4o83ASiJm/a3MHFFMDxpzwTp1 2Ag8sVPJwTGJSaw== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240825_071439_838968_85F73B58 X-CRM114-Status: GOOD ( 11.26 ) 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 Use dev_err_probe() to avoid dmesg flood on actual defer. This makes the code also simpler. Signed-off-by: Krzysztof Kozlowski Acked-by: Vladimir Zapolskiy Reviewed-by: Vladimir Zapolskiy Reviewed-by: Damien Le Moal --- drivers/reset/reset-lpc18xx.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/reset/reset-lpc18xx.c b/drivers/reset/reset-lpc18xx.c index 28fb85772b3e..e7896e3f1851 100644 --- a/drivers/reset/reset-lpc18xx.c +++ b/drivers/reset/reset-lpc18xx.c @@ -151,16 +151,14 @@ static int lpc18xx_rgu_probe(struct platform_device *pdev) return PTR_ERR(rc->base); rc->clk_reg = devm_clk_get(&pdev->dev, "reg"); - if (IS_ERR(rc->clk_reg)) { - dev_err(&pdev->dev, "reg clock not found\n"); - return PTR_ERR(rc->clk_reg); - } + if (IS_ERR(rc->clk_reg)) + return dev_err_probe(&pdev->dev, PTR_ERR(rc->clk_reg), + "reg clock not found\n"); rc->clk_delay = devm_clk_get(&pdev->dev, "delay"); - if (IS_ERR(rc->clk_delay)) { - dev_err(&pdev->dev, "delay clock not found\n"); - return PTR_ERR(rc->clk_delay); - } + if (IS_ERR(rc->clk_delay)) + return dev_err_probe(&pdev->dev, PTR_ERR(rc->clk_delay), + "delay clock not found\n"); ret = clk_prepare_enable(rc->clk_reg); if (ret) { From patchwork Sun Aug 25 14:14:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13776790 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 C0959C5320E for ; Sun, 25 Aug 2024 14:19:21 +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:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=dPfVC68w4G9TItKcZX9hLfDBOa9Rh2fNT0mcRYJpZNk=; b=NQ2r6wRTE4LzOrstiG4kzM//WB 2aUCE0ud04X4YeARgJ7E+K7IydSnNoqvN8FdJNIcgWIxqdwIrIHs8poFvpkHiUuRzCZvsJW6WG+nP ahU2W6u9wW+8swkP3nyNQmHtabR8Y8ti+G+GoVSmlof8K9tkt2jSWF6eLazVsIfOvtLTz2lKF8IeA VWfNl45ACuqh2W6mBdh6u4Gnm1CeP8oPvKKt2gMxCruY8RPnqR2PZ5qqCTByyZvOXaS8RUrHD057i V7vCLYo4Y4gqz60jUCDxiwBwfyfn64pAEXxH/ST8hdG02eAG0deypGWfC4Ya8STS+Z1TAR7FObLxh YyM1sZdw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1siE5I-00000004TXd-3bQj; Sun, 25 Aug 2024 14:19:12 +0000 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1siE0v-00000004SK5-1rF1 for linux-arm-kernel@lists.infradead.org; Sun, 25 Aug 2024 14:14:43 +0000 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-4280ef642fbso4330385e9.1 for ; Sun, 25 Aug 2024 07:14:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724595280; x=1725200080; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=dPfVC68w4G9TItKcZX9hLfDBOa9Rh2fNT0mcRYJpZNk=; b=hD+65tpTEWtq9ENKXa6rVYWm2o9DjwkzSIIAQ/6ZPh3U8vNqRVirdIdl/E1NC0tFCP 7lHyqXhy4rhkRnLgW2mzQaXc7ymfLI+WoKD4y00eUfumb6hihseGcdOG/hvoGVpSm1Kz kgNDuA4itjv+VClB1qW3uJQpN4uBQJkNGQDx0SaIMy5zFAbU4ak5CAPBpriVboygbBEz VX41uPW+HAmbJfEgvytOdZ7CH4dTgTrSjcNxPysmnfdci32uBNTZgaWGx72HOM9gxm2m RbnEPdtdYtFOthfQQeYhWrUFAbXutY5v7UhzrKS4oXUoPRGzdgggmyy4clnwz9oSnM6U Sr/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724595280; x=1725200080; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dPfVC68w4G9TItKcZX9hLfDBOa9Rh2fNT0mcRYJpZNk=; b=jwuvPPH+z3zXDx/35Zw/E2WqLKg06x9w4gZnIynHbm/zYC5rY6oKgxXB5X/xeh8PjP 5oNyJQVcqqmamOpLP1CJY8sANZkYH1wFcU9kXgIDGbzztuWLzSpoflw1+dzdk49ji3b+ eVHq1qO3qSYirn6d0lTm8mr8OMF0tCF+8JTOHUKr3dKAZbIW/f5OcZBx8cdqO6oslLkH zOmQ0KFxYCl6MEr8KsuzgXoiDqO5KHhIi5rRWH89nx6UVFOwo0RlLiJCKqI8qBxsMp9y jT4WT3ebUKZXOaPWPwvLeBd6dvq357UTbhjGbtO0rHAPjRVg/z9R8VgPrJr0eoATbizh Br+A== X-Forwarded-Encrypted: i=1; AJvYcCUCYFT38JkkKaFH8YZ/ORrqkEdOkEUYYcXSp5lsZzv6dHcAoqwKGbRHXQkKZa5ogBHWuS4TqDdjiWRDJkgGD1+u@lists.infradead.org X-Gm-Message-State: AOJu0YywviASRdKcqqmpIy6lc/Td94kYmmOpQuk9XjH8XgLiABhASxln ehuNuGJUh4PQudK2PnlN0waeMIKFg5FKL2paB/VKmrb+Numy4ZOxnRYNJVXBlD4= X-Google-Smtp-Source: AGHT+IElMKRI5xZ8yzDk8JbJF8qKOxDYwCIunD6hU146I7V15XtRVaFAqCfrraqfYRZZ0YGENwgH/A== X-Received: by 2002:a05:600c:1c1f:b0:427:9f71:16ba with SMTP id 5b1f17b1804b1-42acca112admr31861355e9.5.1724595279439; Sun, 25 Aug 2024 07:14:39 -0700 (PDT) Received: from [127.0.1.1] ([178.197.222.82]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42ac5162347sm122556045e9.23.2024.08.25.07.14.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Aug 2024 07:14:39 -0700 (PDT) From: Krzysztof Kozlowski Date: Sun, 25 Aug 2024 16:14:28 +0200 Subject: [PATCH 5/5] reset: lpc18xx: simplify with devm_clk_get_enabled() MIME-Version: 1.0 Message-Id: <20240825-reset-cleanup-scoped-v1-5-03f6d834f8c0@linaro.org> References: <20240825-reset-cleanup-scoped-v1-0-03f6d834f8c0@linaro.org> In-Reply-To: <20240825-reset-cleanup-scoped-v1-0-03f6d834f8c0@linaro.org> To: Philipp Zabel , Antoine Tenart , Sebastian Hesselbarth , Damien Le Moal , Palmer Dabbelt , Vladimir Zapolskiy Cc: linux-kernel@vger.kernel.org, Damien Le Moal , linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2441; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=3FUpFc5Q6VFd1fQ8A/U87QLsFQnyhnFox4YWGWQ0Hbk=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmyzxGxK3ymr8fJfvYSTHWGw3mhICORfcHW0/ex woHJNmabneJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZss8RgAKCRDBN2bmhouD 15u+D/9Enprg8sJbkA1Du6xadF51tsosIPpeLdcevWdfza41+UoHchX5cxoDdM6x3VHFYX5PSvr Vomw26pQKB8SMQUS38dtxNYBc3yrtp97ZP+t1ryzjTmkPEX7Nl76aJnQgsDxFFqoHepwuupIHCs FUoV6QMXQbjQvINTbf+hIky6dYdBoaYMe6ln95ldHsqc+3hJzfiKkum72zx3hK1kepxrvn7NikR O7dV/PuemP226IU/zwtMmhwCNTRaU+OFVdWrC807JD/Kua7UZ8bERqRR1aZw2p2jyyvXXCsb6yu gehSPqxngcswmzrm2lPn+CRZhKGdpxHLjyzoJX0edDaYAtvUeOlnVxKrm6mV6g0tPjV5p+qfj2P /CYDSpOaNixEpQqahTXrdrx1PW45Y7NVkfPYZaaFSqNLo5R17dbZCq960XCavRAdEXmAPCaVFa9 0TM+Rl5tlPvjpkKutR7FtTrJhq29nVqACJIFbcgK6Z2rr/X7He2hf76yDDfHTQM6xAq079EdQIr eGxBvKCPMoNs3sxD47j8uBxqztQ7eCWvZbGljfM3g2sPWhYi9n16BP95eZt9xH0cPj4nKAmNMWE jbXjXkQ/TK235iBhyt+rEN/t91x9JxGZmALel2kJeKHIejYXTEd75zBGb3WGxS93VDUjVyqBdBu i6S6vCcYnfzEz6w== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240825_071441_504962_F48D2242 X-CRM114-Status: GOOD ( 13.07 ) 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 Use devm_clk_get_enabled() to drop clock prepare/unprepare parts and make code simpler. Change to dev_err_probe() in handling reset_controller_register() error to make it even simpler. Signed-off-by: Krzysztof Kozlowski Acked-by: Vladimir Zapolskiy Reviewed-by: Vladimir Zapolskiy Reviewed-by: Damien Le Moal --- drivers/reset/reset-lpc18xx.c | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/drivers/reset/reset-lpc18xx.c b/drivers/reset/reset-lpc18xx.c index e7896e3f1851..e42b2f24a93d 100644 --- a/drivers/reset/reset-lpc18xx.c +++ b/drivers/reset/reset-lpc18xx.c @@ -150,28 +150,16 @@ static int lpc18xx_rgu_probe(struct platform_device *pdev) if (IS_ERR(rc->base)) return PTR_ERR(rc->base); - rc->clk_reg = devm_clk_get(&pdev->dev, "reg"); + rc->clk_reg = devm_clk_get_enabled(&pdev->dev, "reg"); if (IS_ERR(rc->clk_reg)) return dev_err_probe(&pdev->dev, PTR_ERR(rc->clk_reg), "reg clock not found\n"); - rc->clk_delay = devm_clk_get(&pdev->dev, "delay"); + rc->clk_delay = devm_clk_get_enabled(&pdev->dev, "delay"); if (IS_ERR(rc->clk_delay)) return dev_err_probe(&pdev->dev, PTR_ERR(rc->clk_delay), "delay clock not found\n"); - ret = clk_prepare_enable(rc->clk_reg); - if (ret) { - dev_err(&pdev->dev, "unable to enable reg clock\n"); - return ret; - } - - ret = clk_prepare_enable(rc->clk_delay); - if (ret) { - dev_err(&pdev->dev, "unable to enable delay clock\n"); - goto dis_clk_reg; - } - fcclk = clk_get_rate(rc->clk_reg) / USEC_PER_SEC; firc = clk_get_rate(rc->clk_delay) / USEC_PER_SEC; if (fcclk == 0 || firc == 0) @@ -187,10 +175,8 @@ static int lpc18xx_rgu_probe(struct platform_device *pdev) rc->rcdev.of_node = pdev->dev.of_node; ret = reset_controller_register(&rc->rcdev); - if (ret) { - dev_err(&pdev->dev, "unable to register device\n"); - goto dis_clks; - } + if (ret) + return dev_err_probe(&pdev->dev, ret, "unable to register device\n"); rc->restart_nb.priority = 192, rc->restart_nb.notifier_call = lpc18xx_rgu_restart, @@ -199,13 +185,6 @@ static int lpc18xx_rgu_probe(struct platform_device *pdev) dev_warn(&pdev->dev, "failed to register restart handler\n"); return 0; - -dis_clks: - clk_disable_unprepare(rc->clk_delay); -dis_clk_reg: - clk_disable_unprepare(rc->clk_reg); - - return ret; } static const struct of_device_id lpc18xx_rgu_match[] = {