From patchwork Sat Jan 20 10:07:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Marussi X-Patchwork-Id: 13524350 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 6DC0EC47258 for ; Sat, 20 Jan 2024 10:07:55 +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: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=+yeDCk8TVOEOChmernPqiBn56DzNbuiNox2Jhh9DRBw=; b=OVNMG/hqprAf3I k9zB0G7l0T4TcJ8urOphJ+pV/g7CDh5/7J1CBZTGbJ6uQXGnV0xlJzwTWhGixlgCqkzMF0Er/Etal 8lXhEz8tk3P7pMNXsRWc38ftevRvSOK6PMdgJ+2FzWQFPznoEKVS+N5GdK39DpQzNAcj8k+hf77b3 5XgT0buZjDSKfWsInzRvPmelVFL3n9svYgPP/lnk9u4j8vH0N8lW0KIZO11VRtoXpuatqPW65dYWi vJ1bRSrG0mzM4a3xWw+gAZLXKzx6/+/i5FYfQNDsoTs7KAX+SWPjgew8ZHenVPrDjzBE+92A3a34W I9aBsXJxuIkilHEwSmfQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rR8G6-007bwm-0X; Sat, 20 Jan 2024 10:07:26 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rR8G2-007bwI-2V for linux-arm-kernel@lists.infradead.org; Sat, 20 Jan 2024 10:07:24 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 24B96DA7; Sat, 20 Jan 2024 02:08:07 -0800 (PST) Received: from pluto.fritz.box (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5F7003F73F; Sat, 20 Jan 2024 02:07:19 -0800 (PST) From: Cristian Marussi To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: sudeep.holla@arm.com, peng.fan@oss.nxp.com, Cristian Marussi , Michael Turquette , Stephen Boyd , linux-clk@vger.kernel.org Subject: [PATCH] clk: Check ops are available in clk_gate_restore_context Date: Sat, 20 Jan 2024 10:07:11 +0000 Message-ID: <20240120100711.2832897-1-cristian.marussi@arm.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240120_020722_900061_13B93556 X-CRM114-Status: UNSURE ( 8.40 ) X-CRM114-Notice: Please train this message. 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 a check in clk_gate_restore_context() to assure that the clock enable and disable ops are available before calling them. CC: Michael Turquette CC: Stephen Boyd CC: linux-clk@vger.kernel.org Fixes: 9be766274db4 ("clk: Clean up suspend/resume coding style") Signed-off-by: Cristian Marussi --- Spotted this by code inspection. I may be missing something, though, given my limited familiarity with CLK. --- drivers/clk/clk.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index f0940af485a5..79b90a8099d7 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -1200,9 +1200,11 @@ void clk_gate_restore_context(struct clk_hw *hw) struct clk_core *core = hw->core; if (core->enable_count) - core->ops->enable(hw); + if (core->ops->enable) + core->ops->enable(hw); else - core->ops->disable(hw); + if (core->ops->disable) + core->ops->disable(hw); } EXPORT_SYMBOL_GPL(clk_gate_restore_context);