[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250217163713.211949-6-thierry.reding@gmail.com>
Date: Mon, 17 Feb 2025 17:37:11 +0100
From: Thierry Reding <thierry.reding@...il.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: x86@...nel.org,
linux-arm-kernel@...ts.infradead.org,
linux-riscv@...ts.infradead.org,
linux-mips@...r.kernel.org,
loongarch@...ts.linux.dev,
linuxppc-dev@...ts.ozlabs.org,
linux-sh@...r.kernel.org,
linux-pci@...r.kernel.org,
linux-acpi@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH 5/7] clk: mvebu: Embed syscore_ops in clock context
From: Thierry Reding <treding@...dia.com>
This enables the syscore callbacks to obtain the clock context without
relying on a separate global variable.
Signed-off-by: Thierry Reding <treding@...dia.com>
---
drivers/clk/mvebu/common.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/drivers/clk/mvebu/common.c b/drivers/clk/mvebu/common.c
index ee77d307efe0..53712c3e5087 100644
--- a/drivers/clk/mvebu/common.c
+++ b/drivers/clk/mvebu/common.c
@@ -189,6 +189,7 @@ void __init mvebu_coreclk_setup(struct device_node *np,
DEFINE_SPINLOCK(ctrl_gating_lock);
struct clk_gating_ctrl {
+ struct syscore_ops syscore;
spinlock_t *lock;
struct clk **gates;
int num_gates;
@@ -196,11 +197,15 @@ struct clk_gating_ctrl {
u32 saved_reg;
};
-static struct clk_gating_ctrl *ctrl;
+static inline struct clk_gating_ctrl *from_syscore(struct syscore_ops *ops)
+{
+ return container_of(ops, struct clk_gating_ctrl, syscore);
+}
static struct clk *clk_gating_get_src(
struct of_phandle_args *clkspec, void *data)
{
+ struct clk_gating_ctrl *ctrl = data;
int n;
if (clkspec->args_count < 1)
@@ -217,23 +222,23 @@ static struct clk *clk_gating_get_src(
static int mvebu_clk_gating_suspend(struct syscore_ops *ops)
{
+ struct clk_gating_ctrl *ctrl = from_syscore(ops);
+
ctrl->saved_reg = readl(ctrl->base);
return 0;
}
static void mvebu_clk_gating_resume(struct syscore_ops *ops)
{
+ struct clk_gating_ctrl *ctrl = from_syscore(ops);
+
writel(ctrl->saved_reg, ctrl->base);
}
-static struct syscore_ops clk_gate_syscore_ops = {
- .suspend = mvebu_clk_gating_suspend,
- .resume = mvebu_clk_gating_resume,
-};
-
void __init mvebu_clk_gating_setup(struct device_node *np,
const struct clk_gating_soc_desc *desc)
{
+ static struct clk_gating_ctrl *ctrl;
struct clk *clk;
void __iomem *base;
const char *default_parent = NULL;
@@ -284,7 +289,9 @@ void __init mvebu_clk_gating_setup(struct device_node *np,
of_clk_add_provider(np, clk_gating_get_src, ctrl);
- register_syscore_ops(&clk_gate_syscore_ops);
+ ctrl->syscore.suspend = mvebu_clk_gating_suspend;
+ ctrl->syscore.resume = mvebu_clk_gating_resume;
+ register_syscore_ops(&ctrl->syscore);
return;
gates_out:
--
2.48.1
Powered by blists - more mailing lists