aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw/mthca/mthca_mr.c
diff options
context:
space:
mode:
authorRoland Dreier <roland@topspin.com>2005-06-27 17:36:43 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-27 18:11:45 -0400
commita03a5a67b243e9a24805ee18272ad25e5b2ca92c (patch)
tree5e4a1d3ec8482a482caa6697cba12a819ef6aa8a /drivers/infiniband/hw/mthca/mthca_mr.c
parenta852092e8cb305595ff630dfc3e9b25966a98276 (diff)
[PATCH] IB/mthca: Move mthca_is_memfree checks
Make mthca_table_put() and mthca_table_put_range() NOPs if the device is not mem-free, so that we don't have to have "if (mthca_is_memfree())" tests in the callers of these functions. This makes our code more readable and maintainable, and saves a couple dozen bytes of text in ib_mthca.ko as well. Signed-off-by: Roland Dreier <roland@topspin.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/infiniband/hw/mthca/mthca_mr.c')
-rw-r--r--drivers/infiniband/hw/mthca/mthca_mr.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
index 8960fc2306be..29e5fe708b83 100644
--- a/drivers/infiniband/hw/mthca/mthca_mr.c
+++ b/drivers/infiniband/hw/mthca/mthca_mr.c
@@ -195,10 +195,8 @@ static void mthca_free_mtt(struct mthca_dev *dev, u32 seg, int order,
195 struct mthca_buddy* buddy) 195 struct mthca_buddy* buddy)
196{ 196{
197 mthca_buddy_free(buddy, seg, order); 197 mthca_buddy_free(buddy, seg, order);
198 198 mthca_table_put_range(dev, dev->mr_table.mtt_table, seg,
199 if (mthca_is_memfree(dev)) 199 seg + (1 << order) - 1);
200 mthca_table_put_range(dev, dev->mr_table.mtt_table, seg,
201 seg + (1 << order) - 1);
202} 200}
203 201
204static inline u32 tavor_hw_index_to_key(u32 ind) 202static inline u32 tavor_hw_index_to_key(u32 ind)
@@ -299,8 +297,7 @@ int mthca_mr_alloc_notrans(struct mthca_dev *dev, u32 pd,
299 return err; 297 return err;
300 298
301err_out_table: 299err_out_table:
302 if (mthca_is_memfree(dev)) 300 mthca_table_put(dev, dev->mr_table.mpt_table, key);
303 mthca_table_put(dev, dev->mr_table.mpt_table, key);
304 301
305err_out_mpt_free: 302err_out_mpt_free:
306 mthca_free(&dev->mr_table.mpt_alloc, key); 303 mthca_free(&dev->mr_table.mpt_alloc, key);
@@ -437,8 +434,7 @@ err_out_free_mtt:
437 mthca_free_mtt(dev, mr->first_seg, mr->order, &dev->mr_table.mtt_buddy); 434 mthca_free_mtt(dev, mr->first_seg, mr->order, &dev->mr_table.mtt_buddy);
438 435
439err_out_table: 436err_out_table:
440 if (mthca_is_memfree(dev)) 437 mthca_table_put(dev, dev->mr_table.mpt_table, key);
441 mthca_table_put(dev, dev->mr_table.mpt_table, key);
442 438
443err_out_mpt_free: 439err_out_mpt_free:
444 mthca_free(&dev->mr_table.mpt_alloc, key); 440 mthca_free(&dev->mr_table.mpt_alloc, key);
@@ -452,9 +448,8 @@ static void mthca_free_region(struct mthca_dev *dev, u32 lkey, int order,
452 if (order >= 0) 448 if (order >= 0)
453 mthca_free_mtt(dev, first_seg, order, buddy); 449 mthca_free_mtt(dev, first_seg, order, buddy);
454 450
455 if (mthca_is_memfree(dev)) 451 mthca_table_put(dev, dev->mr_table.mpt_table,
456 mthca_table_put(dev, dev->mr_table.mpt_table, 452 arbel_key_to_hw_index(lkey));
457 arbel_key_to_hw_index(lkey));
458 453
459 mthca_free(&dev->mr_table.mpt_alloc, key_to_hw_index(dev, lkey)); 454 mthca_free(&dev->mr_table.mpt_alloc, key_to_hw_index(dev, lkey));
460} 455}
@@ -596,8 +591,7 @@ err_out_free_mtt:
596 dev->mr_table.fmr_mtt_buddy); 591 dev->mr_table.fmr_mtt_buddy);
597 592
598err_out_table: 593err_out_table:
599 if (mthca_is_memfree(dev)) 594 mthca_table_put(dev, dev->mr_table.mpt_table, key);
600 mthca_table_put(dev, dev->mr_table.mpt_table, key);
601 595
602err_out_mpt_free: 596err_out_mpt_free:
603 mthca_free(&dev->mr_table.mpt_alloc, mr->ibmr.lkey); 597 mthca_free(&dev->mr_table.mpt_alloc, mr->ibmr.lkey);