blob: 9a9467ae73a26ce8e9e02f93af312e14eaefdee1 [file] [log] [blame]
Meng Wang688a8672019-01-29 13:43:33 +08001// SPDX-License-Identifier: GPL-2.0-only
Meng Wang61af6842018-09-10 17:47:55 +08002/*
3 * Copyright (c) 2016, The Linux Foundation. All rights reserved.
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +05304 */
5
6#include <linux/module.h>
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +05307#include <soc/qcom/subsystem_restart.h>
8#include <soc/qcom/subsystem_notif.h>
Laxminath Kasam605b42f2017-08-01 22:02:15 +05309#include "audio_ssr.h"
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +053010
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +053011static char *audio_ssr_domains[] = {
12 "adsp",
13 "modem"
14};
15
Laxminath Kasam8b1366a2017-10-05 01:44:16 +053016/**
17 * audio_ssr_register -
18 * register to SSR framework
19 *
20 * @domain_id: Domain ID to register with
21 * @nb: notifier block
22 *
23 * Returns handle pointer on success or error PTR on failure
24 */
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +053025void *audio_ssr_register(int domain_id, struct notifier_block *nb)
26{
27 if ((domain_id < 0) ||
28 (domain_id >= AUDIO_SSR_DOMAIN_MAX)) {
29 pr_err("%s: Invalid service ID %d\n", __func__, domain_id);
30 return ERR_PTR(-EINVAL);
31 }
32
33 return subsys_notif_register_notifier(
34 audio_ssr_domains[domain_id], nb);
35}
36EXPORT_SYMBOL(audio_ssr_register);
37
Laxminath Kasam8b1366a2017-10-05 01:44:16 +053038/**
39 * audio_ssr_deregister -
40 * Deregister handle from SSR framework
41 *
42 * @handle: SSR handle
43 * @nb: notifier block
44 *
45 * Returns 0 on success or error on failure
46 */
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +053047int audio_ssr_deregister(void *handle, struct notifier_block *nb)
48{
49 return subsys_notif_unregister_notifier(handle, nb);
50}
51EXPORT_SYMBOL(audio_ssr_deregister);
52