audio_ssr.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* Copyright (c) 2016, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. */
  12. #include <linux/module.h>
  13. #include <soc/qcom/subsystem_restart.h>
  14. #include <soc/qcom/subsystem_notif.h>
  15. #include "audio_ssr.h"
  16. static char *audio_ssr_domains[] = {
  17. "adsp",
  18. "modem"
  19. };
  20. /**
  21. * audio_ssr_register -
  22. * register to SSR framework
  23. *
  24. * @domain_id: Domain ID to register with
  25. * @nb: notifier block
  26. *
  27. * Returns handle pointer on success or error PTR on failure
  28. */
  29. void *audio_ssr_register(int domain_id, struct notifier_block *nb)
  30. {
  31. if ((domain_id < 0) ||
  32. (domain_id >= AUDIO_SSR_DOMAIN_MAX)) {
  33. pr_err("%s: Invalid service ID %d\n", __func__, domain_id);
  34. return ERR_PTR(-EINVAL);
  35. }
  36. return subsys_notif_register_notifier(
  37. audio_ssr_domains[domain_id], nb);
  38. }
  39. EXPORT_SYMBOL(audio_ssr_register);
  40. /**
  41. * audio_ssr_deregister -
  42. * Deregister handle from SSR framework
  43. *
  44. * @handle: SSR handle
  45. * @nb: notifier block
  46. *
  47. * Returns 0 on success or error on failure
  48. */
  49. int audio_ssr_deregister(void *handle, struct notifier_block *nb)
  50. {
  51. return subsys_notif_unregister_notifier(handle, nb);
  52. }
  53. EXPORT_SYMBOL(audio_ssr_deregister);