diff mbox series

[v2,3/5] clk: composite: Allow gate ops with only .is_enabled op

Message ID 1606394409-12755-4-git-send-email-abel.vesa@nxp.com (mailing list archive)
State New, archived
Headers show
Series clk: imx: Register the dram_apb and dram_alt as read-only | expand

Commit Message

Abel Vesa Nov. 26, 2020, 12:40 p.m. UTC
Some composite clocks might be enabled/disabled from outside the
clock framework. So allow the composite clock register successfully
with only the .is_enabled op for gate ops.

Signed-off-by: Abel Vesa <abel.vesa@nxp.com>
---
 drivers/clk/clk-composite.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c
index 2ddb54f..29f00a9 100644
--- a/drivers/clk/clk-composite.c
+++ b/drivers/clk/clk-composite.c
@@ -278,17 +278,18 @@  static struct clk_hw *__clk_hw_register_composite(struct device *dev,
 	}
 
 	if (gate_hw && gate_ops) {
-		if (!gate_ops->is_enabled || !gate_ops->enable ||
-		    !gate_ops->disable) {
-			hw = ERR_PTR(-EINVAL);
-			goto err;
-		}
-
 		composite->gate_hw = gate_hw;
 		composite->gate_ops = gate_ops;
-		clk_composite_ops->is_enabled = clk_composite_is_enabled;
-		clk_composite_ops->enable = clk_composite_enable;
-		clk_composite_ops->disable = clk_composite_disable;
+		if (gate_ops->is_enabled) {
+			clk_composite_ops->is_enabled = clk_composite_is_enabled;
+		} else {
+			hw = ERR_PTR(-EINVAL);
+			goto err;
+		}
+		if (gate_ops->enable)
+			clk_composite_ops->enable = clk_composite_enable;
+		if (gate_ops->disable)
+			clk_composite_ops->disable = clk_composite_disable;
 	}
 
 	init.ops = clk_composite_ops;