blob: 5865eff23c05cc19e4668b037e2952d1e5ea24b0 [file] [log] [blame]
Seemanta Duttabac64552012-12-14 15:47:27 -08001/* Copyright (c) 2011, 2013, The Linux Foundation. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002 *
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
22enum subsys_notif_type {
23 SUBSYS_BEFORE_SHUTDOWN,
24 SUBSYS_AFTER_SHUTDOWN,
25 SUBSYS_BEFORE_POWERUP,
26 SUBSYS_AFTER_POWERUP,
Seemanta Duttabac64552012-12-14 15:47:27 -080027 SUBSYS_RAMDUMP_NOTIFICATION,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070028 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 */
42void *subsys_notif_register_notifier(
43 const char *subsys_name, struct notifier_block *nb);
44int 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 */
52void *subsys_notif_add_subsys(const char *);
53int subsys_notif_queue_notification(void *subsys_handle,
Seemanta Duttabac64552012-12-14 15:47:27 -080054 enum subsys_notif_type notif_type,
55 void *data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070056#else
57
58static inline void *subsys_notif_register_notifier(
59 const char *subsys_name, struct notifier_block *nb)
60{
61 return NULL;
62}
63
64static inline int subsys_notif_unregister_notifier(void *subsys_handle,
65 struct notifier_block *nb)
66{
67 return 0;
68}
69
70static inline void *subsys_notif_add_subsys(const char *subsys_name)
71{
72 return NULL;
73}
74
75static inline int subsys_notif_queue_notification(void *subsys_handle,
Seemanta Duttabac64552012-12-14 15:47:27 -080076 enum subsys_notif_type notif_type,
77 void *data)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070078{
79 return 0;
80}
81#endif /* CONFIG_MSM_SUBSYSTEM_RESTART */
82
83#endif