PageRenderTime 11ms CodeModel.GetById 7ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/drivers/staging/tidspbridge/pmgr/msg.c

https://bitbucket.org/cyanogenmod/android_kernel_asus_tf300t
C | 129 lines | 59 code | 24 blank | 46 comment | 7 complexity | 843eaa57b00d5632c080333cd2ede503 MD5 | raw file
Possible License(s): LGPL-2.0, AGPL-1.0, GPL-2.0
  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/*  ----------------------------------- Trace & Debug */
 27#include <dspbridge/dbc.h>
 28
 29/*  ----------------------------------- Bridge Driver */
 30#include <dspbridge/dspdefs.h>
 31
 32/*  ----------------------------------- Platform Manager */
 33#include <dspbridge/dev.h>
 34
 35/*  ----------------------------------- This */
 36#include <msgobj.h>
 37#include <dspbridge/msg.h>
 38
 39/*  ----------------------------------- Globals */
 40static u32 refs;		/* module reference count */
 41
 42/*
 43 *  ======== msg_create ========
 44 *  Purpose:
 45 *      Create an object to manage message queues. Only one of these objects
 46 *      can exist per device object.
 47 */
 48int msg_create(struct msg_mgr **msg_man,
 49		      struct dev_object *hdev_obj, msg_onexit msg_callback)
 50{
 51	struct bridge_drv_interface *intf_fxns;
 52	struct msg_mgr_ *msg_mgr_obj;
 53	struct msg_mgr *hmsg_mgr;
 54	int status = 0;
 55
 56	DBC_REQUIRE(refs > 0);
 57	DBC_REQUIRE(msg_man != NULL);
 58	DBC_REQUIRE(msg_callback != NULL);
 59	DBC_REQUIRE(hdev_obj != NULL);
 60
 61	*msg_man = NULL;
 62
 63	dev_get_intf_fxns(hdev_obj, &intf_fxns);
 64
 65	/* Let Bridge message module finish the create: */
 66	status =
 67	    (*intf_fxns->msg_create) (&hmsg_mgr, hdev_obj, msg_callback);
 68
 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;
 74
 75		/* Finally, return the new message manager handle: */
 76		*msg_man = hmsg_mgr;
 77	} else {
 78		status = -EPERM;
 79	}
 80	return status;
 81}
 82
 83/*
 84 *  ======== msg_delete ========
 85 *  Purpose:
 86 *      Delete a msg_ctrl manager allocated in msg_create().
 87 */
 88void msg_delete(struct msg_mgr *hmsg_mgr)
 89{
 90	struct msg_mgr_ *msg_mgr_obj = (struct msg_mgr_ *)hmsg_mgr;
 91	struct bridge_drv_interface *intf_fxns;
 92
 93	DBC_REQUIRE(refs > 0);
 94
 95	if (msg_mgr_obj) {
 96		intf_fxns = msg_mgr_obj->intf_fxns;
 97
 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);
103	}
104}
105
106/*
107 *  ======== msg_exit ========
108 */
109void msg_exit(void)
110{
111	DBC_REQUIRE(refs > 0);
112	refs--;
113
114	DBC_ENSURE(refs >= 0);
115}
116
117/*
118 *  ======== msg_mod_init ========
119 */
120bool msg_mod_init(void)
121{
122	DBC_REQUIRE(refs >= 0);
123
124	refs++;
125
126	DBC_ENSURE(refs >= 0);
127
128	return true;
129}