net-next:asix: V2 Update VERSION
[zen-stable.git] / drivers / staging / tidspbridge / pmgr / msg.c
bloba6916039eed6bf026744ab4a4caef1bdc3b5c8cb
1 /*
2 * msg.c
4 * DSP-BIOS Bridge driver support functions for TI OMAP processors.
6 * DSP/BIOS Bridge msg_ctrl Module.
8 * Copyright (C) 2005-2006 Texas Instruments, Inc.
10 * This package is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
14 * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
16 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
18 #include <linux/types.h>
20 /* ----------------------------------- Host OS */
21 #include <dspbridge/host_os.h>
23 /* ----------------------------------- DSP/BIOS Bridge */
24 #include <dspbridge/dbdefs.h>
26 /* ----------------------------------- Trace & Debug */
27 #include <dspbridge/dbc.h>
29 /* ----------------------------------- Bridge Driver */
30 #include <dspbridge/dspdefs.h>
32 /* ----------------------------------- Platform Manager */
33 #include <dspbridge/dev.h>
35 /* ----------------------------------- This */
36 #include <msgobj.h>
37 #include <dspbridge/msg.h>
39 /* ----------------------------------- Globals */
40 static u32 refs; /* module reference count */
43 * ======== msg_create ========
44 * Purpose:
45 * Create an object to manage message queues. Only one of these objects
46 * can exist per device object.
48 int msg_create(struct msg_mgr **msg_man,
49 struct dev_object *hdev_obj, msg_onexit msg_callback)
51 struct bridge_drv_interface *intf_fxns;
52 struct msg_mgr_ *msg_mgr_obj;
53 struct msg_mgr *hmsg_mgr;
54 int status = 0;
56 DBC_REQUIRE(refs > 0);
57 DBC_REQUIRE(msg_man != NULL);
58 DBC_REQUIRE(msg_callback != NULL);
59 DBC_REQUIRE(hdev_obj != NULL);
61 *msg_man = NULL;
63 dev_get_intf_fxns(hdev_obj, &intf_fxns);
65 /* Let Bridge message module finish the create: */
66 status =
67 (*intf_fxns->msg_create) (&hmsg_mgr, hdev_obj, msg_callback);
69 if (!status) {
70 /* Fill in DSP API message module's fields of the msg_mgr
71 * structure */
72 msg_mgr_obj = (struct msg_mgr_ *)hmsg_mgr;
73 msg_mgr_obj->intf_fxns = intf_fxns;
75 /* Finally, return the new message manager handle: */
76 *msg_man = hmsg_mgr;
77 } else {
78 status = -EPERM;
80 return status;
84 * ======== msg_delete ========
85 * Purpose:
86 * Delete a msg_ctrl manager allocated in msg_create().
88 void msg_delete(struct msg_mgr *hmsg_mgr)
90 struct msg_mgr_ *msg_mgr_obj = (struct msg_mgr_ *)hmsg_mgr;
91 struct bridge_drv_interface *intf_fxns;
93 DBC_REQUIRE(refs > 0);
95 if (msg_mgr_obj) {
96 intf_fxns = msg_mgr_obj->intf_fxns;
98 /* Let Bridge message module destroy the msg_mgr: */
99 (*intf_fxns->msg_delete) (hmsg_mgr);
100 } else {
101 dev_dbg(bridge, "%s: Error hmsg_mgr handle: %p\n",
102 __func__, hmsg_mgr);
107 * ======== msg_exit ========
109 void msg_exit(void)
111 DBC_REQUIRE(refs > 0);
112 refs--;
114 DBC_ENSURE(refs >= 0);
118 * ======== msg_mod_init ========
120 bool msg_mod_init(void)
122 DBC_REQUIRE(refs >= 0);
124 refs++;
126 DBC_ENSURE(refs >= 0);
128 return true;