aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Cox <alan@linux.intel.com>2010-12-08 10:57:25 +0000
committerAlan Cox <alan@linux.intel.com>2010-12-08 10:57:25 +0000
commitd8da9fe1a3c920d1d91bcf258c748dbf06f3604a (patch)
tree910308c48f02370251804e69458c847456ea72a4
parent31071084b5a35310b8431ffdfb40958d636e40f4 (diff)
downloadmrst-s0i3-test-d8da9fe1a3c920d1d91bcf258c748dbf06f3604a.tar.gz
mrst-s0i3-test-d8da9fe1a3c920d1d91bcf258c748dbf06f3604a.tar.xz
mrst-s0i3-test-d8da9fe1a3c920d1d91bcf258c748dbf06f3604a.zip
Signed-off-by: Mark A. Allyn <mark.a.allyn@intel.com>
-rw-r--r--drivers/staging/sep/sep_driver.c189
1 files changed, 185 insertions, 4 deletions
diff --git a/drivers/staging/sep/sep_driver.c b/drivers/staging/sep/sep_driver.c
index 2991fe7651d..8eed123dc78 100644
--- a/drivers/staging/sep/sep_driver.c
+++ b/drivers/staging/sep/sep_driver.c
@@ -1044,7 +1044,8 @@ static unsigned long sep_set_time(struct sep_device *sep)
u32 *time_addr; /* address of time as seen by the kernel */
- dbg("sep:sep_set_time start\n");
+ dev_dbg(&sep->pdev->dev,
+ "sep:sep_set_time start\n");
do_gettimeofday(&time);
@@ -1054,13 +1055,193 @@ static unsigned long sep_set_time(struct sep_device *sep)
time_addr[0] = SEP_TIME_VAL_TOKEN;
time_addr[1] = time.tv_sec;
- edbg("SEP Driver:time.tv_sec is %lu\n", time.tv_sec);
- edbg("SEP Driver:time_addr is %p\n", time_addr);
- edbg("SEP Driver:sep->shared_addr is %p\n", sep->shared_addr);
+ dev_dbg(&sep->pdev->dev,
+ "time.tv_sec is %lu\n", time.tv_sec);
+ dev_dbg(&sep->pdev->dev,
+ "time_addr is %p\n", time_addr);
+ dev_dbg(&sep->pdev->dev,
+ "sep->shared_addr is %p\n", sep->shared_addr);
return time.tv_sec;
}
+/*
+ initializes the caller id functionality
+ @sep: sep device
+*/
+static int sep_init_caller_id(struct sep_device *sep)
+{
+ /* return value */
+ int ret_val;
+
+ /* counter */
+ int counter;
+
+ struct cb_id caller_id;
+
+
+ /*----------------------------
+ CODE
+ ---------------------------------*/
+
+ dev_dbg(&sep->pdev->dev,
+ "sep_init_caller_id start\n");
+
+ ret_val = 0;
+
+ /* init cb_id struct */
+ caller_id.idx = CN_IDX_PROC;
+ caller_id.val = CN_VAL_PROC;
+
+ /* init caller id table */
+ for (counter = 0; counter < SEP_CALLER_ID_TABLE_NUM_ENTRIES; counter++)
+ sep->caller_id_table[counter].pid = 0;
+
+
+ /* init access flag */
+ sep->singleton_access_flag = 0;
+
+ dev_dbg(&sep->pdev->dev,
+ "caller id table init finished\n");
+
+ /* register to netlink connector */
+ /* ret_val = cn_add_callback(&caller_id,
+ "sep_caller_id", sep_cn_callback); */
+
+ if (ret_val)
+ dev_warn(&sep->pdev->dev,
+ "cn_add_callback failed %x\n", ret_val);
+
+ dev_dbg(&sep->pdev->dev,
+ "sep_init_caller_id end\n");
+
+ return ret_val;
+}
+
+/*
+ inserts the data into the caller id table
+ @sep: sep device
+ @arg: pointer to struct sep_driver_set_caller_id_t
+*/
+static int sep_set_caller_id_handler(struct sep_device *sep, u32 arg)
+{
+ /* error */
+ int error;
+
+ /* counter */
+ int i;
+
+ /* command arguments */
+ struct sep_driver_set_caller_id_t command_args;
+
+ /*----------------------------
+ CODE
+ ------------------------------*/
+
+ dev_dbg(&sep->pdev->dev,
+ "sep_set_caller_id_handler start\n");
+
+ error = 0;
+
+ for (i = 0; i < SEP_CALLER_ID_TABLE_NUM_ENTRIES; i++) {
+ if (sep->caller_id_table[i].pid == 0)
+ break;
+ }
+
+ if (i == SEP_CALLER_ID_TABLE_NUM_ENTRIES) {
+
+ dev_warn(&sep->pdev->dev,
+ "no more caller id entries left\n");
+ dev_warn(&sep->pdev->dev,
+ "maximum number is %d\n",
+ SEP_CALLER_ID_TABLE_NUM_ENTRIES);
+
+ error = -ENOMEM;
+ goto end_function;
+ }
+
+ /* copy the data */
+ if (copy_from_user(&command_args, (void *)arg,
+ sizeof(command_args))) {
+ dev_warn(&sep->pdev->dev,
+ "copy_from_user failed\n");
+ error = -EFAULT;
+ goto end_function;
+ }
+
+ if (!command_args.pid || !command_args.callerIdAddress ||
+ !command_args.callerIdSizeInBytes) {
+ dev_warn(&sep->pdev->dev,
+ "params validation error\n");
+ error = -EINVAL;
+ goto end_function;
+ }
+
+ dev_dbg(&sep->pdev->dev,
+ "pid is %x\n", command_args.pid);
+ dev_dbg(&sep->pdev->dev,
+ "callerIdSizeInBytes is %x\n",
+ command_args.callerIdSizeInBytes);
+
+ if (command_args.callerIdSizeInBytes >
+ SEP_CALLER_ID_HASH_SIZE_IN_BYTES) {
+ dev_warn(&sep->pdev->dev,
+ "callerIdSizeInBytes too big\n");
+ error = -EINVAL;
+ goto end_function;
+ }
+
+ sep->caller_id_table[i].pid = command_args.pid;
+
+ if (copy_from_user(sep->caller_id_table[i].callerIdHash,
+ command_args.callerIdAddress, command_args.callerIdSizeInBytes))
+ dev_warn(&sep->pdev->dev,
+ "copy_from_user for callerIdAddress failed\n");
+ error = -EFAULT;
+
+end_function:
+
+ dev_dbg(&sep->pdev->dev,
+ "sep_set_caller_id_handler end\n");
+
+ return error;
+}
+
+/*
+ set the caller id (if exists) to the sep
+ @sep: pointer to struct_sep
+*/
+static int sep_set_current_caller_id(struct sep_device *sep)
+{
+ int i;
+
+ dev_dbg(&sep->pdev->dev, "sep_set_current_caller_id start\n");
+
+ dev_dbg(&sep->pdev->dev, "current process is %d\n", current->pid);
+
+ /* zero the previous value */
+ memset((void *)(sep->shared_addr +
+ (SEP_CALLER_ID_OFFSET_BYTES)),
+ 0,
+ SEP_CALLER_ID_HASH_SIZE_IN_BYTES);
+
+ for (i = 0; i < SEP_CALLER_ID_TABLE_NUM_ENTRIES; i++) {
+ if (sep->caller_id_table[i].pid == current->pid) {
+ dev_dbg(&sep->pdev->dev, "Caller Id found\n");
+
+ memcpy((void *)(sep->shared_addr +
+ (SEP_CALLER_ID_OFFSET_BYTES)),
+ (void *)(sep->caller_id_table[i].callerIdHash),
+ SEP_CALLER_ID_HASH_SIZE_IN_BYTES);
+ break;
+ }
+ }
+
+ dev_dbg(&sep->pdev->dev, "sep_set_current_caller_id end\n");
+
+ return 0;
+}
+
/**
* sep_send_command_handler - kick off a command
* @sep: sep being signalled