Seemanta Dutta | bac6455 | 2012-12-14 15:47:27 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2011, 2013, The Linux Foundation. All rights reserved. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 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 | * Subsystem restart notifier API header |
| 14 | * |
| 15 | */ |
| 16 | |
| 17 | #ifndef _SUBSYS_NOTIFIER_H |
| 18 | #define _SUBSYS_NOTIFIER_H |
| 19 | |
| 20 | #include <linux/notifier.h> |
| 21 | |
| 22 | enum subsys_notif_type { |
| 23 | SUBSYS_BEFORE_SHUTDOWN, |
| 24 | SUBSYS_AFTER_SHUTDOWN, |
| 25 | SUBSYS_BEFORE_POWERUP, |
| 26 | SUBSYS_AFTER_POWERUP, |
Seemanta Dutta | bac6455 | 2012-12-14 15:47:27 -0800 | [diff] [blame] | 27 | SUBSYS_RAMDUMP_NOTIFICATION, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 28 | SUBSYS_NOTIF_TYPE_COUNT |
| 29 | }; |
| 30 | |
| 31 | #if defined(CONFIG_MSM_SUBSYSTEM_RESTART) |
| 32 | /* Use the subsys_notif_register_notifier API to register for notifications for |
| 33 | * a particular subsystem. This API will return a handle that can be used to |
| 34 | * un-reg for notifications using the subsys_notif_unregister_notifier API by |
| 35 | * passing in that handle as an argument. |
| 36 | * |
| 37 | * On receiving a notification, the second (unsigned long) argument of the |
| 38 | * notifier callback will contain the notification type, and the third (void *) |
| 39 | * argument will contain the handle that was returned by |
| 40 | * subsys_notif_register_notifier. |
| 41 | */ |
| 42 | void *subsys_notif_register_notifier( |
| 43 | const char *subsys_name, struct notifier_block *nb); |
| 44 | int subsys_notif_unregister_notifier(void *subsys_handle, |
| 45 | struct notifier_block *nb); |
| 46 | |
| 47 | /* Use the subsys_notif_init_subsys API to initialize the notifier chains form |
| 48 | * a particular subsystem. This API will return a handle that can be used to |
| 49 | * queue notifications using the subsys_notif_queue_notification API by passing |
| 50 | * in that handle as an argument. |
| 51 | */ |
| 52 | void *subsys_notif_add_subsys(const char *); |
| 53 | int subsys_notif_queue_notification(void *subsys_handle, |
Seemanta Dutta | bac6455 | 2012-12-14 15:47:27 -0800 | [diff] [blame] | 54 | enum subsys_notif_type notif_type, |
| 55 | void *data); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 56 | #else |
| 57 | |
| 58 | static inline void *subsys_notif_register_notifier( |
| 59 | const char *subsys_name, struct notifier_block *nb) |
| 60 | { |
| 61 | return NULL; |
| 62 | } |
| 63 | |
| 64 | static inline int subsys_notif_unregister_notifier(void *subsys_handle, |
| 65 | struct notifier_block *nb) |
| 66 | { |
| 67 | return 0; |
| 68 | } |
| 69 | |
| 70 | static inline void *subsys_notif_add_subsys(const char *subsys_name) |
| 71 | { |
| 72 | return NULL; |
| 73 | } |
| 74 | |
| 75 | static inline int subsys_notif_queue_notification(void *subsys_handle, |
Seemanta Dutta | bac6455 | 2012-12-14 15:47:27 -0800 | [diff] [blame] | 76 | enum subsys_notif_type notif_type, |
| 77 | void *data) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 78 | { |
| 79 | return 0; |
| 80 | } |
| 81 | #endif /* CONFIG_MSM_SUBSYSTEM_RESTART */ |
| 82 | |
| 83 | #endif |