clk.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright (c) 2012-2016 Zhang, Keguang <keguang.zhang@gmail.com>
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License as published by the
  6. * Free Software Foundation; either version 2 of the License, or (at your
  7. * option) any later version.
  8. */
  9. #include <linux/clk-provider.h>
  10. #include <linux/slab.h>
  11. struct clk_hw *__init clk_hw_register_pll(struct device *dev,
  12. const char *name,
  13. const char *parent_name,
  14. const struct clk_ops *ops,
  15. unsigned long flags)
  16. {
  17. int ret;
  18. struct clk_hw *hw;
  19. struct clk_init_data init;
  20. /* allocate the divider */
  21. hw = kzalloc(sizeof(*hw), GFP_KERNEL);
  22. if (!hw)
  23. return ERR_PTR(-ENOMEM);
  24. init.name = name;
  25. init.ops = ops;
  26. init.flags = flags | CLK_IS_BASIC;
  27. init.parent_names = (parent_name ? &parent_name : NULL);
  28. init.num_parents = (parent_name ? 1 : 0);
  29. hw->init = &init;
  30. /* register the clock */
  31. ret = clk_hw_register(dev, hw);
  32. if (ret) {
  33. kfree(hw);
  34. hw = ERR_PTR(ret);
  35. }
  36. return hw;
  37. }