Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 33114
b: refs/heads/master
c: 69e9fbb
h: refs/heads/master
v: v3
  • Loading branch information
Roland Dreier committed Aug 3, 2006
1 parent eba507d commit 3e91140
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: bf74c7479ef47652005a2418eeb0d867451690da
refs/heads/master: 69e9fbb460fa8766428960439841ffcf565032c1
15 changes: 7 additions & 8 deletions trunk/drivers/infiniband/hw/mthca/mthca_allocator.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,15 @@ void mthca_alloc_cleanup(struct mthca_alloc *alloc)
* serialize access to the array.
*/

#define MTHCA_ARRAY_MASK (PAGE_SIZE / sizeof (void *) - 1)

void *mthca_array_get(struct mthca_array *array, int index)
{
int p = (index * sizeof (void *)) >> PAGE_SHIFT;

if (array->page_list[p].page) {
int i = index & (PAGE_SIZE / sizeof (void *) - 1);
return array->page_list[p].page[i];
} else
if (array->page_list[p].page)
return array->page_list[p].page[index & MTHCA_ARRAY_MASK];
else
return NULL;
}

Expand All @@ -130,8 +131,7 @@ int mthca_array_set(struct mthca_array *array, int index, void *value)
if (!array->page_list[p].page)
return -ENOMEM;

array->page_list[p].page[index & (PAGE_SIZE / sizeof (void *) - 1)] =
value;
array->page_list[p].page[index & MTHCA_ARRAY_MASK] = value;
++array->page_list[p].used;

return 0;
Expand All @@ -145,8 +145,7 @@ void mthca_array_clear(struct mthca_array *array, int index)
free_page((unsigned long) array->page_list[p].page);
array->page_list[p].page = NULL;
} else
array->page_list[p].page[index & (PAGE_SIZE /
sizeof (void *) - 1)] = NULL;
array->page_list[p].page[index & MTHCA_ARRAY_MASK] = NULL;

if (array->page_list[p].used < 0)
pr_debug("Array %p index %d page %d with ref count %d < 0\n",
Expand Down

0 comments on commit 3e91140

Please sign in to comment.