trusty-fiq.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Copyright (C) 2013 Google, Inc.
  3. *
  4. * This software is licensed under the terms of the GNU General Public
  5. * License version 2, as published by the Free Software Foundation, and
  6. * may be copied, distributed, and modified under those terms.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. */
  14. #include <linux/of_platform.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/trusty/smcall.h>
  17. #include <linux/trusty/trusty.h>
  18. #include "trusty-fiq.h"
  19. static int trusty_fiq_remove_child(struct device *dev, void *data)
  20. {
  21. platform_device_unregister(to_platform_device(dev));
  22. return 0;
  23. }
  24. static int trusty_fiq_probe(struct platform_device *pdev)
  25. {
  26. int ret;
  27. ret = trusty_fiq_arch_probe(pdev);
  28. if (ret)
  29. goto err_set_fiq_return;
  30. ret = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
  31. if (ret < 0) {
  32. dev_err(&pdev->dev, "Failed to add children: %d\n", ret);
  33. goto err_add_children;
  34. }
  35. return 0;
  36. err_add_children:
  37. device_for_each_child(&pdev->dev, NULL, trusty_fiq_remove_child);
  38. trusty_fiq_arch_remove(pdev);
  39. err_set_fiq_return:
  40. return ret;
  41. }
  42. static int trusty_fiq_remove(struct platform_device *pdev)
  43. {
  44. device_for_each_child(&pdev->dev, NULL, trusty_fiq_remove_child);
  45. trusty_fiq_arch_remove(pdev);
  46. return 0;
  47. }
  48. static const struct of_device_id trusty_fiq_of_match[] = {
  49. { .compatible = "android,trusty-fiq-v1", },
  50. {},
  51. };
  52. static struct platform_driver trusty_fiq_driver = {
  53. .probe = trusty_fiq_probe,
  54. .remove = trusty_fiq_remove,
  55. .driver = {
  56. .name = "trusty-fiq",
  57. .owner = THIS_MODULE,
  58. .of_match_table = trusty_fiq_of_match,
  59. },
  60. };
  61. static int __init trusty_fiq_driver_init(void)
  62. {
  63. return platform_driver_register(&trusty_fiq_driver);
  64. }
  65. static void __exit trusty_fiq_driver_exit(void)
  66. {
  67. platform_driver_unregister(&trusty_fiq_driver);
  68. }
  69. subsys_initcall(trusty_fiq_driver_init);
  70. module_exit(trusty_fiq_driver_exit);