[PATCH 10/13] clk: mediatek: reset: Return mtk_reset pointer on register

Yassine Oudjana
2022-05-04T12:33:29Z

Return a struct mtk_reset* when registering a reset controller
in preparation for adding an unregister helper that will take
it as an argument.

Signed-off-by: Yassine Oudjana <y.oudjana@protonmail.com>
---
drivers/clk/mediatek/clk-mtk.h | 6 +++---
drivers/clk/mediatek/reset.c | 22 ++++++++++++----------
2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mtk.h
index bf6565aa7319..317905ec4a36 100644
--- a/drivers/clk/mediatek/clk-mtk.h
+++ b/drivers/clk/mediatek/clk-mtk.h
@@ -190,10 +190,10 @@ void mtk_free_clk_data(struct clk_onecell_data *clk_data);
struct clk *mtk_clk_register_ref2usb_tx(const char *name,
const char *parent_name, void __iomem *reg);

-void mtk_register_reset_controller(struct device_node *np,
- unsigned int num_regs, int regofs);
+struct mtk_reset *mtk_register_reset_controller(struct device_node *np,
+ unsigned int num_regs, int regofs);

-void mtk_register_reset_controller_set_clr(struct device_node *np,
+struct mtk_reset *mtk_register_reset_controller_set_clr(struct device_node *np,
unsigned int num_regs, int regofs);

struct mtk_clk_desc {
diff --git a/drivers/clk/mediatek/reset.c b/drivers/clk/mediatek/reset.c
index 6c2effe6afef..f853bc8a7092 100644
--- a/drivers/clk/mediatek/reset.c
+++ b/drivers/clk/mediatek/reset.c
@@ -90,9 +90,9 @@ static const struct reset_control_ops mtk_reset_ops_set_clr = {
.reset = mtk_reset_set_clr,
};

-static void mtk_register_reset_controller_common(struct device_node *np,
- unsigned int num_regs, int regofs,
- const struct reset_control_ops *reset_ops)
+static struct mtk_reset *mtk_register_reset_controller_common(
+ struct device_node *np, unsigned int num_regs, int regofs,
+ const struct reset_control_ops *reset_ops)
{
struct mtk_reset *data;
int ret;
@@ -101,12 +101,12 @@ static void mtk_register_reset_controller_common(struct device_node *np,
regmap = device_node_to_regmap(np);
if (IS_ERR(regmap)) {
pr_err("Cannot find regmap for %pOF: %pe\n", np, regmap);
- return;
+ return (struct mtk_reset *)regmap;
}

data = kzalloc(sizeof(*data), GFP_KERNEL);
if (!data)
- return;
+ return ERR_PTR(-ENOMEM);

data->regmap = regmap;
data->regofs = regofs;
@@ -119,22 +119,24 @@ static void mtk_register_reset_controller_common(struct device_node *np,
if (ret) {
pr_err("could not register reset controller: %d\n", ret);
kfree(data);
- return;
+ return ERR_PTR(ret);
}
+
+ return data;
}

-void mtk_register_reset_controller(struct device_node *np,
+struct mtk_reset *mtk_register_reset_controller(struct device_node *np,
unsigned int num_regs, int regofs)
{
- mtk_register_reset_controller_common(np, num_regs, regofs,
+ return mtk_register_reset_controller_common(np, num_regs, regofs,
&mtk_reset_ops);
}
EXPORT_SYMBOL_GPL(mtk_register_reset_controller);

-void mtk_register_reset_controller_set_clr(struct device_node *np,
+struct mtk_reset *mtk_register_reset_controller_set_clr(struct device_node *np,
unsigned int num_regs, int regofs)
{
- mtk_register_reset_controller_common(np, num_regs, regofs,
+ return mtk_register_reset_controller_common(np, num_regs, regofs,
&mtk_reset_ops_set_clr);
}
EXPORT_SYMBOL_GPL(mtk_register_reset_controller_set_clr);
--
2.36.0