Meng Wang | 688a867 | 2019-01-29 13:43:33 +0800 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Meng Wang | 61af684 | 2018-09-10 17:47:55 +0800 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2016, The Linux Foundation. All rights reserved. |
Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <linux/module.h> |
Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 7 | #include <soc/qcom/subsystem_restart.h> |
| 8 | #include <soc/qcom/subsystem_notif.h> |
Laxminath Kasam | 605b42f | 2017-08-01 22:02:15 +0530 | [diff] [blame] | 9 | #include "audio_ssr.h" |
Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 10 | |
Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 11 | static char *audio_ssr_domains[] = { |
| 12 | "adsp", |
| 13 | "modem" |
| 14 | }; |
| 15 | |
Laxminath Kasam | 8b1366a | 2017-10-05 01:44:16 +0530 | [diff] [blame] | 16 | /** |
| 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 Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 25 | void *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 | } |
| 36 | EXPORT_SYMBOL(audio_ssr_register); |
| 37 | |
Laxminath Kasam | 8b1366a | 2017-10-05 01:44:16 +0530 | [diff] [blame] | 38 | /** |
| 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 Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 47 | int audio_ssr_deregister(void *handle, struct notifier_block *nb) |
| 48 | { |
| 49 | return subsys_notif_unregister_notifier(handle, nb); |
| 50 | } |
| 51 | EXPORT_SYMBOL(audio_ssr_deregister); |
| 52 | |