hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/base/power/clock_ops.c
....@@ -1,9 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * drivers/base/power/clock_ops.c - Generic clock manipulation PM callbacks
34 *
45 * Copyright (c) 2011 Rafael J. Wysocki <rjw@sisk.pl>, Renesas Electronics Corp.
5
- *
6
- * This file is released under the GPLv2.
76 */
87
98 #include <linux/kernel.h>
....@@ -13,6 +12,7 @@
1312 #include <linux/pm_clock.h>
1413 #include <linux/clk.h>
1514 #include <linux/clkdev.h>
15
+#include <linux/of_clk.h>
1616 #include <linux/slab.h>
1717 #include <linux/err.h>
1818 #include <linux/pm_domain.h>
....@@ -65,10 +65,15 @@
6565 if (IS_ERR(ce->clk)) {
6666 ce->status = PCE_STATUS_ERROR;
6767 } else {
68
- clk_prepare(ce->clk);
69
- ce->status = PCE_STATUS_ACQUIRED;
70
- dev_dbg(dev, "Clock %pC con_id %s managed by runtime PM.\n",
71
- ce->clk, ce->con_id);
68
+ if (clk_prepare(ce->clk)) {
69
+ ce->status = PCE_STATUS_ERROR;
70
+ dev_err(dev, "clk_prepare() failed\n");
71
+ } else {
72
+ ce->status = PCE_STATUS_ACQUIRED;
73
+ dev_dbg(dev,
74
+ "Clock %pC con_id %s managed by runtime PM.\n",
75
+ ce->clk, ce->con_id);
76
+ }
7277 }
7378 }
7479
....@@ -88,8 +93,6 @@
8893 if (con_id) {
8994 ce->con_id = kstrdup(con_id, GFP_KERNEL);
9095 if (!ce->con_id) {
91
- dev_err(dev,
92
- "Not enough memory for clock connection ID.\n");
9396 kfree(ce);
9497 return -ENOMEM;
9598 }
....@@ -191,8 +194,7 @@
191194 if (!dev || !dev->of_node)
192195 return -EINVAL;
193196
194
- count = of_count_phandle_with_args(dev->of_node, "clocks",
195
- "#clock-cells");
197
+ count = of_clk_get_parent_count(dev->of_node);
196198 if (count <= 0)
197199 return -ENODEV;
198200