From patchwork Mon Aug 26 01:44:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guoqing Jiang X-Patchwork-Id: 13776950 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 56CF6C5321E for ; Mon, 26 Aug 2024 01:45:37 +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: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=Lmv4uiN3qZvU6/NgG4L5k3mc5szxVQmfiLjQ/I/duo4=; b=1eW1NbzlQUAfkqNp5loKGDTqJ5 88UgGs0zIe/iccrYTvkNvrUm2Es6GH3rf2zv6BvchJcw8fqaNaxvIhQZPx0idljgePjK90Y0guRx5 7Ngqf6rLZUAMlp6TK38mgrPUtVqT9lELEKH+NfuF9l1DYnGKR+CvLTgcOA3BYfi7AGi8v0CdBH7sP 9ZnCf0pf9QMzQgKFuZJeeYcnBXg+E791t3nlg0kcX3J7mDfbCykUwMGtZkEw+2yDq1CAqv2GiZjms 2UTy0IY3R0PQTjNEEK4G5q7P55FSl2s7PFh9fTB1LZmij73Z8n7H0bU3AeJYYG7Iygwn7wzvFa/tW sIpc7LZw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1siOnM-00000005SxX-3BD6; Mon, 26 Aug 2024 01:45:24 +0000 Received: from smtp-relay-canonical-1.canonical.com ([185.125.188.121]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1siOmZ-00000005Sti-34Jl; Mon, 26 Aug 2024 01:44:37 +0000 Received: from laptop.lan (unknown [125.33.218.254]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPSA id 150733F20C; Mon, 26 Aug 2024 01:44:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1724636672; bh=Lmv4uiN3qZvU6/NgG4L5k3mc5szxVQmfiLjQ/I/duo4=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=tym4uvgG9Udo5WNioWWSdBBcT46ciJcwfgAjFbHHnhfpyinKDvA0D1qk4ohr3Om9t zkGJz7dNXG+zXKk/7tZqmizIkLOyycxGD9/57TqOdHNsUphMd+BVqRnD33WXdLoJ8H NbhuYkoJqUT57do3uDvH+XYwiyXWdlaWPP6Ad3TyivT3GEsyHoQXsEXPNlqwR6LFQx FLpLWsB0Sigd6KbtVR0TvjCujBf8cdPXIfQBQtDw3CTJt3ZA/HyDBQTTWyaviPTODc nK3lqcMEjNpU2deoeEGfwCbJzml9QYy289HeBPeZE6nqyjoKtBDBVqlaGKq+eeON/I m93QssRd3z0Fg== From: Guoqing Jiang To: sean.wang@mediatek.com, olivia@selenic.com, herbert@gondor.apana.org.au, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com Cc: linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH] hwrng: mtk - Add remove function Date: Mon, 26 Aug 2024 09:44:19 +0800 Message-Id: <20240826014419.5151-1-guoqing.jiang@canonical.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240825_184436_173734_BDA86C62 X-CRM114-Status: GOOD ( 10.63 ) 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 Add mtk_rng_remove function which calles pm_runtime relevant funcs and unregister hwrng to paired with mtk_rng_probe. And without remove function, pm_runtime complains below when reload the driver. mtk_rng 1020f000.rng: Unbalanced pm_runtime_enable! Signed-off-by: Guoqing Jiang --- drivers/char/hw_random/mtk-rng.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/char/hw_random/mtk-rng.c b/drivers/char/hw_random/mtk-rng.c index 302e201b51c2..1b6aa9406b11 100644 --- a/drivers/char/hw_random/mtk-rng.c +++ b/drivers/char/hw_random/mtk-rng.c @@ -149,6 +149,15 @@ static int mtk_rng_probe(struct platform_device *pdev) return 0; } +static void mtk_rng_remove(struct platform_device *pdev) +{ + struct mtk_rng *priv = platform_get_drvdata(pdev); + + pm_runtime_disable(&pdev->dev); + pm_runtime_set_suspended(&pdev->dev); + devm_hwrng_unregister(&pdev->dev, &priv->rng); +} + #ifdef CONFIG_PM static int mtk_rng_runtime_suspend(struct device *dev) { @@ -186,6 +195,7 @@ MODULE_DEVICE_TABLE(of, mtk_rng_match); static struct platform_driver mtk_rng_driver = { .probe = mtk_rng_probe, + .remove_new = mtk_rng_remove, .driver = { .name = MTK_RNG_DEV, .pm = MTK_RNG_PM_OPS,