clk.c 841 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Copyright (c) 2012-2016 Zhang, Keguang <[email protected]>
  4. */
  5. #include <linux/clk-provider.h>
  6. #include <linux/slab.h>
  7. #include "clk.h"
  8. struct clk_hw *__init clk_hw_register_pll(struct device *dev,
  9. const char *name,
  10. const char *parent_name,
  11. const struct clk_ops *ops,
  12. unsigned long flags)
  13. {
  14. int ret;
  15. struct clk_hw *hw;
  16. struct clk_init_data init;
  17. /* allocate the divider */
  18. hw = kzalloc(sizeof(*hw), GFP_KERNEL);
  19. if (!hw)
  20. return ERR_PTR(-ENOMEM);
  21. init.name = name;
  22. init.ops = ops;
  23. init.flags = flags;
  24. init.parent_names = parent_name ? &parent_name : NULL;
  25. init.num_parents = parent_name ? 1 : 0;
  26. hw->init = &init;
  27. /* register the clock */
  28. ret = clk_hw_register(dev, hw);
  29. if (ret) {
  30. kfree(hw);
  31. hw = ERR_PTR(ret);
  32. }
  33. return hw;
  34. }