From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from layka.disroot.org (layka.disroot.org [178.21.23.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 980203F65EB; Mon, 25 May 2026 16:42:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.21.23.139 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779727370; cv=none; b=RH3MSOMCoXwDx79uB6Fy9SBLTiAbpE8lAsui5ewCI+8AJKi0c1Vs/zTIlSN8b7VJN6oyFy4eFahh9bm/9zZ/zujgxCWlW3uiXBB7NNVDaRl78LQnNKfLOdulpHsdPrOWyPde6fkf+r/5MdiriQxcFUga4vwcD9ETze5Mbb1V36Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779727370; c=relaxed/simple; bh=2OF8js3j011GkbvGK5yHUNv8z+itCdsM0bZhVVbT3Gs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=paE075nEThYHzb0qG0jOgorE3/oUMaN2OAsOUblJtZyRsXfmtCKW2d4bMApJwB4Fymrz0/LLgLnOXWqZlT61WMbtyr6KeAcCGlHR1YjSATjjeIuMSCcREeU+VcGQYGrRBv1htNwo9leQgGjWeaSytrOmRxQxgUe3JJSu0P2jQ5k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=disroot.org; spf=pass smtp.mailfrom=disroot.org; dkim=pass (2048-bit key) header.d=disroot.org header.i=@disroot.org header.b=jyx8dljb; arc=none smtp.client-ip=178.21.23.139 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=disroot.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=disroot.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=disroot.org header.i=@disroot.org header.b="jyx8dljb" Received: from mail01.disroot.lan (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 56D8D271DC; Mon, 25 May 2026 18:42:46 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from layka.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id ZOP0gYfiY2U5; Mon, 25 May 2026 18:42:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1779727365; bh=2OF8js3j011GkbvGK5yHUNv8z+itCdsM0bZhVVbT3Gs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=jyx8dljb0o9X2Zu8q11qd/9fDwiFed/WZj5YPpRnlTa5LWwS92gCuM8dPAVnNa2qs W2I/M6J7OoYAidzZAURRqswTyyYX9lHiyZdA9k7vQpZF4fd+HgOoIdDANwQwtV6aH5 AN3ZganVnzUAZl/EZ+zvlcrYqjSQTTKiRkpd4viPHE3ZQNw1Nj4CLeBJwcXyICboG5 QVVEyRi5cEg8EYV/F121Y2bahwrO9Glgyr9hJ+GWSLEdDbf3tzWbl+a2n9TvG4DBhG vTDdjMI8UlDY6FuvpaqU0/zBxEJLYBa1SsLwd86C7FLKOPzIWu62QInGQd1pxpQBgT rpNAZrzE/Nuxg== From: "Marco Scardovi (scardracs)" To: linusw@kernel.org, brgl@kernel.org, heiko@sntech.de Cc: linux-gpio@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, "Marco Scardovi (scardracs)" Subject: [PATCH 1/2] gpio: rockchip: convert bank->clk to devm_clk_get_enabled() Date: Mon, 25 May 2026 18:39:38 +0200 Message-ID: <20260525164230.43307-2-scardracs@disroot.org> In-Reply-To: <20260525164230.43307-1-scardracs@disroot.org> References: <20260525164230.43307-1-scardracs@disroot.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The bank->clk was previously obtained via of_clk_get() and manually prepared/enabled. However, it was missing a corresponding clk_put() in both the error paths and the remove function, leading to a reference leak. Convert the allocation to devm_clk_get_enabled(), which also properly propagates failures from clk_prepare_enable() that were previously ignored. The GPIO bank device uses the same OF node as the previous of_clk_get() call, so devm_clk_get_enabled(dev, NULL) correctly resolves the same clock provider entry. This change fixes the reference leak and simplifies the code by removing the manual clk_disable_unprepare() calls in the probe error paths and in the remove function. Assisted-by: Antigravity:gemini-3.5-flash Signed-off-by: Marco Scardovi --- drivers/gpio/gpio-rockchip.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/gpio/gpio-rockchip.c b/drivers/gpio/gpio-rockchip.c index 44d7ebd12724..33580093a4e7 100644 --- a/drivers/gpio/gpio-rockchip.c +++ b/drivers/gpio/gpio-rockchip.c @@ -656,11 +656,10 @@ static int rockchip_get_bank_data(struct rockchip_pin_bank *bank) if (!bank->irq) return -EINVAL; - bank->clk = of_clk_get(bank->of_node, 0); + bank->clk = devm_clk_get_enabled(bank->dev, NULL); if (IS_ERR(bank->clk)) return PTR_ERR(bank->clk); - clk_prepare_enable(bank->clk); id = readl(bank->reg_base + gpio_regs_v2.version_id); switch (id) { @@ -672,7 +671,6 @@ static int rockchip_get_bank_data(struct rockchip_pin_bank *bank) bank->db_clk = of_clk_get(bank->of_node, 1); if (IS_ERR(bank->db_clk)) { dev_err(bank->dev, "cannot find debounce clk\n"); - clk_disable_unprepare(bank->clk); return -EINVAL; } break; @@ -751,7 +749,6 @@ static int rockchip_gpio_probe(struct platform_device *pdev) ret = rockchip_gpiolib_register(bank); if (ret) { - clk_disable_unprepare(bank->clk); mutex_unlock(&bank->deferred_lock); return ret; } @@ -792,7 +789,6 @@ static void rockchip_gpio_remove(struct platform_device *pdev) { struct rockchip_pin_bank *bank = platform_get_drvdata(pdev); - clk_disable_unprepare(bank->clk); gpiochip_remove(&bank->gpio_chip); } -- 2.54.0