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: 13776784 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 2D9F8C5320E for ; Sun, 25 Aug 2024 14:16:12 +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:Cc:To:In-Reply-To:References:Message-Id :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=iCyCC90FsuNRyB4eaDBxVzVmJGSAePc9XF+CpNfQ2S8=; b=kdJhHPUEBhakml VFgxsN2tUU2A92CntG8Q+azm0otXtb4ey+Ix9M0dXZ8h/p9uY6EehEmfJzRUOURL0D6XR1DwsNdJH Ca+W6AlW6W9IJz6DdQFI1dshRXc9Hp5BM6loEGl8dqsFNxpcg9Pg3dLMpxL1U8oVrV8sIiSArALEJ SJxyxqr41pCYbfMkZOIGl2bKfIPw/d444hUttRvgJVrk9kdWm8mI9gnxposyASSu1j3Awc8VHL4US PaOEncljNgktWWwUjivpdWyUB7EY+ttm17b6mD0lqtx/cKv4MxOvGSd/3Nyn4qch85JoAzUpUWI9/ eNkQOzQv23YYv/wg/kWA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1siE2L-00000004Sk4-2ZO9; Sun, 25 Aug 2024 14:16:09 +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-00000004SGo-2clP for linux-riscv@lists.infradead.org; Sun, 25 Aug 2024 14:14:37 +0000 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-428e09ee91eso4317215e9.3 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=JDqsbFWUNdeX2wK8XoDG2oxzVy16Jyd8+3cLEhdqa5X91MIfO0y2XleMUi0nlxKZxf ammy/f2rsPvGLUvp7l5OTUatQcxbGOJs8cBFkUARKtIt2f3WiQuTT1s+FTei4KrdVkdp e0ci4jyJ2r9O15Vfa7Bv+nBEA61kWH/7/dOq5dCW9g4tl/zRRy/wW4GYbseDkTqqPqZR Q0azsu3woGhcGHs+OTxZNK9mF2O86nlFtdUOJMsNXnYPs2Q09emFkprwI0QR2NnvfgEn Yk/bIsFH28x6vDV/wB9rIIaSEkPg816qcrEqlGV5qBWv6FUdYZzlXtuXvI5If7wfEWCf Jfiw== X-Forwarded-Encrypted: i=1; AJvYcCV7nopvkO4HwybepUJKUoCI8xAocmK1JgvoFX4/d4XhbrnVhvlpxP1R1FsdST8vGOuNLShlov7JOev/tw==@lists.infradead.org X-Gm-Message-State: AOJu0YzvAEhVSUdxEtsbdgIyR4W5Q9n2D04wlPlilInQMEXJZnFwslTj RHcbWJcsTC6BrJqQmomntNV6IAymuyoUhH/mnveIQoOUuV1QIj01r7XCZ2qKaCA= 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_699768_BA1276CA X-CRM114-Status: GOOD ( 11.37 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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: 13776785 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 91B4FC5320E for ; Sun, 25 Aug 2024 14:16:58 +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:Cc:To:In-Reply-To:References:Message-Id :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=Artp7mRu6C7jjBDRY5zgoEo+QYR/XWSeT+oQEwc+F5w=; b=bwWFXA2s3BcGXz M1jupA22eSkRUQDaAY8/DNFZiOcb8i5DzVLcG1Onyd1up/645yqA8m9hXF3qMN+HuivRVYRQohLHQ 8/mM+C9cHv1CtswXbjiX8mOCeLqBjspy54rz1Wm0gMGVTf36rwam9w8x97rJ5b5yk/QZTWvMuVrSV ykcOtE9vbyuZPsOgXORIYviB2+5cpuhgxz9Vmfi2ULKu6N0x+TKc5MXYYo8ISdp1olMvC02JNtT7Y oKbXX6fD2jhSZJPiNWycMvOm+FVWpJ4ThBKjGoPg2u0y4oqfGGWZVXKsOPopwwL6zgi6aaL6Uh63n y5/B9Dw/hqm4RowhEVcg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1siE35-00000004SwC-2Tcl; Sun, 25 Aug 2024 14:16:55 +0000 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1siE0r-00000004SHs-09YE for linux-riscv@lists.infradead.org; Sun, 25 Aug 2024 14:14:39 +0000 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4280772333eso5433855e9.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=HHn9ZZTlaMQtUkWE379hmiXDpTVWMvq2/bpmOxoGe4sqassaVsKPkAv90ydax7dno0 G42BpH/ef9Cp/bWAseJeL7kJflhSFt74ZbHWiMeI8j5M5B704HUYb4lYvCkqiAtlBJv+ nzRyCNuPv07FauStrvF0bTOBMN079/1C7z89UbH1acHFMLCDd/7OJ5ZSaqTyjQatgxw2 gfCBOlT82Q3PoqHol416OPf1fM2kg2iKmQ5A0QND0VwVRwdiE2mDZVM8iPApScORpX4y YwdqC5WI3wzZOjOUIUxt1TRJmkd5xW51A7OFRb6cK0tXXlC53JcHS0DFClevqoo6kdBX /AWQ== X-Forwarded-Encrypted: i=1; AJvYcCUgUP4TM+rRDslvNQZYXxxAZodROWt2OtUHNUeeKJatMV/lW98HSjV1pp2TKJaERElt0KpTkZ3x5Y93Hg==@lists.infradead.org X-Gm-Message-State: AOJu0Yzf2DAUqzD6d7dwW15B0JZ9LaTycL591QwiQmcLOfKLVQr0R7FG 4rYs9MabGLL+2ZMAAJv8lKJu02yeEADKfpny41MTrK79aAXXe/vnWmSs/ZyBjvE= 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_133312_FB91A3CE X-CRM114-Status: GOOD ( 11.88 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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: 13776786 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 D71A2C5321E for ; Sun, 25 Aug 2024 14:16:58 +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:Cc:To:In-Reply-To:References:Message-Id :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=U1sfCmtlUwsqKJJgnU1JocSKDfIq6V5+l5iy1Ucdv5M=; b=KZrNB+kDY/B4QP RV2BVHv3yX+z9vCKw3DJmortJtiMNzQsa8hbrh5+j4FkvZQz+NM8MTYirzYYCZlhzs3yKVWrsi5aD ZtOP3ScRyHoKYVfVE8euBzJTp3GwSxznWL1xwX8hMZ3XIuyxdZTYXIUugpTaVcIUKU896Z2vE1h65 m/fKHkZ/utPdrY1UlmtJRcP9pVeS7Gnej63NcihHIEGlY0PT4oyCy2uZTakk/QwC5n2AvGEXmaF4k ONNN7ACqPVBVU94rnV63TokRTZtcBYX3u8Xw+rLfKzI77lwDmqh4sKz/VR5gnCdN/2KKAc2m2cb7z 6f/onxzoIQfQqusRC7ZA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1siE36-00000004Swf-1Isz; Sun, 25 Aug 2024 14:16:56 +0000 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1siE0r-00000004SIF-3Y6y for linux-riscv@lists.infradead.org; Sun, 25 Aug 2024 14:14:39 +0000 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-4281da2cdaeso5392115e9.2 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=qv1sWZ7VDZRXJK8zQlprGgoU44pI5nS4mS2kj3UO7t/0UighITVlitzgdN9lGiQUvI Am6KTP8p81bAz+y7NedR9TVFJW2Py3BjysCI4hgWY6HiqfOgpneaDDMTU2fW2+SGobp7 vrXjMdm5PMWhBsEwZmJOtba6DhDHET/eTlSMt9wQ3+EaOBQmC9rY9vU87B1rsaa0xuZo 5ons64TFIsNzeH2WkTGyGjQRADYL2aMM1cbnWhU264YXCoKFQ2ku8r+m4lLPMPXiSrEA 85yDYBjFGlcY6jsXrGpBK6tfV7mDSFTX8gws98k/nKFw01h75yLOYRyICNSVPCPE4N4O 7ezA== X-Forwarded-Encrypted: i=1; AJvYcCXL11oLzr4dA25Ij2LAv/K82EIo7iFg0xwlSZLgT8/6WtDObRlBvoxSMgM4X62J+veIZXBGFmdOoccAVQ==@lists.infradead.org X-Gm-Message-State: AOJu0YwrI8sE+khCGGI2YPnQ82zTfprPDZ250Kc+Il/KtTt53eyni3mA ty4xD/MiMidfSZtnfMbyrJFHq6mDO8N4T8le/GzU3MkuhFfstl/wm8nuXiqhQOg= 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_071437_920142_49D0662F X-CRM114-Status: GOOD ( 11.62 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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: 13776787 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 993B5C5320E for ; Sun, 25 Aug 2024 14:17:44 +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:Cc:To:In-Reply-To:References:Message-Id :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=+6Lyx5aeITdar0CPQTKekPWa/D4tsoWIOiGABDVbc/4=; b=NCVv9SNbL47jIo iSGX8n+SBUl812nRYpl0Qqgs+TFSKKTdV4ErShbXyAL/dZYbzr+sDutI276fJwRwIx8CnGHYKR+Lx WcEs7DzdNQv9qVOnDy8nlC1tjs99z9tL5qy5U9Cd1iNesZXuU5C+CK600+zyl4fIu0vwM07jJnjUt g6XdLpukPsIcezG3vP/Jfr5LzDptesN0Tl1hyFHDZXqqZM+lGAKHJ16TOBiM03Vx7HkJpnYeyccI2 fbUNeTqn/UZ1cli7xdMZdRMfaVMNo3AOHEdgaD3C2/CaDzmrxG0QcIQQmYbzNsXiwHvxbbP8um7mw 6IwucKH5tNukP1QtaiAw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1siE3q-00000004T9w-00uf; Sun, 25 Aug 2024 14:17:42 +0000 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1siE0t-00000004SJD-3CLV for linux-riscv@lists.infradead.org; Sun, 25 Aug 2024 14:14:41 +0000 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-4280ef642fbso4330345e9.1 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=kX4wdskNwWFQl3MWp9MB0piyLv2szrP5f8uoR0AE4uMcw5YKoBu8Qg1X5EXoRe0aih W57Cu3rJUTZHEg+ThiuY0YFW3cF4v1AF3DESheO49uFoNk3psYa/LAbPHlr52eyuXUoC /o5FNYSlApEZM6IZ6ohNqy8toyXYbiacQFZGYKLhuqy5EoG6rjuy4nlwDFmSqD9kGJ+N 90QIqqiAuGbPYox9dc67y+o2K16kLAG5A/wH73mzXEUhZDdDSTvFzk3fkFO9jeQEui3+ j7Omg2yH0jzNjYSkPevwlN5ymqnuGnAbLxHxKIQZIS1QhdrnI7tqTwZM0BFuUjMxfuaN mldQ== X-Forwarded-Encrypted: i=1; AJvYcCVplzCjA6wJwY9c+RT19vRlPfFChIjip8kUJ+b6zGCfRTevxy6I+4uBo1Nx1vm9M892IwNgiKQKucwZYw==@lists.infradead.org X-Gm-Message-State: AOJu0YwaKvXmxiUpS/AyS+PNzkP+RpY3oeDIM+8mGn57uo1XLJBmRMP7 xSsOuK7uVeKRhrHAFPQNtTH0ky7r5IcJvIluDwDeT0OE420cBFTz91SUKjn8WUI= 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_839295_F4B1C9E2 X-CRM114-Status: UNSURE ( 9.75 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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: 13776791 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 9CB8FC5320E for ; Sun, 25 Aug 2024 14:18:32 +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:Cc:To:In-Reply-To:References:Message-Id :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=U8zpHIrMeHY2huE65j8eR8KhnIEgbnYxzaSRTsJjZN8=; b=nvXXCmVgCO/xmc fWWPfKfMS54JITN6AzQ3zTa3y+2FqndX/OuHDlE4vqKrFkPcHHHplGZP33CLT8c6RAS3IiHP9Vq/X xyGXwgJYhGUp9BMkW0mZah0/MTLUf/UNqxUvta8gbfHtAR5SdZcVvLqEV6tMD8Aa4/w3TwsenNsh2 jJTo03bZv1Iho/4PZGAXOIWMkVeCjsO5XTf2Hzux1ymdjjFqyj6C7rt9QF98gzQdrU+wWLCTZe5+z ZhrUO7tS5bI9+aqTlsEY09EtUuWBP1TKkaDKZO+jXUSmJb1Fn5ayL+wFenbWb+syKiEWYjt3LIXVg j3+jV90YdQkKpnZUq7lA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1siE4Z-00000004TN1-35Gm; Sun, 25 Aug 2024 14:18:27 +0000 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1siE0v-00000004SK4-1cd3 for linux-riscv@lists.infradead.org; Sun, 25 Aug 2024 14:14:43 +0000 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4290075c7e1so4344985e9.0 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=qNR8hITJlhs4jF29f2y2ilc9cVNAD31OsSDZTgW+H+W0GIi55/PHqiW8IO3VgBHeQH wGnRcHehVqzBvmyArd+7j4/xppEQVnbBU2jDz34F71R8fwWNozuDcKc9WAf3TLHkEef3 LdAHovXQF2vcJws2i8I0kCOew3zIu7Q07ObewJOm/wlUxxvu+m/1ZZbpNoe2atAUI3Qk oI0bLMsUNAD3OJur7KB1H7I4dHkbTAn1SXjj3ebXpEYEr62LuqRB0nKer+JpH6ah35qf ItACwIkuUBaknZYJ2E2vIWVJ7JlpzFzVOe16xzTRAu8652hh4baf19NGhV82fS5w2p8Z ceBA== X-Forwarded-Encrypted: i=1; AJvYcCU5Tch9wCxxiaKf2oiw58xMQW2NkV73AIGG1O3b+c1ADs26ZdIMwJuPHbYks2w8XFnJQbxkr1vW8NgyHA==@lists.infradead.org X-Gm-Message-State: AOJu0Yy5L08QewFqfVb6qBBPtLB0SX5cXRBc7e8hWGX+dABQm2iqu7GU PwddP/hBuuIzp7QxYmFuZWlQDnHDpLDcFX5vVP+giiVMaMTlkl51qb23XcE7HG45sEn7TCW5tlL O 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_495212_FF9FB70D X-CRM114-Status: GOOD ( 11.54 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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[] = {