diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2010-08-05 14:18:03 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-08-05 14:18:03 -0700 |
commit | e9563355ac1175dd3440dc2ea5c28b27ed51a283 (patch) | |
tree | 8546d55832714b5d19ba4c7799266918ca04882e /drivers/staging/tidspbridge/pmgr/io.c | |
parent | cdd854bc42b5e6c79bbbc40c6600d995ffe6e747 (diff) | |
parent | b12d1995f650e92f26184afd28e6cf40bf64467a (diff) | |
download | op-kernel-dev-e9563355ac1175dd3440dc2ea5c28b27ed51a283.zip op-kernel-dev-e9563355ac1175dd3440dc2ea5c28b27ed51a283.tar.gz |
Staging: Merge staging-next into Linus's tree
Conflicts:
drivers/staging/Kconfig
drivers/staging/batman-adv/bat_sysfs.c
drivers/staging/batman-adv/device.c
drivers/staging/batman-adv/hard-interface.c
drivers/staging/cx25821/cx25821-audups11.c
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/tidspbridge/pmgr/io.c')
-rw-r--r-- | drivers/staging/tidspbridge/pmgr/io.c | 142 |
1 files changed, 142 insertions, 0 deletions
diff --git a/drivers/staging/tidspbridge/pmgr/io.c b/drivers/staging/tidspbridge/pmgr/io.c new file mode 100644 index 0000000..7970fe5 --- /dev/null +++ b/drivers/staging/tidspbridge/pmgr/io.c @@ -0,0 +1,142 @@ +/* + * io.c + * + * DSP-BIOS Bridge driver support functions for TI OMAP processors. + * + * IO manager interface: Manages IO between CHNL and msg_ctrl. + * + * Copyright (C) 2005-2006 Texas Instruments, Inc. + * + * This package is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ +#include <linux/types.h> + +/* ----------------------------------- Host OS */ +#include <dspbridge/host_os.h> + +/* ----------------------------------- DSP/BIOS Bridge */ +#include <dspbridge/dbdefs.h> + +/* ----------------------------------- Trace & Debug */ +#include <dspbridge/dbc.h> + +/* ----------------------------------- OS Adaptation Layer */ +#include <dspbridge/cfg.h> + +/* ----------------------------------- Platform Manager */ +#include <dspbridge/dev.h> + +/* ----------------------------------- This */ +#include <ioobj.h> +#include <dspbridge/iodefs.h> +#include <dspbridge/io.h> + +/* ----------------------------------- Globals */ +static u32 refs; + +/* + * ======== io_create ======== + * Purpose: + * Create an IO manager object, responsible for managing IO between + * CHNL and msg_ctrl + */ +int io_create(struct io_mgr **io_man, struct dev_object *hdev_obj, + const struct io_attrs *mgr_attrts) +{ + struct bridge_drv_interface *intf_fxns; + struct io_mgr *hio_mgr = NULL; + struct io_mgr_ *pio_mgr = NULL; + int status = 0; + + DBC_REQUIRE(refs > 0); + DBC_REQUIRE(io_man != NULL); + DBC_REQUIRE(mgr_attrts != NULL); + + *io_man = NULL; + + /* A memory base of 0 implies no memory base: */ + if ((mgr_attrts->shm_base != 0) && (mgr_attrts->usm_length == 0)) + status = -EINVAL; + + if (mgr_attrts->word_size == 0) + status = -EINVAL; + + if (!status) { + dev_get_intf_fxns(hdev_obj, &intf_fxns); + + /* Let Bridge channel module finish the create: */ + status = (*intf_fxns->pfn_io_create) (&hio_mgr, hdev_obj, + mgr_attrts); + + if (!status) { + pio_mgr = (struct io_mgr_ *)hio_mgr; + pio_mgr->intf_fxns = intf_fxns; + pio_mgr->hdev_obj = hdev_obj; + + /* Return the new channel manager handle: */ + *io_man = hio_mgr; + } + } + + return status; +} + +/* + * ======== io_destroy ======== + * Purpose: + * Delete IO manager. + */ +int io_destroy(struct io_mgr *hio_mgr) +{ + struct bridge_drv_interface *intf_fxns; + struct io_mgr_ *pio_mgr = (struct io_mgr_ *)hio_mgr; + int status; + + DBC_REQUIRE(refs > 0); + + intf_fxns = pio_mgr->intf_fxns; + + /* Let Bridge channel module destroy the io_mgr: */ + status = (*intf_fxns->pfn_io_destroy) (hio_mgr); + + return status; +} + +/* + * ======== io_exit ======== + * Purpose: + * Discontinue usage of the IO module. + */ +void io_exit(void) +{ + DBC_REQUIRE(refs > 0); + + refs--; + + DBC_ENSURE(refs >= 0); +} + +/* + * ======== io_init ======== + * Purpose: + * Initialize the IO module's private state. + */ +bool io_init(void) +{ + bool ret = true; + + DBC_REQUIRE(refs >= 0); + + if (ret) + refs++; + + DBC_ENSURE((ret && (refs > 0)) || (!ret && (refs >= 0))); + + return ret; +} |