[PATCH] clk: bulk: export of_clk_bulk_get_all

From: Peng Fan (OSS)
Date: Mon Dec 20 2021 - 22:17:58 EST


From: Peng Fan <peng.fan@xxxxxxx>

There are cases that need to get the bulk clks of a device_node which not
has device created, so export of_clk_bulk_get_all to let consumers could
use it.

Signed-off-by: Peng Fan <peng.fan@xxxxxxx>
---

V1:
An example here, mediamix node has clocks property, but it will not
have device of it, so we need of_X api to get the clks.
src: src@0x30390000 {
compatible = "fsl,imx[X]-src";
reg = <0x30390000 0x10000>;

slice {
#address-cells = <1>;
#size-cells = <0>;

mediamix: slice@2400 {
reg = <IMX93_POWER_DOMAIN_MEDIAMIX>;
#power-domain-cells = <0>;
clocks = <&clk IMX_MEDIAMIX_ROOT>, <&clk IMX_MEDIAMIX_AHB>;
};
};

drivers/clk/clk-bulk.c | 5 +++--
include/linux/clk.h | 18 ++++++++++++++++++
2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/clk-bulk.c b/drivers/clk/clk-bulk.c
index e9e16425c739..6dd7aac0b84c 100644
--- a/drivers/clk/clk-bulk.c
+++ b/drivers/clk/clk-bulk.c
@@ -43,8 +43,8 @@ static int __must_check of_clk_bulk_get(struct device_node *np, int num_clks,
return ret;
}

-static int __must_check of_clk_bulk_get_all(struct device_node *np,
- struct clk_bulk_data **clks)
+int __must_check of_clk_bulk_get_all(struct device_node *np,
+ struct clk_bulk_data **clks)
{
struct clk_bulk_data *clk_bulk;
int num_clks;
@@ -68,6 +68,7 @@ static int __must_check of_clk_bulk_get_all(struct device_node *np,

return num_clks;
}
+EXPORT_SYMBOL_GPL(of_clk_bulk_get_all);

void clk_bulk_put(int num_clks, struct clk_bulk_data *clks)
{
diff --git a/include/linux/clk.h b/include/linux/clk.h
index 266e8de3cb51..c49c7918d6ef 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -372,6 +372,18 @@ int __must_check clk_bulk_get(struct device *dev, int num_clks,
int __must_check clk_bulk_get_all(struct device *dev,
struct clk_bulk_data **clks);

+/**
+ * of_clk_bulk_get_all - lookup and obtain all available references to clock
+ * producer.
+ * @np: device node for clock "consumer"
+ * @clks: pointer to the clk_bulk_data table of consumer
+ *
+ * Same with clk_bulk_get_all except the first parameter use device node
+ * pointer.
+ */
+int __must_check of_clk_bulk_get_all(struct device_node *np,
+ struct clk_bulk_data **clks);
+
/**
* clk_bulk_get_optional - lookup and obtain a number of references to clock producer
* @dev: device for clock "consumer"
@@ -808,6 +820,12 @@ static inline int __must_check clk_bulk_get_all(struct device *dev,
return 0;
}

+static inline int __must_check of_clk_bulk_get_all(struct device *dev,
+ struct clk_bulk_data **clks)
+{
+ return 0;
+}
+
static inline struct clk *devm_clk_get(struct device *dev, const char *id)
{
return NULL;
--
2.25.1