@@ -13,10 +13,9 @@
#include "mtk_mdp_comp.h"
-
-void mtk_mdp_comp_clock_on(struct device *dev, struct mtk_mdp_comp *comp)
+int mtk_mdp_comp_clock_on(struct device *dev, struct mtk_mdp_comp *comp)
{
- int i, err;
+ int i, err, status;
if (comp->larb_dev) {
err = mtk_smi_larb_get(comp->larb_dev);
@@ -30,11 +29,23 @@ void mtk_mdp_comp_clock_on(struct device *dev, struct mtk_mdp_comp *comp)
if (IS_ERR(comp->clk[i]))
continue;
err = clk_prepare_enable(comp->clk[i]);
- if (err)
- dev_err(dev,
- "failed to enable clock, err %d. type:%d i:%d\n",
- err, comp->type, i);
+ if (err) {
+ status = err;
+ dev_err(dev, "failed to enable clock, err %d. i:%d\n", err, i);
+ goto err_clk_prepare_enable;
+ }
+ }
+
+ return 0;
+
+err_clk_prepare_enable:
+ for (--i; i >= 0; i--) {
+ if (IS_ERR(comp->clk[i]))
+ continue;
+ clk_disable_unprepare(comp->clk[i]);
}
+
+ return status;
}
void mtk_mdp_comp_clock_off(struct device *dev, struct mtk_mdp_comp *comp)
@@ -41,7 +41,7 @@ int mtk_mdp_comp_init(struct device *dev, struct device_node *node,
struct mtk_mdp_comp *comp,
enum mtk_mdp_comp_type comp_type);
void mtk_mdp_comp_deinit(struct device *dev, struct mtk_mdp_comp *comp);
-void mtk_mdp_comp_clock_on(struct device *dev, struct mtk_mdp_comp *comp);
+int mtk_mdp_comp_clock_on(struct device *dev, struct mtk_mdp_comp *comp);
void mtk_mdp_comp_clock_off(struct device *dev, struct mtk_mdp_comp *comp);
@@ -52,13 +52,28 @@ static const struct of_device_id mtk_mdp_of_ids[] = {
};
MODULE_DEVICE_TABLE(of, mtk_mdp_of_ids);
-static void mtk_mdp_clock_on(struct mtk_mdp_dev *mdp)
+static int mtk_mdp_clock_on(struct mtk_mdp_dev *mdp)
{
- struct device *dev = &mdp->pdev->dev;
struct mtk_mdp_comp *comp_node;
+ int status;
+ struct device *dev = &mdp->pdev->dev;
+ int err;
- list_for_each_entry(comp_node, &mdp->comp_list, node)
- mtk_mdp_comp_clock_on(dev, comp_node);
+ list_for_each_entry(comp_node, &mdp->comp_list, node) {
+ err = mtk_mdp_comp_clock_on(dev, comp_node);
+ if (err) {
+ status = err;
+ goto err_mtk_mdp_comp_clock_on;
+ }
+ }
+
+ return 0;
+
+err_mtk_mdp_comp_clock_on:
+ list_for_each_entry_continue_reverse(comp_node, &mdp->comp_list, node)
+ mtk_mdp_comp_clock_off(dev, comp_node);
+
+ return status;
}
static void mtk_mdp_clock_off(struct mtk_mdp_dev *mdp)
@@ -274,9 +289,7 @@ static int __maybe_unused mtk_mdp_pm_resume(struct device *dev)
{
struct mtk_mdp_dev *mdp = dev_get_drvdata(dev);
- mtk_mdp_clock_on(mdp);
-
- return 0;
+ return mtk_mdp_clock_on(mdp);
}
static int __maybe_unused mtk_mdp_suspend(struct device *dev)