blob: b1acb918e0fc36ebc3bfc57405354b16f6d73d6e [file] [log] [blame]
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +05301/* 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
13#include <linux/module.h>
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +053014#include <soc/qcom/subsystem_restart.h>
15#include <soc/qcom/subsystem_notif.h>
Laxminath Kasam605b42f2017-08-01 22:02:15 +053016#include "audio_ssr.h"
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +053017
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +053018static char *audio_ssr_domains[] = {
19 "adsp",
20 "modem"
21};
22
Laxminath Kasam8b1366a2017-10-05 01:44:16 +053023/**
24 * audio_ssr_register -
25 * register to SSR framework
26 *
27 * @domain_id: Domain ID to register with
28 * @nb: notifier block
29 *
30 * Returns handle pointer on success or error PTR on failure
31 */
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +053032void *audio_ssr_register(int domain_id, struct notifier_block *nb)
33{
34 if ((domain_id < 0) ||
35 (domain_id >= AUDIO_SSR_DOMAIN_MAX)) {
36 pr_err("%s: Invalid service ID %d\n", __func__, domain_id);
37 return ERR_PTR(-EINVAL);
38 }
39
40 return subsys_notif_register_notifier(
41 audio_ssr_domains[domain_id], nb);
42}
43EXPORT_SYMBOL(audio_ssr_register);
44
Laxminath Kasam8b1366a2017-10-05 01:44:16 +053045/**
46 * audio_ssr_deregister -
47 * Deregister handle from SSR framework
48 *
49 * @handle: SSR handle
50 * @nb: notifier block
51 *
52 * Returns 0 on success or error on failure
53 */
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +053054int audio_ssr_deregister(void *handle, struct notifier_block *nb)
55{
56 return subsys_notif_unregister_notifier(handle, nb);
57}
58EXPORT_SYMBOL(audio_ssr_deregister);
59