Re: [PATCH 2/2] staging: tidspbridge: rmgr code cleanup

2010-12-24 Thread Ionut Nicu
Hi Omar,

On Wed, 2010-12-22 at 14:52 -0600, Ramirez Luna, Omar wrote:
 Hi Ionut,
 
 On Thu, Dec 9, 2010 at 3:47 PM, Ionut Nicu ionut.n...@gmail.com wrote:
  Reorganized some code in the rmgr module to increase
  its readability. No functional changes were done.
 
  Signed-off-by: Ionut Nicu ionut.n...@mindbit.ro
  ---
   drivers/staging/tidspbridge/rmgr/drv.c  |  171 +---
   drivers/staging/tidspbridge/rmgr/node.c |   81 +-
   drivers/staging/tidspbridge/rmgr/rmm.c  |  266 
  +-
   3 files changed, 229 insertions(+), 289 deletions(-)
 
  +
  +   /* Update the Driver Object List */
  +   list_add_tail((struct list_head *)pszdev_node,
  +   pdrv_object-dev_node_string);
 
 I'm not quite comfortable casting to list_head ptr, given that there
 is already a member of that type, if the struct type of pszdev_node is
 moved around and the first member changes, there should be issues.
 
 Any reason to use them in this patch?
 

You are right, it's useless and error prone. I will fix this and the
other occurrences.

Regards,
Ionut.

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Inconsistent lock state caused by omap_mbox_msg_send() called from tidspbridge

2010-12-12 Thread Ionut Nicu
Hi Laurent,

On Sun, 2010-12-12 at 13:44 +0100, Laurent Pinchart wrote:
 Hi Ohad,
 
 While testing the tidspbridge driver (2.6.37-rc5, plus patches from the 
 dspbridge branch in linux-omap-2.6) I ran into the following lock 
 inconsistency:
 
 [  191.045166] =
 [  191.051269] [ INFO: inconsistent lock state ]
 [  191.055816] 2.6.37-rc5-00062-gd8b8a63 #8
 [  191.059906] -
 [  191.064453] inconsistent {IN-SOFTIRQ-W} - {SOFTIRQ-ON-W} usage.
 [  191.070709] dummy/1544 [HC0[0]:SC0[0]:HE1:SE1] takes:
 [  191.075988]  ((mq-lock)-rlock){+.?...}, at: [bf000744] 
 omap_mbox_msg_send+0x18/0xa4 [mailbox]
 [  191.085479] {IN-SOFTIRQ-W} state was registered at:
 [  191.090576]   [c008e914] __lock_acquire+0x5f0/0x17c4
 [  191.095947]   [c008fbc0] lock_acquire+0xd8/0xfc
 [  191.100860]   [c0373d3c] _raw_spin_lock+0x30/0x40
 [  191.105957]   [bf000744] omap_mbox_msg_send+0x18/0xa4 [mailbox]
 [  191.112335]   [bf014a08] sm_interrupt_dsp+0xe0/0x114 [bridgedriver]
 [  191.119201]   [bf0122d4] io_dpc+0x364/0x6c4 [bridgedriver]
 [  191.125152]   [c0067294] tasklet_action+0x70/0x100
 [  191.130371]   [c0067974] __do_softirq+0xc4/0x1b4
 [  191.135375]   [c0067b44] do_softirq+0x44/0x68
 [  191.140136]   [c0067bcc] run_ksoftirqd+0x64/0x10c
 [  191.145233]   [c007c3a0] kthread+0x84/0x8c
 [  191.149688]   [c003aad0] kernel_thread_exit+0x0/0x8
 [  191.154968] irq event stamp: 3602


I noticed this too, but this patch should fix it:

https://patchwork.kernel.org/patch/365292/

Ionut.

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] staging: tidspbridge: rmgr/node.c code cleanup

2010-12-12 Thread Ionut Nicu
Hi,

On Thu, 2010-12-09 at 17:03 -0600, Ramirez Luna, Omar wrote:
 Hi Ionut,
 
 On Thu, Dec 9, 2010 at 4:22 PM, Ionut Nicu ionut.n...@mindbit.ro wrote:
  Hi Omar,
 
  On Thu, 2010-12-09 at 23:47 +0200, Ionut Nicu wrote:
  Reorganized some code in rmgr/node.c to increase its
  readability. Most of the changes reduce the code
  indentation level and simplifiy the code. No functional
  changes were done.
 
  snip
 
/*
 * Check stream mode. Default is STRMMODE_PROCCOPY.
 */
  - if (!status  pattrs) {
  - if (pattrs-strm_mode != STRMMODE_PROCCOPY)
  - status = -EPERM;/* illegal stream mode */
  -
  - }
  - if (status)
  - goto func_end;
  + if (pattrs  pattrs-strm_mode != STRMMODE_PROCCOPY)
  + return -EPERM;  /* illegal stream mode */
 
 
  While cleaning up and reviewing the code I saw this check,  which unless
  it's intentional I think it looks like a bug. See comment below.
 
  snip
  + strm_mode = pattrs ? pattrs-strm_mode : STRMMODE_PROCCOPY;
  + switch (strm_mode) {
  + case STRMMODE_RDMA:
 
  ...
 
  +
  + case STRMMODE_ZEROCOPY:
 
  ...
 
  + case STRMMODE_PROCCOPY:
 
  It looks like all modes are handled here although the only one that
  could escape the validation from above is STRMMODE_PROCCOPY.
 
  I tried removing the first check and tested with the
  userspace-dspbridge strmcopy application, but I noticed the DSP hangs if
  I try to use it with anything else than the copy mode.
 
  Are the other modes (rdma, zerocopy) not supported at all?
 
 No, those modes are not supported... the only one working for dsp
 streams is proc-copy.
 

Is there any plan to make them work? If not, maybe the code that handles
them should be removed...

Thanks,
Ionut.

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] staging: tidspbridge: use the right type for list_is_last

2010-12-12 Thread Ionut Nicu
Hi Omar,

On Wed, 2010-12-08 at 16:20 -0600, Omar Ramirez Luna wrote:
 Removes the following warning:
 
   CC [M]  drivers/staging/tidspbridge/rmgr/rmm.o
 drivers/staging/tidspbridge/rmgr/rmm.c: In function 'rmm_alloc':
 drivers/staging/tidspbridge/rmgr/rmm.c:147: warning: passing
   argument 1 of 'list_is_last' from incompatible pointer type
 include/linux/list.h:170: note: expected 'const struct list_head *'
   but argument is of type 'struct rmm_ovly_sect *'
 
 Signed-off-by: Omar Ramirez Luna omar.rami...@ti.com
 ---
  drivers/staging/tidspbridge/rmgr/rmm.c |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
 
 diff --git a/drivers/staging/tidspbridge/rmgr/rmm.c 
 b/drivers/staging/tidspbridge/rmgr/rmm.c
 index aae8657..5a3f09c 100644
 --- a/drivers/staging/tidspbridge/rmgr/rmm.c
 +++ b/drivers/staging/tidspbridge/rmgr/rmm.c
 @@ -144,7 +144,7 @@ int rmm_alloc(struct rmm_target_obj *target, u32 segid, 
 u32 size,
   new_sect-addr = addr;
   new_sect-size = size;
   new_sect-page = segid;
 - if (list_is_last(sect, target-ovly_list))
 + if (list_is_last(sect-list_elem, target-ovly_list))
   /* Put new section at the end of the list */
   list_add_tail(new_sect-list_elem,
   target-ovly_list);


Sorry, I added this warning by mistake, so ...

Acked-by: Ionut Nicu ionut.n...@mindbit.ro

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/2] staging: tidspbridge: various cleanups

2010-12-09 Thread Ionut Nicu
This series is a reduced set of the previous one, containing only two
patches that were changed based on Omar's review:

http://marc.info/?l=linux-omapm=129162731925095

Also rebased to the latest dspbridge branch from the
omapzoom.org git tree.

Ionut Nicu (2):
  staging: tidspbridge: rmgr/node.c code cleanup
  staging: tidspbridge: rmgr code cleanup

 drivers/staging/tidspbridge/rmgr/drv.c  |  171 -
 drivers/staging/tidspbridge/rmgr/node.c |  682 +++
 drivers/staging/tidspbridge/rmgr/rmm.c  |  266 ++---
 3 files changed, 509 insertions(+), 610 deletions(-)

-- 
1.7.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] staging: tidspbridge: rmgr/node.c code cleanup

2010-12-09 Thread Ionut Nicu
Reorganized some code in rmgr/node.c to increase its
readability. Most of the changes reduce the code
indentation level and simplifiy the code. No functional
changes were done.

Signed-off-by: Ionut Nicu ionut.n...@mindbit.ro
---
 drivers/staging/tidspbridge/rmgr/node.c |  607 ++
 1 files changed, 283 insertions(+), 324 deletions(-)

diff --git a/drivers/staging/tidspbridge/rmgr/node.c 
b/drivers/staging/tidspbridge/rmgr/node.c
index 62d5c31..b196a7a 100644
--- a/drivers/staging/tidspbridge/rmgr/node.c
+++ b/drivers/staging/tidspbridge/rmgr/node.c
@@ -236,9 +236,9 @@ struct node_object {
 
 /* Default buffer attributes */
 static struct dsp_bufferattr node_dfltbufattrs = {
-   0,  /* cb_struct */
-   1,  /* segment_id */
-   0,  /* buf_alignment */
+   .cb_struct = 0,
+   .segment_id = 1,
+   .buf_alignment = 0,
 };
 
 static void delete_node(struct node_object *hnode,
@@ -284,8 +284,7 @@ enum node_state node_get_state(void *hnode)
struct node_object *pnode = (struct node_object *)hnode;
if (!pnode)
return -1;
-   else
-   return pnode-node_state;
+   return pnode-node_state;
 }
 
 /*
@@ -844,6 +843,7 @@ int node_connect(struct node_object *node1, u32 stream1,
char *pstr_dev_name = NULL;
enum node_type node1_type = NODE_TASK;
enum node_type node2_type = NODE_TASK;
+   enum dsp_strmmode strm_mode;
struct node_strmdef *pstrm_def;
struct node_strmdef *input = NULL;
struct node_strmdef *output = NULL;
@@ -857,60 +857,49 @@ int node_connect(struct node_object *node1, u32 stream1,
int status = 0;
DBC_REQUIRE(refs  0);
 
-   if ((node1 != (struct node_object *)DSP_HGPPNODE  !node1) ||
-   (node2 != (struct node_object *)DSP_HGPPNODE  !node2))
-   status = -EFAULT;
+   if (!node1 || !node2)
+   return -EFAULT;
 
-   if (!status) {
-   /* The two nodes must be on the same processor */
-   if (node1 != (struct node_object *)DSP_HGPPNODE 
-   node2 != (struct node_object *)DSP_HGPPNODE 
-   node1-hnode_mgr != node2-hnode_mgr)
-   status = -EPERM;
-   /* Cannot connect a node to itself */
-   if (node1 == node2)
-   status = -EPERM;
+   /* The two nodes must be on the same processor */
+   if (node1 != (struct node_object *)DSP_HGPPNODE 
+   node2 != (struct node_object *)DSP_HGPPNODE 
+   node1-hnode_mgr != node2-hnode_mgr)
+   return -EPERM;
 
-   }
-   if (!status) {
-   /* node_get_type() will return NODE_GPP if hnode =
-* DSP_HGPPNODE. */
-   node1_type = node_get_type(node1);
-   node2_type = node_get_type(node2);
-   /* Check stream indices ranges */
-   if ((node1_type != NODE_GPP  node1_type != NODE_DEVICE 
-stream1 = MAX_OUTPUTS(node1)) || (node2_type != NODE_GPP
-  node2_type !=
- NODE_DEVICE
-  stream2 =
- MAX_INPUTS(node2)))
-   status = -EINVAL;
-   }
-   if (!status) {
-   /*
-*  Only the following types of connections are allowed:
-*  task/dais socket  ==  task/dais socket
-*  task/dais socket  ==  device
-*  task/dais socket  ==  GPP
-*
-*  ie, no message nodes, and at least one task or dais
-*  socket node.
-*/
-   if (node1_type == NODE_MESSAGE || node2_type == NODE_MESSAGE ||
-   (node1_type != NODE_TASK  node1_type != NODE_DAISSOCKET 
-node2_type != NODE_TASK  node2_type != NODE_DAISSOCKET))
-   status = -EPERM;
-   }
+   /* Cannot connect a node to itself */
+   if (node1 == node2)
+   return -EPERM;
+
+   /* node_get_type() will return NODE_GPP if hnode =  DSP_HGPPNODE. */
+   node1_type = node_get_type(node1);
+   node2_type = node_get_type(node2);
+   /* Check stream indices ranges */
+   if ((node1_type != NODE_GPP  node1_type != NODE_DEVICE 
+   stream1 = MAX_OUTPUTS(node1)) ||
+   (node2_type != NODE_GPP  node2_type != NODE_DEVICE 
+stream2 = MAX_INPUTS(node2)))
+   return -EINVAL;
+
+   /*
+*  Only the following types of connections are allowed:
+*  task/dais socket  ==  task/dais socket
+*  task/dais socket

[PATCH 2/2] staging: tidspbridge: rmgr code cleanup

2010-12-09 Thread Ionut Nicu
Reorganized some code in the rmgr module to increase
its readability. No functional changes were done.

Signed-off-by: Ionut Nicu ionut.n...@mindbit.ro
---
 drivers/staging/tidspbridge/rmgr/drv.c  |  171 +---
 drivers/staging/tidspbridge/rmgr/node.c |   81 +-
 drivers/staging/tidspbridge/rmgr/rmm.c  |  266 +-
 3 files changed, 229 insertions(+), 289 deletions(-)

diff --git a/drivers/staging/tidspbridge/rmgr/drv.c 
b/drivers/staging/tidspbridge/rmgr/drv.c
index e0fc895..71a9489 100644
--- a/drivers/staging/tidspbridge/rmgr/drv.c
+++ b/drivers/staging/tidspbridge/rmgr/drv.c
@@ -304,40 +304,28 @@ int drv_proc_update_strm_res(u32 num_bufs, void 
*strm_resources)
  */
 int drv_create(struct drv_object **drv_obj)
 {
-   int status = 0;
struct drv_object *pdrv_object = NULL;
struct drv_data *drv_datap = dev_get_drvdata(bridge);
 
DBC_REQUIRE(drv_obj != NULL);
DBC_REQUIRE(refs  0);
 
+   if (!drv_datap)
+   return -EFAULT;
+
pdrv_object = kzalloc(sizeof(struct drv_object), GFP_KERNEL);
-   if (pdrv_object) {
-   /* Create and Initialize List of device objects */
-   INIT_LIST_HEAD(pdrv_object-dev_list);
-   INIT_LIST_HEAD(pdrv_object-dev_node_string);
-   } else {
-   status = -ENOMEM;
-   }
-   /* Store the DRV Object in the driver data */
-   if (!status) {
-   if (drv_datap) {
-   drv_datap-drv_object = (void *)pdrv_object;
-   } else {
-   status = -EPERM;
-   pr_err(%s: Failed to store DRV object\n, __func__);
-   }
-   }
+   if (!pdrv_object)
+   return -ENOMEM;
 
-   if (!status) {
-   *drv_obj = pdrv_object;
-   } else {
-   /* Free the DRV Object */
-   kfree(pdrv_object);
-   }
+   /* Create and Initialize List of device objects */
+   INIT_LIST_HEAD(pdrv_object-dev_list);
+   INIT_LIST_HEAD(pdrv_object-dev_node_string);
 
-   DBC_ENSURE(status || pdrv_object);
-   return status;
+   /* Store the DRV Object in the driver data */
+   drv_datap-drv_object = (void *)pdrv_object;
+   *drv_obj = pdrv_object;
+
+   return 0;
 }
 
 /*
@@ -424,19 +412,19 @@ int drv_get_dev_object(u32 index, struct drv_object 
*hdrv_obj,
  */
 u32 drv_get_first_dev_object(void)
 {
-   u32 dw_dev_object = 0;
struct drv_object *pdrv_obj;
struct drv_data *drv_datap = dev_get_drvdata(bridge);
 
-   if (drv_datap  drv_datap-drv_object) {
-   pdrv_obj = drv_datap-drv_object;
-   if (!list_empty(pdrv_obj-dev_list))
-   dw_dev_object = (u32) pdrv_obj-dev_list.next;
-   } else {
+   if (!drv_datap || !drv_datap-drv_object) {
pr_err(%s: Failed to retrieve the object handle\n, __func__);
+   return 0;
}
 
-   return dw_dev_object;
+   pdrv_obj = drv_datap-drv_object;
+   if (list_empty(pdrv_obj-dev_list))
+   return 0;
+
+   return (u32) pdrv_obj-dev_list.next;
 }
 
 /*
@@ -447,21 +435,19 @@ u32 drv_get_first_dev_object(void)
  */
 u32 drv_get_first_dev_extension(void)
 {
-   u32 dw_dev_extension = 0;
struct drv_object *pdrv_obj;
struct drv_data *drv_datap = dev_get_drvdata(bridge);
 
-   if (drv_datap  drv_datap-drv_object) {
-   pdrv_obj = drv_datap-drv_object;
-   if (!list_empty(pdrv_obj-dev_node_string)) {
-   dw_dev_extension =
-   (u32) pdrv_obj-dev_node_string.next;
-   }
-   } else {
+   if (!drv_datap || !drv_datap-drv_object) {
pr_err(%s: Failed to retrieve the object handle\n, __func__);
+   return 0;
}
 
-   return dw_dev_extension;
+   pdrv_obj = drv_datap-drv_object;
+   if (list_empty(pdrv_obj-dev_node_string))
+   return 0;
+
+   return (u32) pdrv_obj-dev_node_string.next;
 }
 
 /*
@@ -473,24 +459,25 @@ u32 drv_get_first_dev_extension(void)
  */
 u32 drv_get_next_dev_object(u32 hdev_obj)
 {
-   u32 dw_next_dev_object = 0;
struct drv_object *pdrv_obj;
struct drv_data *drv_datap = dev_get_drvdata(bridge);
struct list_head *curr;
 
-   if (drv_datap  drv_datap-drv_object) {
-   pdrv_obj = drv_datap-drv_object;
-   if (!list_empty(pdrv_obj-dev_list)) {
-   curr = (struct list_head *)hdev_obj;
-   if (list_is_last(curr, pdrv_obj-dev_list))
-   return 0;
-   dw_next_dev_object = (u32) curr-next;
-   }
-   } else {
+   if (!drv_datap || !drv_datap-drv_object) {
pr_err(%s: Failed to retrieve the object handle\n, __func__);
+   return 0

Re: [PATCH 1/2] staging: tidspbridge: rmgr/node.c code cleanup

2010-12-09 Thread Ionut Nicu
Hi Omar,

On Thu, 2010-12-09 at 23:47 +0200, Ionut Nicu wrote:
 Reorganized some code in rmgr/node.c to increase its
 readability. Most of the changes reduce the code
 indentation level and simplifiy the code. No functional
 changes were done.

snip

   /*
* Check stream mode. Default is STRMMODE_PROCCOPY.
*/
 - if (!status  pattrs) {
 - if (pattrs-strm_mode != STRMMODE_PROCCOPY)
 - status = -EPERM;/* illegal stream mode */
 -
 - }
 - if (status)
 - goto func_end;
 + if (pattrs  pattrs-strm_mode != STRMMODE_PROCCOPY)
 + return -EPERM;  /* illegal stream mode */
  

While cleaning up and reviewing the code I saw this check,  which unless
it's intentional I think it looks like a bug. See comment below.

snip
 + strm_mode = pattrs ? pattrs-strm_mode : STRMMODE_PROCCOPY;
 + switch (strm_mode) {
 + case STRMMODE_RDMA:

...

 + 
 + case STRMMODE_ZEROCOPY:

...

 + case STRMMODE_PROCCOPY:

It looks like all modes are handled here although the only one that
could escape the validation from above is STRMMODE_PROCCOPY.

I tried removing the first check and tested with the
userspace-dspbridge strmcopy application, but I noticed the DSP hangs if
I try to use it with anything else than the copy mode.

Are the other modes (rdma, zerocopy) not supported at all?

Thanks,
Ionut.

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 00/12] staging: tidspbridge: various cleanups

2010-12-06 Thread Ionut Nicu
Hi Omar,

On Mon, 2010-12-06 at 02:59 -0600, Ramirez Luna, Omar wrote:
 Hi Ionut,
 
 On Sun, Nov 21, 2010 at 4:46 AM, Ionut Nicu ionut.n...@gmail.com wrote:
  This set of patches replaces some of the redundant components of
  the tidspbridge driver, such as:
 
  * wrapper functions for kmalloc/kfree
  * custom bitmap implementation
  * custom linked list implementation (list_head wrapper)
 
  with the standard linux kernel interfaces.
 
  The patches also do some code reorganization for increasing readability.
  Most of the changes reduce the code indentation level and simplify the code.
  No functional changes were done.
 
  There are many places in this driver that need this kind of cleanup, but
  these patches only fix the functions that were touched while converting
  the code to use linux bitmap and list_head.
 
 Thanks for your patches, I just fixed the style of some multiline
 comments before pushing, since these are very minor fixes I avoided
 the noise of resending the patches.
 
 Please remember to follow the Coding Style for multi line comments
 whenever you insert back those lines (even if the code was that way).
 

Thanks for your review. It's strange scripts/checkpatch.pl didn't
complain, so that's why I must have missed them.

   staging: tidspbridge: rmgr/node.c code cleanup
 
 Changes requested
 

I'll take care of the changes you requested in the other email and
resubmit it.

   staging: tidspbridge: rmgr code cleanup
 
 Doesn't apply because of patch staging: tidspbridge: rmgr/node.c code
 cleanup was not pushed.
 

I'll make a 2-patch series containing this one and the one above.

Thanks,
Ionut.

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 2/4] drivers: hwspinlock: add OMAP implementation

2010-11-23 Thread Ionut Nicu
Hi Ohad,

On Tue, 2010-11-23 at 17:38 +0200, Ohad Ben-Cohen wrote:
 From: Simon Que s...@ti.com
 
 Add hwspinlock support for the OMAP4 Hardware Spinlock device.
 

snip

 +
 + io_base = ioremap(res-start, resource_size(res));
 + if (!io_base) {
 + ret = -ENOMEM;
 + goto free_state;
 + }
 +
 + /* Determine number of locks */
 + i = readl(io_base + SYSSTATUS_OFFSET);
 + i = SPINLOCK_NUMLOCKS_BIT_OFFSET;
 +
 + /* exactly one of the four least significant bits must be 1 */
 + if (!i || !is_power_of_2(i) || i  8) {
 + ret = -EINVAL;
 + goto iounmap_base;
 + }
 +

At iounmap_base you unmap state-io_base, but that's set only after this
check. You should probably iounmap(io_base).

Regards,
Ionut.


--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 00/12] staging: tidspbridge: various cleanups

2010-11-21 Thread Ionut Nicu
This set of patches replaces some of the redundant components of
the tidspbridge driver, such as:

* wrapper functions for kmalloc/kfree
* custom bitmap implementation
* custom linked list implementation (list_head wrapper)

with the standard linux kernel interfaces.

The patches also do some code reorganization for increasing readability.
Most of the changes reduce the code indentation level and simplify the code.
No functional changes were done.

There are many places in this driver that need this kind of cleanup, but
these patches only fix the functions that were touched while converting
the code to use linux bitmap and list_head.

Changes since v1:

* Split the bitmap patch into multiple patches
* Split the list_head patch into multiple patches

Changes since v2:

* Fixes to the list_head patches based on Rene Sapiens' review

Ionut Nicu (12):
  staging: tidspbridge: remove gs memory allocator
  staging: tidspbridge: remove utildefs
  staging: tidspbridge: switch to linux bitmap API
  staging: tidspbridge: remove gb bitmap implementation
  staging: tidspbridge: rmgr/node.c code cleanup
  staging: tidspbridge: convert core to list_head
  staging: tidspbridge: convert pmgr to list_head
  staging: tidspbridge: convert rmgr to list_head
  staging: tidspbridge: remove custom linked list
  staging: tidspbridge: core code cleanup
  staging: tidspbridge: pmgr code cleanup
  staging: tidspbridge: rmgr code cleanup

 drivers/staging/tidspbridge/Makefile   |2 +-
 drivers/staging/tidspbridge/TODO   |1 -
 drivers/staging/tidspbridge/core/_msg_sm.h |   12 +-
 drivers/staging/tidspbridge/core/chnl_sm.c |  630 +++-
 drivers/staging/tidspbridge/core/io_sm.c   |  266 +++
 drivers/staging/tidspbridge/core/msg_sm.c  |  601 ++-
 drivers/staging/tidspbridge/gen/gb.c   |  166 -
 drivers/staging/tidspbridge/gen/gh.c   |   38 +-
 drivers/staging/tidspbridge/gen/gs.c   |   88 ---
 .../tidspbridge/include/dspbridge/_chnl_sm.h   |8 +-
 .../tidspbridge/include/dspbridge/cmmdefs.h|1 -
 drivers/staging/tidspbridge/include/dspbridge/gb.h |   79 --
 drivers/staging/tidspbridge/include/dspbridge/gs.h |   59 --
 .../staging/tidspbridge/include/dspbridge/list.h   |  225 --
 .../staging/tidspbridge/include/dspbridge/sync.h   |1 +
 .../tidspbridge/include/dspbridge/utildefs.h   |   39 -
 drivers/staging/tidspbridge/pmgr/cmm.c |  535 +-
 drivers/staging/tidspbridge/pmgr/dev.c |   73 +--
 drivers/staging/tidspbridge/rmgr/drv.c |  242 ++
 drivers/staging/tidspbridge/rmgr/node.c|  775 +---
 drivers/staging/tidspbridge/rmgr/proc.c|2 -
 drivers/staging/tidspbridge/rmgr/rmm.c |  313 -
 22 files changed, 1448 insertions(+), 2708 deletions(-)
 delete mode 100644 drivers/staging/tidspbridge/gen/gb.c
 delete mode 100644 drivers/staging/tidspbridge/gen/gs.c
 delete mode 100644 drivers/staging/tidspbridge/include/dspbridge/gb.h
 delete mode 100644 drivers/staging/tidspbridge/include/dspbridge/gs.h
 delete mode 100644 drivers/staging/tidspbridge/include/dspbridge/list.h
 delete mode 100644 drivers/staging/tidspbridge/include/dspbridge/utildefs.h

-- 
1.7.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 01/12] staging: tidspbridge: remove gs memory allocator

2010-11-21 Thread Ionut Nicu
Remove unnecessary wrappers for linux kernel memory
allocation primitives.

Signed-off-by: Ionut Nicu ionut.n...@mindbit.ro
---
 drivers/staging/tidspbridge/Makefile   |2 +-
 drivers/staging/tidspbridge/gen/gb.c   |   11 +--
 drivers/staging/tidspbridge/gen/gh.c   |   38 ++---
 drivers/staging/tidspbridge/gen/gs.c   |   88 
 drivers/staging/tidspbridge/include/dspbridge/gs.h |   59 -
 5 files changed, 15 insertions(+), 183 deletions(-)
 delete mode 100644 drivers/staging/tidspbridge/gen/gs.c
 delete mode 100644 drivers/staging/tidspbridge/include/dspbridge/gs.h

diff --git a/drivers/staging/tidspbridge/Makefile 
b/drivers/staging/tidspbridge/Makefile
index 41c644c..648e392 100644
--- a/drivers/staging/tidspbridge/Makefile
+++ b/drivers/staging/tidspbridge/Makefile
@@ -1,6 +1,6 @@
 obj-$(CONFIG_TIDSPBRIDGE)  += bridgedriver.o
 
-libgen = gen/gb.o gen/gs.o gen/gh.o gen/uuidutil.o
+libgen = gen/gb.o gen/gh.o gen/uuidutil.o
 libcore = core/chnl_sm.o core/msg_sm.o core/io_sm.o core/tiomap3430.o \
core/tiomap3430_pwr.o core/tiomap_io.o \
core/ue_deh.o core/wdt.o core/dsp-clock.o core/sync.o
diff --git a/drivers/staging/tidspbridge/gen/gb.c 
b/drivers/staging/tidspbridge/gen/gb.c
index 9f59023..3c0e04c 100644
--- a/drivers/staging/tidspbridge/gen/gb.c
+++ b/drivers/staging/tidspbridge/gen/gb.c
@@ -19,7 +19,6 @@
 /*  --- DSP/BIOS Bridge */
 #include linux/types.h
 /*  --- This */
-#include dspbridge/gs.h
 #include dspbridge/gb.h
 
 struct gb_t_map {
@@ -52,17 +51,17 @@ struct gb_t_map *gb_create(u32 len)
 {
struct gb_t_map *map;
u32 i;
-   map = (struct gb_t_map *)gs_alloc(sizeof(struct gb_t_map));
+   map = kzalloc(sizeof(struct gb_t_map), GFP_KERNEL);
if (map != NULL) {
map-len = len;
map-wcnt = len / BITS_PER_LONG + 1;
-   map-words = (u32 *) gs_alloc(map-wcnt * sizeof(u32));
+   map-words = kzalloc(map-wcnt * sizeof(u32), GFP_KERNEL);
if (map-words != NULL) {
for (i = 0; i  map-wcnt; i++)
map-words[i] = 0L;
 
} else {
-   gs_frees(map, sizeof(struct gb_t_map));
+   kfree(map);
map = NULL;
}
}
@@ -78,8 +77,8 @@ struct gb_t_map *gb_create(u32 len)
 
 void gb_delete(struct gb_t_map *map)
 {
-   gs_frees(map-words, map-wcnt * sizeof(u32));
-   gs_frees(map, sizeof(struct gb_t_map));
+   kfree(map-words);
+   kfree(map);
 }
 
 /*
diff --git a/drivers/staging/tidspbridge/gen/gh.c 
b/drivers/staging/tidspbridge/gen/gh.c
index f72d943..cd72503 100644
--- a/drivers/staging/tidspbridge/gen/gh.c
+++ b/drivers/staging/tidspbridge/gen/gh.c
@@ -17,9 +17,6 @@
 #include linux/types.h
 
 #include dspbridge/host_os.h
-
-#include dspbridge/gs.h
-
 #include dspbridge/gh.h
 
 struct element {
@@ -37,8 +34,6 @@ struct gh_t_hash_tab {
 };
 
 static void noop(void *p);
-static s32 cur_init;
-static void myfree(void *ptr, s32 size);
 
 /*
  *   gh_create 
@@ -51,8 +46,7 @@ struct gh_t_hash_tab *gh_create(u16 max_bucket, u16 val_size,
 {
struct gh_t_hash_tab *hash_tab;
u16 i;
-   hash_tab =
-   (struct gh_t_hash_tab *)gs_alloc(sizeof(struct gh_t_hash_tab));
+   hash_tab = kzalloc(sizeof(struct gh_t_hash_tab), GFP_KERNEL);
if (hash_tab == NULL)
return NULL;
hash_tab-max_bucket = max_bucket;
@@ -62,7 +56,7 @@ struct gh_t_hash_tab *gh_create(u16 max_bucket, u16 val_size,
hash_tab-delete = delete == NULL ? noop : delete;
 
hash_tab-buckets = (struct element **)
-   gs_alloc(sizeof(struct element *) * max_bucket);
+   kzalloc(sizeof(struct element *) * max_bucket, GFP_KERNEL);
if (hash_tab-buckets == NULL) {
gh_delete(hash_tab);
return NULL;
@@ -89,17 +83,14 @@ void gh_delete(struct gh_t_hash_tab *hash_tab)
 elem = next) {
next = elem-next;
(*hash_tab-delete) (elem-data);
-   myfree(elem,
-  sizeof(struct element) - 1 +
-  hash_tab-val_size);
+   kfree(elem);
}
}
 
-   myfree(hash_tab-buckets, sizeof(struct element *)
-  * hash_tab-max_bucket);
+   kfree(hash_tab-buckets);
}
 
-   myfree(hash_tab, sizeof(struct gh_t_hash_tab));
+   kfree(hash_tab);
}
 }
 
@@ -109,9 +100,7 @@ void gh_delete

[PATCH v3 02/12] staging: tidspbridge: remove utildefs

2010-11-21 Thread Ionut Nicu
Remove a header file that was not very useful to
the dspbridge driver.

Signed-off-by: Ionut Nicu ionut.n...@mindbit.ro
---
 .../tidspbridge/include/dspbridge/utildefs.h   |   39 
 drivers/staging/tidspbridge/pmgr/cmm.c |9 +
 2 files changed, 1 insertions(+), 47 deletions(-)
 delete mode 100644 drivers/staging/tidspbridge/include/dspbridge/utildefs.h

diff --git a/drivers/staging/tidspbridge/include/dspbridge/utildefs.h 
b/drivers/staging/tidspbridge/include/dspbridge/utildefs.h
deleted file mode 100644
index 8fe5414..000
--- a/drivers/staging/tidspbridge/include/dspbridge/utildefs.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * utildefs.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Global UTIL constants and types, shared between DSP API and DSPSYS.
- *
- * 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.
- */
-
-#ifndef UTILDEFS_
-#define UTILDEFS_
-
-/* constants taken from configmg.h */
-#define UTIL_MAXMEMREGS 9
-#define UTIL_MAXIOPORTS 20
-#define UTIL_MAXIRQS7
-#define UTIL_MAXDMACHNLS7
-
-/* misc. constants */
-#define UTIL_MAXARGVS   10
-
-/* Platform specific important info */
-struct util_sysinfo {
-   /* Granularity of page protection; usually 1k or 4k */
-   u32 dw_page_size;
-   u32 dw_allocation_granularity;  /* VM granularity, usually 64K */
-   u32 dw_number_of_processors;/* Used as sanity check */
-};
-
-#endif /* UTILDEFS_ */
diff --git a/drivers/staging/tidspbridge/pmgr/cmm.c 
b/drivers/staging/tidspbridge/pmgr/cmm.c
index 93a7c4f..8dbdd20 100644
--- a/drivers/staging/tidspbridge/pmgr/cmm.c
+++ b/drivers/staging/tidspbridge/pmgr/cmm.c
@@ -40,7 +40,6 @@
 /*  --- OS Adaptation Layer */
 #include dspbridge/list.h
 #include dspbridge/sync.h
-#include dspbridge/utildefs.h
 
 /*  --- Platform Manager */
 #include dspbridge/dev.h
@@ -245,7 +244,6 @@ int cmm_create(struct cmm_object **ph_cmm_mgr,
 {
struct cmm_object *cmm_obj = NULL;
int status = 0;
-   struct util_sysinfo sys_info;
 
DBC_REQUIRE(refs  0);
DBC_REQUIRE(ph_cmm_mgr != NULL);
@@ -261,12 +259,7 @@ int cmm_create(struct cmm_object **ph_cmm_mgr,
DBC_ASSERT(mgr_attrts-ul_min_block_size = 4);
/* save away smallest block allocation for this cmm mgr */
cmm_obj-ul_min_block_size = mgr_attrts-ul_min_block_size;
-   /* save away the systems memory page size */
-   sys_info.dw_page_size = PAGE_SIZE;
-   sys_info.dw_allocation_granularity = PAGE_SIZE;
-   sys_info.dw_number_of_processors = 1;
-
-   cmm_obj-dw_page_size = sys_info.dw_page_size;
+   cmm_obj-dw_page_size = PAGE_SIZE;
 
/* Note: DSP SM seg table(aDSPSMSegTab[]) zero'd by
 * MEM_ALLOC_OBJECT */
-- 
1.7.3.2

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 03/12] staging: tidspbridge: switch to linux bitmap API

2010-11-21 Thread Ionut Nicu
Replace the tidspbridge generic bitmap operations
with the linux standard bitmap implementation.

Signed-off-by: Ionut Nicu ionut.n...@mindbit.ro
---
 drivers/staging/tidspbridge/rmgr/node.c |  166 ++-
 1 files changed, 74 insertions(+), 92 deletions(-)

diff --git a/drivers/staging/tidspbridge/rmgr/node.c 
b/drivers/staging/tidspbridge/rmgr/node.c
index 1562f3c..ab35806 100644
--- a/drivers/staging/tidspbridge/rmgr/node.c
+++ b/drivers/staging/tidspbridge/rmgr/node.c
@@ -17,6 +17,7 @@
  */
 
 #include linux/types.h
+#include linux/bitmap.h
 /*  --- Host OS */
 #include dspbridge/host_os.h
 
@@ -50,7 +51,6 @@
 #include dspbridge/dspioctl.h
 
 /*  --- Others */
-#include dspbridge/gb.h
 #include dspbridge/uuidutil.h
 
 /*  --- This */
@@ -132,11 +132,14 @@ struct node_mgr {
struct lst_list *node_list; /* List of all allocated nodes */
u32 num_nodes;  /* Number of nodes in node_list */
u32 num_created;/* Number of nodes *created* on DSP */
-   struct gb_t_map *pipe_map;  /* Pipe connection bit map */
-   struct gb_t_map *pipe_done_map; /* Pipes that are half free */
-   struct gb_t_map *chnl_map;  /* Channel allocation bit map */
-   struct gb_t_map *dma_chnl_map;  /* DMA Channel allocation bit map */
-   struct gb_t_map *zc_chnl_map;   /* Zero-Copy Channel alloc bit map */
+   DECLARE_BITMAP(pipe_map, MAXPIPES); /* Pipe connection bitmap */
+   DECLARE_BITMAP(pipe_done_map, MAXPIPES); /* Pipes that are half free */
+   /* Channel allocation bitmap */
+   DECLARE_BITMAP(chnl_map, CHNL_MAXCHANNELS);
+   /* DMA Channel allocation bitmap */
+   DECLARE_BITMAP(dma_chnl_map, CHNL_MAXCHANNELS);
+   /* Zero-Copy Channel alloc bitmap */
+   DECLARE_BITMAP(zc_chnl_map, CHNL_MAXCHANNELS);
struct ntfy_object *ntfy_obj;   /* Manages registered notifications */
struct mutex node_mgr_lock; /* For critical sections */
u32 ul_fxn_addrs[NUMRMSFXNS];   /* RMS function addresses */
@@ -847,8 +850,8 @@ int node_connect(struct node_object *node1, u32 stream1,
struct node_object *dev_node_obj;
struct node_object *hnode;
struct stream_chnl *pstream;
-   u32 pipe_id = GB_NOBITS;
-   u32 chnl_id = GB_NOBITS;
+   u32 pipe_id;
+   u32 chnl_id;
s8 chnl_mode;
u32 dw_length;
int status = 0;
@@ -951,10 +954,11 @@ int node_connect(struct node_object *node1, u32 stream1,
   (node2_type == NODE_TASK
  || node2_type == NODE_DAISSOCKET))) {
/* Find available pipe */
-   pipe_id = gb_findandset(hnode_mgr-pipe_map);
-   if (pipe_id == GB_NOBITS) {
+   pipe_id = find_first_zero_bit(hnode_mgr-pipe_map, MAXPIPES);
+   if (pipe_id == MAXPIPES) {
status = -ECONNREFUSED;
} else {
+   set_bit(pipe_id, hnode_mgr-pipe_map);
node1-outputs[stream1].type = NODECONNECT;
node2-inputs[stream2].type = NODECONNECT;
node1-outputs[stream1].dev_id = pipe_id;
@@ -971,7 +975,7 @@ int node_connect(struct node_object *node1, u32 stream1,
 
output-sz_device = NULL;
input-sz_device = NULL;
-   gb_clear(hnode_mgr-pipe_map, pipe_id);
+   clear_bit(pipe_id, hnode_mgr-pipe_map);
status = -ENOMEM;
} else {
/* Copy /dbpipepipId name to device names */
@@ -996,34 +1000,47 @@ int node_connect(struct node_object *node1, u32 stream1,
 *  called for this node. */
if (pattrs) {
if (pattrs-strm_mode == STRMMODE_RDMA) {
-   chnl_id =
-   gb_findandset(hnode_mgr-dma_chnl_map);
+   chnl_id = find_first_zero_bit(
+   hnode_mgr-dma_chnl_map,
+   CHNL_MAXCHANNELS);
/* dma chans are 2nd transport chnl set
 * ids(e.g. 16-31) */
-   (chnl_id != GB_NOBITS) ?
-   (chnl_id =
-chnl_id +
-hnode_mgr-ul_num_chnls) : chnl_id;
+   if (chnl_id != CHNL_MAXCHANNELS) {
+   set_bit(chnl_id,
+   hnode_mgr-dma_chnl_map);
+   chnl_id = chnl_id

[PATCH v3 04/12] staging: tidspbridge: remove gb bitmap implementation

2010-11-21 Thread Ionut Nicu
Now that all users of gb have been converted to the
standard linux bitmap API, we can remove it from the
gen library.

Signed-off-by: Ionut Nicu ionut.n...@mindbit.ro
---
 drivers/staging/tidspbridge/Makefile   |2 +-
 drivers/staging/tidspbridge/gen/gb.c   |  165 
 drivers/staging/tidspbridge/include/dspbridge/gb.h |   79 --
 3 files changed, 1 insertions(+), 245 deletions(-)
 delete mode 100644 drivers/staging/tidspbridge/gen/gb.c
 delete mode 100644 drivers/staging/tidspbridge/include/dspbridge/gb.h

diff --git a/drivers/staging/tidspbridge/Makefile 
b/drivers/staging/tidspbridge/Makefile
index 648e392..fd6a276 100644
--- a/drivers/staging/tidspbridge/Makefile
+++ b/drivers/staging/tidspbridge/Makefile
@@ -1,6 +1,6 @@
 obj-$(CONFIG_TIDSPBRIDGE)  += bridgedriver.o
 
-libgen = gen/gb.o gen/gh.o gen/uuidutil.o
+libgen = gen/gh.o gen/uuidutil.o
 libcore = core/chnl_sm.o core/msg_sm.o core/io_sm.o core/tiomap3430.o \
core/tiomap3430_pwr.o core/tiomap_io.o \
core/ue_deh.o core/wdt.o core/dsp-clock.o core/sync.o
diff --git a/drivers/staging/tidspbridge/gen/gb.c 
b/drivers/staging/tidspbridge/gen/gb.c
deleted file mode 100644
index 3c0e04c..000
--- a/drivers/staging/tidspbridge/gen/gb.c
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * gb.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Generic bitmap operations.
- *
- * 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.
- */
-
-/*  --- DSP/BIOS Bridge */
-#include linux/types.h
-/*  --- This */
-#include dspbridge/gb.h
-
-struct gb_t_map {
-   u32 len;
-   u32 wcnt;
-   u32 *words;
-};
-
-/*
- *   gb_clear 
- *  purpose:
- *  Clears a bit in the bit map.
- */
-
-void gb_clear(struct gb_t_map *map, u32 bitn)
-{
-   u32 mask;
-
-   mask = 1L  (bitn % BITS_PER_LONG);
-   map-words[bitn / BITS_PER_LONG] = ~mask;
-}
-
-/*
- *   gb_create 
- *  purpose:
- *  Creates a bit map.
- */
-
-struct gb_t_map *gb_create(u32 len)
-{
-   struct gb_t_map *map;
-   u32 i;
-   map = kzalloc(sizeof(struct gb_t_map), GFP_KERNEL);
-   if (map != NULL) {
-   map-len = len;
-   map-wcnt = len / BITS_PER_LONG + 1;
-   map-words = kzalloc(map-wcnt * sizeof(u32), GFP_KERNEL);
-   if (map-words != NULL) {
-   for (i = 0; i  map-wcnt; i++)
-   map-words[i] = 0L;
-
-   } else {
-   kfree(map);
-   map = NULL;
-   }
-   }
-
-   return map;
-}
-
-/*
- *   gb_delete 
- *  purpose:
- *  Frees a bit map.
- */
-
-void gb_delete(struct gb_t_map *map)
-{
-   kfree(map-words);
-   kfree(map);
-}
-
-/*
- *   gb_findandset 
- *  purpose:
- *  Finds a free bit and sets it.
- */
-u32 gb_findandset(struct gb_t_map *map)
-{
-   u32 bitn;
-
-   bitn = gb_minclear(map);
-
-   if (bitn != GB_NOBITS)
-   gb_set(map, bitn);
-
-   return bitn;
-}
-
-/*
- *   gb_minclear 
- *  purpose:
- *  returns the location of the first unset bit in the bit map.
- */
-u32 gb_minclear(struct gb_t_map *map)
-{
-   u32 bit_location = 0;
-   u32 bit_acc = 0;
-   u32 i;
-   u32 bit;
-   u32 *word;
-
-   for (word = map-words, i = 0; i  map-wcnt; word++, i++) {
-   if (~*word) {
-   for (bit = 0; bit  BITS_PER_LONG; bit++, bit_acc++) {
-   if (bit_acc == map-len)
-   return GB_NOBITS;
-
-   if (~*word  (1L  bit)) {
-   bit_location = i * BITS_PER_LONG + bit;
-   return bit_location;
-   }
-
-   }
-   } else {
-   bit_acc += BITS_PER_LONG;
-   }
-   }
-
-   return GB_NOBITS;
-}
-
-/*
- *   gb_set 
- *  purpose:
- *  Sets a bit in the bit map.
- */
-
-void gb_set(struct gb_t_map *map, u32 bitn)
-{
-   u32 mask;
-
-   mask = 1L  (bitn % BITS_PER_LONG);
-   map-words[bitn / BITS_PER_LONG] |= mask;
-}
-
-/*
- *   gb_test 
- *  purpose:
- *  Returns true if the bit is set in the specified location.
- */
-
-bool gb_test(struct gb_t_map *map, u32 bitn

[PATCH v3 05/12] staging: tidspbridge: rmgr/node.c code cleanup

2010-11-21 Thread Ionut Nicu
Reorganized some code in rmgr/node.c to increase its
readability. Most of the changes reduce the code
indentation level and simplifiy the code. No functional
changes were done.

Signed-off-by: Ionut Nicu ionut.n...@mindbit.ro
---
 drivers/staging/tidspbridge/rmgr/node.c |  607 +++
 1 files changed, 284 insertions(+), 323 deletions(-)

diff --git a/drivers/staging/tidspbridge/rmgr/node.c 
b/drivers/staging/tidspbridge/rmgr/node.c
index ab35806..f213652 100644
--- a/drivers/staging/tidspbridge/rmgr/node.c
+++ b/drivers/staging/tidspbridge/rmgr/node.c
@@ -235,9 +235,9 @@ struct node_object {
 
 /* Default buffer attributes */
 static struct dsp_bufferattr node_dfltbufattrs = {
-   0,  /* cb_struct */
-   1,  /* segment_id */
-   0,  /* buf_alignment */
+   .cb_struct = 0,
+   .segment_id = 1,
+   .buf_alignment = 0,
 };
 
 static void delete_node(struct node_object *hnode,
@@ -283,8 +283,7 @@ enum node_state node_get_state(void *hnode)
struct node_object *pnode = (struct node_object *)hnode;
if (!pnode)
return -1;
-   else
-   return pnode-node_state;
+   return pnode-node_state;
 }
 
 /*
@@ -844,6 +843,7 @@ int node_connect(struct node_object *node1, u32 stream1,
char *pstr_dev_name = NULL;
enum node_type node1_type = NODE_TASK;
enum node_type node2_type = NODE_TASK;
+   enum dsp_strmmode strm_mode;
struct node_strmdef *pstrm_def;
struct node_strmdef *input = NULL;
struct node_strmdef *output = NULL;
@@ -857,60 +857,50 @@ int node_connect(struct node_object *node1, u32 stream1,
int status = 0;
DBC_REQUIRE(refs  0);
 
-   if ((node1 != (struct node_object *)DSP_HGPPNODE  !node1) ||
-   (node2 != (struct node_object *)DSP_HGPPNODE  !node2))
-   status = -EFAULT;
+   if (!node1 || !node2)
+   return -EFAULT;
 
-   if (!status) {
-   /* The two nodes must be on the same processor */
-   if (node1 != (struct node_object *)DSP_HGPPNODE 
-   node2 != (struct node_object *)DSP_HGPPNODE 
-   node1-hnode_mgr != node2-hnode_mgr)
-   status = -EPERM;
-   /* Cannot connect a node to itself */
-   if (node1 == node2)
-   status = -EPERM;
+   /* The two nodes must be on the same processor */
+   if (node1 != (struct node_object *)DSP_HGPPNODE 
+   node2 != (struct node_object *)DSP_HGPPNODE 
+   node1-hnode_mgr != node2-hnode_mgr)
+   return -EPERM;
 
-   }
-   if (!status) {
-   /* node_get_type() will return NODE_GPP if hnode =
-* DSP_HGPPNODE. */
-   node1_type = node_get_type(node1);
-   node2_type = node_get_type(node2);
-   /* Check stream indices ranges */
-   if ((node1_type != NODE_GPP  node1_type != NODE_DEVICE 
-stream1 = MAX_OUTPUTS(node1)) || (node2_type != NODE_GPP
-  node2_type !=
- NODE_DEVICE
-  stream2 =
- MAX_INPUTS(node2)))
-   status = -EINVAL;
-   }
-   if (!status) {
-   /*
-*  Only the following types of connections are allowed:
-*  task/dais socket  ==  task/dais socket
-*  task/dais socket  ==  device
-*  task/dais socket  ==  GPP
-*
-*  ie, no message nodes, and at least one task or dais
-*  socket node.
-*/
-   if (node1_type == NODE_MESSAGE || node2_type == NODE_MESSAGE ||
-   (node1_type != NODE_TASK  node1_type != NODE_DAISSOCKET 
-node2_type != NODE_TASK  node2_type != NODE_DAISSOCKET))
-   status = -EPERM;
-   }
+   /* Cannot connect a node to itself */
+   if (node1 == node2)
+   return -EPERM;
+
+   /* node_get_type() will return NODE_GPP if hnode =
+* DSP_HGPPNODE. */
+   node1_type = node_get_type(node1);
+   node2_type = node_get_type(node2);
+   /* Check stream indices ranges */
+   if ((node1_type != NODE_GPP  node1_type != NODE_DEVICE 
+   stream1 = MAX_OUTPUTS(node1)) ||
+   (node2_type != NODE_GPP  node2_type != NODE_DEVICE 
+stream2 = MAX_INPUTS(node2)))
+   return -EINVAL;
+
+   /*
+*  Only the following types of connections are allowed:
+*  task/dais socket  ==  task/dais socket
+*  task/dais

[PATCH v3 06/12] staging: tidspbridge: convert core to list_head

2010-11-21 Thread Ionut Nicu
Convert the core module of the tidspbridge driver
to use struct list_head instead of struct lst_list.

Signed-off-by: Ionut Nicu ionut.n...@mindbit.ro
---
 drivers/staging/tidspbridge/core/_msg_sm.h |   12 +-
 drivers/staging/tidspbridge/core/chnl_sm.c |  243 ---
 drivers/staging/tidspbridge/core/io_sm.c   |  142 +---
 drivers/staging/tidspbridge/core/msg_sm.c  |  236 +++
 .../tidspbridge/include/dspbridge/_chnl_sm.h   |8 +-
 .../tidspbridge/include/dspbridge/cmmdefs.h|1 -
 .../staging/tidspbridge/include/dspbridge/sync.h   |1 +
 7 files changed, 262 insertions(+), 381 deletions(-)

diff --git a/drivers/staging/tidspbridge/core/_msg_sm.h 
b/drivers/staging/tidspbridge/core/_msg_sm.h
index 556de5c..b78d1a6 100644
--- a/drivers/staging/tidspbridge/core/_msg_sm.h
+++ b/drivers/staging/tidspbridge/core/_msg_sm.h
@@ -20,7 +20,7 @@
 #ifndef _MSG_SM_
 #define _MSG_SM_
 
-#include dspbridge/list.h
+#include linux/list.h
 #include dspbridge/msgdefs.h
 
 /*
@@ -86,12 +86,12 @@ struct msg_mgr {
struct bridge_drv_interface *intf_fxns;
 
struct io_mgr *hio_mgr; /* IO manager */
-   struct lst_list *queue_list;/* List of MSG_QUEUEs */
+   struct list_head queue_list;/* List of MSG_QUEUEs */
spinlock_t msg_mgr_lock;/* For critical sections */
/* Signalled when MsgFrame is available */
struct sync_object *sync_event;
-   struct lst_list *msg_free_list; /* Free MsgFrames ready to be filled */
-   struct lst_list *msg_used_list; /* MsgFrames ready to go to DSP */
+   struct list_head msg_free_list; /* Free MsgFrames ready to be filled */
+   struct list_head msg_used_list; /* MsgFrames ready to go to DSP */
u32 msgs_pending;   /* # of queued messages to go to DSP */
u32 max_msgs;   /* Max # of msgs that fit in buffer */
msg_onexit on_exit; /* called when RMS_EXIT is received */
@@ -111,9 +111,9 @@ struct msg_queue {
struct msg_mgr *hmsg_mgr;
u32 max_msgs;   /* Node message depth */
u32 msgq_id;/* Node environment pointer */
-   struct lst_list *msg_free_list; /* Free MsgFrames ready to be filled */
+   struct list_head msg_free_list; /* Free MsgFrames ready to be filled */
/* Filled MsgFramess waiting to be read */
-   struct lst_list *msg_used_list;
+   struct list_head msg_used_list;
void *arg;  /* Handle passed to mgr on_exit callback */
struct sync_object *sync_event; /* Signalled when message is ready */
struct sync_object *sync_done;  /* For synchronizing cleanup */
diff --git a/drivers/staging/tidspbridge/core/chnl_sm.c 
b/drivers/staging/tidspbridge/core/chnl_sm.c
index 662a5b5..ca19ede 100644
--- a/drivers/staging/tidspbridge/core/chnl_sm.c
+++ b/drivers/staging/tidspbridge/core/chnl_sm.c
@@ -37,9 +37,9 @@
  *  which may cause timeouts and/or failure offunction sync_wait_on_event.
  *  This invariant condition is:
  *
- *  LST_Empty(pchnl-pio_completions) == pchnl-sync_event is reset
+ *  list_empty(pchnl-pio_completions) == pchnl-sync_event is reset
  *  and
- *  !LST_Empty(pchnl-pio_completions) == pchnl-sync_event is set.
+ *  !list_empty(pchnl-pio_completions) == pchnl-sync_event is set.
  */
 
 #include linux/types.h
@@ -73,11 +73,9 @@
 #define MAILBOX_IRQ INT_MAIL_MPU_IRQ
 
 /*  --- Function Prototypes */
-static struct lst_list *create_chirp_list(u32 chirps);
+static int create_chirp_list(struct list_head *list, u32 chirps);
 
-static void free_chirp_list(struct lst_list *chirp_list);
-
-static struct chnl_irp *make_new_chirp(void);
+static void free_chirp_list(struct list_head *list);
 
 static int search_free_channel(struct chnl_mgr *chnl_mgr_obj,
  u32 *chnl);
@@ -179,10 +177,14 @@ func_cont:
}
if (!status) {
/* Get a free chirp: */
-   chnl_packet_obj =
-   (struct chnl_irp *)lst_get_head(pchnl-free_packets_list);
-   if (chnl_packet_obj == NULL)
+   if (!list_empty(pchnl-free_packets_list)) {
+   chnl_packet_obj = list_first_entry(
+   pchnl-free_packets_list,
+   struct chnl_irp, link);
+   list_del(chnl_packet_obj-link);
+   } else {
status = -EIO;
+   }
 
}
if (!status) {
@@ -206,8 +208,7 @@ func_cont:
chnl_packet_obj-dw_arg = dw_arg;
chnl_packet_obj-status = (is_eos ? CHNL_IOCSTATEOS :
   CHNL_IOCSTATCOMPLETE);
-   lst_put_tail(pchnl-pio_requests,
-(struct list_head *)chnl_packet_obj

[PATCH v3 07/12] staging: tidspbridge: convert pmgr to list_head

2010-11-21 Thread Ionut Nicu
Convert the pmgr module of the tidspbridge driver
to use struct list_head instead of struct lst_list.

Signed-off-by: Ionut Nicu ionut.n...@mindbit.ro
---
 drivers/staging/tidspbridge/pmgr/cmm.c |  237 ++--
 drivers/staging/tidspbridge/pmgr/dev.c |   59 +++-
 2 files changed, 98 insertions(+), 198 deletions(-)

diff --git a/drivers/staging/tidspbridge/pmgr/cmm.c 
b/drivers/staging/tidspbridge/pmgr/cmm.c
index 8dbdd20..d7ca2a4 100644
--- a/drivers/staging/tidspbridge/pmgr/cmm.c
+++ b/drivers/staging/tidspbridge/pmgr/cmm.c
@@ -12,7 +12,7 @@
  * describes a block of physically contiguous shared memory used for
  * future allocations by CMM.
  *
- * Memory is coelesced back to the appropriate heap when a buffer is
+ * Memory is coalesced back to the appropriate heap when a buffer is
  * freed.
  *
  * Notes:
@@ -30,6 +30,7 @@
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 #include linux/types.h
+#include linux/list.h
 
 /*  --- DSP/BIOS Bridge */
 #include dspbridge/dbdefs.h
@@ -38,7 +39,6 @@
 #include dspbridge/dbc.h
 
 /*  --- OS Adaptation Layer */
-#include dspbridge/list.h
 #include dspbridge/sync.h
 
 /*  --- Platform Manager */
@@ -73,9 +73,9 @@ struct cmm_allocator {/* sma */
u32 ul_dsp_size;/* DSP seg size in bytes */
struct cmm_object *hcmm_mgr;/* back ref to parent mgr */
/* node list of available memory */
-   struct lst_list *free_list_head;
+   struct list_head free_list;
/* node list of memory in use */
-   struct lst_list *in_use_list_head;
+   struct list_head in_use_list;
 };
 
 struct cmm_xlator {/* Pa-Va translator object */
@@ -97,7 +97,7 @@ struct cmm_object {
 * Cmm Lock is used to serialize access mem manager for multi-threads.
 */
struct mutex cmm_lock;  /* Lock to access cmm mgr */
-   struct lst_list *node_free_list_head;   /* Free list of memory nodes */
+   struct list_head node_free_list;/* Free list of memory nodes */
u32 ul_min_block_size;  /* Min SM block; default 16 bytes */
u32 dw_page_size;   /* Memory Page size (1k/4k) */
/* GPP SM segment ptrs */
@@ -215,8 +215,7 @@ void *cmm_calloc_buf(struct cmm_object *hcmm_mgr, u32 usize,
pnode-client_proc = current-tgid;
 
/* put our node on InUse list */
-   lst_put_tail(allocator-in_use_list_head,
-(struct list_head *)pnode);
+   list_add_tail(pnode-link, allocator-in_use_list);
buf_pa = (void *)pnode-dw_pa;  /* physical address */
/* clear mem */
pbyte = (u8 *) pnode-dw_va;
@@ -265,18 +264,9 @@ int cmm_create(struct cmm_object **ph_cmm_mgr,
 * MEM_ALLOC_OBJECT */
 
/* create node free list */
-   cmm_obj-node_free_list_head =
-   kzalloc(sizeof(struct lst_list),
-   GFP_KERNEL);
-   if (cmm_obj-node_free_list_head == NULL) {
-   status = -ENOMEM;
-   cmm_destroy(cmm_obj, true);
-   } else {
-   INIT_LIST_HEAD(cmm_obj-
-  node_free_list_head-head);
-   mutex_init(cmm_obj-cmm_lock);
-   *ph_cmm_mgr = cmm_obj;
-   }
+   INIT_LIST_HEAD(cmm_obj-node_free_list);
+   mutex_init(cmm_obj-cmm_lock);
+   *ph_cmm_mgr = cmm_obj;
} else {
status = -ENOMEM;
}
@@ -294,7 +284,7 @@ int cmm_destroy(struct cmm_object *hcmm_mgr, bool force)
struct cmm_info temp_info;
int status = 0;
s32 slot_seg;
-   struct cmm_mnode *pnode;
+   struct cmm_mnode *node, *tmp;
 
DBC_REQUIRE(refs  0);
if (!hcmm_mgr) {
@@ -324,15 +314,10 @@ int cmm_destroy(struct cmm_object *hcmm_mgr, bool force)
}
}
}
-   if (cmm_mgr_obj-node_free_list_head != NULL) {
-   /* Free the free nodes */
-   while (!LST_IS_EMPTY(cmm_mgr_obj-node_free_list_head)) {
-   pnode = (struct cmm_mnode *)
-   lst_get_head(cmm_mgr_obj-node_free_list_head);
-   kfree(pnode);
-   }
-   /* delete NodeFreeList list */
-   kfree(cmm_mgr_obj-node_free_list_head);
+   list_for_each_entry_safe(node, tmp, cmm_mgr_obj-node_free_list,
+   link) {
+   list_del(node-link);
+   kfree(node);
}
mutex_unlock(cmm_mgr_obj-cmm_lock);
if (!status) {
@@ -366,7 +351,7 @@ int

[PATCH v3 08/12] staging: tidspbridge: convert rmgr to list_head

2010-11-21 Thread Ionut Nicu
Convert the rmgr module of the tidspbridge driver
to use struct list_head instead of struct lst_list.

Signed-off-by: Ionut Nicu ionut.n...@mindbit.ro
---
 drivers/staging/tidspbridge/rmgr/drv.c  |  115 --
 drivers/staging/tidspbridge/rmgr/node.c |   53 --
 drivers/staging/tidspbridge/rmgr/proc.c |2 -
 drivers/staging/tidspbridge/rmgr/rmm.c  |   75 +++-
 4 files changed, 72 insertions(+), 173 deletions(-)

diff --git a/drivers/staging/tidspbridge/rmgr/drv.c 
b/drivers/staging/tidspbridge/rmgr/drv.c
index 81b1b90..2ca3a23 100644
--- a/drivers/staging/tidspbridge/rmgr/drv.c
+++ b/drivers/staging/tidspbridge/rmgr/drv.c
@@ -16,6 +16,7 @@
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 #include linux/types.h
+#include linux/list.h
 
 /*  --- Host OS */
 #include dspbridge/host_os.h
@@ -26,9 +27,6 @@
 /*  --- Trace  Debug */
 #include dspbridge/dbc.h
 
-/*  --- OS Adaptation Layer */
-#include dspbridge/list.h
-
 /*  --- This */
 #include dspbridge/drv.h
 #include dspbridge/dev.h
@@ -42,8 +40,8 @@
 
 /*  --- Defines, Data Structures, Typedefs */
 struct drv_object {
-   struct lst_list *dev_list;
-   struct lst_list *dev_node_string;
+   struct list_head dev_list;
+   struct list_head dev_node_string;
 };
 
 /*
@@ -316,22 +314,8 @@ int drv_create(struct drv_object **drv_obj)
pdrv_object = kzalloc(sizeof(struct drv_object), GFP_KERNEL);
if (pdrv_object) {
/* Create and Initialize List of device objects */
-   pdrv_object-dev_list = kzalloc(sizeof(struct lst_list),
-   GFP_KERNEL);
-   if (pdrv_object-dev_list) {
-   /* Create and Initialize List of device Extension */
-   pdrv_object-dev_node_string =
-   kzalloc(sizeof(struct lst_list), GFP_KERNEL);
-   if (!(pdrv_object-dev_node_string)) {
-   status = -EPERM;
-   } else {
-   INIT_LIST_HEAD(pdrv_object-
-  dev_node_string-head);
-   INIT_LIST_HEAD(pdrv_object-dev_list-head);
-   }
-   } else {
-   status = -ENOMEM;
-   }
+   INIT_LIST_HEAD(pdrv_object-dev_list);
+   INIT_LIST_HEAD(pdrv_object-dev_node_string);
} else {
status = -ENOMEM;
}
@@ -348,8 +332,6 @@ int drv_create(struct drv_object **drv_obj)
if (!status) {
*drv_obj = pdrv_object;
} else {
-   kfree(pdrv_object-dev_list);
-   kfree(pdrv_object-dev_node_string);
/* Free the DRV Object */
kfree(pdrv_object);
}
@@ -386,13 +368,6 @@ int drv_destroy(struct drv_object *driver_obj)
DBC_REQUIRE(refs  0);
DBC_REQUIRE(pdrv_object);
 
-   /*
-*  Delete the List if it exists.Should not come here
-*  as the drv_remove_dev_object and the Last drv_request_resources
-*  removes the list if the lists are empty.
-*/
-   kfree(pdrv_object-dev_list);
-   kfree(pdrv_object-dev_node_string);
kfree(pdrv_object);
/* Update the DRV Object in the driver data */
if (drv_datap) {
@@ -424,7 +399,7 @@ int drv_get_dev_object(u32 index, struct drv_object 
*hdrv_obj,
DBC_REQUIRE(device_obj != NULL);
DBC_REQUIRE(index = 0);
DBC_REQUIRE(refs  0);
-   DBC_ASSERT(!(LST_IS_EMPTY(pdrv_obj-dev_list)));
+   DBC_ASSERT(!(list_empty(pdrv_obj-dev_list)));
 
dev_obj = (struct dev_object *)drv_get_first_dev_object();
for (i = 0; i  index; i++) {
@@ -455,9 +430,8 @@ u32 drv_get_first_dev_object(void)
 
if (drv_datap  drv_datap-drv_object) {
pdrv_obj = drv_datap-drv_object;
-   if ((pdrv_obj-dev_list != NULL) 
-   !LST_IS_EMPTY(pdrv_obj-dev_list))
-   dw_dev_object = (u32) lst_first(pdrv_obj-dev_list);
+   if (!list_empty(pdrv_obj-dev_list))
+   dw_dev_object = (u32) pdrv_obj-dev_list.next;
} else {
pr_err(%s: Failed to retrieve the object handle\n, __func__);
}
@@ -479,10 +453,9 @@ u32 drv_get_first_dev_extension(void)
 
if (drv_datap  drv_datap-drv_object) {
pdrv_obj = drv_datap-drv_object;
-   if ((pdrv_obj-dev_node_string != NULL) 
-   !LST_IS_EMPTY(pdrv_obj-dev_node_string)) {
+   if (!list_empty(pdrv_obj-dev_node_string)) {
dw_dev_extension =
-   (u32

[PATCH v3 09/12] staging: tidspbridge: remove custom linked list

2010-11-21 Thread Ionut Nicu
Now that all users of lst_list have been converted to the
standard linux list_head API, we can remove the associated
header file.

Signed-off-by: Ionut Nicu ionut.n...@mindbit.ro
---
 drivers/staging/tidspbridge/TODO   |1 -
 .../staging/tidspbridge/include/dspbridge/list.h   |  225 
 2 files changed, 0 insertions(+), 226 deletions(-)
 delete mode 100644 drivers/staging/tidspbridge/include/dspbridge/list.h

diff --git a/drivers/staging/tidspbridge/TODO b/drivers/staging/tidspbridge/TODO
index 187363f..1c51e2d 100644
--- a/drivers/staging/tidspbridge/TODO
+++ b/drivers/staging/tidspbridge/TODO
@@ -6,7 +6,6 @@
 * Eliminate general services and libraries - use or extend existing kernel
   libraries instead (e.g. gcf/lcm in nldr.c, global helpers in gen/)
 * Eliminate direct manipulation of OMAP_SYSC_BASE
-* Eliminate list.h : seem like a redundant wrapper to existing kernel lists
 * Eliminate DSP_SUCCEEDED macros and their imposed redundant indentations
   (adopt the kernel way of checking for return values)
 * Audit interfaces exposed to user space
diff --git a/drivers/staging/tidspbridge/include/dspbridge/list.h 
b/drivers/staging/tidspbridge/include/dspbridge/list.h
deleted file mode 100644
index 6837b61..000
--- a/drivers/staging/tidspbridge/include/dspbridge/list.h
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * list.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Declarations of list management control structures and definitions
- * of inline list management functions.
- *
- * Copyright (C) 2008 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.
- */
-
-#ifndef LIST_
-#define LIST_
-
-#include dspbridge/host_os.h
-#include linux/list.h
-
-#define LST_IS_EMPTY(l)  list_empty((l)-head)
-
-struct lst_list {
-   struct list_head head;
-};
-
-/*
- *   lst_first 
- *  Purpose:
- *  Returns a pointer to the first element of the list, or NULL if the list
- *  is empty.
- *  Parameters:
- *  lst:  Pointer to list control structure.
- *  Returns:
- *  Pointer to first list element, or NULL.
- *  Requires:
- *  - LST initialized.
- *  - lst != NULL.
- *  Ensures:
- */
-static inline struct list_head *lst_first(struct lst_list *lst)
-{
-   if (lst  !list_empty(lst-head))
-   return lst-head.next;
-   return NULL;
-}
-
-/*
- *   lst_get_head 
- *  Purpose:
- *  Pops the head off the list and returns a pointer to it.
- *  Details:
- *  If the list is empty, returns NULL.
- *  Else, removes the element at the head of the list, making the next
- *  element the head of the list.
- *  The head is removed by making the tail element of the list point its
- *  next pointer at the next element after the head, and by making the
- *  prev pointer of the next element after the head point at the tail
- *  element.  So the next element after the head becomes the new head of
- *  the list.
- *  Parameters:
- *  lst:Pointer to list control structure of list whose head
- *  element is to be removed
- *  Returns:
- *  Pointer to element that was at the head of the list (success)
- *  NULL  No elements in list
- *  Requires:
- *  - LST initialized.
- *  - lst != NULL.
- *  Ensures:
- *  Notes:
- *  Because the tail of the list points forward (its next pointer) to
- *  the head of the list, and the head of the list points backward (its
- *  prev pointer) to the tail of the list, this list is circular.
- */
-static inline struct list_head *lst_get_head(struct lst_list *lst)
-{
-   struct list_head *elem_list;
-
-   if (!lst || list_empty(lst-head))
-   return NULL;
-
-   elem_list = lst-head.next;
-   lst-head.next = elem_list-next;
-   elem_list-next-prev = lst-head;
-
-   return elem_list;
-}
-
-/*
- *   lst_init_elem 
- *  Purpose:
- *  Initializes a list element to default (cleared) values
- *  Details:
- *  Parameters:
- *  elem_list:  Pointer to list element to be reset
- *  Returns:
- *  Requires:
- *  LST initialized.
- *  Ensures:
- *  Notes:
- *  This function must not be called to reset an element in the middle
- *  of a list chain -- that would break the chain.
- *
- */
-static inline void lst_init_elem(struct list_head *elem_list)
-{
-   if (elem_list) {
-   elem_list-next = NULL;
-   elem_list-prev = NULL;
-   }
-}
-
-/*
- *   lst_insert_before 
- *  Purpose:
- * Insert the element before

[PATCH v3 10/12] staging: tidspbridge: core code cleanup

2010-11-21 Thread Ionut Nicu
Reorganized some code in the core module to increase its
readability. Most of the changes reduce the code
indentation level and simplifiy the code. No functional
changes were done.

Signed-off-by: Ionut Nicu ionut.n...@mindbit.ro
---
 drivers/staging/tidspbridge/core/chnl_sm.c |  449 +---
 drivers/staging/tidspbridge/core/io_sm.c   |  192 ++---
 drivers/staging/tidspbridge/core/msg_sm.c  |  447 ---
 3 files changed, 496 insertions(+), 592 deletions(-)

diff --git a/drivers/staging/tidspbridge/core/chnl_sm.c 
b/drivers/staging/tidspbridge/core/chnl_sm.c
index ca19ede..bfa8999 100644
--- a/drivers/staging/tidspbridge/core/chnl_sm.c
+++ b/drivers/staging/tidspbridge/core/chnl_sm.c
@@ -105,35 +105,31 @@ int bridge_chnl_add_io_req(struct chnl_object *chnl_obj, 
void *host_buf,
is_eos = (byte_size == 0);
 
/* Validate args */
-   if (!host_buf || !pchnl) {
-   status = -EFAULT;
-   } else if (is_eos  CHNL_IS_INPUT(pchnl-chnl_mode)) {
-   status = -EPERM;
-   } else {
-   /*
-* Check the channel state: only queue chirp if channel state
-* allows it.
-*/
-   dw_state = pchnl-dw_state;
-   if (dw_state != CHNL_STATEREADY) {
-   if (dw_state  CHNL_STATECANCEL)
-   status = -ECANCELED;
-   else if ((dw_state  CHNL_STATEEOS) 
-CHNL_IS_OUTPUT(pchnl-chnl_mode))
-   status = -EPIPE;
-   else
-   /* No other possible states left */
-   DBC_ASSERT(0);
-   }
+   if (!host_buf || !pchnl)
+   return -EFAULT;
+
+   if (is_eos  CHNL_IS_INPUT(pchnl-chnl_mode))
+   return -EPERM;
+
+   /*
+* Check the channel state: only queue chirp if channel state
+* allows it.
+*/
+   dw_state = pchnl-dw_state;
+   if (dw_state != CHNL_STATEREADY) {
+   if (dw_state  CHNL_STATECANCEL)
+   return -ECANCELED;
+   if ((dw_state  CHNL_STATEEOS) 
+   CHNL_IS_OUTPUT(pchnl-chnl_mode))
+   return -EPIPE;
+   /* No other possible states left */
+   DBC_ASSERT(0);
}
 
dev_obj = dev_get_first();
dev_get_bridge_context(dev_obj, dev_ctxt);
if (!dev_ctxt)
-   status = -EFAULT;
-
-   if (status)
-   goto func_end;
+   return -EFAULT;
 
if (pchnl-chnl_type == CHNL_PCPY  pchnl-chnl_id  1  host_buf) {
if (!(host_buf  (void *)USERMODE_ADDR)) {
@@ -142,18 +138,16 @@ int bridge_chnl_add_io_req(struct chnl_object *chnl_obj, 
void *host_buf,
}
/* if addr in user mode, then copy to kernel space */
host_sys_buf = kmalloc(buf_size, GFP_KERNEL);
-   if (host_sys_buf == NULL) {
-   status = -ENOMEM;
-   goto func_end;
-   }
+   if (host_sys_buf == NULL)
+   return -ENOMEM;
+
if (CHNL_IS_OUTPUT(pchnl-chnl_mode)) {
status = copy_from_user(host_sys_buf, host_buf,
-   buf_size);
+   buf_size);
if (status) {
kfree(host_sys_buf);
host_sys_buf = NULL;
-   status = -EFAULT;
-   goto func_end;
+   return -EFAULT;
}
}
}
@@ -167,66 +161,62 @@ func_cont:
omap_mbox_disable_irq(dev_ctxt-mbox, IRQ_RX);
if (pchnl-chnl_type == CHNL_PCPY) {
/* This is a processor-copy channel. */
-   if (!status  CHNL_IS_OUTPUT(pchnl-chnl_mode)) {
+   if (CHNL_IS_OUTPUT(pchnl-chnl_mode)) {
/* Check buffer size on output channels for fit. */
-   if (byte_size 
-   io_buf_size(pchnl-chnl_mgr_obj-hio_mgr))
+   if (byte_size  io_buf_size(
+   pchnl-chnl_mgr_obj-hio_mgr)) {
status = -EINVAL;
-
-   }
-   }
-   if (!status) {
-   /* Get a free chirp: */
-   if (!list_empty(pchnl-free_packets_list)) {
-   chnl_packet_obj = list_first_entry(
-   pchnl-free_packets_list,
-   struct chnl_irp, link);
-   list_del(chnl_packet_obj-link);
-   } else {
-   status = -EIO

[PATCH v3 11/12] staging: tidspbridge: pmgr code cleanup

2010-11-21 Thread Ionut Nicu
Reorganized some code in the pmgr module to increase
its readability. No functional changes were done.

Signed-off-by: Ionut Nicu ionut.n...@mindbit.ro
---
 drivers/staging/tidspbridge/pmgr/cmm.c |  357 ++-
 drivers/staging/tidspbridge/pmgr/dev.c |   20 +--
 2 files changed, 167 insertions(+), 210 deletions(-)

diff --git a/drivers/staging/tidspbridge/pmgr/cmm.c 
b/drivers/staging/tidspbridge/pmgr/cmm.c
index d7ca2a4..d4f55ec 100644
--- a/drivers/staging/tidspbridge/pmgr/cmm.c
+++ b/drivers/staging/tidspbridge/pmgr/cmm.c
@@ -250,26 +250,23 @@ int cmm_create(struct cmm_object **ph_cmm_mgr,
*ph_cmm_mgr = NULL;
/* create, zero, and tag a cmm mgr object */
cmm_obj = kzalloc(sizeof(struct cmm_object), GFP_KERNEL);
-   if (cmm_obj != NULL) {
-   if (mgr_attrts == NULL)
-   mgr_attrts = cmm_dfltmgrattrs; /* set defaults */
-
-   /* 4 bytes minimum */
-   DBC_ASSERT(mgr_attrts-ul_min_block_size = 4);
-   /* save away smallest block allocation for this cmm mgr */
-   cmm_obj-ul_min_block_size = mgr_attrts-ul_min_block_size;
-   cmm_obj-dw_page_size = PAGE_SIZE;
-
-   /* Note: DSP SM seg table(aDSPSMSegTab[]) zero'd by
-* MEM_ALLOC_OBJECT */
-
-   /* create node free list */
-   INIT_LIST_HEAD(cmm_obj-node_free_list);
-   mutex_init(cmm_obj-cmm_lock);
-   *ph_cmm_mgr = cmm_obj;
-   } else {
-   status = -ENOMEM;
-   }
+   if (!cmm_obj)
+   return -ENOMEM;
+
+   if (mgr_attrts == NULL)
+   mgr_attrts = cmm_dfltmgrattrs; /* set defaults */
+
+   /* 4 bytes minimum */
+   DBC_ASSERT(mgr_attrts-ul_min_block_size = 4);
+   /* save away smallest block allocation for this cmm mgr */
+   cmm_obj-ul_min_block_size = mgr_attrts-ul_min_block_size;
+   cmm_obj-dw_page_size = PAGE_SIZE;
+
+   /* create node free list */
+   INIT_LIST_HEAD(cmm_obj-node_free_list);
+   mutex_init(cmm_obj-cmm_lock);
+   *ph_cmm_mgr = cmm_obj;
+
return status;
 }
 
@@ -346,13 +343,12 @@ void cmm_exit(void)
  *  Purpose:
  *  Free the given buffer.
  */
-int cmm_free_buf(struct cmm_object *hcmm_mgr, void *buf_pa,
-   u32 ul_seg_id)
+int cmm_free_buf(struct cmm_object *hcmm_mgr, void *buf_pa, u32 ul_seg_id)
 {
struct cmm_object *cmm_mgr_obj = (struct cmm_object *)hcmm_mgr;
int status = -EFAULT;
struct cmm_mnode *curr, *tmp;
-   struct cmm_allocator *allocator = NULL;
+   struct cmm_allocator *allocator;
struct cmm_attrs *pattrs;
 
DBC_REQUIRE(refs  0);
@@ -366,21 +362,22 @@ int cmm_free_buf(struct cmm_object *hcmm_mgr, void 
*buf_pa,
status = -EFAULT;
return status;
}
-   /* get the allocator for this segment id */
+
allocator = get_allocator(cmm_mgr_obj, ul_seg_id);
-   if (allocator != NULL) {
-   mutex_lock(cmm_mgr_obj-cmm_lock);
-   list_for_each_entry_safe(curr, tmp, allocator-in_use_list,
-   link) {
-   if (curr-dw_pa == (u32) buf_pa) {
-   list_del(curr-link);
-   add_to_free_list(allocator, curr);
-   status = 0;
-   break;
-   }
+   if (!allocator)
+   return status;
+
+   mutex_lock(cmm_mgr_obj-cmm_lock);
+   list_for_each_entry_safe(curr, tmp, allocator-in_use_list, link) {
+   if (curr-dw_pa == (u32) buf_pa) {
+   list_del(curr-link);
+   add_to_free_list(allocator, curr);
+   status = 0;
+   break;
}
-   mutex_unlock(cmm_mgr_obj-cmm_lock);
}
+   mutex_unlock(cmm_mgr_obj-cmm_lock);
+
return status;
 }
 
@@ -438,31 +435,30 @@ int cmm_get_info(struct cmm_object *hcmm_mgr,
for (ul_seg = 1; ul_seg = CMM_MAXGPPSEGS; ul_seg++) {
/* get the allocator object for this segment id */
altr = get_allocator(cmm_mgr_obj, ul_seg);
-   if (altr != NULL) {
-   cmm_info_obj-ul_num_gppsm_segs++;
-   cmm_info_obj-seg_info[ul_seg - 1].dw_seg_base_pa =
-   altr-shm_base - altr-ul_dsp_size;
-   cmm_info_obj-seg_info[ul_seg - 1].ul_total_seg_size =
-   altr-ul_dsp_size + altr-ul_sm_size;
-   cmm_info_obj-seg_info[ul_seg - 1].dw_gpp_base_pa =
-   altr-shm_base;
-   cmm_info_obj-seg_info[ul_seg - 1].ul_gpp_size =
-   altr-ul_sm_size;
-   cmm_info_obj-seg_info[ul_seg - 1].dw_dsp_base_va

[PATCH v3 12/12] staging: tidspbridge: rmgr code cleanup

2010-11-21 Thread Ionut Nicu
Reorganized some code in the rmgr module to increase
its readability. No functional changes were done.

Signed-off-by: Ionut Nicu ionut.n...@mindbit.ro
---
 drivers/staging/tidspbridge/rmgr/drv.c  |  171 +---
 drivers/staging/tidspbridge/rmgr/node.c |   81 +-
 drivers/staging/tidspbridge/rmgr/rmm.c  |  266 +-
 3 files changed, 229 insertions(+), 289 deletions(-)

diff --git a/drivers/staging/tidspbridge/rmgr/drv.c 
b/drivers/staging/tidspbridge/rmgr/drv.c
index 2ca3a23..6e9fc2e 100644
--- a/drivers/staging/tidspbridge/rmgr/drv.c
+++ b/drivers/staging/tidspbridge/rmgr/drv.c
@@ -304,40 +304,28 @@ int drv_proc_update_strm_res(u32 num_bufs, void 
*strm_resources)
  */
 int drv_create(struct drv_object **drv_obj)
 {
-   int status = 0;
struct drv_object *pdrv_object = NULL;
struct drv_data *drv_datap = dev_get_drvdata(bridge);
 
DBC_REQUIRE(drv_obj != NULL);
DBC_REQUIRE(refs  0);
 
+   if (!drv_datap)
+   return -EFAULT;
+
pdrv_object = kzalloc(sizeof(struct drv_object), GFP_KERNEL);
-   if (pdrv_object) {
-   /* Create and Initialize List of device objects */
-   INIT_LIST_HEAD(pdrv_object-dev_list);
-   INIT_LIST_HEAD(pdrv_object-dev_node_string);
-   } else {
-   status = -ENOMEM;
-   }
-   /* Store the DRV Object in the driver data */
-   if (!status) {
-   if (drv_datap) {
-   drv_datap-drv_object = (void *)pdrv_object;
-   } else {
-   status = -EPERM;
-   pr_err(%s: Failed to store DRV object\n, __func__);
-   }
-   }
+   if (!pdrv_object)
+   return -ENOMEM;
 
-   if (!status) {
-   *drv_obj = pdrv_object;
-   } else {
-   /* Free the DRV Object */
-   kfree(pdrv_object);
-   }
+   /* Create and Initialize List of device objects */
+   INIT_LIST_HEAD(pdrv_object-dev_list);
+   INIT_LIST_HEAD(pdrv_object-dev_node_string);
 
-   DBC_ENSURE(status || pdrv_object);
-   return status;
+   /* Store the DRV Object in the driver data */
+   drv_datap-drv_object = (void *)pdrv_object;
+   *drv_obj = pdrv_object;
+
+   return 0;
 }
 
 /*
@@ -424,19 +412,19 @@ int drv_get_dev_object(u32 index, struct drv_object 
*hdrv_obj,
  */
 u32 drv_get_first_dev_object(void)
 {
-   u32 dw_dev_object = 0;
struct drv_object *pdrv_obj;
struct drv_data *drv_datap = dev_get_drvdata(bridge);
 
-   if (drv_datap  drv_datap-drv_object) {
-   pdrv_obj = drv_datap-drv_object;
-   if (!list_empty(pdrv_obj-dev_list))
-   dw_dev_object = (u32) pdrv_obj-dev_list.next;
-   } else {
+   if (!drv_datap || !drv_datap-drv_object) {
pr_err(%s: Failed to retrieve the object handle\n, __func__);
+   return 0;
}
 
-   return dw_dev_object;
+   pdrv_obj = drv_datap-drv_object;
+   if (list_empty(pdrv_obj-dev_list))
+   return 0;
+
+   return (u32) pdrv_obj-dev_list.next;
 }
 
 /*
@@ -447,21 +435,19 @@ u32 drv_get_first_dev_object(void)
  */
 u32 drv_get_first_dev_extension(void)
 {
-   u32 dw_dev_extension = 0;
struct drv_object *pdrv_obj;
struct drv_data *drv_datap = dev_get_drvdata(bridge);
 
-   if (drv_datap  drv_datap-drv_object) {
-   pdrv_obj = drv_datap-drv_object;
-   if (!list_empty(pdrv_obj-dev_node_string)) {
-   dw_dev_extension =
-   (u32) pdrv_obj-dev_node_string.next;
-   }
-   } else {
+   if (!drv_datap || !drv_datap-drv_object) {
pr_err(%s: Failed to retrieve the object handle\n, __func__);
+   return 0;
}
 
-   return dw_dev_extension;
+   pdrv_obj = drv_datap-drv_object;
+   if (list_empty(pdrv_obj-dev_node_string))
+   return 0;
+
+   return (u32) pdrv_obj-dev_node_string.next;
 }
 
 /*
@@ -473,24 +459,25 @@ u32 drv_get_first_dev_extension(void)
  */
 u32 drv_get_next_dev_object(u32 hdev_obj)
 {
-   u32 dw_next_dev_object = 0;
struct drv_object *pdrv_obj;
struct drv_data *drv_datap = dev_get_drvdata(bridge);
struct list_head *curr;
 
-   if (drv_datap  drv_datap-drv_object) {
-   pdrv_obj = drv_datap-drv_object;
-   if (!list_empty(pdrv_obj-dev_list)) {
-   curr = (struct list_head *)hdev_obj;
-   if (list_is_last(curr, pdrv_obj-dev_list))
-   return 0;
-   dw_next_dev_object = (u32) curr-next;
-   }
-   } else {
+   if (!drv_datap || !drv_datap-drv_object) {
pr_err(%s: Failed to retrieve the object handle\n, __func__);
+   return 0

Re: [PATCH 1/1] serial: omap-serial: Add support for kernel debugger

2010-11-21 Thread Ionut Nicu
Hi Cosmin,

On Sat, 2010-11-20 at 21:51 +0100, Cosmin Cojocar wrote:
 The kgdb invokes the poll_put_char and poll_get_char when communicating
 with the host. This patch also changes the initialization order because the
 kgdb will check at the very beginning, if there is a valid serial
 driver.
 
 Signed-off-by: Cosmin Cojocar cosmin.cojo...@gmail.com
 ---
  drivers/serial/Makefile  |2 +-
  drivers/serial/omap-serial.c |   38 --
  2 files changed, 37 insertions(+), 3 deletions(-)
 
 diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
 index c570576..ad86113 100644
 --- a/drivers/serial/Makefile
 +++ b/drivers/serial/Makefile
 @@ -80,6 +80,7 @@ obj-$(CONFIG_SERIAL_NETX) += netx-serial.o
  obj-$(CONFIG_SERIAL_OF_PLATFORM) += of_serial.o
  obj-$(CONFIG_SERIAL_OF_PLATFORM_NWPSERIAL) += nwpserial.o
  obj-$(CONFIG_SERIAL_KS8695) += serial_ks8695.o
 +obj-$(CONFIG_SERIAL_OMAP) += omap-serial.o
  obj-$(CONFIG_KGDB_SERIAL_CONSOLE) += kgdboc.o
  obj-$(CONFIG_SERIAL_QE) += ucc_uart.o
  obj-$(CONFIG_SERIAL_TIMBERDALE)  += timbuart.o
 @@ -88,4 +89,3 @@ obj-$(CONFIG_SERIAL_ALTERA_JTAGUART) += altera_jtaguart.o
  obj-$(CONFIG_SERIAL_ALTERA_UART) += altera_uart.o
  obj-$(CONFIG_SERIAL_MRST_MAX3110)+= mrst_max3110.o
  obj-$(CONFIG_SERIAL_MFD_HSU) += mfd.o
 -obj-$(CONFIG_SERIAL_OMAP) += omap-serial.o
 diff --git a/drivers/serial/omap-serial.c b/drivers/serial/omap-serial.c
 index 03a96db..df6ba03 100644
 --- a/drivers/serial/omap-serial.c
 +++ b/drivers/serial/omap-serial.c
 @@ -866,14 +866,44 @@ serial_omap_type(struct uart_port *port)
   return up-name;
  }
  
 +#define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)
 +
 +#ifdef CONFIG_CONSOLE_POLL
 +static void serial_omap_poll_put_char(struct uart_port *port, unsigned char 
 ch)
 +{
 + struct uart_omap_port *up = (struct uart_omap_port *)port;
 + unsigned int status;
 +
 + do {
 + status = serial_in(up, UART_LSR);
 + udelay(1);
 + } while ((status  BOTH_EMPTY) != BOTH_EMPTY);
 +

Shouldn't you use wait_for_xmitr() instead? If you do that, then you
don't need to move the BOTH_EMPTY macro anymore.

 + serial_out(up, UART_TX, ch);
 +}
 +
 +static int serial_omap_poll_get_char(struct uart_port *port)
 +{
 + struct uart_omap_port *up = (struct uart_omap_port *)port;
 + unsigned int status;
 + int ch;
 +
 + do {
 + status = serial_in(up, UART_LSR);
 + udelay(1);
 + } while ((status  UART_LSR_DR) != UART_LSR_DR);
 +

I think you should be returning NO_POLL_CHAR if the condition is false,
instead of busy looping.

 + ch = (int)serial_in(up, UART_RX);
 + return ch;
 +}

I don't think you need the extra ch variable. Just return serial_in(up,
UART_RX).

Cheers,
Ionut.

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 08/12] staging: tidspbridge: convert rmgr to list_head

2010-11-07 Thread Ionut Nicu
Hi Greg,

On Sat, 2010-11-06 at 11:26 -0700, Greg KH wrote:
 On Sat, Nov 06, 2010 at 08:18:27PM +0200, Ionut Nicu wrote:
  Hi Rene,
  
  On Fri, 2010-11-05 at 18:07 -0600, Sapiens, Rene wrote:
   Hi Ionut,
   
   On Fri, Nov 5, 2010 at 9:13 AM, Ionut Nicu ionut.n...@gmail.com wrote:
Convert the rmgr module of the tidspbridge driver
to use struct list_head instead of struct lst_list.
   
Signed-off-by: Ionut Nicu ionut.n...@mindbit.ro
   
   snip
   
diff --git a/drivers/staging/tidspbridge/rmgr/drv.c 
b/drivers/staging/tidspbridge/rmgr/drv.c
   
   snip
   
@@ -492,16 +465,17 @@ u32 drv_get_next_dev_object(u32 hdev_obj)
   u32 dw_next_dev_object = 0;
   struct drv_object *pdrv_obj;
   struct drv_data *drv_datap = dev_get_drvdata(bridge);
+   struct list_head *curr;
   
   DBC_REQUIRE(hdev_obj != 0);
   
   can we remove the DBC_REQUIRE and always check for !hdev_obj?
   
  
  Sounds ok to me.
  
  As a general remark, I personally think that the DBC_* macros should be
  replaced with BUG_ON, WARN_ON, but that's a subject for other patches.
  What do you think? 
 
 They should probably be deleted, I will not add any BUG_ON to a driver,
 nor should anyone else.  That's just rude behavior to crash the system,
 don't you think?
 

You're right. Removing them sounds like a better plan. There over 1000
DBC_* lines in this driver, so I guess it will clean it up a little bit.

Just out of curiosity, in what cases is it acceptable to use
BUG_ON/WARN_ON?

Thanks,
Ionut.

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 07/12] staging: tidspbridge: convert pmgr to list_head

2010-11-07 Thread Ionut Nicu
Hi Rene,

On Fri, 2010-11-05 at 16:41 -0600, Sapiens, Rene wrote:
 Hi Ionut,
 
 On Fri, Nov 5, 2010 at 9:13 AM, Ionut Nicu ionut.n...@gmail.com wrote:
  Convert the pmgr module of the tidspbridge driver
  to use struct list_head instead of struct lst_list.
 
 snip
 
  + * Memory is coalesced back to the appropriate heap when a buffer is
 
 What is being fixed here?
 

It was a typo (s/coelesced/coalesced/).

   * freed.
   *
   * Notes:
 
 snip
 
  @@ -833,67 +768,44 @@ static void add_to_free_list(struct cmm_allocator 
  *allocator,
 DBC_REQUIRE(allocator != NULL);
 dw_this_pa = pnode-dw_pa;
 dw_next_pa = NEXT_PA(pnode);
 
 i think it would be good to return with error if !allocator or !pnode
 and remove theresulting duplicated DBC_REQUIRE.
 

Yeah I think pnode should be checked for null. Can allocator ever be
null?

  -   mnode_obj = (struct cmm_mnode 
  *)lst_first(allocator-free_list_head);
  -   while (mnode_obj) {
  +   list_for_each_entry(mnode_obj, allocator-free_list, link) {
 if (dw_this_pa == NEXT_PA(mnode_obj)) {
 
 snip
 
  @@ -748,18 +736,16 @@ bool dev_init(void)
   */
   int dev_notify_clients(struct dev_object *hdev_obj, u32 ret)
   {
  -   int status = 0;
  -
 struct dev_object *dev_obj = hdev_obj;
  -   void *proc_obj;
  +   struct list_head *curr;
 
 can we add a check for !dev_obj and !dev_obj-proc_list just to be
 sure that we get always the correct pointer?
 

proc_list isn't a pointer. Can dev_obj ever be null?

 snip
 
  @@ -947,15 +933,17 @@ int dev_insert_proc_object(struct dev_object 
  *hdev_obj,
 DBC_REQUIRE(refs  0);
 DBC_REQUIRE(dev_obj);
 DBC_REQUIRE(proc_obj != 0);
  -   DBC_REQUIRE(dev_obj-proc_list != NULL);
 DBC_REQUIRE(already_attached != NULL);
 
 can we check for !hdev_obj, !already_attached even if we have the
 DBC_REQUIRE?, maybe we can actually remove the DBC_REQUIRE that could
 be redundant after applying this.
 

Same question here.

  -   if (!LST_IS_EMPTY(dev_obj-proc_list))
  +   if (!list_empty(dev_obj-proc_list))
 *already_attached = true;
 
 snip
 
  @@ -986,15 +974,12 @@ int dev_remove_proc_object(struct dev_object 
  *hdev_obj, u32 proc_obj)
 
 DBC_REQUIRE(dev_obj);
 DBC_REQUIRE(proc_obj != 0);
  -   DBC_REQUIRE(dev_obj-proc_list != NULL);
  -   DBC_REQUIRE(!LST_IS_EMPTY(dev_obj-proc_list));
  +   DBC_REQUIRE(!list_empty(dev_obj-proc_list));
 
 
  The same comment as above.
 

Regards,
Ionut.

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 06/12] staging: tidspbridge: convert core to list_head

2010-11-06 Thread Ionut Nicu
Hi Rene,

On Fri, 2010-11-05 at 15:07 -0600, Sapiens, Rene wrote:
 Hi Ionut,
 
 On Fri, Nov 5, 2010 at 9:13 AM, Ionut Nicu ionut.n...@gmail.com wrote:
  Convert the core module of the tidspbridge driver
  to use struct list_head instead of struct lst_list.
 
 
 snip
 
 if (!status) {
 /* Get a free chirp: */
  -   chnl_packet_obj =
  -   (struct chnl_irp 
  *)lst_get_head(pchnl-free_packets_list);
  -   if (chnl_packet_obj == NULL)
  +   if (!list_empty(pchnl-free_packets_list)) {
  +   chnl_packet_obj = list_first_entry(
  +   pchnl-free_packets_list,
  +   struct chnl_irp, link);
  +   list_del(chnl_packet_obj-link);
  +   } else
 status = -EIO;
 
 What do you think if we close the braces, since the first conditional
 has more than one statement?
 

Can you clarify? I don't think I understand which brace we need to close
here.

 snip
 
  @@ -286,18 +286,16 @@ int bridge_chnl_cancel_io(struct chnl_object 
  *chnl_obj)
 }
 }
 /* Move all IOR's to IOC queue: */
  -   while (!LST_IS_EMPTY(pchnl-pio_requests)) {
  -   chnl_packet_obj =
  -   (struct chnl_irp *)lst_get_head(pchnl-pio_requests);
  -   if (chnl_packet_obj) {
  -   chnl_packet_obj-byte_size = 0;
  -   chnl_packet_obj-status |= CHNL_IOCSTATCANCEL;
  -   lst_put_tail(pchnl-pio_completions,
  -(struct list_head *)chnl_packet_obj);
  -   pchnl-cio_cs++;
  -   pchnl-cio_reqs--;
  -   DBC_ASSERT(pchnl-cio_reqs = 0);
  -   }
  +   while (!list_empty(pchnl-pio_requests)) {
  +   chnl_packet_obj = list_first_entry(pchnl-pio_requests,
  +   struct chnl_irp, link);
  +   list_del(chnl_packet_obj-link);
  +   chnl_packet_obj-byte_size = 0;
  +   chnl_packet_obj-status |= CHNL_IOCSTATCANCEL;
  +   list_add_tail(chnl_packet_obj-link, 
  pchnl-pio_completions);
  +   pchnl-cio_cs++;
  +   pchnl-cio_reqs--;
  +   DBC_ASSERT(pchnl-cio_reqs = 0);
 
 Why don't we use list_for_each_entry_safe() instead?
 

Agreed, it will look better.


 }
   func_cont:
 spin_unlock_bh(chnl_mgr_obj-chnl_mgr_lock);
 
 snip
 
  @@ -818,9 +804,19 @@ int bridge_chnl_open(struct chnl_object **chnl,
 /* Protect queues from io_dpc: */
 pchnl-dw_state = CHNL_STATECANCEL;
 /* Allocate initial IOR and IOC queues: */
  -   pchnl-free_packets_list = create_chirp_list(pattrs-uio_reqs);
  -   pchnl-pio_requests = create_chirp_list(0);
  -   pchnl-pio_completions = create_chirp_list(0);
  +   status = create_chirp_list(pchnl-free_packets_list,
  +   pattrs-uio_reqs);
  +   if (status)
  +   goto func_end;
  +
  +   status = create_chirp_list(pchnl-pio_requests, 0);
  +   if (status)
  +   goto func_end;
  +
  +   status = create_chirp_list(pchnl-pio_completions, 0);
  +   if (status)
  +   goto func_end;
  +
 
 With these goto you are not freeing the memory allocated for pchnl, please 
 free
 it at func_end.
 

Thanks for catching this. Freeing it at func_end is not a very good
idea, because it's also freed above. 

What do you think if I replace the last two calls for
create_chirp_list() with just INIT_LIST_HEAD()? This way we'll have only
one error check where we'll also kfree(pchnl) and we'll have 2 less
un-necessary function calls / error checks.

Regards,
Ionut.

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 06/12] staging: tidspbridge: convert core to list_head

2010-11-06 Thread Ionut Nicu
Hi Rene,

On Fri, 2010-11-05 at 16:12 -0600, Sapiens, Rene wrote:
 Hi Ionut,
 
 On Fri, Nov 5, 2010 at 9:13 AM, Ionut Nicu ionut.n...@gmail.com wrote:
  Convert the core module of the tidspbridge driver
  to use struct list_head instead of struct lst_list.
 
  Signed-off-by: Ionut Nicu ionut.n...@mindbit.ro
 
 snip
 
  diff --git a/drivers/staging/tidspbridge/core/io_sm.c 
  b/drivers/staging/tidspbridge/core/io_sm.c
  index 194bada..9851f32 100644
  --- a/drivers/staging/tidspbridge/core/io_sm.c
  +++ b/drivers/staging/tidspbridge/core/io_sm.c
 
 snip
 
  @@ -1106,47 +1103,38 @@ static void input_msg(struct io_mgr *pio_mgr, 
  struct msg_mgr *hmsg_mgr)
  * queued.
  */
 (*hmsg_mgr-on_exit) ((void *)
  -  
  msg_queue_obj-arg,
  -  msg.msg.dw_arg1);
  +   msg_queue_obj-arg,
  +   msg.msg.dw_arg1);
  +   break;
  +   }
  +   /*
  +* Not an exit acknowledgement, queue
  +* the message.
  +*/
  +   if 
  (!list_empty(msg_queue_obj-msg_free_list)) {
 
 You are going beyond the 80 chars.
 

I thought about it too when using scripts/checkpatch.pl on this patch.
The thing is that it's 81 chars and breaking it into two lines makes it
look uglier. Also, this gets fixed in patch 10/12 (core code cleanup).

Regards,
Ionut.

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 08/12] staging: tidspbridge: convert rmgr to list_head

2010-11-06 Thread Ionut Nicu
Hi Rene,

On Fri, 2010-11-05 at 18:07 -0600, Sapiens, Rene wrote:
 Hi Ionut,
 
 On Fri, Nov 5, 2010 at 9:13 AM, Ionut Nicu ionut.n...@gmail.com wrote:
  Convert the rmgr module of the tidspbridge driver
  to use struct list_head instead of struct lst_list.
 
  Signed-off-by: Ionut Nicu ionut.n...@mindbit.ro
 
 snip
 
  diff --git a/drivers/staging/tidspbridge/rmgr/drv.c 
  b/drivers/staging/tidspbridge/rmgr/drv.c
 
 snip
 
  @@ -492,16 +465,17 @@ u32 drv_get_next_dev_object(u32 hdev_obj)
 u32 dw_next_dev_object = 0;
 struct drv_object *pdrv_obj;
 struct drv_data *drv_datap = dev_get_drvdata(bridge);
  +   struct list_head *curr;
 
 DBC_REQUIRE(hdev_obj != 0);
 
 can we remove the DBC_REQUIRE and always check for !hdev_obj?
 

Sounds ok to me.

As a general remark, I personally think that the DBC_* macros should be
replaced with BUG_ON, WARN_ON, but that's a subject for other patches.
What do you think? 

 
 if (drv_datap  drv_datap-drv_object) {
 pdrv_obj = drv_datap-drv_object;
  -   if ((pdrv_obj-dev_list != NULL) 
  -   !LST_IS_EMPTY(pdrv_obj-dev_list)) {
  -   dw_next_dev_object = (u32) 
  lst_next(pdrv_obj-dev_list,
  -   (struct 
  list_head *)
  -   hdev_obj);
  +   if (!list_empty(pdrv_obj-dev_list)) {
  +   curr = (struct list_head *)hdev_obj;
  +   if (curr-next == pdrv_obj-dev_list)
 
 Can we use list_is_last() instead?
 

Good point. I'll fix this.

  +   return 0;
  +   dw_next_dev_object = (u32) curr-next;
 
 snip
 
  @@ -573,11 +548,8 @@ int drv_insert_dev_object(struct drv_object 
  *driver_obj,
 DBC_REQUIRE(refs  0);
 DBC_REQUIRE(hdev_obj != NULL);
 DBC_REQUIRE(pdrv_object);
  -   DBC_ASSERT(pdrv_object-dev_list);
  -
 
 As a comment for all the functions that are manipulating lists, can we
 check the parameters that they receive?, this applies for some other
 functions in these patches, old lst_* functions were internally validating
 the having of a valid pointer, now i think that we have to add this to each
 function.
 

I don't think we need to put extra checks. The list head pointer will
never be null and I don't see any use cases where the list_head
container structure can be null...

  -   lst_put_tail(pdrv_object-dev_list, (struct list_head *)hdev_obj);
 
  -   DBC_ENSURE(!LST_IS_EMPTY(pdrv_object-dev_list));
  +   list_add_tail((struct list_head *)hdev_obj, pdrv_object-dev_list);
 
 snip
 
  @@ -1571,15 +1566,9 @@ int node_enum_nodes(struct node_mgr *hnode_mgr, void 
  **node_tab,
 *pu_num_nodes = 0;
 status = -EINVAL;
 } else {
  -   hnode = (struct node_object *)lst_first(hnode_mgr-
  -   node_list);
  -   for (i = 0; i  hnode_mgr-num_nodes; i++) {
  -   DBC_ASSERT(hnode);
  -   node_tab[i] = hnode;
  -   hnode = (struct node_object *)lst_next
  -   (hnode_mgr-node_list,
  -   (struct list_head *)hnode);
  -   }
  +   i = 0;
 
 just a comment, what if we initialize this i when declared and
 remove this line.
 

Ok, will do.


  +   list_for_each_entry(hnode, hnode_mgr-node_list, list_elem)
  +   node_tab[i++] = hnode;
 *pu_allocated = *pu_num_nodes = hnode_mgr-num_nodes;
 }
 
 snip
 
  diff --git a/drivers/staging/tidspbridge/rmgr/rmm.c 
  b/drivers/staging/tidspbridge/rmgr/rmm.c
 
 snip
 
  @@ -145,20 +141,17 @@ int rmm_alloc(struct rmm_target_obj *target, u32 
  segid, u32 size,
 if (new_sect == NULL) {
 status = -ENOMEM;
 } else {
  -   lst_init_elem((struct list_head *)new_sect);
 new_sect-addr = addr;
 new_sect-size = size;
 new_sect-page = segid;
  -   if (sect == NULL) {
  +   if (sect == NULL)
 
 I think that sect can't be NULL at this point... can be?
 can we use: if (list_is_last(sect-list_elem, target-ovly_list)) instead?
 

Yes, you are right.


 /* Put new section at the end of the list */
  -   lst_put_tail(target-ovly_list,
  -(struct list_head *)new_sect);
  -   } else {
  +   list_add_tail(new_sect-list_elem,
  +   target-ovly_list);
  +   else
 
 snip
 
  @@ -333,24 +316,17 @@ bool rmm_free(struct rmm_target_obj *target, u32 
  segid

[PATCH v2 00/12] staging: tidspbridge: various cleanups

2010-11-05 Thread Ionut Nicu
This set of patches replaces some of the redundant components of
the tidspbridge driver, such as:

* wrapper functions for kmalloc/kfree
* custom bitmap implementation
* custom linked list implementation (list_head wrapper)

with the standard linux kernel interfaces.

The patches also do some code reorganization for increasing readability.
Most of the changes reduce the code indentation level and simplify the code.
No functional changes were done.

There are many places in this driver that need this kind of cleanup, but
these patches only fix the functions that were touched while converting
the code to use linux bitmap and list_head.

Changes since v1:

* Split the bitmap patch into multiple patches
* Split the list_head patch into multiple patches

Ionut Nicu (12):
  staging: tidspbridge: remove gs memory allocator
  staging: tidspbridge: remove utildefs
  staging: tidspbridge: switch to linux bitmap API
  staging: tidspbridge: remove gb bitmap implementation
  staging: tidspbridge: rmgr/node.c code cleanup
  staging: tidspbridge: convert core to list_head
  staging: tidspbridge: convert pmgr to list_head
  staging: tidspbridge: convert rmgr to list_head
  staging: tidspbridge: remove custom linked list
  staging: tidspbridge: core code cleanup
  staging: tidspbridge: pmgr code cleanup
  staging: tidspbridge: rmgr code cleanup

 drivers/staging/tidspbridge/Makefile   |2 +-
 drivers/staging/tidspbridge/TODO   |1 -
 drivers/staging/tidspbridge/core/_msg_sm.h |   12 +-
 drivers/staging/tidspbridge/core/chnl_sm.c |  634 +++-
 drivers/staging/tidspbridge/core/io_sm.c   |  266 +++
 drivers/staging/tidspbridge/core/msg_sm.c  |  601 ++-
 drivers/staging/tidspbridge/gen/gb.c   |  166 -
 drivers/staging/tidspbridge/gen/gh.c   |   38 +-
 drivers/staging/tidspbridge/gen/gs.c   |   88 ---
 .../tidspbridge/include/dspbridge/_chnl_sm.h   |8 +-
 .../tidspbridge/include/dspbridge/cmmdefs.h|1 -
 drivers/staging/tidspbridge/include/dspbridge/gb.h |   79 --
 drivers/staging/tidspbridge/include/dspbridge/gs.h |   59 --
 .../staging/tidspbridge/include/dspbridge/list.h   |  225 --
 .../staging/tidspbridge/include/dspbridge/sync.h   |1 +
 .../tidspbridge/include/dspbridge/utildefs.h   |   39 -
 drivers/staging/tidspbridge/pmgr/cmm.c |  531 +-
 drivers/staging/tidspbridge/pmgr/dev.c |   73 +--
 drivers/staging/tidspbridge/rmgr/drv.c |  238 ++
 drivers/staging/tidspbridge/rmgr/node.c|  773 +---
 drivers/staging/tidspbridge/rmgr/proc.c|2 -
 drivers/staging/tidspbridge/rmgr/rmm.c |  313 -
 22 files changed, 1449 insertions(+), 2701 deletions(-)
 delete mode 100644 drivers/staging/tidspbridge/gen/gb.c
 delete mode 100644 drivers/staging/tidspbridge/gen/gs.c
 delete mode 100644 drivers/staging/tidspbridge/include/dspbridge/gb.h
 delete mode 100644 drivers/staging/tidspbridge/include/dspbridge/gs.h
 delete mode 100644 drivers/staging/tidspbridge/include/dspbridge/list.h
 delete mode 100644 drivers/staging/tidspbridge/include/dspbridge/utildefs.h

-- 
1.7.2.3

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 01/12] staging: tidspbridge: remove gs memory allocator

2010-11-05 Thread Ionut Nicu
Remove unnecessary wrappers for linux kernel memory
allocation primitives.

Signed-off-by: Ionut Nicu ionut.n...@mindbit.ro
---
 drivers/staging/tidspbridge/Makefile   |2 +-
 drivers/staging/tidspbridge/gen/gb.c   |   11 +--
 drivers/staging/tidspbridge/gen/gh.c   |   38 ++---
 drivers/staging/tidspbridge/gen/gs.c   |   88 
 drivers/staging/tidspbridge/include/dspbridge/gs.h |   59 -
 5 files changed, 15 insertions(+), 183 deletions(-)
 delete mode 100644 drivers/staging/tidspbridge/gen/gs.c
 delete mode 100644 drivers/staging/tidspbridge/include/dspbridge/gs.h

diff --git a/drivers/staging/tidspbridge/Makefile 
b/drivers/staging/tidspbridge/Makefile
index 50decc2..aaf397f 100644
--- a/drivers/staging/tidspbridge/Makefile
+++ b/drivers/staging/tidspbridge/Makefile
@@ -1,6 +1,6 @@
 obj-$(CONFIG_TIDSPBRIDGE)  += bridgedriver.o
 
-libgen = gen/gb.o gen/gs.o gen/gh.o gen/uuidutil.o
+libgen = gen/gb.o gen/gh.o gen/uuidutil.o
 libcore = core/chnl_sm.o core/msg_sm.o core/io_sm.o core/tiomap3430.o \
core/tiomap3430_pwr.o core/tiomap_io.o core/dsp-mmu.o \
core/ue_deh.o core/wdt.o core/dsp-clock.o core/sync.o
diff --git a/drivers/staging/tidspbridge/gen/gb.c 
b/drivers/staging/tidspbridge/gen/gb.c
index 9f59023..3c0e04c 100644
--- a/drivers/staging/tidspbridge/gen/gb.c
+++ b/drivers/staging/tidspbridge/gen/gb.c
@@ -19,7 +19,6 @@
 /*  --- DSP/BIOS Bridge */
 #include linux/types.h
 /*  --- This */
-#include dspbridge/gs.h
 #include dspbridge/gb.h
 
 struct gb_t_map {
@@ -52,17 +51,17 @@ struct gb_t_map *gb_create(u32 len)
 {
struct gb_t_map *map;
u32 i;
-   map = (struct gb_t_map *)gs_alloc(sizeof(struct gb_t_map));
+   map = kzalloc(sizeof(struct gb_t_map), GFP_KERNEL);
if (map != NULL) {
map-len = len;
map-wcnt = len / BITS_PER_LONG + 1;
-   map-words = (u32 *) gs_alloc(map-wcnt * sizeof(u32));
+   map-words = kzalloc(map-wcnt * sizeof(u32), GFP_KERNEL);
if (map-words != NULL) {
for (i = 0; i  map-wcnt; i++)
map-words[i] = 0L;
 
} else {
-   gs_frees(map, sizeof(struct gb_t_map));
+   kfree(map);
map = NULL;
}
}
@@ -78,8 +77,8 @@ struct gb_t_map *gb_create(u32 len)
 
 void gb_delete(struct gb_t_map *map)
 {
-   gs_frees(map-words, map-wcnt * sizeof(u32));
-   gs_frees(map, sizeof(struct gb_t_map));
+   kfree(map-words);
+   kfree(map);
 }
 
 /*
diff --git a/drivers/staging/tidspbridge/gen/gh.c 
b/drivers/staging/tidspbridge/gen/gh.c
index f72d943..cd72503 100644
--- a/drivers/staging/tidspbridge/gen/gh.c
+++ b/drivers/staging/tidspbridge/gen/gh.c
@@ -17,9 +17,6 @@
 #include linux/types.h
 
 #include dspbridge/host_os.h
-
-#include dspbridge/gs.h
-
 #include dspbridge/gh.h
 
 struct element {
@@ -37,8 +34,6 @@ struct gh_t_hash_tab {
 };
 
 static void noop(void *p);
-static s32 cur_init;
-static void myfree(void *ptr, s32 size);
 
 /*
  *   gh_create 
@@ -51,8 +46,7 @@ struct gh_t_hash_tab *gh_create(u16 max_bucket, u16 val_size,
 {
struct gh_t_hash_tab *hash_tab;
u16 i;
-   hash_tab =
-   (struct gh_t_hash_tab *)gs_alloc(sizeof(struct gh_t_hash_tab));
+   hash_tab = kzalloc(sizeof(struct gh_t_hash_tab), GFP_KERNEL);
if (hash_tab == NULL)
return NULL;
hash_tab-max_bucket = max_bucket;
@@ -62,7 +56,7 @@ struct gh_t_hash_tab *gh_create(u16 max_bucket, u16 val_size,
hash_tab-delete = delete == NULL ? noop : delete;
 
hash_tab-buckets = (struct element **)
-   gs_alloc(sizeof(struct element *) * max_bucket);
+   kzalloc(sizeof(struct element *) * max_bucket, GFP_KERNEL);
if (hash_tab-buckets == NULL) {
gh_delete(hash_tab);
return NULL;
@@ -89,17 +83,14 @@ void gh_delete(struct gh_t_hash_tab *hash_tab)
 elem = next) {
next = elem-next;
(*hash_tab-delete) (elem-data);
-   myfree(elem,
-  sizeof(struct element) - 1 +
-  hash_tab-val_size);
+   kfree(elem);
}
}
 
-   myfree(hash_tab-buckets, sizeof(struct element *)
-  * hash_tab-max_bucket);
+   kfree(hash_tab-buckets);
}
 
-   myfree(hash_tab, sizeof(struct gh_t_hash_tab));
+   kfree(hash_tab);
}
 }
 
@@ -109,9 +100,7

[PATCH v2 03/12] staging: tidspbridge: switch to linux bitmap API

2010-11-05 Thread Ionut Nicu
Replace the tidspbridge generic bitmap operations
with the linux standard bitmap implementation.

Signed-off-by: Ionut Nicu ionut.n...@mindbit.ro
---
 drivers/staging/tidspbridge/rmgr/node.c |  166 ++-
 1 files changed, 74 insertions(+), 92 deletions(-)

diff --git a/drivers/staging/tidspbridge/rmgr/node.c 
b/drivers/staging/tidspbridge/rmgr/node.c
index a660247..e48ddba 100644
--- a/drivers/staging/tidspbridge/rmgr/node.c
+++ b/drivers/staging/tidspbridge/rmgr/node.c
@@ -17,6 +17,7 @@
  */
 
 #include linux/types.h
+#include linux/bitmap.h
 /*  --- Host OS */
 #include dspbridge/host_os.h
 
@@ -50,7 +51,6 @@
 #include dspbridge/dspioctl.h
 
 /*  --- Others */
-#include dspbridge/gb.h
 #include dspbridge/uuidutil.h
 
 /*  --- This */
@@ -131,11 +131,14 @@ struct node_mgr {
struct lst_list *node_list; /* List of all allocated nodes */
u32 num_nodes;  /* Number of nodes in node_list */
u32 num_created;/* Number of nodes *created* on DSP */
-   struct gb_t_map *pipe_map;  /* Pipe connection bit map */
-   struct gb_t_map *pipe_done_map; /* Pipes that are half free */
-   struct gb_t_map *chnl_map;  /* Channel allocation bit map */
-   struct gb_t_map *dma_chnl_map;  /* DMA Channel allocation bit map */
-   struct gb_t_map *zc_chnl_map;   /* Zero-Copy Channel alloc bit map */
+   DECLARE_BITMAP(pipe_map, MAXPIPES); /* Pipe connection bitmap */
+   DECLARE_BITMAP(pipe_done_map, MAXPIPES); /* Pipes that are half free */
+   /* Channel allocation bitmap */
+   DECLARE_BITMAP(chnl_map, CHNL_MAXCHANNELS);
+   /* DMA Channel allocation bitmap */
+   DECLARE_BITMAP(dma_chnl_map, CHNL_MAXCHANNELS);
+   /* Zero-Copy Channel alloc bitmap */
+   DECLARE_BITMAP(zc_chnl_map, CHNL_MAXCHANNELS);
struct ntfy_object *ntfy_obj;   /* Manages registered notifications */
struct mutex node_mgr_lock; /* For critical sections */
u32 ul_fxn_addrs[NUMRMSFXNS];   /* RMS function addresses */
@@ -820,8 +823,8 @@ int node_connect(struct node_object *node1, u32 stream1,
struct node_object *dev_node_obj;
struct node_object *hnode;
struct stream_chnl *pstream;
-   u32 pipe_id = GB_NOBITS;
-   u32 chnl_id = GB_NOBITS;
+   u32 pipe_id;
+   u32 chnl_id;
s8 chnl_mode;
u32 dw_length;
int status = 0;
@@ -924,10 +927,11 @@ int node_connect(struct node_object *node1, u32 stream1,
   (node2_type == NODE_TASK
  || node2_type == NODE_DAISSOCKET))) {
/* Find available pipe */
-   pipe_id = gb_findandset(hnode_mgr-pipe_map);
-   if (pipe_id == GB_NOBITS) {
+   pipe_id = find_first_zero_bit(hnode_mgr-pipe_map, MAXPIPES);
+   if (pipe_id == MAXPIPES) {
status = -ECONNREFUSED;
} else {
+   set_bit(pipe_id, hnode_mgr-pipe_map);
node1-outputs[stream1].type = NODECONNECT;
node2-inputs[stream2].type = NODECONNECT;
node1-outputs[stream1].dev_id = pipe_id;
@@ -944,7 +948,7 @@ int node_connect(struct node_object *node1, u32 stream1,
 
output-sz_device = NULL;
input-sz_device = NULL;
-   gb_clear(hnode_mgr-pipe_map, pipe_id);
+   clear_bit(pipe_id, hnode_mgr-pipe_map);
status = -ENOMEM;
} else {
/* Copy /dbpipepipId name to device names */
@@ -969,34 +973,47 @@ int node_connect(struct node_object *node1, u32 stream1,
 *  called for this node. */
if (pattrs) {
if (pattrs-strm_mode == STRMMODE_RDMA) {
-   chnl_id =
-   gb_findandset(hnode_mgr-dma_chnl_map);
+   chnl_id = find_first_zero_bit(
+   hnode_mgr-dma_chnl_map,
+   CHNL_MAXCHANNELS);
/* dma chans are 2nd transport chnl set
 * ids(e.g. 16-31) */
-   (chnl_id != GB_NOBITS) ?
-   (chnl_id =
-chnl_id +
-hnode_mgr-ul_num_chnls) : chnl_id;
+   if (chnl_id != CHNL_MAXCHANNELS) {
+   set_bit(chnl_id,
+   hnode_mgr-dma_chnl_map);
+   chnl_id = chnl_id

[PATCH v2 04/12] staging: tidspbridge: remove gb bitmap implementation

2010-11-05 Thread Ionut Nicu
Now that all users of gb have been converted to the
standard linux bitmap API, we can remove it from the
gen library.

Signed-off-by: Ionut Nicu ionut.n...@mindbit.ro
---
 drivers/staging/tidspbridge/Makefile   |2 +-
 drivers/staging/tidspbridge/gen/gb.c   |  165 
 drivers/staging/tidspbridge/include/dspbridge/gb.h |   79 --
 3 files changed, 1 insertions(+), 245 deletions(-)
 delete mode 100644 drivers/staging/tidspbridge/gen/gb.c
 delete mode 100644 drivers/staging/tidspbridge/include/dspbridge/gb.h

diff --git a/drivers/staging/tidspbridge/Makefile 
b/drivers/staging/tidspbridge/Makefile
index aaf397f..6080e7e 100644
--- a/drivers/staging/tidspbridge/Makefile
+++ b/drivers/staging/tidspbridge/Makefile
@@ -1,6 +1,6 @@
 obj-$(CONFIG_TIDSPBRIDGE)  += bridgedriver.o
 
-libgen = gen/gb.o gen/gh.o gen/uuidutil.o
+libgen = gen/gh.o gen/uuidutil.o
 libcore = core/chnl_sm.o core/msg_sm.o core/io_sm.o core/tiomap3430.o \
core/tiomap3430_pwr.o core/tiomap_io.o core/dsp-mmu.o \
core/ue_deh.o core/wdt.o core/dsp-clock.o core/sync.o
diff --git a/drivers/staging/tidspbridge/gen/gb.c 
b/drivers/staging/tidspbridge/gen/gb.c
deleted file mode 100644
index 3c0e04c..000
--- a/drivers/staging/tidspbridge/gen/gb.c
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * gb.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Generic bitmap operations.
- *
- * 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.
- */
-
-/*  --- DSP/BIOS Bridge */
-#include linux/types.h
-/*  --- This */
-#include dspbridge/gb.h
-
-struct gb_t_map {
-   u32 len;
-   u32 wcnt;
-   u32 *words;
-};
-
-/*
- *   gb_clear 
- *  purpose:
- *  Clears a bit in the bit map.
- */
-
-void gb_clear(struct gb_t_map *map, u32 bitn)
-{
-   u32 mask;
-
-   mask = 1L  (bitn % BITS_PER_LONG);
-   map-words[bitn / BITS_PER_LONG] = ~mask;
-}
-
-/*
- *   gb_create 
- *  purpose:
- *  Creates a bit map.
- */
-
-struct gb_t_map *gb_create(u32 len)
-{
-   struct gb_t_map *map;
-   u32 i;
-   map = kzalloc(sizeof(struct gb_t_map), GFP_KERNEL);
-   if (map != NULL) {
-   map-len = len;
-   map-wcnt = len / BITS_PER_LONG + 1;
-   map-words = kzalloc(map-wcnt * sizeof(u32), GFP_KERNEL);
-   if (map-words != NULL) {
-   for (i = 0; i  map-wcnt; i++)
-   map-words[i] = 0L;
-
-   } else {
-   kfree(map);
-   map = NULL;
-   }
-   }
-
-   return map;
-}
-
-/*
- *   gb_delete 
- *  purpose:
- *  Frees a bit map.
- */
-
-void gb_delete(struct gb_t_map *map)
-{
-   kfree(map-words);
-   kfree(map);
-}
-
-/*
- *   gb_findandset 
- *  purpose:
- *  Finds a free bit and sets it.
- */
-u32 gb_findandset(struct gb_t_map *map)
-{
-   u32 bitn;
-
-   bitn = gb_minclear(map);
-
-   if (bitn != GB_NOBITS)
-   gb_set(map, bitn);
-
-   return bitn;
-}
-
-/*
- *   gb_minclear 
- *  purpose:
- *  returns the location of the first unset bit in the bit map.
- */
-u32 gb_minclear(struct gb_t_map *map)
-{
-   u32 bit_location = 0;
-   u32 bit_acc = 0;
-   u32 i;
-   u32 bit;
-   u32 *word;
-
-   for (word = map-words, i = 0; i  map-wcnt; word++, i++) {
-   if (~*word) {
-   for (bit = 0; bit  BITS_PER_LONG; bit++, bit_acc++) {
-   if (bit_acc == map-len)
-   return GB_NOBITS;
-
-   if (~*word  (1L  bit)) {
-   bit_location = i * BITS_PER_LONG + bit;
-   return bit_location;
-   }
-
-   }
-   } else {
-   bit_acc += BITS_PER_LONG;
-   }
-   }
-
-   return GB_NOBITS;
-}
-
-/*
- *   gb_set 
- *  purpose:
- *  Sets a bit in the bit map.
- */
-
-void gb_set(struct gb_t_map *map, u32 bitn)
-{
-   u32 mask;
-
-   mask = 1L  (bitn % BITS_PER_LONG);
-   map-words[bitn / BITS_PER_LONG] |= mask;
-}
-
-/*
- *   gb_test 
- *  purpose:
- *  Returns true if the bit is set in the specified location.
- */
-
-bool gb_test(struct gb_t_map *map, u32

[PATCH v2 05/12] staging: tidspbridge: rmgr/node.c code cleanup

2010-11-05 Thread Ionut Nicu
Reorganized some code in rmgr/node.c to increase its
readability. Most of the changes reduce the code
indentation level and simplifiy the code. No functional
changes were done.

Signed-off-by: Ionut Nicu ionut.n...@mindbit.ro
---
 drivers/staging/tidspbridge/rmgr/node.c |  607 +++
 1 files changed, 284 insertions(+), 323 deletions(-)

diff --git a/drivers/staging/tidspbridge/rmgr/node.c 
b/drivers/staging/tidspbridge/rmgr/node.c
index e48ddba..f660d1f 100644
--- a/drivers/staging/tidspbridge/rmgr/node.c
+++ b/drivers/staging/tidspbridge/rmgr/node.c
@@ -234,9 +234,9 @@ struct node_object {
 
 /* Default buffer attributes */
 static struct dsp_bufferattr node_dfltbufattrs = {
-   0,  /* cb_struct */
-   1,  /* segment_id */
-   0,  /* buf_alignment */
+   .cb_struct = 0,
+   .segment_id = 1,
+   .buf_alignment = 0,
 };
 
 static void delete_node(struct node_object *hnode,
@@ -282,8 +282,7 @@ enum node_state node_get_state(void *hnode)
struct node_object *pnode = (struct node_object *)hnode;
if (!pnode)
return -1;
-   else
-   return pnode-node_state;
+   return pnode-node_state;
 }
 
 /*
@@ -817,6 +816,7 @@ int node_connect(struct node_object *node1, u32 stream1,
char *pstr_dev_name = NULL;
enum node_type node1_type = NODE_TASK;
enum node_type node2_type = NODE_TASK;
+   enum dsp_strmmode strm_mode;
struct node_strmdef *pstrm_def;
struct node_strmdef *input = NULL;
struct node_strmdef *output = NULL;
@@ -830,60 +830,50 @@ int node_connect(struct node_object *node1, u32 stream1,
int status = 0;
DBC_REQUIRE(refs  0);
 
-   if ((node1 != (struct node_object *)DSP_HGPPNODE  !node1) ||
-   (node2 != (struct node_object *)DSP_HGPPNODE  !node2))
-   status = -EFAULT;
+   if (!node1 || !node2)
+   return -EFAULT;
 
-   if (!status) {
-   /* The two nodes must be on the same processor */
-   if (node1 != (struct node_object *)DSP_HGPPNODE 
-   node2 != (struct node_object *)DSP_HGPPNODE 
-   node1-hnode_mgr != node2-hnode_mgr)
-   status = -EPERM;
-   /* Cannot connect a node to itself */
-   if (node1 == node2)
-   status = -EPERM;
+   /* The two nodes must be on the same processor */
+   if (node1 != (struct node_object *)DSP_HGPPNODE 
+   node2 != (struct node_object *)DSP_HGPPNODE 
+   node1-hnode_mgr != node2-hnode_mgr)
+   return -EPERM;
 
-   }
-   if (!status) {
-   /* node_get_type() will return NODE_GPP if hnode =
-* DSP_HGPPNODE. */
-   node1_type = node_get_type(node1);
-   node2_type = node_get_type(node2);
-   /* Check stream indices ranges */
-   if ((node1_type != NODE_GPP  node1_type != NODE_DEVICE 
-stream1 = MAX_OUTPUTS(node1)) || (node2_type != NODE_GPP
-  node2_type !=
- NODE_DEVICE
-  stream2 =
- MAX_INPUTS(node2)))
-   status = -EINVAL;
-   }
-   if (!status) {
-   /*
-*  Only the following types of connections are allowed:
-*  task/dais socket  ==  task/dais socket
-*  task/dais socket  ==  device
-*  task/dais socket  ==  GPP
-*
-*  ie, no message nodes, and at least one task or dais
-*  socket node.
-*/
-   if (node1_type == NODE_MESSAGE || node2_type == NODE_MESSAGE ||
-   (node1_type != NODE_TASK  node1_type != NODE_DAISSOCKET 
-node2_type != NODE_TASK  node2_type != NODE_DAISSOCKET))
-   status = -EPERM;
-   }
+   /* Cannot connect a node to itself */
+   if (node1 == node2)
+   return -EPERM;
+
+   /* node_get_type() will return NODE_GPP if hnode =
+* DSP_HGPPNODE. */
+   node1_type = node_get_type(node1);
+   node2_type = node_get_type(node2);
+   /* Check stream indices ranges */
+   if ((node1_type != NODE_GPP  node1_type != NODE_DEVICE 
+   stream1 = MAX_OUTPUTS(node1)) ||
+   (node2_type != NODE_GPP  node2_type != NODE_DEVICE 
+stream2 = MAX_INPUTS(node2)))
+   return -EINVAL;
+
+   /*
+*  Only the following types of connections are allowed:
+*  task/dais socket  ==  task/dais socket
+*  task/dais

[PATCH v2 06/12] staging: tidspbridge: convert core to list_head

2010-11-05 Thread Ionut Nicu
Convert the core module of the tidspbridge driver
to use struct list_head instead of struct lst_list.

Signed-off-by: Ionut Nicu ionut.n...@mindbit.ro
---
 drivers/staging/tidspbridge/core/_msg_sm.h |   12 +-
 drivers/staging/tidspbridge/core/chnl_sm.c |  245 +---
 drivers/staging/tidspbridge/core/io_sm.c   |  141 +---
 drivers/staging/tidspbridge/core/msg_sm.c  |  236 +++
 .../tidspbridge/include/dspbridge/_chnl_sm.h   |8 +-
 .../tidspbridge/include/dspbridge/cmmdefs.h|1 -
 .../staging/tidspbridge/include/dspbridge/sync.h   |1 +
 7 files changed, 264 insertions(+), 380 deletions(-)

diff --git a/drivers/staging/tidspbridge/core/_msg_sm.h 
b/drivers/staging/tidspbridge/core/_msg_sm.h
index 556de5c..b78d1a6 100644
--- a/drivers/staging/tidspbridge/core/_msg_sm.h
+++ b/drivers/staging/tidspbridge/core/_msg_sm.h
@@ -20,7 +20,7 @@
 #ifndef _MSG_SM_
 #define _MSG_SM_
 
-#include dspbridge/list.h
+#include linux/list.h
 #include dspbridge/msgdefs.h
 
 /*
@@ -86,12 +86,12 @@ struct msg_mgr {
struct bridge_drv_interface *intf_fxns;
 
struct io_mgr *hio_mgr; /* IO manager */
-   struct lst_list *queue_list;/* List of MSG_QUEUEs */
+   struct list_head queue_list;/* List of MSG_QUEUEs */
spinlock_t msg_mgr_lock;/* For critical sections */
/* Signalled when MsgFrame is available */
struct sync_object *sync_event;
-   struct lst_list *msg_free_list; /* Free MsgFrames ready to be filled */
-   struct lst_list *msg_used_list; /* MsgFrames ready to go to DSP */
+   struct list_head msg_free_list; /* Free MsgFrames ready to be filled */
+   struct list_head msg_used_list; /* MsgFrames ready to go to DSP */
u32 msgs_pending;   /* # of queued messages to go to DSP */
u32 max_msgs;   /* Max # of msgs that fit in buffer */
msg_onexit on_exit; /* called when RMS_EXIT is received */
@@ -111,9 +111,9 @@ struct msg_queue {
struct msg_mgr *hmsg_mgr;
u32 max_msgs;   /* Node message depth */
u32 msgq_id;/* Node environment pointer */
-   struct lst_list *msg_free_list; /* Free MsgFrames ready to be filled */
+   struct list_head msg_free_list; /* Free MsgFrames ready to be filled */
/* Filled MsgFramess waiting to be read */
-   struct lst_list *msg_used_list;
+   struct list_head msg_used_list;
void *arg;  /* Handle passed to mgr on_exit callback */
struct sync_object *sync_event; /* Signalled when message is ready */
struct sync_object *sync_done;  /* For synchronizing cleanup */
diff --git a/drivers/staging/tidspbridge/core/chnl_sm.c 
b/drivers/staging/tidspbridge/core/chnl_sm.c
index 662a5b5..83403bb 100644
--- a/drivers/staging/tidspbridge/core/chnl_sm.c
+++ b/drivers/staging/tidspbridge/core/chnl_sm.c
@@ -37,9 +37,9 @@
  *  which may cause timeouts and/or failure offunction sync_wait_on_event.
  *  This invariant condition is:
  *
- *  LST_Empty(pchnl-pio_completions) == pchnl-sync_event is reset
+ *  list_empty(pchnl-pio_completions) == pchnl-sync_event is reset
  *  and
- *  !LST_Empty(pchnl-pio_completions) == pchnl-sync_event is set.
+ *  !list_empty(pchnl-pio_completions) == pchnl-sync_event is set.
  */
 
 #include linux/types.h
@@ -73,11 +73,9 @@
 #define MAILBOX_IRQ INT_MAIL_MPU_IRQ
 
 /*  --- Function Prototypes */
-static struct lst_list *create_chirp_list(u32 chirps);
+static int create_chirp_list(struct list_head *list, u32 chirps);
 
-static void free_chirp_list(struct lst_list *chirp_list);
-
-static struct chnl_irp *make_new_chirp(void);
+static void free_chirp_list(struct list_head *list);
 
 static int search_free_channel(struct chnl_mgr *chnl_mgr_obj,
  u32 *chnl);
@@ -179,9 +177,12 @@ func_cont:
}
if (!status) {
/* Get a free chirp: */
-   chnl_packet_obj =
-   (struct chnl_irp *)lst_get_head(pchnl-free_packets_list);
-   if (chnl_packet_obj == NULL)
+   if (!list_empty(pchnl-free_packets_list)) {
+   chnl_packet_obj = list_first_entry(
+   pchnl-free_packets_list,
+   struct chnl_irp, link);
+   list_del(chnl_packet_obj-link);
+   } else
status = -EIO;
 
}
@@ -206,8 +207,7 @@ func_cont:
chnl_packet_obj-dw_arg = dw_arg;
chnl_packet_obj-status = (is_eos ? CHNL_IOCSTATEOS :
   CHNL_IOCSTATCOMPLETE);
-   lst_put_tail(pchnl-pio_requests,
-(struct list_head *)chnl_packet_obj);
+   list_add_tail(chnl_packet_obj-link, pchnl

[PATCH v2 07/12] staging: tidspbridge: convert pmgr to list_head

2010-11-05 Thread Ionut Nicu
Convert the pmgr module of the tidspbridge driver
to use struct list_head instead of struct lst_list.

Signed-off-by: Ionut Nicu ionut.n...@mindbit.ro
---
 drivers/staging/tidspbridge/pmgr/cmm.c |  230 ++--
 drivers/staging/tidspbridge/pmgr/dev.c |   59 +++-
 2 files changed, 93 insertions(+), 196 deletions(-)

diff --git a/drivers/staging/tidspbridge/pmgr/cmm.c 
b/drivers/staging/tidspbridge/pmgr/cmm.c
index 8dbdd20..603ed55 100644
--- a/drivers/staging/tidspbridge/pmgr/cmm.c
+++ b/drivers/staging/tidspbridge/pmgr/cmm.c
@@ -12,7 +12,7 @@
  * describes a block of physically contiguous shared memory used for
  * future allocations by CMM.
  *
- * Memory is coelesced back to the appropriate heap when a buffer is
+ * Memory is coalesced back to the appropriate heap when a buffer is
  * freed.
  *
  * Notes:
@@ -30,6 +30,7 @@
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 #include linux/types.h
+#include linux/list.h
 
 /*  --- DSP/BIOS Bridge */
 #include dspbridge/dbdefs.h
@@ -38,7 +39,6 @@
 #include dspbridge/dbc.h
 
 /*  --- OS Adaptation Layer */
-#include dspbridge/list.h
 #include dspbridge/sync.h
 
 /*  --- Platform Manager */
@@ -73,9 +73,9 @@ struct cmm_allocator {/* sma */
u32 ul_dsp_size;/* DSP seg size in bytes */
struct cmm_object *hcmm_mgr;/* back ref to parent mgr */
/* node list of available memory */
-   struct lst_list *free_list_head;
+   struct list_head free_list;
/* node list of memory in use */
-   struct lst_list *in_use_list_head;
+   struct list_head in_use_list;
 };
 
 struct cmm_xlator {/* Pa-Va translator object */
@@ -97,7 +97,7 @@ struct cmm_object {
 * Cmm Lock is used to serialize access mem manager for multi-threads.
 */
struct mutex cmm_lock;  /* Lock to access cmm mgr */
-   struct lst_list *node_free_list_head;   /* Free list of memory nodes */
+   struct list_head node_free_list;/* Free list of memory nodes */
u32 ul_min_block_size;  /* Min SM block; default 16 bytes */
u32 dw_page_size;   /* Memory Page size (1k/4k) */
/* GPP SM segment ptrs */
@@ -215,8 +215,7 @@ void *cmm_calloc_buf(struct cmm_object *hcmm_mgr, u32 usize,
pnode-client_proc = current-tgid;
 
/* put our node on InUse list */
-   lst_put_tail(allocator-in_use_list_head,
-(struct list_head *)pnode);
+   list_add_tail(pnode-link, allocator-in_use_list);
buf_pa = (void *)pnode-dw_pa;  /* physical address */
/* clear mem */
pbyte = (u8 *) pnode-dw_va;
@@ -265,18 +264,9 @@ int cmm_create(struct cmm_object **ph_cmm_mgr,
 * MEM_ALLOC_OBJECT */
 
/* create node free list */
-   cmm_obj-node_free_list_head =
-   kzalloc(sizeof(struct lst_list),
-   GFP_KERNEL);
-   if (cmm_obj-node_free_list_head == NULL) {
-   status = -ENOMEM;
-   cmm_destroy(cmm_obj, true);
-   } else {
-   INIT_LIST_HEAD(cmm_obj-
-  node_free_list_head-head);
-   mutex_init(cmm_obj-cmm_lock);
-   *ph_cmm_mgr = cmm_obj;
-   }
+   INIT_LIST_HEAD(cmm_obj-node_free_list);
+   mutex_init(cmm_obj-cmm_lock);
+   *ph_cmm_mgr = cmm_obj;
} else {
status = -ENOMEM;
}
@@ -294,7 +284,7 @@ int cmm_destroy(struct cmm_object *hcmm_mgr, bool force)
struct cmm_info temp_info;
int status = 0;
s32 slot_seg;
-   struct cmm_mnode *pnode;
+   struct cmm_mnode *node, *tmp;
 
DBC_REQUIRE(refs  0);
if (!hcmm_mgr) {
@@ -324,15 +314,10 @@ int cmm_destroy(struct cmm_object *hcmm_mgr, bool force)
}
}
}
-   if (cmm_mgr_obj-node_free_list_head != NULL) {
-   /* Free the free nodes */
-   while (!LST_IS_EMPTY(cmm_mgr_obj-node_free_list_head)) {
-   pnode = (struct cmm_mnode *)
-   lst_get_head(cmm_mgr_obj-node_free_list_head);
-   kfree(pnode);
-   }
-   /* delete NodeFreeList list */
-   kfree(cmm_mgr_obj-node_free_list_head);
+   list_for_each_entry_safe(node, tmp, cmm_mgr_obj-node_free_list,
+   link) {
+   list_del(node-link);
+   kfree(node);
}
mutex_unlock(cmm_mgr_obj-cmm_lock);
if (!status) {
@@ -366,7 +351,7 @@ int

[PATCH v2 08/12] staging: tidspbridge: convert rmgr to list_head

2010-11-05 Thread Ionut Nicu
Convert the rmgr module of the tidspbridge driver
to use struct list_head instead of struct lst_list.

Signed-off-by: Ionut Nicu ionut.n...@mindbit.ro
---
 drivers/staging/tidspbridge/rmgr/drv.c  |  111 +--
 drivers/staging/tidspbridge/rmgr/node.c |   52 +--
 drivers/staging/tidspbridge/rmgr/proc.c |2 -
 drivers/staging/tidspbridge/rmgr/rmm.c  |   74 +++--
 4 files changed, 72 insertions(+), 167 deletions(-)

diff --git a/drivers/staging/tidspbridge/rmgr/drv.c 
b/drivers/staging/tidspbridge/rmgr/drv.c
index 91cc1685..18fae55 100644
--- a/drivers/staging/tidspbridge/rmgr/drv.c
+++ b/drivers/staging/tidspbridge/rmgr/drv.c
@@ -16,6 +16,7 @@
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 #include linux/types.h
+#include linux/list.h
 
 /*  --- Host OS */
 #include dspbridge/host_os.h
@@ -26,9 +27,6 @@
 /*  --- Trace  Debug */
 #include dspbridge/dbc.h
 
-/*  --- OS Adaptation Layer */
-#include dspbridge/list.h
-
 /*  --- This */
 #include dspbridge/drv.h
 #include dspbridge/dev.h
@@ -42,8 +40,8 @@
 
 /*  --- Defines, Data Structures, Typedefs */
 struct drv_object {
-   struct lst_list *dev_list;
-   struct lst_list *dev_node_string;
+   struct list_head dev_list;
+   struct list_head dev_node_string;
 };
 
 /*
@@ -305,22 +303,8 @@ int drv_create(struct drv_object **drv_obj)
pdrv_object = kzalloc(sizeof(struct drv_object), GFP_KERNEL);
if (pdrv_object) {
/* Create and Initialize List of device objects */
-   pdrv_object-dev_list = kzalloc(sizeof(struct lst_list),
-   GFP_KERNEL);
-   if (pdrv_object-dev_list) {
-   /* Create and Initialize List of device Extension */
-   pdrv_object-dev_node_string =
-   kzalloc(sizeof(struct lst_list), GFP_KERNEL);
-   if (!(pdrv_object-dev_node_string)) {
-   status = -EPERM;
-   } else {
-   INIT_LIST_HEAD(pdrv_object-
-  dev_node_string-head);
-   INIT_LIST_HEAD(pdrv_object-dev_list-head);
-   }
-   } else {
-   status = -ENOMEM;
-   }
+   INIT_LIST_HEAD(pdrv_object-dev_list);
+   INIT_LIST_HEAD(pdrv_object-dev_node_string);
} else {
status = -ENOMEM;
}
@@ -337,8 +321,6 @@ int drv_create(struct drv_object **drv_obj)
if (!status) {
*drv_obj = pdrv_object;
} else {
-   kfree(pdrv_object-dev_list);
-   kfree(pdrv_object-dev_node_string);
/* Free the DRV Object */
kfree(pdrv_object);
}
@@ -375,13 +357,6 @@ int drv_destroy(struct drv_object *driver_obj)
DBC_REQUIRE(refs  0);
DBC_REQUIRE(pdrv_object);
 
-   /*
-*  Delete the List if it exists.Should not come here
-*  as the drv_remove_dev_object and the Last drv_request_resources
-*  removes the list if the lists are empty.
-*/
-   kfree(pdrv_object-dev_list);
-   kfree(pdrv_object-dev_node_string);
kfree(pdrv_object);
/* Update the DRV Object in the driver data */
if (drv_datap) {
@@ -413,7 +388,7 @@ int drv_get_dev_object(u32 index, struct drv_object 
*hdrv_obj,
DBC_REQUIRE(device_obj != NULL);
DBC_REQUIRE(index = 0);
DBC_REQUIRE(refs  0);
-   DBC_ASSERT(!(LST_IS_EMPTY(pdrv_obj-dev_list)));
+   DBC_ASSERT(!(list_empty(pdrv_obj-dev_list)));
 
dev_obj = (struct dev_object *)drv_get_first_dev_object();
for (i = 0; i  index; i++) {
@@ -444,9 +419,8 @@ u32 drv_get_first_dev_object(void)
 
if (drv_datap  drv_datap-drv_object) {
pdrv_obj = drv_datap-drv_object;
-   if ((pdrv_obj-dev_list != NULL) 
-   !LST_IS_EMPTY(pdrv_obj-dev_list))
-   dw_dev_object = (u32) lst_first(pdrv_obj-dev_list);
+   if (!list_empty(pdrv_obj-dev_list))
+   dw_dev_object = (u32) pdrv_obj-dev_list.next;
} else {
pr_err(%s: Failed to retrieve the object handle\n, __func__);
}
@@ -468,10 +442,9 @@ u32 drv_get_first_dev_extension(void)
 
if (drv_datap  drv_datap-drv_object) {
pdrv_obj = drv_datap-drv_object;
-   if ((pdrv_obj-dev_node_string != NULL) 
-   !LST_IS_EMPTY(pdrv_obj-dev_node_string)) {
+   if (!list_empty(pdrv_obj-dev_node_string)) {
dw_dev_extension =
-   (u32

[PATCH v2 09/12] staging: tidspbridge: remove custom linked list

2010-11-05 Thread Ionut Nicu
Now that all users of lst_list have been converted to the
standard linux list_head API, we can remove the associated
header file.

Signed-off-by: Ionut Nicu ionut.n...@mindbit.ro
---
 drivers/staging/tidspbridge/TODO   |1 -
 .../staging/tidspbridge/include/dspbridge/list.h   |  225 
 2 files changed, 0 insertions(+), 226 deletions(-)
 delete mode 100644 drivers/staging/tidspbridge/include/dspbridge/list.h

diff --git a/drivers/staging/tidspbridge/TODO b/drivers/staging/tidspbridge/TODO
index 187363f..1c51e2d 100644
--- a/drivers/staging/tidspbridge/TODO
+++ b/drivers/staging/tidspbridge/TODO
@@ -6,7 +6,6 @@
 * Eliminate general services and libraries - use or extend existing kernel
   libraries instead (e.g. gcf/lcm in nldr.c, global helpers in gen/)
 * Eliminate direct manipulation of OMAP_SYSC_BASE
-* Eliminate list.h : seem like a redundant wrapper to existing kernel lists
 * Eliminate DSP_SUCCEEDED macros and their imposed redundant indentations
   (adopt the kernel way of checking for return values)
 * Audit interfaces exposed to user space
diff --git a/drivers/staging/tidspbridge/include/dspbridge/list.h 
b/drivers/staging/tidspbridge/include/dspbridge/list.h
deleted file mode 100644
index 6837b61..000
--- a/drivers/staging/tidspbridge/include/dspbridge/list.h
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * list.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Declarations of list management control structures and definitions
- * of inline list management functions.
- *
- * Copyright (C) 2008 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.
- */
-
-#ifndef LIST_
-#define LIST_
-
-#include dspbridge/host_os.h
-#include linux/list.h
-
-#define LST_IS_EMPTY(l)  list_empty((l)-head)
-
-struct lst_list {
-   struct list_head head;
-};
-
-/*
- *   lst_first 
- *  Purpose:
- *  Returns a pointer to the first element of the list, or NULL if the list
- *  is empty.
- *  Parameters:
- *  lst:  Pointer to list control structure.
- *  Returns:
- *  Pointer to first list element, or NULL.
- *  Requires:
- *  - LST initialized.
- *  - lst != NULL.
- *  Ensures:
- */
-static inline struct list_head *lst_first(struct lst_list *lst)
-{
-   if (lst  !list_empty(lst-head))
-   return lst-head.next;
-   return NULL;
-}
-
-/*
- *   lst_get_head 
- *  Purpose:
- *  Pops the head off the list and returns a pointer to it.
- *  Details:
- *  If the list is empty, returns NULL.
- *  Else, removes the element at the head of the list, making the next
- *  element the head of the list.
- *  The head is removed by making the tail element of the list point its
- *  next pointer at the next element after the head, and by making the
- *  prev pointer of the next element after the head point at the tail
- *  element.  So the next element after the head becomes the new head of
- *  the list.
- *  Parameters:
- *  lst:Pointer to list control structure of list whose head
- *  element is to be removed
- *  Returns:
- *  Pointer to element that was at the head of the list (success)
- *  NULL  No elements in list
- *  Requires:
- *  - LST initialized.
- *  - lst != NULL.
- *  Ensures:
- *  Notes:
- *  Because the tail of the list points forward (its next pointer) to
- *  the head of the list, and the head of the list points backward (its
- *  prev pointer) to the tail of the list, this list is circular.
- */
-static inline struct list_head *lst_get_head(struct lst_list *lst)
-{
-   struct list_head *elem_list;
-
-   if (!lst || list_empty(lst-head))
-   return NULL;
-
-   elem_list = lst-head.next;
-   lst-head.next = elem_list-next;
-   elem_list-next-prev = lst-head;
-
-   return elem_list;
-}
-
-/*
- *   lst_init_elem 
- *  Purpose:
- *  Initializes a list element to default (cleared) values
- *  Details:
- *  Parameters:
- *  elem_list:  Pointer to list element to be reset
- *  Returns:
- *  Requires:
- *  LST initialized.
- *  Ensures:
- *  Notes:
- *  This function must not be called to reset an element in the middle
- *  of a list chain -- that would break the chain.
- *
- */
-static inline void lst_init_elem(struct list_head *elem_list)
-{
-   if (elem_list) {
-   elem_list-next = NULL;
-   elem_list-prev = NULL;
-   }
-}
-
-/*
- *   lst_insert_before 
- *  Purpose:
- * Insert the element before

[PATCH v2 10/12] staging: tidspbridge: core code cleanup

2010-11-05 Thread Ionut Nicu
Reorganized some code in the core module to increase its
readability. Most of the changes reduce the code
indentation level and simplifiy the code. No functional
changes were done.

Signed-off-by: Ionut Nicu ionut.n...@mindbit.ro
---
 drivers/staging/tidspbridge/core/chnl_sm.c |  451 +---
 drivers/staging/tidspbridge/core/io_sm.c   |  191 ++---
 drivers/staging/tidspbridge/core/msg_sm.c  |  447 ---
 3 files changed, 498 insertions(+), 591 deletions(-)

diff --git a/drivers/staging/tidspbridge/core/chnl_sm.c 
b/drivers/staging/tidspbridge/core/chnl_sm.c
index 83403bb..ba6313f 100644
--- a/drivers/staging/tidspbridge/core/chnl_sm.c
+++ b/drivers/staging/tidspbridge/core/chnl_sm.c
@@ -105,35 +105,31 @@ int bridge_chnl_add_io_req(struct chnl_object *chnl_obj, 
void *host_buf,
is_eos = (byte_size == 0);
 
/* Validate args */
-   if (!host_buf || !pchnl) {
-   status = -EFAULT;
-   } else if (is_eos  CHNL_IS_INPUT(pchnl-chnl_mode)) {
-   status = -EPERM;
-   } else {
-   /*
-* Check the channel state: only queue chirp if channel state
-* allows it.
-*/
-   dw_state = pchnl-dw_state;
-   if (dw_state != CHNL_STATEREADY) {
-   if (dw_state  CHNL_STATECANCEL)
-   status = -ECANCELED;
-   else if ((dw_state  CHNL_STATEEOS) 
-CHNL_IS_OUTPUT(pchnl-chnl_mode))
-   status = -EPIPE;
-   else
-   /* No other possible states left */
-   DBC_ASSERT(0);
-   }
+   if (!host_buf || !pchnl)
+   return -EFAULT;
+
+   if (is_eos  CHNL_IS_INPUT(pchnl-chnl_mode))
+   return -EPERM;
+
+   /*
+* Check the channel state: only queue chirp if channel state
+* allows it.
+*/
+   dw_state = pchnl-dw_state;
+   if (dw_state != CHNL_STATEREADY) {
+   if (dw_state  CHNL_STATECANCEL)
+   return -ECANCELED;
+   if ((dw_state  CHNL_STATEEOS) 
+   CHNL_IS_OUTPUT(pchnl-chnl_mode))
+   return -EPIPE;
+   /* No other possible states left */
+   DBC_ASSERT(0);
}
 
dev_obj = dev_get_first();
dev_get_bridge_context(dev_obj, dev_ctxt);
if (!dev_ctxt)
-   status = -EFAULT;
-
-   if (status)
-   goto func_end;
+   return -EFAULT;
 
if (pchnl-chnl_type == CHNL_PCPY  pchnl-chnl_id  1  host_buf) {
if (!(host_buf  (void *)USERMODE_ADDR)) {
@@ -142,18 +138,16 @@ int bridge_chnl_add_io_req(struct chnl_object *chnl_obj, 
void *host_buf,
}
/* if addr in user mode, then copy to kernel space */
host_sys_buf = kmalloc(buf_size, GFP_KERNEL);
-   if (host_sys_buf == NULL) {
-   status = -ENOMEM;
-   goto func_end;
-   }
+   if (host_sys_buf == NULL)
+   return -ENOMEM;
+
if (CHNL_IS_OUTPUT(pchnl-chnl_mode)) {
status = copy_from_user(host_sys_buf, host_buf,
-   buf_size);
+   buf_size);
if (status) {
kfree(host_sys_buf);
host_sys_buf = NULL;
-   status = -EFAULT;
-   goto func_end;
+   return -EFAULT;
}
}
}
@@ -167,65 +161,62 @@ func_cont:
omap_mbox_disable_irq(dev_ctxt-mbox, IRQ_RX);
if (pchnl-chnl_type == CHNL_PCPY) {
/* This is a processor-copy channel. */
-   if (!status  CHNL_IS_OUTPUT(pchnl-chnl_mode)) {
+   if (CHNL_IS_OUTPUT(pchnl-chnl_mode)) {
/* Check buffer size on output channels for fit. */
-   if (byte_size 
-   io_buf_size(pchnl-chnl_mgr_obj-hio_mgr))
+   if (byte_size  io_buf_size(
+   pchnl-chnl_mgr_obj-hio_mgr)) {
status = -EINVAL;
-
+   goto out;
+   }
}
}
-   if (!status) {
-   /* Get a free chirp: */
-   if (!list_empty(pchnl-free_packets_list)) {
-   chnl_packet_obj = list_first_entry(
-   pchnl-free_packets_list,
-   struct chnl_irp, link);
-   list_del(chnl_packet_obj

[PATCH v2 11/12] staging: tidspbridge: pmgr code cleanup

2010-11-05 Thread Ionut Nicu
Reorganized some code in the pmgr module to increase
its readability. No functional changes were done.

Signed-off-by: Ionut Nicu ionut.n...@mindbit.ro
---
 drivers/staging/tidspbridge/pmgr/cmm.c |  354 ++-
 drivers/staging/tidspbridge/pmgr/dev.c |   20 +--
 2 files changed, 166 insertions(+), 208 deletions(-)

diff --git a/drivers/staging/tidspbridge/pmgr/cmm.c 
b/drivers/staging/tidspbridge/pmgr/cmm.c
index 603ed55..898f3de 100644
--- a/drivers/staging/tidspbridge/pmgr/cmm.c
+++ b/drivers/staging/tidspbridge/pmgr/cmm.c
@@ -250,26 +250,23 @@ int cmm_create(struct cmm_object **ph_cmm_mgr,
*ph_cmm_mgr = NULL;
/* create, zero, and tag a cmm mgr object */
cmm_obj = kzalloc(sizeof(struct cmm_object), GFP_KERNEL);
-   if (cmm_obj != NULL) {
-   if (mgr_attrts == NULL)
-   mgr_attrts = cmm_dfltmgrattrs; /* set defaults */
-
-   /* 4 bytes minimum */
-   DBC_ASSERT(mgr_attrts-ul_min_block_size = 4);
-   /* save away smallest block allocation for this cmm mgr */
-   cmm_obj-ul_min_block_size = mgr_attrts-ul_min_block_size;
-   cmm_obj-dw_page_size = PAGE_SIZE;
-
-   /* Note: DSP SM seg table(aDSPSMSegTab[]) zero'd by
-* MEM_ALLOC_OBJECT */
-
-   /* create node free list */
-   INIT_LIST_HEAD(cmm_obj-node_free_list);
-   mutex_init(cmm_obj-cmm_lock);
-   *ph_cmm_mgr = cmm_obj;
-   } else {
-   status = -ENOMEM;
-   }
+   if (!cmm_obj)
+   return -ENOMEM;
+
+   if (mgr_attrts == NULL)
+   mgr_attrts = cmm_dfltmgrattrs; /* set defaults */
+
+   /* 4 bytes minimum */
+   DBC_ASSERT(mgr_attrts-ul_min_block_size = 4);
+   /* save away smallest block allocation for this cmm mgr */
+   cmm_obj-ul_min_block_size = mgr_attrts-ul_min_block_size;
+   cmm_obj-dw_page_size = PAGE_SIZE;
+
+   /* create node free list */
+   INIT_LIST_HEAD(cmm_obj-node_free_list);
+   mutex_init(cmm_obj-cmm_lock);
+   *ph_cmm_mgr = cmm_obj;
+
return status;
 }
 
@@ -346,13 +343,12 @@ void cmm_exit(void)
  *  Purpose:
  *  Free the given buffer.
  */
-int cmm_free_buf(struct cmm_object *hcmm_mgr, void *buf_pa,
-   u32 ul_seg_id)
+int cmm_free_buf(struct cmm_object *hcmm_mgr, void *buf_pa, u32 ul_seg_id)
 {
struct cmm_object *cmm_mgr_obj = (struct cmm_object *)hcmm_mgr;
int status = -EFAULT;
struct cmm_mnode *curr, *tmp;
-   struct cmm_allocator *allocator = NULL;
+   struct cmm_allocator *allocator;
struct cmm_attrs *pattrs;
 
DBC_REQUIRE(refs  0);
@@ -366,21 +362,22 @@ int cmm_free_buf(struct cmm_object *hcmm_mgr, void 
*buf_pa,
status = -EFAULT;
return status;
}
-   /* get the allocator for this segment id */
+
allocator = get_allocator(cmm_mgr_obj, ul_seg_id);
-   if (allocator != NULL) {
-   mutex_lock(cmm_mgr_obj-cmm_lock);
-   list_for_each_entry_safe(curr, tmp, allocator-in_use_list,
-   link) {
-   if (curr-dw_pa == (u32) buf_pa) {
-   list_del(curr-link);
-   add_to_free_list(allocator, curr);
-   status = 0;
-   break;
-   }
+   if (!allocator)
+   return status;
+
+   mutex_lock(cmm_mgr_obj-cmm_lock);
+   list_for_each_entry_safe(curr, tmp, allocator-in_use_list, link) {
+   if (curr-dw_pa == (u32) buf_pa) {
+   list_del(curr-link);
+   add_to_free_list(allocator, curr);
+   status = 0;
+   break;
}
-   mutex_unlock(cmm_mgr_obj-cmm_lock);
}
+   mutex_unlock(cmm_mgr_obj-cmm_lock);
+
return status;
 }
 
@@ -438,31 +435,30 @@ int cmm_get_info(struct cmm_object *hcmm_mgr,
for (ul_seg = 1; ul_seg = CMM_MAXGPPSEGS; ul_seg++) {
/* get the allocator object for this segment id */
altr = get_allocator(cmm_mgr_obj, ul_seg);
-   if (altr != NULL) {
-   cmm_info_obj-ul_num_gppsm_segs++;
-   cmm_info_obj-seg_info[ul_seg - 1].dw_seg_base_pa =
-   altr-shm_base - altr-ul_dsp_size;
-   cmm_info_obj-seg_info[ul_seg - 1].ul_total_seg_size =
-   altr-ul_dsp_size + altr-ul_sm_size;
-   cmm_info_obj-seg_info[ul_seg - 1].dw_gpp_base_pa =
-   altr-shm_base;
-   cmm_info_obj-seg_info[ul_seg - 1].ul_gpp_size =
-   altr-ul_sm_size;
-   cmm_info_obj-seg_info[ul_seg - 1].dw_dsp_base_va

[PATCH v2 12/12] staging: tidspbridge: rmgr code cleanup

2010-11-05 Thread Ionut Nicu
Reorganized some code in the rmgr module to increase
its readability. No functional changes were done.

Signed-off-by: Ionut Nicu ionut.n...@mindbit.ro
---
 drivers/staging/tidspbridge/rmgr/drv.c  |  171 +---
 drivers/staging/tidspbridge/rmgr/node.c |   82 +-
 drivers/staging/tidspbridge/rmgr/rmm.c  |  267 +--
 3 files changed, 229 insertions(+), 291 deletions(-)

diff --git a/drivers/staging/tidspbridge/rmgr/drv.c 
b/drivers/staging/tidspbridge/rmgr/drv.c
index 18fae55..4eff419 100644
--- a/drivers/staging/tidspbridge/rmgr/drv.c
+++ b/drivers/staging/tidspbridge/rmgr/drv.c
@@ -293,40 +293,28 @@ int drv_proc_update_strm_res(u32 num_bufs, void 
*strm_resources)
  */
 int drv_create(struct drv_object **drv_obj)
 {
-   int status = 0;
struct drv_object *pdrv_object = NULL;
struct drv_data *drv_datap = dev_get_drvdata(bridge);
 
DBC_REQUIRE(drv_obj != NULL);
DBC_REQUIRE(refs  0);
 
+   if (!drv_datap)
+   return -EFAULT;
+
pdrv_object = kzalloc(sizeof(struct drv_object), GFP_KERNEL);
-   if (pdrv_object) {
-   /* Create and Initialize List of device objects */
-   INIT_LIST_HEAD(pdrv_object-dev_list);
-   INIT_LIST_HEAD(pdrv_object-dev_node_string);
-   } else {
-   status = -ENOMEM;
-   }
-   /* Store the DRV Object in the driver data */
-   if (!status) {
-   if (drv_datap) {
-   drv_datap-drv_object = (void *)pdrv_object;
-   } else {
-   status = -EPERM;
-   pr_err(%s: Failed to store DRV object\n, __func__);
-   }
-   }
+   if (!pdrv_object)
+   return -ENOMEM;
 
-   if (!status) {
-   *drv_obj = pdrv_object;
-   } else {
-   /* Free the DRV Object */
-   kfree(pdrv_object);
-   }
+   /* Create and Initialize List of device objects */
+   INIT_LIST_HEAD(pdrv_object-dev_list);
+   INIT_LIST_HEAD(pdrv_object-dev_node_string);
 
-   DBC_ENSURE(status || pdrv_object);
-   return status;
+   /* Store the DRV Object in the driver data */
+   drv_datap-drv_object = (void *)pdrv_object;
+   *drv_obj = pdrv_object;
+
+   return 0;
 }
 
 /*
@@ -413,19 +401,19 @@ int drv_get_dev_object(u32 index, struct drv_object 
*hdrv_obj,
  */
 u32 drv_get_first_dev_object(void)
 {
-   u32 dw_dev_object = 0;
struct drv_object *pdrv_obj;
struct drv_data *drv_datap = dev_get_drvdata(bridge);
 
-   if (drv_datap  drv_datap-drv_object) {
-   pdrv_obj = drv_datap-drv_object;
-   if (!list_empty(pdrv_obj-dev_list))
-   dw_dev_object = (u32) pdrv_obj-dev_list.next;
-   } else {
+   if (!drv_datap || !drv_datap-drv_object) {
pr_err(%s: Failed to retrieve the object handle\n, __func__);
+   return 0;
}
 
-   return dw_dev_object;
+   pdrv_obj = drv_datap-drv_object;
+   if (list_empty(pdrv_obj-dev_list))
+   return 0;
+
+   return (u32) pdrv_obj-dev_list.next;
 }
 
 /*
@@ -436,21 +424,19 @@ u32 drv_get_first_dev_object(void)
  */
 u32 drv_get_first_dev_extension(void)
 {
-   u32 dw_dev_extension = 0;
struct drv_object *pdrv_obj;
struct drv_data *drv_datap = dev_get_drvdata(bridge);
 
-   if (drv_datap  drv_datap-drv_object) {
-   pdrv_obj = drv_datap-drv_object;
-   if (!list_empty(pdrv_obj-dev_node_string)) {
-   dw_dev_extension =
-   (u32) pdrv_obj-dev_node_string.next;
-   }
-   } else {
+   if (!drv_datap || !drv_datap-drv_object) {
pr_err(%s: Failed to retrieve the object handle\n, __func__);
+   return 0;
}
 
-   return dw_dev_extension;
+   pdrv_obj = drv_datap-drv_object;
+   if (list_empty(pdrv_obj-dev_node_string))
+   return 0;
+
+   return (u32) pdrv_obj-dev_node_string.next;
 }
 
 /*
@@ -462,26 +448,27 @@ u32 drv_get_first_dev_extension(void)
  */
 u32 drv_get_next_dev_object(u32 hdev_obj)
 {
-   u32 dw_next_dev_object = 0;
struct drv_object *pdrv_obj;
struct drv_data *drv_datap = dev_get_drvdata(bridge);
struct list_head *curr;
 
DBC_REQUIRE(hdev_obj != 0);
 
-   if (drv_datap  drv_datap-drv_object) {
-   pdrv_obj = drv_datap-drv_object;
-   if (!list_empty(pdrv_obj-dev_list)) {
-   curr = (struct list_head *)hdev_obj;
-   if (curr-next == pdrv_obj-dev_list)
-   return 0;
-   dw_next_dev_object = (u32) curr-next;
-   }
-   } else {
+   if (!drv_datap || !drv_datap-drv_object) {
pr_err(%s: Failed to retrieve the object handle\n, __func__

[PATCH v2 02/12] staging: tidspbridge: remove utildefs

2010-11-05 Thread Ionut Nicu
Remove a header file that was not very useful to
the dspbridge driver.

Signed-off-by: Ionut Nicu ionut.n...@mindbit.ro
---
 .../tidspbridge/include/dspbridge/utildefs.h   |   39 
 drivers/staging/tidspbridge/pmgr/cmm.c |9 +
 2 files changed, 1 insertions(+), 47 deletions(-)
 delete mode 100644 drivers/staging/tidspbridge/include/dspbridge/utildefs.h

diff --git a/drivers/staging/tidspbridge/include/dspbridge/utildefs.h 
b/drivers/staging/tidspbridge/include/dspbridge/utildefs.h
deleted file mode 100644
index 8fe5414..000
--- a/drivers/staging/tidspbridge/include/dspbridge/utildefs.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * utildefs.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Global UTIL constants and types, shared between DSP API and DSPSYS.
- *
- * 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.
- */
-
-#ifndef UTILDEFS_
-#define UTILDEFS_
-
-/* constants taken from configmg.h */
-#define UTIL_MAXMEMREGS 9
-#define UTIL_MAXIOPORTS 20
-#define UTIL_MAXIRQS7
-#define UTIL_MAXDMACHNLS7
-
-/* misc. constants */
-#define UTIL_MAXARGVS   10
-
-/* Platform specific important info */
-struct util_sysinfo {
-   /* Granularity of page protection; usually 1k or 4k */
-   u32 dw_page_size;
-   u32 dw_allocation_granularity;  /* VM granularity, usually 64K */
-   u32 dw_number_of_processors;/* Used as sanity check */
-};
-
-#endif /* UTILDEFS_ */
diff --git a/drivers/staging/tidspbridge/pmgr/cmm.c 
b/drivers/staging/tidspbridge/pmgr/cmm.c
index 93a7c4f..8dbdd20 100644
--- a/drivers/staging/tidspbridge/pmgr/cmm.c
+++ b/drivers/staging/tidspbridge/pmgr/cmm.c
@@ -40,7 +40,6 @@
 /*  --- OS Adaptation Layer */
 #include dspbridge/list.h
 #include dspbridge/sync.h
-#include dspbridge/utildefs.h
 
 /*  --- Platform Manager */
 #include dspbridge/dev.h
@@ -245,7 +244,6 @@ int cmm_create(struct cmm_object **ph_cmm_mgr,
 {
struct cmm_object *cmm_obj = NULL;
int status = 0;
-   struct util_sysinfo sys_info;
 
DBC_REQUIRE(refs  0);
DBC_REQUIRE(ph_cmm_mgr != NULL);
@@ -261,12 +259,7 @@ int cmm_create(struct cmm_object **ph_cmm_mgr,
DBC_ASSERT(mgr_attrts-ul_min_block_size = 4);
/* save away smallest block allocation for this cmm mgr */
cmm_obj-ul_min_block_size = mgr_attrts-ul_min_block_size;
-   /* save away the systems memory page size */
-   sys_info.dw_page_size = PAGE_SIZE;
-   sys_info.dw_allocation_granularity = PAGE_SIZE;
-   sys_info.dw_number_of_processors = 1;
-
-   cmm_obj-dw_page_size = sys_info.dw_page_size;
+   cmm_obj-dw_page_size = PAGE_SIZE;
 
/* Note: DSP SM seg table(aDSPSMSegTab[]) zero'd by
 * MEM_ALLOC_OBJECT */
-- 
1.7.2.3

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 0/3] staging: tidspbridge: bugfixes

2010-11-05 Thread Ionut Nicu
Changes since v1:

* Split the mgr_enum_node_info patch into two patches:
one that fixes the issue and one that reorganizes the
code.

Ionut Nicu (3):
  staging: tidspbridge: fix mgr_enum_node_info
  staging: tidspbridge: mgr_enum_node_info cleanup
  staging: tidspbridge: fix kernel oops in bridge_io_get_proc_load

 drivers/staging/tidspbridge/core/io_sm.c |   78 +++--
 drivers/staging/tidspbridge/rmgr/mgr.c   |   50 +++
 2 files changed, 48 insertions(+), 80 deletions(-)

-- 
1.7.2.3

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 1/3] staging: tidspbridge: fix mgr_enum_node_info

2010-11-05 Thread Ionut Nicu
The current code was always returning a non-zero status value
to userspace applications when this ioctl was called.

The error code was ENODATA, which isn't actually an error,
it's always returned by dcd_enumerate_object() when it hits the
end of list.

Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
Signed-off-by: Ionut Nicu ionut.n...@mindbit.ro
---
 drivers/staging/tidspbridge/rmgr/mgr.c |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/tidspbridge/rmgr/mgr.c 
b/drivers/staging/tidspbridge/rmgr/mgr.c
index 0ea89a1..2eab6a5 100644
--- a/drivers/staging/tidspbridge/rmgr/mgr.c
+++ b/drivers/staging/tidspbridge/rmgr/mgr.c
@@ -169,6 +169,11 @@ int mgr_enum_node_info(u32 node_id, struct dsp_ndbprops 
*pndb_props,
 
}
}
+
+   /* the last status is not 0, but neither an error */
+   if (status  0)
+   status = 0;
+
if (!status) {
if (node_id  (node_index - 1)) {
status = -EINVAL;
-- 
1.7.2.3

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 2/3] staging: tidspbridge: mgr_enum_node_info cleanup

2010-11-05 Thread Ionut Nicu
Reorganized mgr_enum_node_info code to increase its
readability.

Signed-off-by: Ionut Nicu ionut.n...@mindbit.ro
---
 drivers/staging/tidspbridge/rmgr/mgr.c |   51 ++--
 1 files changed, 16 insertions(+), 35 deletions(-)

diff --git a/drivers/staging/tidspbridge/rmgr/mgr.c 
b/drivers/staging/tidspbridge/rmgr/mgr.c
index 2eab6a5..16410a5 100644
--- a/drivers/staging/tidspbridge/rmgr/mgr.c
+++ b/drivers/staging/tidspbridge/rmgr/mgr.c
@@ -134,8 +134,7 @@ int mgr_enum_node_info(u32 node_id, struct dsp_ndbprops 
*pndb_props,
  u32 undb_props_size, u32 *pu_num_nodes)
 {
int status = 0;
-   struct dsp_uuid node_uuid, temp_uuid;
-   u32 temp_index = 0;
+   struct dsp_uuid node_uuid;
u32 node_index = 0;
struct dcd_genericobj gen_obj;
struct mgr_object *pmgr_obj = NULL;
@@ -149,24 +148,27 @@ int mgr_enum_node_info(u32 node_id, struct dsp_ndbprops 
*pndb_props,
*pu_num_nodes = 0;
/* Get the Manager Object from the driver data */
if (!drv_datap || !drv_datap-mgr_object) {
-   status = -ENODATA;
pr_err(%s: Failed to retrieve the object handle\n, __func__);
-   goto func_cont;
-   } else {
-   pmgr_obj = drv_datap-mgr_object;
+   return -ENODATA;
}
+   pmgr_obj = drv_datap-mgr_object;
 
DBC_ASSERT(pmgr_obj);
/* Forever loop till we hit failed or no more items in the
 * Enumeration. We will exit the loop other than 0; */
-   while (status == 0) {
-   status = dcd_enumerate_object(temp_index++, DSP_DCDNODETYPE,
- temp_uuid);
-   if (status == 0) {
-   node_index++;
-   if (node_id == (node_index - 1))
-   node_uuid = temp_uuid;
-
+   while (!status) {
+   status = dcd_enumerate_object(node_index++, DSP_DCDNODETYPE,
+   node_uuid);
+   if (status)
+   break;
+   *pu_num_nodes = node_index;
+   if (node_id == (node_index - 1)) {
+   status = dcd_get_object_def(pmgr_obj-hdcd_mgr,
+   node_uuid, DSP_DCDNODETYPE, gen_obj);
+   if (status)
+   break;
+   /* Get the Obj def */
+   *pndb_props = gen_obj.obj_data.node_obj.ndb_props;
}
}
 
@@ -174,27 +176,6 @@ int mgr_enum_node_info(u32 node_id, struct dsp_ndbprops 
*pndb_props,
if (status  0)
status = 0;
 
-   if (!status) {
-   if (node_id  (node_index - 1)) {
-   status = -EINVAL;
-   } else {
-   status = dcd_get_object_def(pmgr_obj-hdcd_mgr,
-   (struct dsp_uuid *)
-   node_uuid, DSP_DCDNODETYPE,
-   gen_obj);
-   if (!status) {
-   /* Get the Obj def */
-   *pndb_props =
-   gen_obj.obj_data.node_obj.ndb_props;
-   *pu_num_nodes = node_index;
-   }
-   }
-   }
-
-func_cont:
-   DBC_ENSURE((!status  *pu_num_nodes  0) ||
-  (status  *pu_num_nodes == 0));
-
return status;
 }
 
-- 
1.7.2.3

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 3/3] staging: tidspbridge: fix kernel oops in bridge_io_get_proc_load

2010-11-05 Thread Ionut Nicu
The DSP shared memory area gets initialized only when
a COFF file is loaded.

If bridge_io_get_proc_load is called before loading a base
image into the DSP, the shared_mem member of the io manager
will be NULL, resulting in a kernel oops when it's dereferenced.

Also made some coding style changes to bridge_io_create.

Signed-off-by: Ionut Nicu ionut.n...@mindbit.ro
---
 drivers/staging/tidspbridge/core/io_sm.c |   78 +++--
 1 files changed, 30 insertions(+), 48 deletions(-)

diff --git a/drivers/staging/tidspbridge/core/io_sm.c 
b/drivers/staging/tidspbridge/core/io_sm.c
index de2cc3b..bd407b6 100644
--- a/drivers/staging/tidspbridge/core/io_sm.c
+++ b/drivers/staging/tidspbridge/core/io_sm.c
@@ -164,57 +164,41 @@ int bridge_io_create(struct io_mgr **io_man,
struct dev_object *hdev_obj,
const struct io_attrs *mgr_attrts)
 {
-   int status = 0;
struct io_mgr *pio_mgr = NULL;
-   struct shm *shared_mem = NULL;
struct bridge_dev_context *hbridge_context = NULL;
struct cfg_devnode *dev_node_obj;
struct chnl_mgr *hchnl_mgr;
u8 dev_type;
 
/* Check requirements */
-   if (!io_man || !mgr_attrts || mgr_attrts-word_size == 0) {
-   status = -EFAULT;
-   goto func_end;
-   }
+   if (!io_man || !mgr_attrts || mgr_attrts-word_size == 0)
+   return -EFAULT;
+
+   *io_man = NULL;
+
dev_get_chnl_mgr(hdev_obj, hchnl_mgr);
-   if (!hchnl_mgr || hchnl_mgr-hio_mgr) {
-   status = -EFAULT;
-   goto func_end;
-   }
+   if (!hchnl_mgr || hchnl_mgr-hio_mgr)
+   return -EFAULT;
+
/*
 * Message manager will be created when a file is loaded, since
 * size of message buffer in shared memory is configurable in
 * the base image.
 */
dev_get_bridge_context(hdev_obj, hbridge_context);
-   if (!hbridge_context) {
-   status = -EFAULT;
-   goto func_end;
-   }
+   if (!hbridge_context)
+   return -EFAULT;
+
dev_get_dev_type(hdev_obj, dev_type);
-   /*
-* DSP shared memory area will get set properly when
-* a program is loaded. They are unknown until a COFF file is
-* loaded. I chose the value -1 because it was less likely to be
-* a valid address than 0.
-*/
-   shared_mem = (struct shm *)-1;
 
/* Allocate IO manager object */
pio_mgr = kzalloc(sizeof(struct io_mgr), GFP_KERNEL);
-   if (pio_mgr == NULL) {
-   status = -ENOMEM;
-   goto func_end;
-   }
+   if (!pio_mgr)
+   return -ENOMEM;
 
/* Initialize chnl_mgr object */
-#if defined(CONFIG_TIDSPBRIDGE_BACKTRACE) || defined(CONFIG_TIDSPBRIDGE_DEBUG)
-   pio_mgr-pmsg = NULL;
-#endif
pio_mgr-hchnl_mgr = hchnl_mgr;
pio_mgr-word_size = mgr_attrts-word_size;
-   pio_mgr-shared_mem = shared_mem;
 
if (dev_type == DSP_UNIT) {
/* Create an IO DPC */
@@ -226,29 +210,24 @@ int bridge_io_create(struct io_mgr **io_man,
 
spin_lock_init(pio_mgr-dpc_lock);
 
-   status = dev_get_dev_node(hdev_obj, dev_node_obj);
+   if (dev_get_dev_node(hdev_obj, dev_node_obj)) {
+   bridge_io_destroy(pio_mgr);
+   return -EIO;
+   }
}
 
-   if (!status) {
-   pio_mgr-hbridge_context = hbridge_context;
-   pio_mgr-shared_irq = mgr_attrts-irq_shared;
-   if (dsp_wdt_init())
-   status = -EPERM;
-   } else {
-   status = -EIO;
-   }
-func_end:
-   if (status) {
-   /* Cleanup */
+   pio_mgr-hbridge_context = hbridge_context;
+   pio_mgr-shared_irq = mgr_attrts-irq_shared;
+   if (dsp_wdt_init()) {
bridge_io_destroy(pio_mgr);
-   if (io_man)
-   *io_man = NULL;
-   } else {
-   /* Return IO manager object to caller... */
-   hchnl_mgr-hio_mgr = pio_mgr;
-   *io_man = pio_mgr;
+   return -EPERM;
}
-   return status;
+
+   /* Return IO manager object to caller... */
+   hchnl_mgr-hio_mgr = pio_mgr;
+   *io_man = pio_mgr;
+
+   return 0;
 }
 
 /*
@@ -1532,6 +1511,9 @@ int io_sh_msetting(struct io_mgr *hio_mgr, u8 desc, void 
*pargs)
 int bridge_io_get_proc_load(struct io_mgr *hio_mgr,
struct dsp_procloadstat *proc_lstat)
 {
+   if (!hio_mgr-shared_mem)
+   return -EFAULT;
+
proc_lstat-curr_load =
hio_mgr-shared_mem-load_mon_info.curr_dsp_load;
proc_lstat-predicted_load =
-- 
1.7.2.3

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord

Re: [PATCH v2 0/3] staging: tidspbridge: bugfixes

2010-11-05 Thread Ionut Nicu
Hi,

On Fri, 2010-11-05 at 08:43 -0700, Greg KH wrote:
 On Fri, Nov 05, 2010 at 05:15:45PM +0200, Ionut Nicu wrote:
  Changes since v1:
  
  * Split the mgr_enum_node_info patch into two patches:
  one that fixes the issue and one that reorganizes the
  code.
 
 Are these for the .37 or .38 kernel?
 

They're bug fixes, so I think they should get into .37. It's up to you
to decide.

Thanks,
Ionut.

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 00/12] staging: tidspbridge: various cleanups

2010-11-05 Thread Ionut Nicu
Hi,

On Fri, 2010-11-05 at 08:43 -0700, Greg KH wrote:
 On Fri, Nov 05, 2010 at 05:13:04PM +0200, Ionut Nicu wrote:
  This set of patches replaces some of the redundant components of
  the tidspbridge driver, such as:
  
  * wrapper functions for kmalloc/kfree
  * custom bitmap implementation
  * custom linked list implementation (list_head wrapper)
  
  with the standard linux kernel interfaces.
  
  The patches also do some code reorganization for increasing readability.
  Most of the changes reduce the code indentation level and simplify the code.
  No functional changes were done.
  
  There are many places in this driver that need this kind of cleanup, but
  these patches only fix the functions that were touched while converting
  the code to use linux bitmap and list_head.
 
 This is for .38, right?
 

Yes, the diff stat is quite big, so if they pass code review, they
should be considered for .38.

Thanks,
Ionut


--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 1/3] staging: tidspbridge: fix mgr_enum_node_info

2010-11-05 Thread Ionut Nicu
On Fri, 2010-11-05 at 09:09 -0700, Greg KH wrote:
 On Fri, Nov 05, 2010 at 06:01:47PM +0200, Felipe Contreras wrote:
  On Fri, Nov 5, 2010 at 5:15 PM, Ionut Nicu ionut.n...@gmail.com wrote:
   The current code was always returning a non-zero status value
   to userspace applications when this ioctl was called.
  
   The error code was ENODATA, which isn't actually an error,
   it's always returned by dcd_enumerate_object() when it hits the
   end of list.
  
   Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
   Signed-off-by: Ionut Nicu ionut.n...@mindbit.ro
  
  You should leave the original author (me).
 
 Ick, yes, that is very bad.
 
 Ionut, please go re-read Documentation/SubmittingPatches for how to
 properly attribute the original author of the patch.  Please resend all
 of these patches after ensuring that you have the proper authors
 credited.
 

Oops. Sorry about that. I put my sign off on this patch because the fix
was also in v1 of this series, but it was combined with patch 3/3.

I definitely don't want to take credit for other people's work, so I
will re-submit this series.

Thanks,
Ionut. 



--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 1/3] staging: tidspbridge: fix mgr_enum_node_info

2010-11-05 Thread Ionut Nicu
The current code was always returning a non-zero status value
to userspace applications when this ioctl was called.

The error code was ENODATA, which isn't actually an error,
it's always returned by dcd_enumerate_object() when it hits the
end of list.

Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 drivers/staging/tidspbridge/rmgr/mgr.c |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/tidspbridge/rmgr/mgr.c 
b/drivers/staging/tidspbridge/rmgr/mgr.c
index 0ea89a1..2eab6a5 100644
--- a/drivers/staging/tidspbridge/rmgr/mgr.c
+++ b/drivers/staging/tidspbridge/rmgr/mgr.c
@@ -169,6 +169,11 @@ int mgr_enum_node_info(u32 node_id, struct dsp_ndbprops 
*pndb_props,
 
}
}
+
+   /* the last status is not 0, but neither an error */
+   if (status  0)
+   status = 0;
+
if (!status) {
if (node_id  (node_index - 1)) {
status = -EINVAL;
-- 
1.7.2.3

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 2/3] staging: tidspbridge: mgr_enum_node_info cleanup

2010-11-05 Thread Ionut Nicu
Reorganized mgr_enum_node_info code to increase its
readability.

Signed-off-by: Ionut Nicu ionut.n...@mindbit.ro
---
 drivers/staging/tidspbridge/rmgr/mgr.c |   51 ++--
 1 files changed, 16 insertions(+), 35 deletions(-)

diff --git a/drivers/staging/tidspbridge/rmgr/mgr.c 
b/drivers/staging/tidspbridge/rmgr/mgr.c
index 2eab6a5..16410a5 100644
--- a/drivers/staging/tidspbridge/rmgr/mgr.c
+++ b/drivers/staging/tidspbridge/rmgr/mgr.c
@@ -134,8 +134,7 @@ int mgr_enum_node_info(u32 node_id, struct dsp_ndbprops 
*pndb_props,
  u32 undb_props_size, u32 *pu_num_nodes)
 {
int status = 0;
-   struct dsp_uuid node_uuid, temp_uuid;
-   u32 temp_index = 0;
+   struct dsp_uuid node_uuid;
u32 node_index = 0;
struct dcd_genericobj gen_obj;
struct mgr_object *pmgr_obj = NULL;
@@ -149,24 +148,27 @@ int mgr_enum_node_info(u32 node_id, struct dsp_ndbprops 
*pndb_props,
*pu_num_nodes = 0;
/* Get the Manager Object from the driver data */
if (!drv_datap || !drv_datap-mgr_object) {
-   status = -ENODATA;
pr_err(%s: Failed to retrieve the object handle\n, __func__);
-   goto func_cont;
-   } else {
-   pmgr_obj = drv_datap-mgr_object;
+   return -ENODATA;
}
+   pmgr_obj = drv_datap-mgr_object;
 
DBC_ASSERT(pmgr_obj);
/* Forever loop till we hit failed or no more items in the
 * Enumeration. We will exit the loop other than 0; */
-   while (status == 0) {
-   status = dcd_enumerate_object(temp_index++, DSP_DCDNODETYPE,
- temp_uuid);
-   if (status == 0) {
-   node_index++;
-   if (node_id == (node_index - 1))
-   node_uuid = temp_uuid;
-
+   while (!status) {
+   status = dcd_enumerate_object(node_index++, DSP_DCDNODETYPE,
+   node_uuid);
+   if (status)
+   break;
+   *pu_num_nodes = node_index;
+   if (node_id == (node_index - 1)) {
+   status = dcd_get_object_def(pmgr_obj-hdcd_mgr,
+   node_uuid, DSP_DCDNODETYPE, gen_obj);
+   if (status)
+   break;
+   /* Get the Obj def */
+   *pndb_props = gen_obj.obj_data.node_obj.ndb_props;
}
}
 
@@ -174,27 +176,6 @@ int mgr_enum_node_info(u32 node_id, struct dsp_ndbprops 
*pndb_props,
if (status  0)
status = 0;
 
-   if (!status) {
-   if (node_id  (node_index - 1)) {
-   status = -EINVAL;
-   } else {
-   status = dcd_get_object_def(pmgr_obj-hdcd_mgr,
-   (struct dsp_uuid *)
-   node_uuid, DSP_DCDNODETYPE,
-   gen_obj);
-   if (!status) {
-   /* Get the Obj def */
-   *pndb_props =
-   gen_obj.obj_data.node_obj.ndb_props;
-   *pu_num_nodes = node_index;
-   }
-   }
-   }
-
-func_cont:
-   DBC_ENSURE((!status  *pu_num_nodes  0) ||
-  (status  *pu_num_nodes == 0));
-
return status;
 }
 
-- 
1.7.2.3

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 3/3] staging: tidspbridge: fix kernel oops in bridge_io_get_proc_load

2010-11-05 Thread Ionut Nicu
The DSP shared memory area gets initialized only when
a COFF file is loaded.

If bridge_io_get_proc_load is called before loading a base
image into the DSP, the shared_mem member of the io manager
will be NULL, resulting in a kernel oops when it's dereferenced.

Also made some coding style changes to bridge_io_create.

Signed-off-by: Ionut Nicu ionut.n...@mindbit.ro
---
 drivers/staging/tidspbridge/core/io_sm.c |   78 +++--
 1 files changed, 30 insertions(+), 48 deletions(-)

diff --git a/drivers/staging/tidspbridge/core/io_sm.c 
b/drivers/staging/tidspbridge/core/io_sm.c
index de2cc3b..bd407b6 100644
--- a/drivers/staging/tidspbridge/core/io_sm.c
+++ b/drivers/staging/tidspbridge/core/io_sm.c
@@ -164,57 +164,41 @@ int bridge_io_create(struct io_mgr **io_man,
struct dev_object *hdev_obj,
const struct io_attrs *mgr_attrts)
 {
-   int status = 0;
struct io_mgr *pio_mgr = NULL;
-   struct shm *shared_mem = NULL;
struct bridge_dev_context *hbridge_context = NULL;
struct cfg_devnode *dev_node_obj;
struct chnl_mgr *hchnl_mgr;
u8 dev_type;
 
/* Check requirements */
-   if (!io_man || !mgr_attrts || mgr_attrts-word_size == 0) {
-   status = -EFAULT;
-   goto func_end;
-   }
+   if (!io_man || !mgr_attrts || mgr_attrts-word_size == 0)
+   return -EFAULT;
+
+   *io_man = NULL;
+
dev_get_chnl_mgr(hdev_obj, hchnl_mgr);
-   if (!hchnl_mgr || hchnl_mgr-hio_mgr) {
-   status = -EFAULT;
-   goto func_end;
-   }
+   if (!hchnl_mgr || hchnl_mgr-hio_mgr)
+   return -EFAULT;
+
/*
 * Message manager will be created when a file is loaded, since
 * size of message buffer in shared memory is configurable in
 * the base image.
 */
dev_get_bridge_context(hdev_obj, hbridge_context);
-   if (!hbridge_context) {
-   status = -EFAULT;
-   goto func_end;
-   }
+   if (!hbridge_context)
+   return -EFAULT;
+
dev_get_dev_type(hdev_obj, dev_type);
-   /*
-* DSP shared memory area will get set properly when
-* a program is loaded. They are unknown until a COFF file is
-* loaded. I chose the value -1 because it was less likely to be
-* a valid address than 0.
-*/
-   shared_mem = (struct shm *)-1;
 
/* Allocate IO manager object */
pio_mgr = kzalloc(sizeof(struct io_mgr), GFP_KERNEL);
-   if (pio_mgr == NULL) {
-   status = -ENOMEM;
-   goto func_end;
-   }
+   if (!pio_mgr)
+   return -ENOMEM;
 
/* Initialize chnl_mgr object */
-#if defined(CONFIG_TIDSPBRIDGE_BACKTRACE) || defined(CONFIG_TIDSPBRIDGE_DEBUG)
-   pio_mgr-pmsg = NULL;
-#endif
pio_mgr-hchnl_mgr = hchnl_mgr;
pio_mgr-word_size = mgr_attrts-word_size;
-   pio_mgr-shared_mem = shared_mem;
 
if (dev_type == DSP_UNIT) {
/* Create an IO DPC */
@@ -226,29 +210,24 @@ int bridge_io_create(struct io_mgr **io_man,
 
spin_lock_init(pio_mgr-dpc_lock);
 
-   status = dev_get_dev_node(hdev_obj, dev_node_obj);
+   if (dev_get_dev_node(hdev_obj, dev_node_obj)) {
+   bridge_io_destroy(pio_mgr);
+   return -EIO;
+   }
}
 
-   if (!status) {
-   pio_mgr-hbridge_context = hbridge_context;
-   pio_mgr-shared_irq = mgr_attrts-irq_shared;
-   if (dsp_wdt_init())
-   status = -EPERM;
-   } else {
-   status = -EIO;
-   }
-func_end:
-   if (status) {
-   /* Cleanup */
+   pio_mgr-hbridge_context = hbridge_context;
+   pio_mgr-shared_irq = mgr_attrts-irq_shared;
+   if (dsp_wdt_init()) {
bridge_io_destroy(pio_mgr);
-   if (io_man)
-   *io_man = NULL;
-   } else {
-   /* Return IO manager object to caller... */
-   hchnl_mgr-hio_mgr = pio_mgr;
-   *io_man = pio_mgr;
+   return -EPERM;
}
-   return status;
+
+   /* Return IO manager object to caller... */
+   hchnl_mgr-hio_mgr = pio_mgr;
+   *io_man = pio_mgr;
+
+   return 0;
 }
 
 /*
@@ -1532,6 +1511,9 @@ int io_sh_msetting(struct io_mgr *hio_mgr, u8 desc, void 
*pargs)
 int bridge_io_get_proc_load(struct io_mgr *hio_mgr,
struct dsp_procloadstat *proc_lstat)
 {
+   if (!hio_mgr-shared_mem)
+   return -EFAULT;
+
proc_lstat-curr_load =
hio_mgr-shared_mem-load_mon_info.curr_dsp_load;
proc_lstat-predicted_load =
-- 
1.7.2.3

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord

[PATCH v4 0/3] staging: tidspbridge: bugfixes

2010-11-05 Thread Ionut Nicu
Changes since v1:

* Split the mgr_enum_node_info patch into two patches:
one that fixes the issue and one that reorganizes the
code.

Changes since v2:

* Set proper authorship on patch 1/3

Felipe Contreras (1):
  staging: tidspbridge: fix mgr_enum_node_info

Ionut Nicu (2):
  staging: tidspbridge: mgr_enum_node_info cleanup
  staging: tidspbridge: fix kernel oops in bridge_io_get_proc_load

 drivers/staging/tidspbridge/core/io_sm.c |   78 +++--
 drivers/staging/tidspbridge/rmgr/mgr.c   |   50 +++
 2 files changed, 48 insertions(+), 80 deletions(-)

-- 
1.7.2.3

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 1/3] staging: tidspbridge: fix mgr_enum_node_info

2010-11-05 Thread Ionut Nicu
From: Felipe Contreras felipe.contre...@gmail.com

The current code was always returning a non-zero status value
to userspace applications when this ioctl was called.

The error code was ENODATA, which isn't actually an error,
it's always returned by dcd_enumerate_object() when it hits the
end of list.

Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
---
 drivers/staging/tidspbridge/rmgr/mgr.c |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/tidspbridge/rmgr/mgr.c 
b/drivers/staging/tidspbridge/rmgr/mgr.c
index 0ea89a1..2eab6a5 100644
--- a/drivers/staging/tidspbridge/rmgr/mgr.c
+++ b/drivers/staging/tidspbridge/rmgr/mgr.c
@@ -169,6 +169,11 @@ int mgr_enum_node_info(u32 node_id, struct dsp_ndbprops 
*pndb_props,
 
}
}
+
+   /* the last status is not 0, but neither an error */
+   if (status  0)
+   status = 0;
+
if (!status) {
if (node_id  (node_index - 1)) {
status = -EINVAL;
-- 
1.7.2.3

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 2/3] staging: tidspbridge: mgr_enum_node_info cleanup

2010-11-05 Thread Ionut Nicu
Reorganized mgr_enum_node_info code to increase its
readability.

Signed-off-by: Ionut Nicu ionut.n...@mindbit.ro
---
 drivers/staging/tidspbridge/rmgr/mgr.c |   51 ++--
 1 files changed, 16 insertions(+), 35 deletions(-)

diff --git a/drivers/staging/tidspbridge/rmgr/mgr.c 
b/drivers/staging/tidspbridge/rmgr/mgr.c
index 2eab6a5..16410a5 100644
--- a/drivers/staging/tidspbridge/rmgr/mgr.c
+++ b/drivers/staging/tidspbridge/rmgr/mgr.c
@@ -134,8 +134,7 @@ int mgr_enum_node_info(u32 node_id, struct dsp_ndbprops 
*pndb_props,
  u32 undb_props_size, u32 *pu_num_nodes)
 {
int status = 0;
-   struct dsp_uuid node_uuid, temp_uuid;
-   u32 temp_index = 0;
+   struct dsp_uuid node_uuid;
u32 node_index = 0;
struct dcd_genericobj gen_obj;
struct mgr_object *pmgr_obj = NULL;
@@ -149,24 +148,27 @@ int mgr_enum_node_info(u32 node_id, struct dsp_ndbprops 
*pndb_props,
*pu_num_nodes = 0;
/* Get the Manager Object from the driver data */
if (!drv_datap || !drv_datap-mgr_object) {
-   status = -ENODATA;
pr_err(%s: Failed to retrieve the object handle\n, __func__);
-   goto func_cont;
-   } else {
-   pmgr_obj = drv_datap-mgr_object;
+   return -ENODATA;
}
+   pmgr_obj = drv_datap-mgr_object;
 
DBC_ASSERT(pmgr_obj);
/* Forever loop till we hit failed or no more items in the
 * Enumeration. We will exit the loop other than 0; */
-   while (status == 0) {
-   status = dcd_enumerate_object(temp_index++, DSP_DCDNODETYPE,
- temp_uuid);
-   if (status == 0) {
-   node_index++;
-   if (node_id == (node_index - 1))
-   node_uuid = temp_uuid;
-
+   while (!status) {
+   status = dcd_enumerate_object(node_index++, DSP_DCDNODETYPE,
+   node_uuid);
+   if (status)
+   break;
+   *pu_num_nodes = node_index;
+   if (node_id == (node_index - 1)) {
+   status = dcd_get_object_def(pmgr_obj-hdcd_mgr,
+   node_uuid, DSP_DCDNODETYPE, gen_obj);
+   if (status)
+   break;
+   /* Get the Obj def */
+   *pndb_props = gen_obj.obj_data.node_obj.ndb_props;
}
}
 
@@ -174,27 +176,6 @@ int mgr_enum_node_info(u32 node_id, struct dsp_ndbprops 
*pndb_props,
if (status  0)
status = 0;
 
-   if (!status) {
-   if (node_id  (node_index - 1)) {
-   status = -EINVAL;
-   } else {
-   status = dcd_get_object_def(pmgr_obj-hdcd_mgr,
-   (struct dsp_uuid *)
-   node_uuid, DSP_DCDNODETYPE,
-   gen_obj);
-   if (!status) {
-   /* Get the Obj def */
-   *pndb_props =
-   gen_obj.obj_data.node_obj.ndb_props;
-   *pu_num_nodes = node_index;
-   }
-   }
-   }
-
-func_cont:
-   DBC_ENSURE((!status  *pu_num_nodes  0) ||
-  (status  *pu_num_nodes == 0));
-
return status;
 }
 
-- 
1.7.2.3

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 3/3] staging: tidspbridge: fix kernel oops in bridge_io_get_proc_load

2010-11-05 Thread Ionut Nicu
The DSP shared memory area gets initialized only when
a COFF file is loaded.

If bridge_io_get_proc_load is called before loading a base
image into the DSP, the shared_mem member of the io manager
will be NULL, resulting in a kernel oops when it's dereferenced.

Also made some coding style changes to bridge_io_create.

Signed-off-by: Ionut Nicu ionut.n...@mindbit.ro
---
 drivers/staging/tidspbridge/core/io_sm.c |   78 +++--
 1 files changed, 30 insertions(+), 48 deletions(-)

diff --git a/drivers/staging/tidspbridge/core/io_sm.c 
b/drivers/staging/tidspbridge/core/io_sm.c
index de2cc3b..bd407b6 100644
--- a/drivers/staging/tidspbridge/core/io_sm.c
+++ b/drivers/staging/tidspbridge/core/io_sm.c
@@ -164,57 +164,41 @@ int bridge_io_create(struct io_mgr **io_man,
struct dev_object *hdev_obj,
const struct io_attrs *mgr_attrts)
 {
-   int status = 0;
struct io_mgr *pio_mgr = NULL;
-   struct shm *shared_mem = NULL;
struct bridge_dev_context *hbridge_context = NULL;
struct cfg_devnode *dev_node_obj;
struct chnl_mgr *hchnl_mgr;
u8 dev_type;
 
/* Check requirements */
-   if (!io_man || !mgr_attrts || mgr_attrts-word_size == 0) {
-   status = -EFAULT;
-   goto func_end;
-   }
+   if (!io_man || !mgr_attrts || mgr_attrts-word_size == 0)
+   return -EFAULT;
+
+   *io_man = NULL;
+
dev_get_chnl_mgr(hdev_obj, hchnl_mgr);
-   if (!hchnl_mgr || hchnl_mgr-hio_mgr) {
-   status = -EFAULT;
-   goto func_end;
-   }
+   if (!hchnl_mgr || hchnl_mgr-hio_mgr)
+   return -EFAULT;
+
/*
 * Message manager will be created when a file is loaded, since
 * size of message buffer in shared memory is configurable in
 * the base image.
 */
dev_get_bridge_context(hdev_obj, hbridge_context);
-   if (!hbridge_context) {
-   status = -EFAULT;
-   goto func_end;
-   }
+   if (!hbridge_context)
+   return -EFAULT;
+
dev_get_dev_type(hdev_obj, dev_type);
-   /*
-* DSP shared memory area will get set properly when
-* a program is loaded. They are unknown until a COFF file is
-* loaded. I chose the value -1 because it was less likely to be
-* a valid address than 0.
-*/
-   shared_mem = (struct shm *)-1;
 
/* Allocate IO manager object */
pio_mgr = kzalloc(sizeof(struct io_mgr), GFP_KERNEL);
-   if (pio_mgr == NULL) {
-   status = -ENOMEM;
-   goto func_end;
-   }
+   if (!pio_mgr)
+   return -ENOMEM;
 
/* Initialize chnl_mgr object */
-#if defined(CONFIG_TIDSPBRIDGE_BACKTRACE) || defined(CONFIG_TIDSPBRIDGE_DEBUG)
-   pio_mgr-pmsg = NULL;
-#endif
pio_mgr-hchnl_mgr = hchnl_mgr;
pio_mgr-word_size = mgr_attrts-word_size;
-   pio_mgr-shared_mem = shared_mem;
 
if (dev_type == DSP_UNIT) {
/* Create an IO DPC */
@@ -226,29 +210,24 @@ int bridge_io_create(struct io_mgr **io_man,
 
spin_lock_init(pio_mgr-dpc_lock);
 
-   status = dev_get_dev_node(hdev_obj, dev_node_obj);
+   if (dev_get_dev_node(hdev_obj, dev_node_obj)) {
+   bridge_io_destroy(pio_mgr);
+   return -EIO;
+   }
}
 
-   if (!status) {
-   pio_mgr-hbridge_context = hbridge_context;
-   pio_mgr-shared_irq = mgr_attrts-irq_shared;
-   if (dsp_wdt_init())
-   status = -EPERM;
-   } else {
-   status = -EIO;
-   }
-func_end:
-   if (status) {
-   /* Cleanup */
+   pio_mgr-hbridge_context = hbridge_context;
+   pio_mgr-shared_irq = mgr_attrts-irq_shared;
+   if (dsp_wdt_init()) {
bridge_io_destroy(pio_mgr);
-   if (io_man)
-   *io_man = NULL;
-   } else {
-   /* Return IO manager object to caller... */
-   hchnl_mgr-hio_mgr = pio_mgr;
-   *io_man = pio_mgr;
+   return -EPERM;
}
-   return status;
+
+   /* Return IO manager object to caller... */
+   hchnl_mgr-hio_mgr = pio_mgr;
+   *io_man = pio_mgr;
+
+   return 0;
 }
 
 /*
@@ -1532,6 +1511,9 @@ int io_sh_msetting(struct io_mgr *hio_mgr, u8 desc, void 
*pargs)
 int bridge_io_get_proc_load(struct io_mgr *hio_mgr,
struct dsp_procloadstat *proc_lstat)
 {
+   if (!hio_mgr-shared_mem)
+   return -EFAULT;
+
proc_lstat-curr_load =
hio_mgr-shared_mem-load_mon_info.curr_dsp_load;
proc_lstat-predicted_load =
-- 
1.7.2.3

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord

RE: [PATCH 3/4] staging: tidspbridge: remove gb bitmap implementation

2010-10-25 Thread Ionut Nicu
Hi Rene,

On Sat, 2010-10-23 at 15:28 -0500, Sapiens, Rene wrote:
 Hi Ionut,
 On Friday, October 22, 2010 9:09 AM Ionut Nicu wrote:
  Most likely I will have to break patch 4/4 from this series (which I
  also believe is way too big) into multiple patches and re-submit.
  
  I'm expecting some advices from the maintainers/list on how to split
  patch 4 (lst_list removal).
 
 I have a version of this patch but yours did it first :). You can break
 it by functionality so that you don't break nor affect bridge's behavior
 i.e.
 
 Patch 1 can include the removing of the wrapper from:
 drivers/staging/tidspbridge/core/_msg_sm.h
 drivers/staging/tidspbridge/core/chnl_sm.c
 drivers/staging/tidspbridge/core/io_sm.c
 drivers/staging/tidspbridge/core/msg_sm.c
 drivers/staging/tidspbridge/include/dspbridge/_chnl_sm.h
 drivers/staging/tidspbridge/include/dspbridge/cmmdefs.h
 The above files share some of the lists.
 
 Patch 2:
 drivers/staging/tidspbridge/pmgr/cmm.c
 
 Patch 3:
 drivers/staging/tidspbridge/pmgr/dev.c
 drivers/staging/tidspbridge/rmgr/drv.c
 drivers/staging/tidspbridge/rmgr/node.c
 drivers/staging/tidspbridge/rmgr/proc.c
 
 Patch 4:
 drivers/staging/tidspbridge/rmgr/rmm.c
 
 Patch 5:
 Removing of the not needed files.
 

Thanks for your suggestions. I will try to do this split-up in version 2
of this series.

Best regards,
Ionut.

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] staging: tidspbridge: fix kernel oops in bridge_io_get_proc_load

2010-10-22 Thread Ionut Nicu
The DSP shared memory area gets initialized only when
a COFF file is loaded.

If bridge_io_get_proc_load is called before loading a base
image into the DSP, the shared_mem member of the io manager
will be NULL, resulting in a kernel oops when it's dereferenced.

Also made some coding style changes to bridge_io_create.

Signed-off-by: Ionut Nicu ionut.n...@mindbit.ro
---
 drivers/staging/tidspbridge/core/io_sm.c |   78 +++--
 1 files changed, 30 insertions(+), 48 deletions(-)

diff --git a/drivers/staging/tidspbridge/core/io_sm.c 
b/drivers/staging/tidspbridge/core/io_sm.c
index 2b287d1..77cd2b6 100644
--- a/drivers/staging/tidspbridge/core/io_sm.c
+++ b/drivers/staging/tidspbridge/core/io_sm.c
@@ -164,57 +164,41 @@ int bridge_io_create(struct io_mgr **io_man,
struct dev_object *hdev_obj,
const struct io_attrs *mgr_attrts)
 {
-   int status = 0;
struct io_mgr *pio_mgr = NULL;
-   struct shm *shared_mem = NULL;
struct bridge_dev_context *hbridge_context = NULL;
struct cfg_devnode *dev_node_obj;
struct chnl_mgr *hchnl_mgr;
u8 dev_type;
 
/* Check requirements */
-   if (!io_man || !mgr_attrts || mgr_attrts-word_size == 0) {
-   status = -EFAULT;
-   goto func_end;
-   }
+   if (!io_man || !mgr_attrts || mgr_attrts-word_size == 0)
+   return -EFAULT;
+
+   *io_man = NULL;
+
dev_get_chnl_mgr(hdev_obj, hchnl_mgr);
-   if (!hchnl_mgr || hchnl_mgr-hio_mgr) {
-   status = -EFAULT;
-   goto func_end;
-   }
+   if (!hchnl_mgr || hchnl_mgr-hio_mgr)
+   return -EFAULT;
+
/*
 * Message manager will be created when a file is loaded, since
 * size of message buffer in shared memory is configurable in
 * the base image.
 */
dev_get_bridge_context(hdev_obj, hbridge_context);
-   if (!hbridge_context) {
-   status = -EFAULT;
-   goto func_end;
-   }
+   if (!hbridge_context)
+   return -EFAULT;
+
dev_get_dev_type(hdev_obj, dev_type);
-   /*
-* DSP shared memory area will get set properly when
-* a program is loaded. They are unknown until a COFF file is
-* loaded. I chose the value -1 because it was less likely to be
-* a valid address than 0.
-*/
-   shared_mem = (struct shm *)-1;
 
/* Allocate IO manager object */
pio_mgr = kzalloc(sizeof(struct io_mgr), GFP_KERNEL);
-   if (pio_mgr == NULL) {
-   status = -ENOMEM;
-   goto func_end;
-   }
+   if (!pio_mgr)
+   return -ENOMEM;
 
/* Initialize chnl_mgr object */
-#if defined(CONFIG_TIDSPBRIDGE_BACKTRACE) || defined(CONFIG_TIDSPBRIDGE_DEBUG)
-   pio_mgr-pmsg = NULL;
-#endif
pio_mgr-hchnl_mgr = hchnl_mgr;
pio_mgr-word_size = mgr_attrts-word_size;
-   pio_mgr-shared_mem = shared_mem;
 
if (dev_type == DSP_UNIT) {
/* Create an IO DPC */
@@ -226,29 +210,24 @@ int bridge_io_create(struct io_mgr **io_man,
 
spin_lock_init(pio_mgr-dpc_lock);
 
-   status = dev_get_dev_node(hdev_obj, dev_node_obj);
+   if (dev_get_dev_node(hdev_obj, dev_node_obj)) {
+   bridge_io_destroy(pio_mgr);
+   return -EIO;
+   }
}
 
-   if (!status) {
-   pio_mgr-hbridge_context = hbridge_context;
-   pio_mgr-shared_irq = mgr_attrts-irq_shared;
-   if (dsp_wdt_init())
-   status = -EPERM;
-   } else {
-   status = -EIO;
-   }
-func_end:
-   if (status) {
-   /* Cleanup */
+   pio_mgr-hbridge_context = hbridge_context;
+   pio_mgr-shared_irq = mgr_attrts-irq_shared;
+   if (dsp_wdt_init()) {
bridge_io_destroy(pio_mgr);
-   if (io_man)
-   *io_man = NULL;
-   } else {
-   /* Return IO manager object to caller... */
-   hchnl_mgr-hio_mgr = pio_mgr;
-   *io_man = pio_mgr;
+   return -EPERM;
}
-   return status;
+
+   /* Return IO manager object to caller... */
+   hchnl_mgr-hio_mgr = pio_mgr;
+   *io_man = pio_mgr;
+
+   return 0;
 }
 
 /*
@@ -1529,6 +1508,9 @@ int io_sh_msetting(struct io_mgr *hio_mgr, u8 desc, void 
*pargs)
 int bridge_io_get_proc_load(struct io_mgr *hio_mgr,
struct dsp_procloadstat *proc_lstat)
 {
+   if (!hio_mgr-shared_mem)
+   return -EFAULT;
+
proc_lstat-curr_load =
hio_mgr-shared_mem-load_mon_info.curr_dsp_load;
proc_lstat-predicted_load =
-- 
1.7.2.3

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord

[PATCH] staging: tidspbridge: make the MGR_ENUMNODE_INFO ioctl work

2010-10-22 Thread Ionut Nicu
The current code was always returning a non-zero status value
to userspace applications when this ioctl was called.

The error code was ENODATA, which isn't actually an error,
it's always returned by dcd_enumerate_object() when it hits the
end of list.

Reorganized the code so that it works like dynreg.out -ln from
the userspace-dspbridge package expects it to work.

Signed-off-by: Ionut Nicu ionut.n...@mindbit.ro
---
 drivers/staging/tidspbridge/rmgr/mgr.c |   48 ++--
 1 files changed, 15 insertions(+), 33 deletions(-)

diff --git a/drivers/staging/tidspbridge/rmgr/mgr.c 
b/drivers/staging/tidspbridge/rmgr/mgr.c
index 0ea89a1..b7b7e5b 100644
--- a/drivers/staging/tidspbridge/rmgr/mgr.c
+++ b/drivers/staging/tidspbridge/rmgr/mgr.c
@@ -134,8 +134,7 @@ int mgr_enum_node_info(u32 node_id, struct dsp_ndbprops 
*pndb_props,
  u32 undb_props_size, u32 *pu_num_nodes)
 {
int status = 0;
-   struct dsp_uuid node_uuid, temp_uuid;
-   u32 temp_index = 0;
+   struct dsp_uuid node_uuid;
u32 node_index = 0;
struct dcd_genericobj gen_obj;
struct mgr_object *pmgr_obj = NULL;
@@ -149,48 +148,31 @@ int mgr_enum_node_info(u32 node_id, struct dsp_ndbprops 
*pndb_props,
*pu_num_nodes = 0;
/* Get the Manager Object from the driver data */
if (!drv_datap || !drv_datap-mgr_object) {
-   status = -ENODATA;
pr_err(%s: Failed to retrieve the object handle\n, __func__);
-   goto func_cont;
-   } else {
-   pmgr_obj = drv_datap-mgr_object;
+   return -ENODATA;
}
+   pmgr_obj = drv_datap-mgr_object;
 
DBC_ASSERT(pmgr_obj);
/* Forever loop till we hit failed or no more items in the
 * Enumeration. We will exit the loop other than 0; */
while (status == 0) {
-   status = dcd_enumerate_object(temp_index++, DSP_DCDNODETYPE,
- temp_uuid);
-   if (status == 0) {
-   node_index++;
-   if (node_id == (node_index - 1))
-   node_uuid = temp_uuid;
-
-   }
-   }
-   if (!status) {
-   if (node_id  (node_index - 1)) {
-   status = -EINVAL;
-   } else {
+   status = dcd_enumerate_object(node_index++, DSP_DCDNODETYPE,
+   node_uuid);
+   if (status)
+   break;
+   *pu_num_nodes = node_index;
+   if (node_id == (node_index - 1)) {
status = dcd_get_object_def(pmgr_obj-hdcd_mgr,
-   (struct dsp_uuid *)
-   node_uuid, DSP_DCDNODETYPE,
-   gen_obj);
-   if (!status) {
-   /* Get the Obj def */
-   *pndb_props =
-   gen_obj.obj_data.node_obj.ndb_props;
-   *pu_num_nodes = node_index;
-   }
+   node_uuid, DSP_DCDNODETYPE, gen_obj);
+   if (status)
+   break;
+   /* Get the Obj def */
+   *pndb_props = gen_obj.obj_data.node_obj.ndb_props;
}
}
 
-func_cont:
-   DBC_ENSURE((!status  *pu_num_nodes  0) ||
-  (status  *pu_num_nodes == 0));
-
-   return status;
+   return status == ENODATA ? 0 : status;
 }
 
 /*
-- 
1.7.2.3

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/4] staging: tidspbridge: various cleanups

2010-10-22 Thread Ionut Nicu
This set of patches replaces some of the redundant components of
the tidspbridge driver, such as:

* wrapper functions for kmalloc/kfree
* custom bitmap implementation
* custom linked list implementation (list_head wrapper)

with the standard linux kernel interfaces.

The patches also do some code reorganization for increasing readability.
Most of the changes reduce the code indentation level and simplify the code.
No functional changes were done.

There are many places in this driver that need this kind of cleanup, but
these patches only fix the functions that were touched while switching
to struct list_head instead of struct lst_list.

Ionut Nicu (4):
  staging: tidspbridge: remove gs memory allocator
  staging: tidspbridge: remove utildefs
  staging: tidspbridge: remove gb bitmap implementation
  staging: tidspbridge: remove custom linked list

 drivers/staging/tidspbridge/Makefile   |2 +-
 drivers/staging/tidspbridge/TODO   |1 -
 drivers/staging/tidspbridge/core/_msg_sm.h |   12 +-
 drivers/staging/tidspbridge/core/chnl_sm.c |  631 --
 drivers/staging/tidspbridge/core/io_sm.c   |  250 +++
 drivers/staging/tidspbridge/core/msg_sm.c  |  600 +++--
 drivers/staging/tidspbridge/gen/gb.c   |  166 -
 drivers/staging/tidspbridge/gen/gh.c   |   38 +-
 drivers/staging/tidspbridge/gen/gs.c   |   88 ---
 .../tidspbridge/include/dspbridge/_chnl_sm.h   |8 +-
 .../tidspbridge/include/dspbridge/cmmdefs.h|2 -
 drivers/staging/tidspbridge/include/dspbridge/gb.h |   79 ---
 drivers/staging/tidspbridge/include/dspbridge/gs.h |   59 --
 .../staging/tidspbridge/include/dspbridge/list.h   |  225 ---
 .../staging/tidspbridge/include/dspbridge/sync.h   |1 +
 .../tidspbridge/include/dspbridge/utildefs.h   |   39 --
 drivers/staging/tidspbridge/pmgr/cmm.c |  538 ++-
 drivers/staging/tidspbridge/pmgr/dev.c |   65 +--
 drivers/staging/tidspbridge/rmgr/drv.c |  240 +++-
 drivers/staging/tidspbridge/rmgr/node.c|  702 +---
 drivers/staging/tidspbridge/rmgr/proc.c|3 +-
 drivers/staging/tidspbridge/rmgr/rmm.c |  314 --
 22 files changed, 1408 insertions(+), 2655 deletions(-)
 delete mode 100644 drivers/staging/tidspbridge/gen/gb.c
 delete mode 100644 drivers/staging/tidspbridge/gen/gs.c
 delete mode 100644 drivers/staging/tidspbridge/include/dspbridge/gb.h
 delete mode 100644 drivers/staging/tidspbridge/include/dspbridge/gs.h
 delete mode 100644 drivers/staging/tidspbridge/include/dspbridge/list.h
 delete mode 100644 drivers/staging/tidspbridge/include/dspbridge/utildefs.h

-- 
1.7.2.3

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/4] staging: tidspbridge: remove utildefs

2010-10-22 Thread Ionut Nicu
Remove a header file that was not very useful to
the dspbridge driver.

Signed-off-by: Ionut Nicu ionut.n...@mindbit.ro
---
 .../tidspbridge/include/dspbridge/utildefs.h   |   39 
 drivers/staging/tidspbridge/pmgr/cmm.c |9 +
 2 files changed, 1 insertions(+), 47 deletions(-)
 delete mode 100644 drivers/staging/tidspbridge/include/dspbridge/utildefs.h

diff --git a/drivers/staging/tidspbridge/include/dspbridge/utildefs.h 
b/drivers/staging/tidspbridge/include/dspbridge/utildefs.h
deleted file mode 100644
index 8fe5414..000
--- a/drivers/staging/tidspbridge/include/dspbridge/utildefs.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * utildefs.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Global UTIL constants and types, shared between DSP API and DSPSYS.
- *
- * 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.
- */
-
-#ifndef UTILDEFS_
-#define UTILDEFS_
-
-/* constants taken from configmg.h */
-#define UTIL_MAXMEMREGS 9
-#define UTIL_MAXIOPORTS 20
-#define UTIL_MAXIRQS7
-#define UTIL_MAXDMACHNLS7
-
-/* misc. constants */
-#define UTIL_MAXARGVS   10
-
-/* Platform specific important info */
-struct util_sysinfo {
-   /* Granularity of page protection; usually 1k or 4k */
-   u32 dw_page_size;
-   u32 dw_allocation_granularity;  /* VM granularity, usually 64K */
-   u32 dw_number_of_processors;/* Used as sanity check */
-};
-
-#endif /* UTILDEFS_ */
diff --git a/drivers/staging/tidspbridge/pmgr/cmm.c 
b/drivers/staging/tidspbridge/pmgr/cmm.c
index 93a7c4f..8dbdd20 100644
--- a/drivers/staging/tidspbridge/pmgr/cmm.c
+++ b/drivers/staging/tidspbridge/pmgr/cmm.c
@@ -40,7 +40,6 @@
 /*  --- OS Adaptation Layer */
 #include dspbridge/list.h
 #include dspbridge/sync.h
-#include dspbridge/utildefs.h
 
 /*  --- Platform Manager */
 #include dspbridge/dev.h
@@ -245,7 +244,6 @@ int cmm_create(struct cmm_object **ph_cmm_mgr,
 {
struct cmm_object *cmm_obj = NULL;
int status = 0;
-   struct util_sysinfo sys_info;
 
DBC_REQUIRE(refs  0);
DBC_REQUIRE(ph_cmm_mgr != NULL);
@@ -261,12 +259,7 @@ int cmm_create(struct cmm_object **ph_cmm_mgr,
DBC_ASSERT(mgr_attrts-ul_min_block_size = 4);
/* save away smallest block allocation for this cmm mgr */
cmm_obj-ul_min_block_size = mgr_attrts-ul_min_block_size;
-   /* save away the systems memory page size */
-   sys_info.dw_page_size = PAGE_SIZE;
-   sys_info.dw_allocation_granularity = PAGE_SIZE;
-   sys_info.dw_number_of_processors = 1;
-
-   cmm_obj-dw_page_size = sys_info.dw_page_size;
+   cmm_obj-dw_page_size = PAGE_SIZE;
 
/* Note: DSP SM seg table(aDSPSMSegTab[]) zero'd by
 * MEM_ALLOC_OBJECT */
-- 
1.7.2.3

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/4] staging: tidspbridge: remove gb bitmap implementation

2010-10-22 Thread Ionut Nicu
Replace the tidspbridge generic bitmap operations
with the linux generic bitmap implementation.

Signed-off-by: Ionut Nicu ionut.n...@mindbit.ro
---
 drivers/staging/tidspbridge/Makefile   |2 +-
 drivers/staging/tidspbridge/gen/gb.c   |  165 --
 drivers/staging/tidspbridge/include/dspbridge/gb.h |   79 ---
 drivers/staging/tidspbridge/rmgr/node.c|  599 +---
 4 files changed, 274 insertions(+), 571 deletions(-)
 delete mode 100644 drivers/staging/tidspbridge/gen/gb.c
 delete mode 100644 drivers/staging/tidspbridge/include/dspbridge/gb.h

diff --git a/drivers/staging/tidspbridge/Makefile 
b/drivers/staging/tidspbridge/Makefile
index aaf397f..6080e7e 100644
--- a/drivers/staging/tidspbridge/Makefile
+++ b/drivers/staging/tidspbridge/Makefile
@@ -1,6 +1,6 @@
 obj-$(CONFIG_TIDSPBRIDGE)  += bridgedriver.o
 
-libgen = gen/gb.o gen/gh.o gen/uuidutil.o
+libgen = gen/gh.o gen/uuidutil.o
 libcore = core/chnl_sm.o core/msg_sm.o core/io_sm.o core/tiomap3430.o \
core/tiomap3430_pwr.o core/tiomap_io.o core/dsp-mmu.o \
core/ue_deh.o core/wdt.o core/dsp-clock.o core/sync.o
diff --git a/drivers/staging/tidspbridge/gen/gb.c 
b/drivers/staging/tidspbridge/gen/gb.c
deleted file mode 100644
index 3c0e04c..000
--- a/drivers/staging/tidspbridge/gen/gb.c
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * gb.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Generic bitmap operations.
- *
- * 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.
- */
-
-/*  --- DSP/BIOS Bridge */
-#include linux/types.h
-/*  --- This */
-#include dspbridge/gb.h
-
-struct gb_t_map {
-   u32 len;
-   u32 wcnt;
-   u32 *words;
-};
-
-/*
- *   gb_clear 
- *  purpose:
- *  Clears a bit in the bit map.
- */
-
-void gb_clear(struct gb_t_map *map, u32 bitn)
-{
-   u32 mask;
-
-   mask = 1L  (bitn % BITS_PER_LONG);
-   map-words[bitn / BITS_PER_LONG] = ~mask;
-}
-
-/*
- *   gb_create 
- *  purpose:
- *  Creates a bit map.
- */
-
-struct gb_t_map *gb_create(u32 len)
-{
-   struct gb_t_map *map;
-   u32 i;
-   map = kzalloc(sizeof(struct gb_t_map), GFP_KERNEL);
-   if (map != NULL) {
-   map-len = len;
-   map-wcnt = len / BITS_PER_LONG + 1;
-   map-words = kzalloc(map-wcnt * sizeof(u32), GFP_KERNEL);
-   if (map-words != NULL) {
-   for (i = 0; i  map-wcnt; i++)
-   map-words[i] = 0L;
-
-   } else {
-   kfree(map);
-   map = NULL;
-   }
-   }
-
-   return map;
-}
-
-/*
- *   gb_delete 
- *  purpose:
- *  Frees a bit map.
- */
-
-void gb_delete(struct gb_t_map *map)
-{
-   kfree(map-words);
-   kfree(map);
-}
-
-/*
- *   gb_findandset 
- *  purpose:
- *  Finds a free bit and sets it.
- */
-u32 gb_findandset(struct gb_t_map *map)
-{
-   u32 bitn;
-
-   bitn = gb_minclear(map);
-
-   if (bitn != GB_NOBITS)
-   gb_set(map, bitn);
-
-   return bitn;
-}
-
-/*
- *   gb_minclear 
- *  purpose:
- *  returns the location of the first unset bit in the bit map.
- */
-u32 gb_minclear(struct gb_t_map *map)
-{
-   u32 bit_location = 0;
-   u32 bit_acc = 0;
-   u32 i;
-   u32 bit;
-   u32 *word;
-
-   for (word = map-words, i = 0; i  map-wcnt; word++, i++) {
-   if (~*word) {
-   for (bit = 0; bit  BITS_PER_LONG; bit++, bit_acc++) {
-   if (bit_acc == map-len)
-   return GB_NOBITS;
-
-   if (~*word  (1L  bit)) {
-   bit_location = i * BITS_PER_LONG + bit;
-   return bit_location;
-   }
-
-   }
-   } else {
-   bit_acc += BITS_PER_LONG;
-   }
-   }
-
-   return GB_NOBITS;
-}
-
-/*
- *   gb_set 
- *  purpose:
- *  Sets a bit in the bit map.
- */
-
-void gb_set(struct gb_t_map *map, u32 bitn)
-{
-   u32 mask;
-
-   mask = 1L  (bitn % BITS_PER_LONG);
-   map-words[bitn / BITS_PER_LONG] |= mask;
-}
-
-/*
- *   gb_test 
- *  purpose:
- *  Returns true if the bit is set in the specified location

[PATCH 1/4] staging: tidspbridge: remove gs memory allocator

2010-10-22 Thread Ionut Nicu
Remove unnecessary wrappers for linux kernel memory
allocation primitives.

Signed-off-by: Ionut Nicu ionut.n...@mindbit.ro
---
 drivers/staging/tidspbridge/Makefile   |2 +-
 drivers/staging/tidspbridge/gen/gb.c   |   11 +--
 drivers/staging/tidspbridge/gen/gh.c   |   38 ++---
 drivers/staging/tidspbridge/gen/gs.c   |   88 
 drivers/staging/tidspbridge/include/dspbridge/gs.h |   59 -
 5 files changed, 15 insertions(+), 183 deletions(-)
 delete mode 100644 drivers/staging/tidspbridge/gen/gs.c
 delete mode 100644 drivers/staging/tidspbridge/include/dspbridge/gs.h

diff --git a/drivers/staging/tidspbridge/Makefile 
b/drivers/staging/tidspbridge/Makefile
index 50decc2..aaf397f 100644
--- a/drivers/staging/tidspbridge/Makefile
+++ b/drivers/staging/tidspbridge/Makefile
@@ -1,6 +1,6 @@
 obj-$(CONFIG_TIDSPBRIDGE)  += bridgedriver.o
 
-libgen = gen/gb.o gen/gs.o gen/gh.o gen/uuidutil.o
+libgen = gen/gb.o gen/gh.o gen/uuidutil.o
 libcore = core/chnl_sm.o core/msg_sm.o core/io_sm.o core/tiomap3430.o \
core/tiomap3430_pwr.o core/tiomap_io.o core/dsp-mmu.o \
core/ue_deh.o core/wdt.o core/dsp-clock.o core/sync.o
diff --git a/drivers/staging/tidspbridge/gen/gb.c 
b/drivers/staging/tidspbridge/gen/gb.c
index 9f59023..3c0e04c 100644
--- a/drivers/staging/tidspbridge/gen/gb.c
+++ b/drivers/staging/tidspbridge/gen/gb.c
@@ -19,7 +19,6 @@
 /*  --- DSP/BIOS Bridge */
 #include linux/types.h
 /*  --- This */
-#include dspbridge/gs.h
 #include dspbridge/gb.h
 
 struct gb_t_map {
@@ -52,17 +51,17 @@ struct gb_t_map *gb_create(u32 len)
 {
struct gb_t_map *map;
u32 i;
-   map = (struct gb_t_map *)gs_alloc(sizeof(struct gb_t_map));
+   map = kzalloc(sizeof(struct gb_t_map), GFP_KERNEL);
if (map != NULL) {
map-len = len;
map-wcnt = len / BITS_PER_LONG + 1;
-   map-words = (u32 *) gs_alloc(map-wcnt * sizeof(u32));
+   map-words = kzalloc(map-wcnt * sizeof(u32), GFP_KERNEL);
if (map-words != NULL) {
for (i = 0; i  map-wcnt; i++)
map-words[i] = 0L;
 
} else {
-   gs_frees(map, sizeof(struct gb_t_map));
+   kfree(map);
map = NULL;
}
}
@@ -78,8 +77,8 @@ struct gb_t_map *gb_create(u32 len)
 
 void gb_delete(struct gb_t_map *map)
 {
-   gs_frees(map-words, map-wcnt * sizeof(u32));
-   gs_frees(map, sizeof(struct gb_t_map));
+   kfree(map-words);
+   kfree(map);
 }
 
 /*
diff --git a/drivers/staging/tidspbridge/gen/gh.c 
b/drivers/staging/tidspbridge/gen/gh.c
index f72d943..cd72503 100644
--- a/drivers/staging/tidspbridge/gen/gh.c
+++ b/drivers/staging/tidspbridge/gen/gh.c
@@ -17,9 +17,6 @@
 #include linux/types.h
 
 #include dspbridge/host_os.h
-
-#include dspbridge/gs.h
-
 #include dspbridge/gh.h
 
 struct element {
@@ -37,8 +34,6 @@ struct gh_t_hash_tab {
 };
 
 static void noop(void *p);
-static s32 cur_init;
-static void myfree(void *ptr, s32 size);
 
 /*
  *   gh_create 
@@ -51,8 +46,7 @@ struct gh_t_hash_tab *gh_create(u16 max_bucket, u16 val_size,
 {
struct gh_t_hash_tab *hash_tab;
u16 i;
-   hash_tab =
-   (struct gh_t_hash_tab *)gs_alloc(sizeof(struct gh_t_hash_tab));
+   hash_tab = kzalloc(sizeof(struct gh_t_hash_tab), GFP_KERNEL);
if (hash_tab == NULL)
return NULL;
hash_tab-max_bucket = max_bucket;
@@ -62,7 +56,7 @@ struct gh_t_hash_tab *gh_create(u16 max_bucket, u16 val_size,
hash_tab-delete = delete == NULL ? noop : delete;
 
hash_tab-buckets = (struct element **)
-   gs_alloc(sizeof(struct element *) * max_bucket);
+   kzalloc(sizeof(struct element *) * max_bucket, GFP_KERNEL);
if (hash_tab-buckets == NULL) {
gh_delete(hash_tab);
return NULL;
@@ -89,17 +83,14 @@ void gh_delete(struct gh_t_hash_tab *hash_tab)
 elem = next) {
next = elem-next;
(*hash_tab-delete) (elem-data);
-   myfree(elem,
-  sizeof(struct element) - 1 +
-  hash_tab-val_size);
+   kfree(elem);
}
}
 
-   myfree(hash_tab-buckets, sizeof(struct element *)
-  * hash_tab-max_bucket);
+   kfree(hash_tab-buckets);
}
 
-   myfree(hash_tab, sizeof(struct gh_t_hash_tab));
+   kfree(hash_tab);
}
 }
 
@@ -109,9 +100,7

Re: [PATCH 3/4] staging: tidspbridge: remove gb bitmap implementation

2010-10-22 Thread Ionut Nicu
Hi Andy,

On Fri, 2010-10-22 at 16:18 +0300, Andy Shevchenko wrote:
 Briefly I see the clean up of the code as well, which is not related
 to the mentioned description.
 I guess it would be better to split this patch at least to two.
 

Point taken. I will split this patch into 2 patches: one that converts
gb to bitmap and one which does the code cleanup.

Most likely I will have to break patch 4/4 from this series (which I
also believe is way too big) into multiple patches and re-submit.

I'm expecting some advices from the maintainers/list on how to split
patch 4 (lst_list removal).

Thanks,
Ionut.

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] staging: tidspbridge: make the MGR_ENUMNODE_INFO ioctl work

2010-10-22 Thread Ionut Nicu
Hi Felipe,

On Fri, 2010-10-22 at 16:36 +0300, Felipe Contreras wrote:
 On Fri, Oct 22, 2010 at 3:59 PM, Ionut Nicu ionut.n...@gmail.com wrote:
  The current code was always returning a non-zero status value
  to userspace applications when this ioctl was called.
 
  The error code was ENODATA, which isn't actually an error,
  it's always returned by dcd_enumerate_object() when it hits the
  end of list.
 
  Reorganized the code so that it works like dynreg.out -ln from
  the userspace-dspbridge package expects it to work.
 
  Signed-off-by: Ionut Nicu ionut.n...@mindbit.ro
 
 I also found this issue, but I have simpler fix. I think my fix should
 be applied first, and then your reorganization.
 

Yeah, mine looks more complex because of the code cleanup in
mgr_enum_node_info().

Anyway I don't have anything against applying your patch first. If your
patch gets merged, I'll rebase my changes and submit a new one with the
code cleanup.

 From 16759e41adc11ad1f34b757dcf19fe55c84bcfc2 Mon Sep 17 00:00:00 2001
 From: Felipe Contreras felipe.contre...@gmail.com
 Date: Sun, 19 Sep 2010 14:52:42 +0300
 Subject: [PATCH] staging: tidspbridge: fix mgr_enum_node_info
 
 It's always erroring out.
 
 Signed-off-by: Felipe Contreras felipe.contre...@gmail.com
 ---
  drivers/staging/tidspbridge/rmgr/mgr.c |5 +
  1 files changed, 5 insertions(+), 0 deletions(-)
 
 diff --git a/drivers/staging/tidspbridge/rmgr/mgr.c
 b/drivers/staging/tidspbridge/rmgr/mgr.c
 index 57a39b9..4ba9517 100644
 --- a/drivers/staging/tidspbridge/rmgr/mgr.c
 +++ b/drivers/staging/tidspbridge/rmgr/mgr.c
 @@ -148,6 +148,11 @@ int mgr_enum_node_info(u32 node_id, struct
 dsp_ndbprops *pndb_props,
 
   }
   }
 +
 + /* the last status is not 0, but neither an error */
 + if (status  0)
 + status = 0;
 +
   if (!status) {
   if (node_id  (node_index - 1)) {
   status = -EINVAL;
 

Acked-by: Ionut Nicu ionut.n...@mindbit.ro

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCHv3 01/11] staging: tidspbridge: replace iommu custom for opensource implementation

2010-10-18 Thread Ionut Nicu
Hi,

On Mon, 2010-10-18 at 01:36 +0300, Felipe Contreras wrote: 
 On Tue, Oct 5, 2010 at 11:35 PM, Fernando Guzman Lugo x0095...@ti.com wrote:
  Now the tidspbridge uses the API's from
  iovmm module.
 
  Signed-off-by: Fernando Guzman Lugo x0095...@ti.com
 
 NAK. This patch doesn't work... I guess it's supposed to.
 
 So far I've found these errors, but it still doesn't work, maybe we
 should start thinking of reverting the whole iommu stuff:
 

I also tested it with the userspace-dspbridge tools and it doesn't work
for me either.

Maybe it's better to revert this patch series for now and re-submit it
when all necessary patches get merged and it actually works on top of
the staging-next tree?

Regards,
Ionut.

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: DSP fails to Initialise due to memory map

2010-10-14 Thread Ionut Nicu
Hi,

On Thu, 2010-10-14 at 15:49 +1100, John Garland wrote:
 Hi,
 
 using both dspbridge (5b4ec5f459a64b70a01d00a2dae9d79dc2a93c0c) and pm
 (e0bcaca00bb6cc2d79c8c3b765f969e00a3d313b) branches,
 I get a memory map failure when trying to load the dspbridge module
 (I've attached the traceback).
 

It's a memory allocation failure for the SHM area which is very large (6
MB of continuous memory). You have to reserve some memory outside of the
kernel control for that (use the mem parameter in your bootargs).

 Has anyone else experienced this?
 Is there a series of patches I need to apply?
 

Try this patch:

http://www.spinics.net/lists/linux-omap/msg38350.html

However, even with this patch, don't expect everything to work just yet.
I got the kernel module to load, but when I try to run some tests (e.g.
load an image with the cexec tool from userspace-dspbridge), I get a
node allocation failure. I didn't have time to debug it further ...

We're probably missing some patches that were not applied yet to the
staging tree ...

Cheers,
Ionut.

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Hang on boot

2010-10-11 Thread Ionut Nicu
Hi,

On Mon, 2010-10-11 at 14:09 +1100, John Garland wrote:
 Hi,
 
 Both the dspbridge and master branch of linux-omap seem to hang when
 trying to boot (i.e. no output) on a beagleboard C2.
 This is with the new omap2plus_defconfig (as opposed to the old
 omap3_defconfig).
 
 Is anybody else experiencing this or does anyone have any idea what
 could be causing this?
 

Make sure you update your u-boot environment so that you have
console=ttyO2,115200 in your kernel command line (btw, it's ttyO2, not
tty02). It's been recently changed in the linux-omap tree (commit
d6e284d).

You'll probably also need to update your /etc/inittab.

Cheers,
Ionut.


--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


tidspbridge compilation broken

2010-10-09 Thread Ionut Nicu
Hi,

I'm trying to compile the tidspbridge driver from the dspbridge branch
of the linux-omap git tree and I stumbled upon a few compilation
problems:

1. First is related to the missing header plat/dsp.h added by the
following patch which was not applied to this branch:

http://marc.info/?l=linux-omapm=128620861805925w=2

2. The second one is related to the missing header plat/control.h which
was moved by a recent commit (81bb9b6) from plat to mach-omap2. The
dspbridge driver requires a few defines from that header but as far as I
understand, that header file is no longer supposed to be accessible by
drivers. Any suggestion on how to fix that in dspbridge?

3. There's a link error triggered by the new iommu dependency. It's
fairly trivial to fix. I will submit a patch for this.

Thanks,
Ionut.

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] tidspbridge: select OMAP_IOMMU dependency

2010-10-09 Thread Ionut Nicu
Since the iommu migration patches tidspbridge depends
on the OMAP specific IOMMU implementation. We need to
add this dependency, otherwise we'll have link time
errors.

Signed-off-by: Ionut Nicu ionut.n...@mindbit.ro
---
 drivers/staging/tidspbridge/Kconfig |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/tidspbridge/Kconfig 
b/drivers/staging/tidspbridge/Kconfig
index 93de4f2..ff64d46 100644
--- a/drivers/staging/tidspbridge/Kconfig
+++ b/drivers/staging/tidspbridge/Kconfig
@@ -6,6 +6,7 @@ menuconfig TIDSPBRIDGE
tristate DSP Bridge driver
depends on ARCH_OMAP3
select OMAP_MBOX_FWK
+   select OMAP_IOMMU
help
  DSP/BIOS Bridge is designed for platforms that contain a GPP and
  one or more attached DSPs.  The GPP is considered the master or
-- 
1.7.2.3

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] tidspbridge: remove gs memory allocator

2010-10-09 Thread Ionut Nicu
Remove un-necessary wrappers for linux kernel memory
allocation primitives.

Signed-off-by: Ionut Nicu ionut.n...@mindbit.ro
---
 drivers/staging/tidspbridge/Makefile   |2 +-
 drivers/staging/tidspbridge/gen/gb.c   |   11 +--
 drivers/staging/tidspbridge/gen/gh.c   |   38 ++---
 drivers/staging/tidspbridge/gen/gs.c   |   88 
 drivers/staging/tidspbridge/include/dspbridge/gs.h |   59 -
 5 files changed, 15 insertions(+), 183 deletions(-)
 delete mode 100644 drivers/staging/tidspbridge/gen/gs.c
 delete mode 100644 drivers/staging/tidspbridge/include/dspbridge/gs.h

diff --git a/drivers/staging/tidspbridge/Makefile 
b/drivers/staging/tidspbridge/Makefile
index 7c122fa..28c5aa8 100644
--- a/drivers/staging/tidspbridge/Makefile
+++ b/drivers/staging/tidspbridge/Makefile
@@ -1,6 +1,6 @@
 obj-$(CONFIG_TIDSPBRIDGE)  += bridgedriver.o
 
-libgen = gen/gb.o gen/gs.o gen/gh.o gen/uuidutil.o
+libgen = gen/gb.o gen/gh.o gen/uuidutil.o
 libcore = core/chnl_sm.o core/msg_sm.o core/io_sm.o core/tiomap3430.o \
core/tiomap3430_pwr.o core/tiomap_io.o core/dsp-mmu.o \
core/ue_deh.o core/wdt.o core/dsp-clock.o core/sync.o
diff --git a/drivers/staging/tidspbridge/gen/gb.c 
b/drivers/staging/tidspbridge/gen/gb.c
index 9f59023..3c0e04c 100644
--- a/drivers/staging/tidspbridge/gen/gb.c
+++ b/drivers/staging/tidspbridge/gen/gb.c
@@ -19,7 +19,6 @@
 /*  --- DSP/BIOS Bridge */
 #include linux/types.h
 /*  --- This */
-#include dspbridge/gs.h
 #include dspbridge/gb.h
 
 struct gb_t_map {
@@ -52,17 +51,17 @@ struct gb_t_map *gb_create(u32 len)
 {
struct gb_t_map *map;
u32 i;
-   map = (struct gb_t_map *)gs_alloc(sizeof(struct gb_t_map));
+   map = kzalloc(sizeof(struct gb_t_map), GFP_KERNEL);
if (map != NULL) {
map-len = len;
map-wcnt = len / BITS_PER_LONG + 1;
-   map-words = (u32 *) gs_alloc(map-wcnt * sizeof(u32));
+   map-words = kzalloc(map-wcnt * sizeof(u32), GFP_KERNEL);
if (map-words != NULL) {
for (i = 0; i  map-wcnt; i++)
map-words[i] = 0L;
 
} else {
-   gs_frees(map, sizeof(struct gb_t_map));
+   kfree(map);
map = NULL;
}
}
@@ -78,8 +77,8 @@ struct gb_t_map *gb_create(u32 len)
 
 void gb_delete(struct gb_t_map *map)
 {
-   gs_frees(map-words, map-wcnt * sizeof(u32));
-   gs_frees(map, sizeof(struct gb_t_map));
+   kfree(map-words);
+   kfree(map);
 }
 
 /*
diff --git a/drivers/staging/tidspbridge/gen/gh.c 
b/drivers/staging/tidspbridge/gen/gh.c
index f72d943..cd72503 100644
--- a/drivers/staging/tidspbridge/gen/gh.c
+++ b/drivers/staging/tidspbridge/gen/gh.c
@@ -17,9 +17,6 @@
 #include linux/types.h
 
 #include dspbridge/host_os.h
-
-#include dspbridge/gs.h
-
 #include dspbridge/gh.h
 
 struct element {
@@ -37,8 +34,6 @@ struct gh_t_hash_tab {
 };
 
 static void noop(void *p);
-static s32 cur_init;
-static void myfree(void *ptr, s32 size);
 
 /*
  *   gh_create 
@@ -51,8 +46,7 @@ struct gh_t_hash_tab *gh_create(u16 max_bucket, u16 val_size,
 {
struct gh_t_hash_tab *hash_tab;
u16 i;
-   hash_tab =
-   (struct gh_t_hash_tab *)gs_alloc(sizeof(struct gh_t_hash_tab));
+   hash_tab = kzalloc(sizeof(struct gh_t_hash_tab), GFP_KERNEL);
if (hash_tab == NULL)
return NULL;
hash_tab-max_bucket = max_bucket;
@@ -62,7 +56,7 @@ struct gh_t_hash_tab *gh_create(u16 max_bucket, u16 val_size,
hash_tab-delete = delete == NULL ? noop : delete;
 
hash_tab-buckets = (struct element **)
-   gs_alloc(sizeof(struct element *) * max_bucket);
+   kzalloc(sizeof(struct element *) * max_bucket, GFP_KERNEL);
if (hash_tab-buckets == NULL) {
gh_delete(hash_tab);
return NULL;
@@ -89,17 +83,14 @@ void gh_delete(struct gh_t_hash_tab *hash_tab)
 elem = next) {
next = elem-next;
(*hash_tab-delete) (elem-data);
-   myfree(elem,
-  sizeof(struct element) - 1 +
-  hash_tab-val_size);
+   kfree(elem);
}
}
 
-   myfree(hash_tab-buckets, sizeof(struct element *)
-  * hash_tab-max_bucket);
+   kfree(hash_tab-buckets);
}
 
-   myfree(hash_tab, sizeof(struct gh_t_hash_tab));
+   kfree(hash_tab);
}
 }
 
@@ -109,9 +100,7