hsi_boardinfo.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * HSI clients registration interface
  4. *
  5. * Copyright (C) 2010 Nokia Corporation. All rights reserved.
  6. *
  7. * Contact: Carlos Chinea <carlos.chinea@nokia.com>
  8. */
  9. #include <linux/hsi/hsi.h>
  10. #include <linux/list.h>
  11. #include <linux/slab.h>
  12. #include "hsi_core.h"
  13. /*
  14. * hsi_board_list is only used internally by the HSI framework.
  15. * No one else is allowed to make use of it.
  16. */
  17. LIST_HEAD(hsi_board_list);
  18. EXPORT_SYMBOL_GPL(hsi_board_list);
  19. /**
  20. * hsi_register_board_info - Register HSI clients information
  21. * @info: Array of HSI clients on the board
  22. * @len: Length of the array
  23. *
  24. * HSI clients are statically declared and registered on board files.
  25. *
  26. * HSI clients will be automatically registered to the HSI bus once the
  27. * controller and the port where the clients wishes to attach are registered
  28. * to it.
  29. *
  30. * Return -errno on failure, 0 on success.
  31. */
  32. int __init hsi_register_board_info(struct hsi_board_info const *info,
  33. unsigned int len)
  34. {
  35. struct hsi_cl_info *cl_info;
  36. cl_info = kcalloc(len, sizeof(*cl_info), GFP_KERNEL);
  37. if (!cl_info)
  38. return -ENOMEM;
  39. for (; len; len--, info++, cl_info++) {
  40. cl_info->info = *info;
  41. list_add_tail(&cl_info->list, &hsi_board_list);
  42. }
  43. return 0;
  44. }