Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
msg.c
Go to the documentation of this file.
1 /*
2  * msg.c
3  *
4  * DSP-BIOS Bridge driver support functions for TI OMAP processors.
5  *
6  * DSP/BIOS Bridge msg_ctrl Module.
7  *
8  * Copyright (C) 2005-2006 Texas Instruments, Inc.
9  *
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.
13  *
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.
17  */
18 #include <linux/types.h>
19 
20 /* ----------------------------------- Host OS */
21 #include <dspbridge/host_os.h>
22 
23 /* ----------------------------------- DSP/BIOS Bridge */
24 #include <dspbridge/dbdefs.h>
25 
26 /* ----------------------------------- Bridge Driver */
27 #include <dspbridge/dspdefs.h>
28 
29 /* ----------------------------------- Platform Manager */
30 #include <dspbridge/dev.h>
31 
32 /* ----------------------------------- This */
33 #include <msgobj.h>
34 #include <dspbridge/msg.h>
35 
36 /*
37  * ======== msg_create ========
38  * Purpose:
39  * Create an object to manage message queues. Only one of these objects
40  * can exist per device object.
41  */
42 int msg_create(struct msg_mgr **msg_man,
43  struct dev_object *hdev_obj, msg_onexit msg_callback)
44 {
45  struct bridge_drv_interface *intf_fxns;
46  struct msg_mgr_ *msg_mgr_obj;
47  struct msg_mgr *hmsg_mgr;
48  int status = 0;
49 
50  *msg_man = NULL;
51 
52  dev_get_intf_fxns(hdev_obj, &intf_fxns);
53 
54  /* Let Bridge message module finish the create: */
55  status =
56  (*intf_fxns->msg_create) (&hmsg_mgr, hdev_obj, msg_callback);
57 
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;
63 
64  /* Finally, return the new message manager handle: */
65  *msg_man = hmsg_mgr;
66  } else {
67  status = -EPERM;
68  }
69  return status;
70 }
71 
72 /*
73  * ======== msg_delete ========
74  * Purpose:
75  * Delete a msg_ctrl manager allocated in msg_create().
76  */
77 void msg_delete(struct msg_mgr *hmsg_mgr)
78 {
79  struct msg_mgr_ *msg_mgr_obj = (struct msg_mgr_ *)hmsg_mgr;
80  struct bridge_drv_interface *intf_fxns;
81 
82  if (msg_mgr_obj) {
83  intf_fxns = msg_mgr_obj->intf_fxns;
84 
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);
90  }
91 }