initial commit with v3.6.7
[linux-3.6.7-moxart.git] / drivers / staging / tidspbridge / pmgr / msg.c
blobf093cfb51c0035e46c7a46b0b45586ff513e84e4
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 /* ----------------------------------- Bridge Driver */
27 #include <dspbridge/dspdefs.h>
29 /* ----------------------------------- Platform Manager */
30 #include <dspbridge/dev.h>
32 /* ----------------------------------- This */
33 #include <msgobj.h>
34 #include <dspbridge/msg.h>
37 * ======== msg_create ========
38 * Purpose:
39 * Create an object to manage message queues. Only one of these objects
40 * can exist per device object.
42 int msg_create(struct msg_mgr **msg_man,
43 struct dev_object *hdev_obj, msg_onexit msg_callback)
45 struct bridge_drv_interface *intf_fxns;
46 struct msg_mgr_ *msg_mgr_obj;
47 struct msg_mgr *hmsg_mgr;
48 int status = 0;
50 *msg_man = NULL;
52 dev_get_intf_fxns(hdev_obj, &intf_fxns);
54 /* Let Bridge message module finish the create: */
55 status =
56 (*intf_fxns->msg_create) (&hmsg_mgr, hdev_obj, msg_callback);
58 if (!status) {
59 /* Fill in DSP API message module's fields of the msg_mgr
60 * structure */
61 msg_mgr_obj = (struct msg_mgr_ *)hmsg_mgr;
62 msg_mgr_obj->intf_fxns = intf_fxns;
64 /* Finally, return the new message manager handle: */
65 *msg_man = hmsg_mgr;
66 } else {
67 status = -EPERM;
69 return status;
73 * ======== msg_delete ========
74 * Purpose:
75 * Delete a msg_ctrl manager allocated in msg_create().
77 void msg_delete(struct msg_mgr *hmsg_mgr)
79 struct msg_mgr_ *msg_mgr_obj = (struct msg_mgr_ *)hmsg_mgr;
80 struct bridge_drv_interface *intf_fxns;
82 if (msg_mgr_obj) {
83 intf_fxns = msg_mgr_obj->intf_fxns;
85 /* Let Bridge message module destroy the msg_mgr: */
86 (*intf_fxns->msg_delete) (hmsg_mgr);
87 } else {
88 dev_dbg(bridge, "%s: Error hmsg_mgr handle: %p\n",
89 __func__, hmsg_mgr);