From 3e91140cb7d33ecdcfe664d3353112cfdbe57eaa Mon Sep 17 00:00:00 2001 From: Roland Dreier Date: Thu, 3 Aug 2006 09:44:22 -0700 Subject: [PATCH] --- yaml --- r: 33114 b: refs/heads/master c: 69e9fbb460fa8766428960439841ffcf565032c1 h: refs/heads/master v: v3 --- [refs] | 2 +- .../drivers/infiniband/hw/mthca/mthca_allocator.c | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/[refs] b/[refs] index 8560b9f40f68..6729c8e14a14 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: bf74c7479ef47652005a2418eeb0d867451690da +refs/heads/master: 69e9fbb460fa8766428960439841ffcf565032c1 diff --git a/trunk/drivers/infiniband/hw/mthca/mthca_allocator.c b/trunk/drivers/infiniband/hw/mthca/mthca_allocator.c index 848e583273d4..25157f57a6d0 100644 --- a/trunk/drivers/infiniband/hw/mthca/mthca_allocator.c +++ b/trunk/drivers/infiniband/hw/mthca/mthca_allocator.c @@ -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; } @@ -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; @@ -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",