aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/clk/clkdev.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/clk/clkdev.c')
-rw-r--r--drivers/clk/clkdev.c75
1 files changed, 56 insertions, 19 deletions
diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c
index eb20b941154b..89cc700fbc37 100644
--- a/drivers/clk/clkdev.c
+++ b/drivers/clk/clkdev.c
@@ -301,6 +301,20 @@ clkdev_alloc(struct clk *clk, const char *con_id, const char *dev_fmt, ...)
301} 301}
302EXPORT_SYMBOL(clkdev_alloc); 302EXPORT_SYMBOL(clkdev_alloc);
303 303
304struct clk_lookup *
305clkdev_hw_alloc(struct clk_hw *hw, const char *con_id, const char *dev_fmt, ...)
306{
307 struct clk_lookup *cl;
308 va_list ap;
309
310 va_start(ap, dev_fmt);
311 cl = vclkdev_alloc(hw, con_id, dev_fmt, ap);
312 va_end(ap);
313
314 return cl;
315}
316EXPORT_SYMBOL(clkdev_hw_alloc);
317
304/** 318/**
305 * clkdev_create - allocate and add a clkdev lookup structure 319 * clkdev_create - allocate and add a clkdev lookup structure
306 * @clk: struct clk to associate with all clk_lookups 320 * @clk: struct clk to associate with all clk_lookups
@@ -324,6 +338,29 @@ struct clk_lookup *clkdev_create(struct clk *clk, const char *con_id,
324} 338}
325EXPORT_SYMBOL_GPL(clkdev_create); 339EXPORT_SYMBOL_GPL(clkdev_create);
326 340
341/**
342 * clkdev_hw_create - allocate and add a clkdev lookup structure
343 * @hw: struct clk_hw to associate with all clk_lookups
344 * @con_id: connection ID string on device
345 * @dev_fmt: format string describing device name
346 *
347 * Returns a clk_lookup structure, which can be later unregistered and
348 * freed.
349 */
350struct clk_lookup *clkdev_hw_create(struct clk_hw *hw, const char *con_id,
351 const char *dev_fmt, ...)
352{
353 struct clk_lookup *cl;
354 va_list ap;
355
356 va_start(ap, dev_fmt);
357 cl = vclkdev_create(hw, con_id, dev_fmt, ap);
358 va_end(ap);
359
360 return cl;
361}
362EXPORT_SYMBOL_GPL(clkdev_hw_create);
363
327int clk_add_alias(const char *alias, const char *alias_dev_name, 364int clk_add_alias(const char *alias, const char *alias_dev_name,
328 const char *con_id, struct device *dev) 365 const char *con_id, struct device *dev)
329{ 366{
@@ -404,28 +441,28 @@ int clk_register_clkdev(struct clk *clk, const char *con_id,
404EXPORT_SYMBOL(clk_register_clkdev); 441EXPORT_SYMBOL(clk_register_clkdev);
405 442
406/** 443/**
407 * clk_register_clkdevs - register a set of clk_lookup for a struct clk 444 * clk_hw_register_clkdev - register one clock lookup for a struct clk_hw
408 * @clk: struct clk to associate with all clk_lookups 445 * @hw: struct clk_hw to associate with all clk_lookups
409 * @cl: array of clk_lookup structures with con_id and dev_id pre-initialized 446 * @con_id: connection ID string on device
410 * @num: number of clk_lookup structures to register 447 * @dev_id: format string describing device name
411 * 448 *
412 * To make things easier for mass registration, we detect error clks 449 * con_id or dev_id may be NULL as a wildcard, just as in the rest of
413 * from a previous clk_register() call, and return the error code for 450 * clkdev.
414 * those. This is to permit this function to be called immediately
415 * after clk_register().
416 */ 451 */
417int clk_register_clkdevs(struct clk *clk, struct clk_lookup *cl, size_t num) 452int clk_hw_register_clkdev(struct clk_hw *hw, const char *con_id,
453 const char *dev_id)
418{ 454{
419 unsigned i; 455 struct clk_lookup *cl;
420
421 if (IS_ERR(clk))
422 return PTR_ERR(clk);
423 456
424 for (i = 0; i < num; i++, cl++) { 457 /*
425 cl->clk_hw = __clk_get_hw(clk); 458 * Since dev_id can be NULL, and NULL is handled specially, we must
426 __clkdev_add(cl); 459 * pass it as either a NULL format string, or with "%s".
427 } 460 */
461 if (dev_id)
462 cl = __clk_register_clkdev(hw, con_id, "%s", dev_id);
463 else
464 cl = __clk_register_clkdev(hw, con_id, NULL);
428 465
429 return 0; 466 return cl ? 0 : -ENOMEM;
430} 467}
431EXPORT_SYMBOL(clk_register_clkdevs); 468EXPORT_SYMBOL(clk_hw_register_clkdev);