Commit f6a0d9d5 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'staging-3.11-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging

Pull staging tree fixes from Greg KH:
 "Here are a few iio driver fixes for 3.11-rc2.  They are still spread
  across drivers/iio and drivers/staging/iio so they are coming in
  through this tree.

  I've also removed the drivers/staging/csr/ driver as the developers
  who originally sent it to me have moved on to other companies, and CSR
  still will not send us the specs for the device, making the driver
  pretty much obsolete and impossible to fix up.  Deleting it now
  prevents people from sending in lots of tiny codingsyle fixes that
  will never go anywhere.

  It also helps to offset the large lustre filesystem merge that
  happened in 3.11-rc1 in the overall 3.11.0 diffstat.  :)"

* tag 'staging-3.11-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging:
  staging: csr: remove driver
  iio: lps331ap: Fix wrong in_pressure_scale output value
  iio staging: fix lis3l02dq, read error handling
  staging:iio:ad7291: add missing .driver_module to struct iio_info
  iio: ti_am335x_adc: add missing .driver_module to struct iio_info
  iio: mxs-lradc: Remove useless check in read_raw
  iio: mxs-lradc: Fix misuse of iio->trig
  iio: inkern: fix iio_convert_raw_to_processed_unlocked
  iio: Fix iio_channel_has_info
  iio:trigger: device_unregister->device_del to avoid double free
  iio: dac: ad7303: fix error return code in ad7303_probe()
parents 36231d25 78077256
......@@ -183,6 +183,7 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
static const struct iio_info tiadc_info = {
.read_raw = &tiadc_read_raw,
.driver_module = THIS_MODULE,
};
static int tiadc_probe(struct platform_device *pdev)
......
......@@ -235,8 +235,10 @@ static int ad7303_probe(struct spi_device *spi)
if (ext_ref) {
st->vref_reg = regulator_get(&spi->dev, "REF");
if (IS_ERR(st->vref_reg))
if (IS_ERR(st->vref_reg)) {
ret = PTR_ERR(st->vref_reg);
goto err_disable_vdd_reg;
}
ret = regulator_enable(st->vref_reg);
if (ret)
......
......@@ -104,7 +104,7 @@ void iio_trigger_unregister(struct iio_trigger *trig_info)
ida_simple_remove(&iio_trigger_ida, trig_info->id);
/* Possible issue in here */
device_unregister(&trig_info->dev);
device_del(&trig_info->dev);
}
EXPORT_SYMBOL(iio_trigger_unregister);
......
......@@ -451,7 +451,7 @@ static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan,
int ret;
ret = iio_channel_read(chan, &offset, NULL, IIO_CHAN_INFO_OFFSET);
if (ret == 0)
if (ret >= 0)
raw64 += offset;
scale_type = iio_channel_read(chan, &scale_val, &scale_val2,
......
......@@ -28,7 +28,9 @@
#include <linux/iio/common/st_sensors.h>
#include "st_pressure.h"
#define ST_PRESS_MBAR_TO_KPASCAL(x) (x * 10)
#define ST_PRESS_LSB_PER_MBAR 4096UL
#define ST_PRESS_KPASCAL_NANO_SCALE (100000000UL / \
ST_PRESS_LSB_PER_MBAR)
#define ST_PRESS_NUMBER_DATA_CHANNELS 1
/* DEFAULT VALUE FOR SENSORS */
......@@ -51,8 +53,8 @@
#define ST_PRESS_1_FS_ADDR 0x23
#define ST_PRESS_1_FS_MASK 0x30
#define ST_PRESS_1_FS_AVL_1260_VAL 0x00
#define ST_PRESS_1_FS_AVL_1260_GAIN ST_PRESS_MBAR_TO_KPASCAL(244141)
#define ST_PRESS_1_FS_AVL_TEMP_GAIN 2083000
#define ST_PRESS_1_FS_AVL_1260_GAIN ST_PRESS_KPASCAL_NANO_SCALE
#define ST_PRESS_1_BDU_ADDR 0x20
#define ST_PRESS_1_BDU_MASK 0x04
#define ST_PRESS_1_DRDY_IRQ_ADDR 0x22
......
......@@ -118,8 +118,6 @@ source "drivers/staging/ozwpan/Kconfig"
source "drivers/staging/gdm72xx/Kconfig"
source "drivers/staging/csr/Kconfig"
source "drivers/staging/silicom/Kconfig"
source "drivers/staging/ced1401/Kconfig"
......
......@@ -52,7 +52,6 @@ obj-$(CONFIG_MFD_NVEC) += nvec/
obj-$(CONFIG_ANDROID) += android/
obj-$(CONFIG_USB_WPAN_HCD) += ozwpan/
obj-$(CONFIG_WIMAX_GDM72XX) += gdm72xx/
obj-$(CONFIG_CSR_WIFI) += csr/
obj-$(CONFIG_NET_VENDOR_SILICOM) += silicom/
obj-$(CONFIG_CED1401) += ced1401/
obj-$(CONFIG_DRM_IMX) += imx-drm/
......
config CSR_WIFI
tristate "CSR wireless driver"
depends on MMC && CFG80211_WEXT && INET
select WIRELESS_EXT
select WEXT_PRIV
help
Driver for the CSR wireless SDIO device.
If unsure, select N.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
Except as contained in this notice, the names of above-listed
copyright holders and the names of any contributors shall not be used
in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
CONTRIBUTORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Alternatively, this software may be distributed under the terms of the
GNU General Public License ("GPL") version 2 as published
by the Free Software Foundation.
As a special exception, if other files instantiate templates or use
macros or inline functions from this file, or you compile this file
and link it with other works to produce a work based on this file,
this file does not by itself cause the resulting work to be covered by
the GNU General Public License. However the source code for this file
must still be made available in accordance with section (3) of the GNU
General Public License.
This exception does not invalidate any other reasons why a work based
on this file might be covered by the GNU General Public License.
ccflags-y := -DCSR_SME_USERSPACE -DCSR_SUPPORT_SME -DREMOTE_SYS_SAP -DCSR_WIFI_SECURITY_WAPI_ENABLE -DENABLE_SHUTDOWN -DUNIFI_DEBUG
ccflags-y += -DSDIO_EXPORTS_STRUCT_DEVICE -DCSR_WIFI_SUPPORT_MMC_DRIVER -DCSR_WIFI_SINGLE_FUNCTION -DCSR_WIFI_SPLIT_PATCH
ccflags-y += -DCSR_SUPPORT_WEXT -DREMOTE_SYS_SAP -DREMOTE_MGT_SAP -DCSR_WIFI_SECURITY_WAPI_ENABLE -DCSR_WIFI_SECURITY_WAPI_QOSCTRL_MIC_WORKAROUND -DENABLE_SHUTDOWN -DCSR_WIFI_NME_ENABLE -DCSR_WIFI_AP_ENABLE -DCSR_SUPPORT_WEXT_AP -DCSR_WIFI_REQUEUE_PACKET_TO_HAL
obj-$(CONFIG_CSR_WIFI) += csr_wifi.o
obj-$(CONFIG_CSR_WIFI) += csr_helper.o
csr_wifi-y := bh.o \
data_tx.o \
drv.o \
firmware.o \
inet.o \
init_hw.o \
io.o \
monitor.o \
netdev.o \
os.o \
putest.o \
sdio_events.o \
sdio_mmc.o \
sdio_stubs.o \
sme_blocking.o \
ul_int.o \
unifi_dbg.o \
unifi_event.o \
unifi_pdu_processing.o \
unifi_sme.o \
csr_wifi_hip_card_sdio.o \
csr_wifi_hip_card_sdio_intr.o \
csr_wifi_hip_card_sdio_mem.o \
csr_wifi_hip_chiphelper.o \
csr_wifi_hip_download.o \
csr_wifi_hip_dump.o \
csr_wifi_hip_packing.o \
csr_wifi_hip_send.o \
csr_wifi_hip_signals.o \
csr_wifi_hip_ta_sampling.o \
csr_wifi_hip_udi.o \
csr_wifi_hip_unifi_signal_names.o \
csr_wifi_hip_xbv.o \
csr_wifi_nme_ap_converter_init.o \
csr_wifi_nme_ap_free_downstream_contents.o \
csr_wifi_nme_ap_free_upstream_contents.o \
csr_wifi_nme_ap_serialize.o \
csr_wifi_nme_ap_sef.o \
csr_wifi_router_ctrl_sef.o \
csr_wifi_router_sef.o \
csr_wifi_router_transport.o \
csr_wifi_sme_sef.o \
csr_wifi_sme_converter_init.o \
csr_wifi_sme_free_downstream_contents.o \
csr_wifi_sme_free_upstream_contents.o \
csr_wifi_sme_serialize.o \
csr_wifi_router_ctrl_converter_init.o \
csr_wifi_router_ctrl_free_downstream_contents.o \
csr_wifi_router_ctrl_free_upstream_contents.o \
csr_wifi_router_ctrl_serialize.o \
csr_wifi_router_converter_init.o \
csr_wifi_router_free_downstream_contents.o \
csr_wifi_router_free_upstream_contents.o \
csr_wifi_router_serialize.o \
sme_mgt.o \
sme_sys.o \
sme_userspace.o \
sme_wext.o \
wext_events.o
csr_helper-y := csr_time.o \
csr_util.o \
csr_framework_ext.o \
csr_wifi_serialize_primitive_types.o \
csr_serialize_primitive_types.o \
csr_msgconv.o
/*
* ---------------------------------------------------------------------------
* FILE: bh.c
*
* PURPOSE:
* Provides an implementation for the driver bottom-half.
* It is part of the porting exercise in Linux.
*
* Copyright (C) 2005-2009 by Cambridge Silicon Radio Ltd.
*
* Refer to LICENSE.txt included with this source code for details on
* the license terms.
*
* ---------------------------------------------------------------------------
*/
#include "csr_wifi_hip_unifi.h"
#include "unifi_priv.h"
#include <linux/sched/rt.h>
/*
* ---------------------------------------------------------------------------
* uf_start_thread
*
* Helper function to start a new thread.
*
* Arguments:
* priv Pointer to OS driver structure for the device.
* thread Pointer to the thread object
* func The thread function
*
* Returns:
* 0 on success or else a Linux error code.
* ---------------------------------------------------------------------------
*/
int uf_start_thread(unifi_priv_t *priv,
struct uf_thread *thread, int (*func)(void *))
{
if (thread->thread_task != NULL) {
unifi_error(priv, "%s thread already started\n", thread->name);
return 0;
}
/* Start the kernel thread that handles all h/w accesses. */
thread->thread_task = kthread_run(func, priv, "%s", thread->name);
if (IS_ERR(thread->thread_task))
return PTR_ERR(thread->thread_task);
/* Module parameter overides the thread priority */
if (bh_priority != -1) {
if (bh_priority >= 0 && bh_priority <= MAX_RT_PRIO) {
struct sched_param param;
priv->bh_thread.prio = bh_priority;
unifi_trace(priv, UDBG1,
"%s thread (RT) priority = %d\n",
thread->name, bh_priority);
param.sched_priority = bh_priority;
sched_setscheduler(thread->thread_task,
SCHED_FIFO, &param);
} else if (bh_priority > MAX_RT_PRIO &&
bh_priority <= MAX_PRIO) {
priv->bh_thread.prio = bh_priority;
unifi_trace(priv, UDBG1, "%s thread priority = %d\n",
thread->name,
PRIO_TO_NICE(bh_priority));
set_user_nice(thread->thread_task,
PRIO_TO_NICE(bh_priority));
} else {
priv->bh_thread.prio = DEFAULT_PRIO;
unifi_warning(priv,
"%s thread unsupported (%d) priority\n",
thread->name, bh_priority);
}
} else
priv->bh_thread.prio = DEFAULT_PRIO;
unifi_trace(priv, UDBG2, "Started %s thread\n", thread->name);
return 0;
} /* uf_start_thread() */
/*
* ---------------------------------------------------------------------------
* uf_stop_thread
*
* Helper function to stop a thread.
*
* Arguments:
* priv Pointer to OS driver structure for the device.
* thread Pointer to the thread object
*
* Returns:
*
* ---------------------------------------------------------------------------
*/
void uf_stop_thread(unifi_priv_t *priv, struct uf_thread *thread)
{
if (!thread->thread_task) {
unifi_notice(priv, "%s thread is already stopped\n",
thread->name);
return;
}
unifi_trace(priv, UDBG2, "Stopping %s thread\n", thread->name);
kthread_stop(thread->thread_task);
thread->thread_task = NULL;
} /* uf_stop_thread() */
/*
* ---------------------------------------------------------------------------
* uf_wait_for_thread_to_stop
*
* Helper function to wait until a thread is stopped.
*
* Arguments:
* priv Pointer to OS driver structure for the device.
*
* Returns:
*
* ---------------------------------------------------------------------------
*/
void
uf_wait_for_thread_to_stop(unifi_priv_t *priv, struct uf_thread *thread)
{
/*
* kthread_stop() cannot handle the thread exiting while
* kthread_should_stop() is false, so sleep until kthread_stop()
* wakes us up
*/
unifi_trace(priv, UDBG2, "%s waiting for the stop signal.\n",
thread->name);
set_current_state(TASK_INTERRUPTIBLE);
if (!kthread_should_stop()) {
unifi_trace(priv, UDBG2, "%s schedule....\n", thread->name);
schedule();
}
thread->thread_task = NULL;
unifi_trace(priv, UDBG2, "%s exiting....\n", thread->name);
} /* uf_wait_for_thread_to_stop() */
/*
* ---------------------------------------------------------------------------
* handle_bh_error
*
* This function reports an error returned from the HIP core bottom-half.
* Normally, implemented during the porting exercise, passing the error
* to the SME using unifi_sys_wifi_off_ind().
* The SME will try to reset the device and go through
* the initialisation of the UniFi.
*
* Arguments:
* priv Pointer to OS driver structure for the device.
*
* Returns:
* None.
* ---------------------------------------------------------------------------
*/
static void
handle_bh_error(unifi_priv_t *priv)
{
netInterface_priv_t *interfacePriv;
u8 conf_param = CONFIG_IND_ERROR;
u8 interfaceTag;
/* Block unifi_run_bh() until the error has been handled. */
priv->bh_thread.block_thread = 1;
/* Consider UniFi to be uninitialised */
priv->init_progress = UNIFI_INIT_NONE;
/* Stop the network traffic */
for (interfaceTag = 0;
interfaceTag < CSR_WIFI_NUM_INTERFACES; interfaceTag++) {
interfacePriv = priv->interfacePriv[interfaceTag];
if (interfacePriv->netdev_registered)
netif_carrier_off(priv->netdev[interfaceTag]);
}
#ifdef CSR_NATIVE_LINUX
/* Force any client waiting on an mlme_wait_for_reply() to abort. */
uf_abort_mlme(priv);
/* Cancel any pending workqueue tasks */
flush_workqueue(priv->unifi_workqueue);
#endif /* CSR_NATIVE_LINUX */
unifi_error(priv,
"handle_bh_error: fatal error is reported to the SME.\n");
/* Notify the clients (SME or unifi_manager) for the error. */
ul_log_config_ind(priv, &conf_param, sizeof(u8));
} /* handle_bh_error() */
/*
* ---------------------------------------------------------------------------
* bh_thread_function
*
* All hardware access happens in this thread.
* This means there is no need for locks on the hardware and we don't need
* to worry about reentrancy with the SDIO library.
* Provides and example implementation on how to call unifi_bh(), which
* is part of the HIP core API.
*
* It processes the events generated by unifi_run_bh() to serialise calls
* to unifi_bh(). It also demonstrates how the timeout parameter passed in
* and returned from unifi_bh() needs to be handled.
*
* Arguments:
* arg Pointer to OS driver structure for the device.
*
* Returns:
* None.
*
* Notes:
* When the bottom half of the driver needs to process signals, events,
* or simply the host status (i.e sleep mode), it invokes unifi_run_bh().
* Since we need all SDIO transaction to be in a single thread, the
* unifi_run_bh() will wake up this thread to process it.
*
* ---------------------------------------------------------------------------
*/
static int bh_thread_function(void *arg)
{
unifi_priv_t *priv = (unifi_priv_t *)arg;
CsrResult csrResult;
long ret;
u32 timeout, t;
struct uf_thread *this_thread;
unifi_trace(priv, UDBG2, "bh_thread_function starting\n");
this_thread = &priv->bh_thread;
t = timeout = 0;
while (!kthread_should_stop()) {
/*
* wait until an error occurs,
* or we need to process something.
*/
unifi_trace(priv, UDBG3, "bh_thread goes to sleep.\n");
if (timeout > 0) {
/* Convert t in ms to jiffies */
t = msecs_to_jiffies(timeout);
ret = wait_event_interruptible_timeout(
this_thread->wakeup_q,
(this_thread->wakeup_flag && !this_thread->block_thread) ||
kthread_should_stop(),
t);
timeout = (ret > 0) ? jiffies_to_msecs(ret) : 0;
} else {
ret = wait_event_interruptible(this_thread->wakeup_q,
(this_thread->wakeup_flag && !this_thread->block_thread) ||
kthread_should_stop());
}
if (kthread_should_stop()) {
unifi_trace(priv, UDBG2,
"bh_thread: signalled to exit\n");
break;
}
if (ret < 0) {
unifi_notice(priv,
"bh_thread: wait_event returned %d, thread will exit\n",
ret);
uf_wait_for_thread_to_stop(priv, this_thread);
break;
}
this_thread->wakeup_flag = 0;
unifi_trace(priv, UDBG3, "bh_thread calls unifi_bh().\n");
CsrSdioClaim(priv->sdio);
csrResult = unifi_bh(priv->card, &timeout);
if (csrResult != CSR_RESULT_SUCCESS) {
if (csrResult == CSR_WIFI_HIP_RESULT_NO_DEVICE) {
CsrSdioRelease(priv->sdio);
uf_wait_for_thread_to_stop(priv, this_thread);
break;
}
/* Errors must be delivered to the error task */
handle_bh_error(priv);
}
CsrSdioRelease(priv->sdio);
}
/*
* I would normally try to call csr_sdio_remove_irq() here to make sure
* that we do not get any interrupts while this thread is not running.
* However, the MMC/SDIO driver tries to kill its' interrupt thread.
* The kernel threads implementation does not allow to kill threads
* from a signalled to stop thread.
* So, instead call csr_sdio_linux_remove_irq() always after calling
* uf_stop_thread() to kill this thread.
*/
unifi_trace(priv, UDBG2, "bh_thread exiting....\n");
return 0;
} /* bh_thread_function() */
/*
* ---------------------------------------------------------------------------
* uf_init_bh
*
* Helper function to start the bottom half of the driver.
* All we need to do here is start the I/O bh thread.
*
* Arguments:
* priv Pointer to OS driver structure for the device.
*
* Returns:
* 0 on success or else a Linux error code.
* ---------------------------------------------------------------------------
*/
int
uf_init_bh(unifi_priv_t *priv)
{
int r;
/* Enable mlme interface. */
priv->io_aborted = 0;
/* Start the BH thread */
r = uf_start_thread(priv, &priv->bh_thread, bh_thread_function);
if (r) {
unifi_error(priv,
"uf_init_bh: failed to start the BH thread.\n");
return r;
}
/* Allow interrupts */
r = csr_sdio_linux_install_irq(priv->sdio);
if (r) {
unifi_error(priv,
"uf_init_bh: failed to install the IRQ.\n");
uf_stop_thread(priv, &priv->bh_thread);
}
return r;
} /* uf_init_bh() */
/*
* ---------------------------------------------------------------------------
* unifi_run_bh
*
* Part of the HIP core lib API, implemented in the porting exercise.
* The bottom half of the driver calls this function when
* it wants to process anything that requires access to unifi.
* We need to call unifi_bh() which in this implementation is done
* by waking up the I/O thread.
*
* Arguments:
* ospriv Pointer to OS driver structure for the device.
*
* Returns:
* 0 on success or else a Linux error code.
*
* Notes:
* ---------------------------------------------------------------------------
*/
CsrResult unifi_run_bh(void *ospriv)
{
unifi_priv_t *priv = ospriv;
/*
* If an error has occurred, we discard silently all messages from the bh
* until the error has been processed and the unifi has been
* reinitialised.
*/
if (priv->bh_thread.block_thread == 1) {
unifi_trace(priv, UDBG3, "unifi_run_bh: discard message.\n");
/*
* Do not try to acknowledge a pending interrupt here.
* This function is called by unifi_send_signal()
* which in turn can be running in an atomic or 'disabled irq'
* level if a signal is sent from a workqueue task
* (i.e multicass addresses set). We can not hold the SDIO lock
* because it might sleep.
*/
return CSR_RESULT_FAILURE;
}
priv->bh_thread.wakeup_flag = 1;
/* wake up I/O thread */
wake_up_interruptible(&priv->bh_thread.wakeup_q);
return CSR_RESULT_SUCCESS;
} /* unifi_run_bh() */
/*****************************************************************************
(c) Cambridge Silicon Radio Limited 2010
All rights reserved and confidential information of CSR
Refer to LICENSE.txt included with this source for details
on the license terms.
*****************************************************************************/
#include <linux/kernel.h>
#include <linux/kthread.h>
#include <linux/module.h>
#include <linux/freezer.h>
#include <linux/semaphore.h>
#include <linux/slab.h>
#include <linux/bitops.h>
#include "csr_framework_ext.h"
/*----------------------------------------------------------------------------*
* NAME
* CsrThreadSleep
*
* DESCRIPTION
* Sleep for a given period.
*
* RETURNS
* void
*
*----------------------------------------------------------------------------*/
void CsrThreadSleep(u16 sleepTimeInMs)
{
unsigned long t;
/* Convert t in ms to jiffies and round up */
t = ((sleepTimeInMs * HZ) + 999) / 1000;
schedule_timeout_uninterruptible(t);
}
EXPORT_SYMBOL_GPL(CsrThreadSleep);
#ifndef CSR_FRAMEWORK_EXT_H__
#define CSR_FRAMEWORK_EXT_H__
/*****************************************************************************
(c) Cambridge Silicon Radio Limited 2010
All rights reserved and confidential information of CSR
Refer to LICENSE.txt included with this source for details
on the license terms.
*****************************************************************************/
#include "csr_result.h"
#include "csr_framework_ext_types.h"
/* Result codes */
#define CSR_FE_RESULT_NO_MORE_EVENTS ((CsrResult) 0x0001)
#define CSR_FE_RESULT_INVALID_POINTER ((CsrResult) 0x0002)
#define CSR_FE_RESULT_INVALID_HANDLE ((CsrResult) 0x0003)
#define CSR_FE_RESULT_NO_MORE_MUTEXES ((CsrResult) 0x0004)
#define CSR_FE_RESULT_TIMEOUT ((CsrResult) 0x0005)
#define CSR_FE_RESULT_NO_MORE_THREADS ((CsrResult) 0x0006)
/* Thread priorities */
#define CSR_THREAD_PRIORITY_HIGHEST ((u16) 0)
#define CSR_THREAD_PRIORITY_HIGH ((u16) 1)
#define CSR_THREAD_PRIORITY_NORMAL ((u16) 2)
#define CSR_THREAD_PRIORITY_LOW ((u16) 3)
#define CSR_THREAD_PRIORITY_LOWEST ((u16) 4)
#define CSR_EVENT_WAIT_INFINITE ((u16) 0xFFFF)
void CsrThreadSleep(u16 sleepTimeInMs);
#endif
#ifndef CSR_FRAMEWORK_EXT_TYPES_H__
#define CSR_FRAMEWORK_EXT_TYPES_H__
/*****************************************************************************
(c) Cambridge Silicon Radio Limited 2010
All rights reserved and confidential information of CSR
Refer to LICENSE.txt included with this source for details
on the license terms.
*****************************************************************************/
#ifdef __KERNEL__
#include <linux/kthread.h>
#include <linux/semaphore.h>
#else
#include <pthread.h>
#endif
#ifdef __KERNEL__
typedef struct semaphore CsrMutexHandle;
#else /* __KERNEL __ */
typedef pthread_mutex_t CsrMutexHandle;
#endif /* __KERNEL__ */
#endif
#ifndef CSR_LOG_H__
#define CSR_LOG_H__
/*****************************************************************************
(c) Cambridge Silicon Radio Limited 2010
All rights reserved and confidential information of CSR
Refer to LICENSE.txt included with this source for details
on the license terms.
*****************************************************************************/
#include "csr_sched.h"
#include "csr_prim_defs.h"
#include "csr_msgconv.h"
/*
* Log filtering
*/
/*----------------------------------------------------*/
/* Filtering on environment specific log levels */
/*----------------------------------------------------*/
typedef u32 CsrLogLevelEnvironment;
#define CSR_LOG_LEVEL_ENVIRONMENT_OFF ((CsrLogLevelEnvironment) 0x00000000) /* No environment data/events are logged */
#define CSR_LOG_LEVEL_ENVIRONMENT_BCI_ACL ((CsrLogLevelEnvironment) 0x00000001) /* BlueCore Channel Interface HCI Acl data are logged */
#define CSR_LOG_LEVEL_ENVIRONMENT_BCI_HCI ((CsrLogLevelEnvironment) 0x00000002) /* BlueCore Channel Interface HCI Cmd/Evt data are logged */
#define CSR_LOG_LEVEL_ENVIRONMENT_BCI_SCO ((CsrLogLevelEnvironment) 0x00000004) /* BlueCore Channel Interface HCI Sco data are logged */
#define CSR_LOG_LEVEL_ENVIRONMENT_BCI_VENDOR ((CsrLogLevelEnvironment) 0x00000008) /* BlueCore Channel Interface HCI Vendor specific data are logged (This includes BCCMD, HQ, VM etc) */
#define CSR_LOG_LEVEL_ENVIRONMENT_TRANSPORTS ((CsrLogLevelEnvironment) 0x00000010) /* Transport protocol data is logged (This includes transport protocols like BCSP, H4 etc.) */
#define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_REG ((CsrLogLevelEnvironment) 0x00000020) /* Background Interrupt registration events are logged */
#define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_UNREG ((CsrLogLevelEnvironment) 0x00000040) /* Background Interrupt unregistration events are logged */
#define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_SET ((CsrLogLevelEnvironment) 0x00000080) /* Background Interrupt set events are logged */
#define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_START ((CsrLogLevelEnvironment) 0x00000100) /* Background Interrupt start events are logged */
#define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_DONE ((CsrLogLevelEnvironment) 0x00000200) /* Background Interrupt done events are logged */
#define CSR_LOG_LEVEL_ENVIRONMENT_PROTO ((CsrLogLevelEnvironment) 0x00000400) /* Transport protocol events are logged */
#define CSR_LOG_LEVEL_ENVIRONMENT_PROTO_LOC ((CsrLogLevelEnvironment) 0x00000800) /* The Location where the transport protocol event occurred are logged NB: This is a supplement to CSR_LOG_LEVEL_ENVIRONMENT_PROTO, it has no effect without it */
/* The bit masks between here are reserved for future usage */
#define CSR_LOG_LEVEL_ENVIRONMENT_ALL ((CsrLogLevelEnvironment) 0xFFFFFFFF) /* All possible environment data/events are logged WARNING: By using this define the application also accepts future possible environment data/events in the logs */
/*----------------------------------------------------*/
/* Filtering on task specific log levels */
/*----------------------------------------------------*/
typedef u32 CsrLogLevelTask;
#define CSR_LOG_LEVEL_TASK_OFF ((CsrLogLevelTask) 0x00000000) /* No events are logged for this task */
#define CSR_LOG_LEVEL_TASK_TEXT ((CsrLogLevelTask) 0x00000001) /* Text strings printed by a task are logged NB: This bit does not affect the CSR_LOG_TEXT_LEVEL interface. This has to be configured separately */
#define CSR_LOG_LEVEL_TASK_TEXT_LOC ((CsrLogLevelTask) 0x00000002) /* The locaction where the text string call occurred are logged. NB: This is a supplement to CSR_LOG_LEVEL_TASK_TEXT, it has no effect without it */
#define CSR_LOG_LEVEL_TASK_STATE ((CsrLogLevelTask) 0x00000004) /* FSM state transitions in a task are logged */
#define CSR_LOG_LEVEL_TASK_STATE_NAME ((CsrLogLevelTask) 0x00000008) /* The name of each state in a FSM state transition are logged. NB: This is a supplement to CSR_LOG_LEVEL_TASK_STATE, it has no effect without it */
#define CSR_LOG_LEVEL_TASK_STATE_LOC ((CsrLogLevelTask) 0x00000010) /* The location where the FSM state transition occurred are logged. NB: This is a supplement to CSR_LOG_LEVEL_TASK_STATE, it has no effect without it */
#define CSR_LOG_LEVEL_TASK_TASK_SWITCH ((CsrLogLevelTask) 0x00000020) /* Activation and deactiation of a task are logged */
#define CSR_LOG_LEVEL_TASK_MESSAGE_PUT ((CsrLogLevelTask) 0x00000080) /* Message put operations are logged */
#define CSR_LOG_LEVEL_TASK_MESSAGE_PUT_LOC ((CsrLogLevelTask) 0x00000100) /* The location where a message was sent are logged. NB: This is a supplement to CSR_LOG_LEVEL_TASK_MESSAGE_PUT, it has no effect without it */
#define CSR_LOG_LEVEL_TASK_MESSAGE_GET ((CsrLogLevelTask) 0x00000200) /* Message get operations are logged */
#define CSR_LOG_LEVEL_TASK_MESSAGE_QUEUE_PUSH ((CsrLogLevelTask) 0x00000400) /* Message push operations are logged */
#define CSR_LOG_LEVEL_TASK_MESSAGE_QUEUE_POP ((CsrLogLevelTask) 0x00000800) /* Message pop operations are logged */
#define CSR_LOG_LEVEL_TASK_PRIM_ONLY_TYPE ((CsrLogLevelTask) 0x00001000) /* Only the type of primitives in messages are logged. By default the entire primitive is serialized and logged */
#define CSR_LOG_LEVEL_TASK_PRIM_APPLY_LIMIT ((CsrLogLevelTask) 0x00002000) /* An upper limit (defined by CSR_LOG_PRIM_SIZE_UPPER_LIMIT) is applied to how much of a primitive in a message are logged. NB: This limit is only applied if CSR_LOG_LEVEL_TASK_PRIM_ONLY_TYPE is _not_ defined */
#define CSR_LOG_LEVEL_TASK_TIMER_IN ((CsrLogLevelTask) 0x00004000) /* TimedEventIn events are logged */
#define CSR_LOG_LEVEL_TASK_TIMER_IN_LOC ((CsrLogLevelTask) 0x00008000) /* The location where a timer was started are logged. NB: This is a supplement to CSR_LOG_LEVEL_TASK_TIMER_IN, it has no effect without it */
#define CSR_LOG_LEVEL_TASK_TIMER_CANCEL ((CsrLogLevelTask) 0x00010000) /* TimedEventCancel events are logged */
#define CSR_LOG_LEVEL_TASK_TIMER_CANCEL_LOC ((CsrLogLevelTask) 0x00020000) /* The location where a timer was cancelled are logged. NB: This is a supplement to CSR_LOG_LEVEL_TASK_TIMER_CANCEL, it has no effect without it */
#define CSR_LOG_LEVEL_TASK_TIMER_FIRE ((CsrLogLevelTask) 0x00040000) /* TimedEventFire events are logged */
#define CSR_LOG_LEVEL_TASK_TIMER_DONE ((CsrLogLevelTask) 0x00080000) /* TimedEventDone events are logged */
/* The bit masks between here are reserved for future usage */
#define CSR_LOG_LEVEL_TASK_ALL ((CsrLogLevelTask) 0xFFFFFFFF & ~(CSR_LOG_LEVEL_TASK_PRIM_ONLY_TYPE | CSR_LOG_LEVEL_TASK_PRIM_APPLY_LIMIT)) /* All info possible to log for a task are logged. WARNING: By using this define the application also accepts future possible task data/events in the logs */
u8 CsrLogEnvironmentIsFiltered(CsrLogLevelEnvironment level);
CsrLogLevelTask CsrLogTaskFilterGet(CsrSchedQid taskId);
u8 CsrLogTaskIsFiltered(CsrSchedQid taskId, CsrLogLevelTask level);
/*
* Logging stuff
*/
#define CSR_LOG_STRINGIFY_REAL(a) (#a)
#define CSR_LOG_STRINGIFY(a) CSR_LOG_STRINGIFY_REAL(a)
typedef struct {
u16 primitiveType;
const char *primitiveName;
CsrMsgConvMsgEntry *messageConv; /* Private - do not use */
} CsrLogPrimitiveInformation;
typedef struct {
const char *techVer;
u32 primitiveInfoCount;
CsrLogPrimitiveInformation *primitiveInfo;
} CsrLogTechInformation;
/*---------------------------------*/
/* Tech logging */
/*---------------------------------*/
typedef u8 bitmask8_t;
typedef u16 bitmask16_t;
typedef u32 bitmask32_t;
#ifdef CSR_LOG_ENABLE
#ifdef CSR_LOG_INCLUDE_FILE_NAME_AND_LINE_NUMBER
/* DEPRECATED - replaced by csr_log_text.h */
#define CSR_LOG_TEXT(text) \
do { \
if (!CsrLogTaskIsFiltered(CsrSchedTaskQueueGet(), CSR_LOG_LEVEL_TASK_TEXT)) { \
CsrLogTaskText(text, __LINE__, __FILE__); \
} \
} while (0)
#else
/* DEPRECATED - replaced by csr_log_text.h */
#define CSR_LOG_TEXT(text) \
do { \
if (!CsrLogTaskIsFiltered(CsrSchedTaskQueueGet(), CSR_LOG_LEVEL_TASK_TEXT)) { \
CsrLogTaskText(text, 0, NULL); \
} \
} while (0)
#endif
#else
#define CSR_LOG_TEXT(text)
#endif
/* DEPRECATED - replaced by csr_log_text.h */
void CsrLogTaskText(const char *text,
u32 line,
const char *file);
#define CSR_LOG_STATE_TRANSITION_MASK_FSM_NAME (0x001)
#define CSR_LOG_STATE_TRANSITION_MASK_NEXT_STATE (0x002)
#define CSR_LOG_STATE_TRANSITION_MASK_NEXT_STATE_STR (0x004)
#define CSR_LOG_STATE_TRANSITION_MASK_PREV_STATE (0x008)
#define CSR_LOG_STATE_TRANSITION_MASK_PREV_STATE_STR (0x010)
#define CSR_LOG_STATE_TRANSITION_MASK_EVENT (0x020)
#define CSR_LOG_STATE_TRANSITION_MASK_EVENT_STR (0x040)
/* DEPRECATED - replaced by csr_log_text.h */
void CsrLogStateTransition(bitmask16_t mask,
u32 identifier,
const char *fsm_name,
u32 prev_state,
const char *prev_state_str,
u32 in_event,
const char *in_event_str,
u32 next_state,
const char *next_state_str,
u32 line,
const char *file);
/*---------------------------------*/
/* BSP logging */
/*---------------------------------*/
void CsrLogSchedInit(u8 thread_id);
void CsrLogSchedDeinit(u8 thread_id);
void CsrLogSchedStart(u8 thread_id);
void CsrLogSchedStop(u8 thread_id);
void CsrLogInitTask(u8 thread_id, CsrSchedQid tskid, const char *tskName);
void CsrLogDeinitTask(u16 task_id);
void CsrLogActivate(CsrSchedQid tskid);
void CsrLogDeactivate(CsrSchedQid tskid);
#define SYNERGY_SERIALIZER_TYPE_DUMP (0x000)
#define SYNERGY_SERIALIZER_TYPE_SER (0x001)
void CsrLogMessagePut(u32 line,
const char *file,
CsrSchedQid src_task_id,
CsrSchedQid dst_taskid,
CsrSchedMsgId msg_id,
u16 prim_type,
const void *msg);
void CsrLogMessageGet(CsrSchedQid src_task_id,
CsrSchedQid dst_taskid,
u8 get_res,
CsrSchedMsgId msg_id,
u16 prim_type,
const void *msg);
void CsrLogTimedEventIn(u32 line,
const char *file,
CsrSchedQid task_id,
CsrSchedTid tid,
u32 requested_delay,
u16 fniarg,
const void *fnvarg);
void CsrLogTimedEventFire(CsrSchedQid task_id,
CsrSchedTid tid);
void CsrLogTimedEventDone(CsrSchedQid task_id,
CsrSchedTid tid);
void CsrLogTimedEventCancel(u32 line,
const char *file,
CsrSchedQid task_id,
CsrSchedTid tid,
u8 cancel_res);
void CsrLogBgintRegister(u8 thread_id,
CsrSchedBgint irq,
const char *callback,
const void *ptr);
void CsrLogBgintUnregister(CsrSchedBgint irq);
void CsrLogBgintSet(CsrSchedBgint irq);
void CsrLogBgintServiceStart(CsrSchedBgint irq);
void CsrLogBgintServiceDone(CsrSchedBgint irq);
void CsrLogExceptionStateEvent(u16 prim_type,
CsrPrim msg_type,
u16 state,
u32 line,
const char *file);
void CsrLogExceptionGeneral(u16 prim_type,
u16 state,
const char *text,
u32 line,
const char *file);
void CsrLogExceptionWarning(u16 prim_type,
u16 state,
const char *text,
u32 line,
const char *file);
#endif
#ifndef CSR_LOG_CONFIGURE_H__
#define CSR_LOG_CONFIGURE_H__
/*****************************************************************************
(c) Cambridge Silicon Radio Limited 2010
All rights reserved and confidential information of CSR
Refer to LICENSE.txt included with this source for details
on the license terms.
*****************************************************************************/
#include "csr_log.h"
/*--------------------------------------------*/
/* Filtering on log text warning levels */
/*--------------------------------------------*/
typedef u32 CsrLogLevelText;
#define CSR_LOG_LEVEL_TEXT_OFF ((CsrLogLevelText) 0x0000)
#define CSR_LOG_LEVEL_TEXT_CRITICAL ((CsrLogLevelText) 0x0001)
#define CSR_LOG_LEVEL_TEXT_ERROR ((CsrLogLevelText) 0x0002)
#define CSR_LOG_LEVEL_TEXT_WARNING ((CsrLogLevelText) 0x0004)
#define CSR_LOG_LEVEL_TEXT_INFO ((CsrLogLevelText) 0x0008)
#define CSR_LOG_LEVEL_TEXT_DEBUG ((CsrLogLevelText) 0x0010)
#define CSR_LOG_LEVEL_TEXT_ALL ((CsrLogLevelText) 0xFFFF)
/* The log text interface is used by both scheduler tasks and components outside the scheduler context.
* Therefore a CsrLogTextTaskId is introduced. It is effectively considered as two u16's. The lower
* 16 bits corresponds one2one with the scheduler queueId's (CsrSchedQid) and as such these bits can not be used
* by components outside scheduler tasks. The upper 16 bits are allocated for use of components outside the
* scheduler like drivers etc. Components in this range is defined independently by each technology. To avoid
* clashes the technologies are only allowed to assign values within the same restrictive range as allies to
* primitive identifiers. eg. for the framework components outside the scheduler is only allowed to assign
* taskId's in the range 0x0600xxxx to 0x06FFxxxx. And so on for other technologies. */
typedef u32 CsrLogTextTaskId;
#endif
#ifndef CSR_LOG_TEXT_H__
#define CSR_LOG_TEXT_H__
/*****************************************************************************
(c) Cambridge Silicon Radio Limited 2010
All rights reserved and confidential information of CSR
Refer to LICENSE.txt included with this source for details
on the license terms.
*****************************************************************************/
#include "csr_log_configure.h"
typedef struct CsrLogSubOrigin
{
u16 subOriginNumber; /* Id of the given SubOrigin */
const char *subOriginName; /* Prefix Text for this SubOrigin */
} CsrLogSubOrigin;
/* Register a task which is going to use the CSR_LOG_TEXT_XXX interface */
#ifdef CSR_LOG_ENABLE
void CsrLogTextRegister(CsrLogTextTaskId taskId, const char *taskName, u16 subOriginsLength, const CsrLogSubOrigin *subOrigins);
#else
#define CsrLogTextRegister(taskId, taskName, subOriginsLength, subOrigins)
#endif
/* CRITICAL: Conditions that are threatening to the integrity/stability of the
system as a whole. */
#if defined(CSR_LOG_ENABLE) && !defined(CSR_LOG_LEVEL_TEXT_CRITICAL_DISABLE)
void CsrLogTextCritical(CsrLogTextTaskId taskId, u16 subOrigin, const char *formatString, ...);
void CsrLogTextBufferCritical(CsrLogTextTaskId taskId, u16 subOrigin, size_t bufferLength, const void *buffer, const char *formatString, ...);
#define CSR_LOG_TEXT_CRITICAL(taskId_subOrigin_formatString_varargs) CsrLogTextCritical taskId_subOrigin_formatString_varargs
#define CSR_LOG_TEXT_CONDITIONAL_CRITICAL(condition, logtextargs) {if (condition) {CSR_LOG_TEXT_CRITICAL(logtextargs);}}
#define CSR_LOG_TEXT_BUFFER_CRITICAL(taskId_subOrigin_length_buffer_formatString_varargs) CsrLogTextBufferCritical taskId_subOrigin_length_buffer_formatString_varargs
#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_CRITICAL(condition, logtextbufferargs) {if (condition) {CSR_LOG_TEXT_BUFFER_CRITICAL(logtextbufferargs);}}
#else
#define CSR_LOG_TEXT_CRITICAL(taskId_subOrigin_formatString_varargs)
#define CSR_LOG_TEXT_CONDITIONAL_CRITICAL(condition, logtextargs)
#define CSR_LOG_TEXT_BUFFER_CRITICAL(taskId_subOrigin_length_buffer_formatString_varargs)
#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_CRITICAL(condition, logtextbufferargs)
#endif
/* ERROR: Malfunction of a component rendering it unable to operate correctly,
causing lack of functionality but not loss of system integrity/stability. */
#if defined(CSR_LOG_ENABLE) && !defined(CSR_LOG_LEVEL_TEXT_ERROR_DISABLE)
void CsrLogTextError(CsrLogTextTaskId taskId, u16 subOrigin, const char *formatString, ...);
void CsrLogTextBufferError(CsrLogTextTaskId taskId, u16 subOrigin, size_t bufferLength, const void *buffer, const char *formatString, ...);
#define CSR_LOG_TEXT_ERROR(taskId_subOrigin_formatString_varargs) CsrLogTextError taskId_subOrigin_formatString_varargs
#define CSR_LOG_TEXT_CONDITIONAL_ERROR(condition, logtextargs) {if (condition) {CSR_LOG_TEXT_ERROR(logtextargs);}}
#define CSR_LOG_TEXT_BUFFER_ERROR(taskId_subOrigin_length_buffer_formatString_varargs) CsrLogTextBufferError taskId_subOrigin_length_buffer_formatString_varargs
#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_ERROR(condition, logtextbufferargs) {if (condition) {CSR_LOG_TEXT_BUFFER_ERROR(logtextbufferargs);}}
#else
#define CSR_LOG_TEXT_ERROR(taskId_subOrigin_formatString_varargs)
#define CSR_LOG_TEXT_CONDITIONAL_ERROR(condition, logtextargs)
#define CSR_LOG_TEXT_BUFFER_ERROR(taskId_subOrigin_length_buffer_formatString_varargs)
#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_ERROR(condition, logtextbufferargs)
#endif
/* WARNING: Conditions that are unexpected and indicative of possible problems
or violations of specifications, where the result of such deviations does not
lead to malfunction of the component. */
#if defined(CSR_LOG_ENABLE) && !defined(CSR_LOG_LEVEL_TEXT_WARNING_DISABLE)
void CsrLogTextWarning(CsrLogTextTaskId taskId, u16 subOrigin, const char *formatString, ...);
void CsrLogTextBufferWarning(CsrLogTextTaskId taskId, u16 subOrigin, size_t bufferLength, const void *buffer, const char *formatString, ...);
#define CSR_LOG_TEXT_WARNING(taskId_subOrigin_formatString_varargs) CsrLogTextWarning taskId_subOrigin_formatString_varargs
#define CSR_LOG_TEXT_CONDITIONAL_WARNING(condition, logtextargs) {if (condition) {CSR_LOG_TEXT_WARNING(logtextargs);}}
#define CSR_LOG_TEXT_BUFFER_WARNING(taskId_subOrigin_length_buffer_formatString_varargs) CsrLogTextBufferWarning taskId_subOrigin_length_buffer_formatString_varargs
#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_WARNING(condition, logtextbufferargs) {if (condition) {CSR_LOG_TEXT_BUFFER_WARNING(logtextbufferargs);}}
#else
#define CSR_LOG_TEXT_WARNING(taskId_subOrigin_formatString_varargs)
#define CSR_LOG_TEXT_CONDITIONAL_WARNING(condition, logtextargs)
#define CSR_LOG_TEXT_BUFFER_WARNING(taskId_subOrigin_length_buffer_formatString_varargs)
#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_WARNING(condition, logtextbufferargs)
#endif
/* INFO: Important events that may aid in determining the conditions under which
the more severe conditions are encountered. */
#if defined(CSR_LOG_ENABLE) && !defined(CSR_LOG_LEVEL_TEXT_INFO_DISABLE)
void CsrLogTextInfo(CsrLogTextTaskId taskId, u16 subOrigin, const char *formatString, ...);
void CsrLogTextBufferInfo(CsrLogTextTaskId taskId, u16 subOrigin, size_t bufferLength, const void *buffer, const char *formatString, ...);
#define CSR_LOG_TEXT_INFO(taskId_subOrigin_formatString_varargs) CsrLogTextInfo taskId_subOrigin_formatString_varargs
#define CSR_LOG_TEXT_CONDITIONAL_INFO(condition, logtextargs) {if (condition) {CSR_LOG_TEXT_INFO(logtextargs);}}
#define CSR_LOG_TEXT_BUFFER_INFO(taskId_subOrigin_length_buffer_formatString_varargs) CsrLogTextBufferInfo taskId_subOrigin_length_buffer_formatString_varargs
#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_INFO(condition, logtextbufferargs) {if (condition) {CSR_LOG_TEXT_BUFFER_INFO(logtextbufferargs);}}
#else
#define CSR_LOG_TEXT_INFO(taskId_subOrigin_formatString_varargs)
#define CSR_LOG_TEXT_CONDITIONAL_INFO(condition, logtextargs)
#define CSR_LOG_TEXT_BUFFER_INFO(taskId_subOrigin_length_buffer_formatString_varargs)
#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_INFO(condition, logtextbufferargs)
#endif
/* DEBUG: Similar to INFO, but dedicated to events that occur more frequently. */
#if defined(CSR_LOG_ENABLE) && !defined(CSR_LOG_LEVEL_TEXT_DEBUG_DISABLE)
void CsrLogTextDebug(CsrLogTextTaskId taskId, u16 subOrigin, const char *formatString, ...);
void CsrLogTextBufferDebug(CsrLogTextTaskId taskId, u16 subOrigin, size_t bufferLength, const void *buffer, const char *formatString, ...);
#define CSR_LOG_TEXT_DEBUG(taskId_subOrigin_formatString_varargs) CsrLogTextDebug taskId_subOrigin_formatString_varargs
#define CSR_LOG_TEXT_CONDITIONAL_DEBUG(condition, logtextargs) {if (condition) {CSR_LOG_TEXT_DEBUG(logtextargs);}}
#define CSR_LOG_TEXT_BUFFER_DEBUG(taskId_subOrigin_length_buffer_formatString_varargs) CsrLogTextBufferDebug taskId_subOrigin_length_buffer_formatString_varargs
#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_DEBUG(condition, logtextbufferargs) {if (condition) {CSR_LOG_TEXT_BUFFER_DEBUG(logtextbufferargs);}}
#else
#define CSR_LOG_TEXT_DEBUG(taskId_subOrigin_formatString_varargs)
#define CSR_LOG_TEXT_CONDITIONAL_DEBUG(condition, logtextargs)
#define CSR_LOG_TEXT_BUFFER_DEBUG(taskId_subOrigin_length_buffer_formatString_varargs)
#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_DEBUG(condition, logtextbufferargs)
#endif
/* CSR_LOG_TEXT_ASSERT (CRITICAL) */
#ifdef CSR_LOG_ENABLE
#define CSR_LOG_TEXT_ASSERT(origin, suborigin, condition) \
{if (!(condition)) {CSR_LOG_TEXT_CRITICAL((origin, suborigin, "Assertion \"%s\" failed at %s:%u", #condition, __FILE__, __LINE__));}}
#else
#define CSR_LOG_TEXT_ASSERT(origin, suborigin, condition)
#endif
/* CSR_LOG_TEXT_UNHANDLED_PRIM (CRITICAL) */
#ifdef CSR_LOG_ENABLE
#define CSR_LOG_TEXT_UNHANDLED_PRIMITIVE(origin, suborigin, primClass, primType) \
CSR_LOG_TEXT_CRITICAL((origin, suborigin, "Unhandled primitive 0x%04X:0x%04X at %s:%u", primClass, primType, __FILE__, __LINE__))
#else
#define CSR_LOG_TEXT_UNHANDLED_PRIMITIVE(origin, suborigin, primClass, primType)
#endif
#endif
#ifndef CSR_MACRO_H__
#define CSR_MACRO_H__
/*****************************************************************************
(c) Cambridge Silicon Radio Limited 2010
All rights reserved and confidential information of CSR
Refer to LICENSE.txt included with this source for details
on the license terms.
*****************************************************************************/
#include <linux/types.h>
#define FALSE (0)
#define TRUE (1)
/*------------------------------------------------------------------*/
/* Endian conversion */
/*------------------------------------------------------------------*/
#define CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr) (((u16) ((u8 *) (ptr))[0]) | ((u16) ((u8 *) (ptr))[1]) << 8)
#define CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr) (((u32) ((u8 *) (ptr))[0]) | ((u32) ((u8 *) (ptr))[1]) << 8 | \
((u32) ((u8 *) (ptr))[2]) << 16 | ((u32) ((u8 *) (ptr))[3]) << 24)
#define CSR_COPY_UINT16_TO_LITTLE_ENDIAN(uint, ptr) ((u8 *) (ptr))[0] = ((u8) ((uint) & 0x00FF)); \
((u8 *) (ptr))[1] = ((u8) ((uint) >> 8))
#define CSR_COPY_UINT32_TO_LITTLE_ENDIAN(uint, ptr) ((u8 *) (ptr))[0] = ((u8) ((uint) & 0x000000FF)); \
((u8 *) (ptr))[1] = ((u8) (((uint) >> 8) & 0x000000FF)); \
((u8 *) (ptr))[2] = ((u8) (((uint) >> 16) & 0x000000FF)); \
((u8 *) (ptr))[3] = ((u8) (((uint) >> 24) & 0x000000FF))
/*------------------------------------------------------------------*/
/* Misc */
/*------------------------------------------------------------------*/
/* Use this macro on unused local variables that cannot be removed (such as
unused function parameters). This will quell warnings from certain compilers
and static code analysis tools like Lint and Valgrind. */
#define CSR_UNUSED(x) ((void) (x))
#endif
#ifndef CSR_MSG_TRANSPORT_H__
#define CSR_MSG_TRANSPORT_H__
/*****************************************************************************
(c) Cambridge Silicon Radio Limited 2010
All rights reserved and confidential information of CSR
Refer to LICENSE.txt included with this source for details
on the license terms.
*****************************************************************************/
#ifndef CsrMsgTransport
#define CsrMsgTransport CsrSchedMessagePut
#endif
#endif /* CSR_MSG_TRANSPORT */
/*****************************************************************************
(c) Cambridge Silicon Radio Limited 2010
All rights reserved and confidential information of CSR
Refer to LICENSE.txt included with this source for details
on the license terms.
*****************************************************************************/
#include <linux/module.h>
#include <linux/types.h>
#include <linux/slab.h>
#include "csr_sched.h"
#include "csr_msgconv.h"
#include "csr_macro.h"
static CsrMsgConvEntry *converter;
CsrMsgConvPrimEntry *CsrMsgConvFind(u16 primType)
{
CsrMsgConvPrimEntry *ptr = NULL;
if (converter)
{
ptr = converter->profile_converters;
while (ptr)
{
if (ptr->primType == primType)
{
break;
}
else
{
ptr = ptr->next;
}
}
}
return ptr;
}
static const CsrMsgConvMsgEntry *find_msg_converter(CsrMsgConvPrimEntry *ptr, u16 msgType)
{
const CsrMsgConvMsgEntry *cv = ptr->conv;
if (ptr->lookupFunc)
{
return (const CsrMsgConvMsgEntry *) ptr->lookupFunc((CsrMsgConvMsgEntry *) cv, msgType);
}
while (cv)
{
if (cv->serFunc == NULL)
{
/* We've reached the end of the chain */
cv = NULL;
break;
}
if (cv->msgType == msgType)
{
break;
}
else
{
cv++;
}
}
return cv;
}
static void *deserialize_data(u16 primType,
size_t length,
u8 *data)
{
CsrMsgConvPrimEntry *ptr;
u8 *ret;
ptr = CsrMsgConvFind(primType);
if (ptr)
{
const CsrMsgConvMsgEntry *cv;
u16 msgId = 0;
size_t offset = 0;
CsrUint16Des(&msgId, data, &offset);
cv = find_msg_converter(ptr, msgId);
if (cv)
{
ret = cv->deserFunc(data, length);
}
else
{
ret = NULL;
}
}
else
{
ret = NULL;
}
return ret;
}
static size_t sizeof_message(u16 primType, void *msg)
{
CsrMsgConvPrimEntry *ptr = CsrMsgConvFind(primType);
size_t ret;
if (ptr)
{
const CsrMsgConvMsgEntry *cv;
u16 msgId = *(u16 *) msg;
cv = find_msg_converter(ptr, msgId);
if (cv)
{
ret = cv->sizeofFunc(msg);
}
else
{
ret = 0;
}
}
else
{
ret = 0;
}
return ret;
}
static u8 free_message(u16 primType, u8 *data)
{
CsrMsgConvPrimEntry *ptr;
u8 ret;
ptr = CsrMsgConvFind(primType);
if (ptr)
{
const CsrMsgConvMsgEntry *cv;
u16 msgId = *(u16 *) data;
cv = find_msg_converter(ptr, msgId);
if (cv)
{
cv->freeFunc(data);
ret = TRUE;
}
else
{
ret = FALSE;
}
}
else
{
ret = FALSE;
}
return ret;
}
static u8 *serialize_message(u16 primType,
void *msg,
size_t *length,
u8 *buffer)
{
CsrMsgConvPrimEntry *ptr;
u8 *ret;
ptr = CsrMsgConvFind(primType);
*length = 0;
if (ptr)
{
const CsrMsgConvMsgEntry *cv;
cv = find_msg_converter(ptr, *(u16 *) msg);
if (cv)
{
ret = cv->serFunc(buffer, length, msg);
}
else
{
ret = NULL;
}
}
else
{
ret = NULL;
}
return ret;
}
size_t CsrMsgConvSizeof(u16 primType, void *msg)
{
return sizeof_message(primType, msg);
}
u8 *CsrMsgConvSerialize(u8 *buffer, size_t maxBufferOffset, size_t *offset, u16 primType, void *msg)
{
if (converter)
{
size_t serializedLength;
u8 *bufSerialized;
u8 *bufOffset = &buffer[*offset];
bufSerialized = converter->serialize_message(primType, msg, &serializedLength, bufOffset);
*offset += serializedLength;
return bufSerialized;
}
else
{
return NULL;
}
}
/* Insert profile converter at head of converter list. */
void CsrMsgConvInsert(u16 primType, const CsrMsgConvMsgEntry *ce)
{
CsrMsgConvPrimEntry *pc;
pc = CsrMsgConvFind(primType);
if (pc)
{
/* Already registered. Do nothing */
}
else
{
pc = kmalloc(sizeof(*pc), GFP_KERNEL);
pc->primType = primType;
pc->conv = ce;
pc->lookupFunc = NULL;
pc->next = converter->profile_converters;
converter->profile_converters = pc;
}
}
EXPORT_SYMBOL_GPL(CsrMsgConvInsert);
CsrMsgConvMsgEntry *CsrMsgConvFindEntry(u16 primType, u16 msgType)
{
CsrMsgConvPrimEntry *ptr = CsrMsgConvFind(primType);
if (ptr)
{
return (CsrMsgConvMsgEntry *) find_msg_converter(ptr, msgType);
}
return NULL;
}
EXPORT_SYMBOL_GPL(CsrMsgConvFindEntry);
CsrMsgConvMsgEntry *CsrMsgConvFindEntryByMsg(u16 primType, const void *msg)
{
CsrMsgConvPrimEntry *ptr = CsrMsgConvFind(primType);
if (ptr && msg)
{
u16 msgType = *((u16 *) msg);
return (CsrMsgConvMsgEntry *) find_msg_converter(ptr, msgType);
}
return NULL;
}
void CsrMsgConvCustomLookupRegister(u16 primType, CsrMsgCustomLookupFunc *lookupFunc)
{
CsrMsgConvPrimEntry *ptr = CsrMsgConvFind(primType);
if (ptr)
{
ptr->lookupFunc = lookupFunc;
}
}
EXPORT_SYMBOL_GPL(CsrMsgConvCustomLookupRegister);
CsrMsgConvEntry *CsrMsgConvInit(void)
{
if (!converter)
{
converter = kmalloc(sizeof(CsrMsgConvEntry), GFP_KERNEL);
converter->profile_converters = NULL;
converter->free_message = free_message;
converter->sizeof_message = sizeof_message;
converter->serialize_message = serialize_message;
converter->deserialize_data = deserialize_data;
}
return converter;
}
EXPORT_SYMBOL_GPL(CsrMsgConvInit);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment