From b2d0960b57a2a3c8d3641028a1be3fb2ddc380d9 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 21 May 2009 06:54:42 +0000 Subject: [PATCH] Moved the code for freeing the ring of I/O context structures to a separate function. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@875 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- srpt/src/ib_srpt.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index 94c4cc3ea..05c45dfda 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -582,6 +582,17 @@ err: return -ENOMEM; } +/* Free the ring of SRPT I/O context structures. */ +static void srpt_free_ioctx_ring(struct srpt_device *sdev) +{ + int i; + + for (i = 0; i < SRPT_SRQ_SIZE; ++i) { + srpt_free_ioctx(sdev, sdev->ioctx_ring[i]); + sdev->ioctx_ring[i] = NULL; + } +} + /* * Post a receive request on the work queue of InfiniBand device 'sdev'. */ @@ -2473,10 +2484,9 @@ free_dev: static void srpt_remove_one(struct ib_device *device) { struct srpt_device *sdev; - int i; sdev = ib_get_client_data(device, &srpt_client); - if (!sdev) + if (!WARN_ON(sdev)) return; wait_for_completion(&sdev->scst_released); @@ -2492,9 +2502,7 @@ static void srpt_remove_one(struct ib_device *device) device_unregister(&sdev->dev); #endif - for (i = 0; i < SRPT_SRQ_SIZE; ++i) - srpt_free_ioctx(sdev, sdev->ioctx_ring[i]); - + srpt_free_ioctx_ring(sdev); list_del(&sdev->list); kfree(sdev); }