hsi_boardinfo.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * HSI clients registration interface
  3. *
  4. * Copyright (C) 2010 Nokia Corporation. All rights reserved.
  5. *
  6. * Contact: Carlos Chinea <carlos.chinea@nokia.com>
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * version 2 as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20. * 02110-1301 USA
  21. */
  22. #include <linux/hsi/hsi.h>
  23. #include <linux/list.h>
  24. #include <linux/slab.h>
  25. #include "hsi_core.h"
  26. /*
  27. * hsi_board_list is only used internally by the HSI framework.
  28. * No one else is allowed to make use of it.
  29. */
  30. LIST_HEAD(hsi_board_list);
  31. EXPORT_SYMBOL_GPL(hsi_board_list);
  32. /**
  33. * hsi_register_board_info - Register HSI clients information
  34. * @info: Array of HSI clients on the board
  35. * @len: Length of the array
  36. *
  37. * HSI clients are statically declared and registered on board files.
  38. *
  39. * HSI clients will be automatically registered to the HSI bus once the
  40. * controller and the port where the clients wishes to attach are registered
  41. * to it.
  42. *
  43. * Return -errno on failure, 0 on success.
  44. */
  45. int __init hsi_register_board_info(struct hsi_board_info const *info,
  46. unsigned int len)
  47. {
  48. struct hsi_cl_info *cl_info;
  49. cl_info = kzalloc(sizeof(*cl_info) * len, GFP_KERNEL);
  50. if (!cl_info)
  51. return -ENOMEM;
  52. for (; len; len--, info++, cl_info++) {
  53. cl_info->info = *info;
  54. list_add_tail(&cl_info->list, &hsi_board_list);
  55. }
  56. return 0;
  57. }