Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 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 | |
| 13 | #include <linux/module.h> |
Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 14 | #include <soc/qcom/subsystem_restart.h> |
| 15 | #include <soc/qcom/subsystem_notif.h> |
Laxminath Kasam | 605b42f | 2017-08-01 22:02:15 +0530 | [diff] [blame] | 16 | #include "audio_ssr.h" |
Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 17 | |
Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 18 | static char *audio_ssr_domains[] = { |
| 19 | "adsp", |
| 20 | "modem" |
| 21 | }; |
| 22 | |
Laxminath Kasam | 8b1366a | 2017-10-05 01:44:16 +0530 | [diff] [blame] | 23 | /** |
| 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 Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 32 | void *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 | } |
| 43 | EXPORT_SYMBOL(audio_ssr_register); |
| 44 | |
Laxminath Kasam | 8b1366a | 2017-10-05 01:44:16 +0530 | [diff] [blame] | 45 | /** |
| 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 Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 54 | int audio_ssr_deregister(void *handle, struct notifier_block *nb) |
| 55 | { |
| 56 | return subsys_notif_unregister_notifier(handle, nb); |
| 57 | } |
| 58 | EXPORT_SYMBOL(audio_ssr_deregister); |
| 59 | |