diff options
| -rw-r--r-- | drivers/clk/clk-devres.c | 21 | ||||
| -rw-r--r-- | include/linux/clk.h | 29 |
2 files changed, 46 insertions, 4 deletions
diff --git a/drivers/clk/clk-devres.c b/drivers/clk/clk-devres.c index 8f571548870f..3a218c3a06ae 100644 --- a/drivers/clk/clk-devres.c +++ b/drivers/clk/clk-devres.c | |||
| @@ -53,3 +53,24 @@ void devm_clk_put(struct device *dev, struct clk *clk) | |||
| 53 | WARN_ON(ret); | 53 | WARN_ON(ret); |
| 54 | } | 54 | } |
| 55 | EXPORT_SYMBOL(devm_clk_put); | 55 | EXPORT_SYMBOL(devm_clk_put); |
| 56 | |||
| 57 | struct clk *devm_get_clk_from_child(struct device *dev, | ||
| 58 | struct device_node *np, const char *con_id) | ||
| 59 | { | ||
| 60 | struct clk **ptr, *clk; | ||
| 61 | |||
| 62 | ptr = devres_alloc(devm_clk_release, sizeof(*ptr), GFP_KERNEL); | ||
| 63 | if (!ptr) | ||
| 64 | return ERR_PTR(-ENOMEM); | ||
| 65 | |||
| 66 | clk = of_clk_get_by_name(np, con_id); | ||
| 67 | if (!IS_ERR(clk)) { | ||
| 68 | *ptr = clk; | ||
| 69 | devres_add(dev, ptr); | ||
| 70 | } else { | ||
| 71 | devres_free(ptr); | ||
| 72 | } | ||
| 73 | |||
| 74 | return clk; | ||
| 75 | } | ||
| 76 | EXPORT_SYMBOL(devm_get_clk_from_child); | ||
diff --git a/include/linux/clk.h b/include/linux/clk.h index 123c02788807..e9d36b3e49de 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h | |||
| @@ -17,8 +17,9 @@ | |||
| 17 | #include <linux/notifier.h> | 17 | #include <linux/notifier.h> |
| 18 | 18 | ||
| 19 | struct device; | 19 | struct device; |
| 20 | |||
| 21 | struct clk; | 20 | struct clk; |
| 21 | struct device_node; | ||
| 22 | struct of_phandle_args; | ||
| 22 | 23 | ||
| 23 | /** | 24 | /** |
| 24 | * DOC: clk notifier callback types | 25 | * DOC: clk notifier callback types |
| @@ -249,6 +250,23 @@ struct clk *clk_get(struct device *dev, const char *id); | |||
| 249 | struct clk *devm_clk_get(struct device *dev, const char *id); | 250 | struct clk *devm_clk_get(struct device *dev, const char *id); |
| 250 | 251 | ||
| 251 | /** | 252 | /** |
| 253 | * devm_get_clk_from_child - lookup and obtain a managed reference to a | ||
| 254 | * clock producer from child node. | ||
| 255 | * @dev: device for clock "consumer" | ||
| 256 | * @np: pointer to clock consumer node | ||
| 257 | * @con_id: clock consumer ID | ||
| 258 | * | ||
| 259 | * This function parses the clocks, and uses them to look up the | ||
| 260 | * struct clk from the registered list of clock providers by using | ||
| 261 | * @np and @con_id | ||
| 262 | * | ||
| 263 | * The clock will automatically be freed when the device is unbound | ||
| 264 | * from the bus. | ||
| 265 | */ | ||
| 266 | struct clk *devm_get_clk_from_child(struct device *dev, | ||
| 267 | struct device_node *np, const char *con_id); | ||
| 268 | |||
| 269 | /** | ||
| 252 | * clk_enable - inform the system when the clock source should be running. | 270 | * clk_enable - inform the system when the clock source should be running. |
| 253 | * @clk: clock source | 271 | * @clk: clock source |
| 254 | * | 272 | * |
| @@ -432,6 +450,12 @@ static inline struct clk *devm_clk_get(struct device *dev, const char *id) | |||
| 432 | return NULL; | 450 | return NULL; |
| 433 | } | 451 | } |
| 434 | 452 | ||
| 453 | static inline struct clk *devm_get_clk_from_child(struct device *dev, | ||
| 454 | struct device_node *np, const char *con_id) | ||
| 455 | { | ||
| 456 | return NULL; | ||
| 457 | } | ||
| 458 | |||
| 435 | static inline void clk_put(struct clk *clk) {} | 459 | static inline void clk_put(struct clk *clk) {} |
| 436 | 460 | ||
| 437 | static inline void devm_clk_put(struct device *dev, struct clk *clk) {} | 461 | static inline void devm_clk_put(struct device *dev, struct clk *clk) {} |
| @@ -501,9 +525,6 @@ static inline void clk_disable_unprepare(struct clk *clk) | |||
| 501 | clk_unprepare(clk); | 525 | clk_unprepare(clk); |
| 502 | } | 526 | } |
| 503 | 527 | ||
| 504 | struct device_node; | ||
| 505 | struct of_phandle_args; | ||
| 506 | |||
| 507 | #if defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK) | 528 | #if defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK) |
| 508 | struct clk *of_clk_get(struct device_node *np, int index); | 529 | struct clk *of_clk_get(struct device_node *np, int index); |
| 509 | struct clk *of_clk_get_by_name(struct device_node *np, const char *name); | 530 | struct clk *of_clk_get_by_name(struct device_node *np, const char *name); |
