From e730c8cd583475e307a128afaa254ce505210a8e Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Mon, 11 Feb 2019 00:08:28 +0000 Subject: [PATCH] scst_user: Introduce a helper function This patch does not change any functionality. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7914 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/dev_handlers/scst_user.c | 39 ++++++++++++++++++------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/scst/src/dev_handlers/scst_user.c b/scst/src/dev_handlers/scst_user.c index 628e1c0b4..8fb443814 100644 --- a/scst/src/dev_handlers/scst_user.c +++ b/scst/src/dev_handlers/scst_user.c @@ -3953,6 +3953,28 @@ out: return 0; } +#ifdef CONFIG_SCST_EXTRACHECKS +static void dev_user_check_lost_ucmds(struct scst_user_dev *dev) +{ + int i; + + for (i = 0; i < (int)ARRAY_SIZE(dev->ucmd_hash); i++) { + struct list_head *head = &dev->ucmd_hash[i]; + struct scst_user_cmd *ucmd2, *tmp; + + list_for_each_entry_safe(ucmd2, tmp, head, hash_list_entry) { + PRINT_ERROR("Lost ucmd %p (state %x, ref %d)", ucmd2, + ucmd2->state, atomic_read(&ucmd2->ucmd_ref)); + ucmd_put(ucmd2); + } + } +} +#else +static void dev_user_check_lost_ucmds(struct scst_user_dev *dev) +{ +} +#endif + static int dev_user_process_cleanup(struct scst_user_dev *dev) { struct scst_user_cmd *ucmd; @@ -3988,22 +4010,7 @@ static int dev_user_process_cleanup(struct scst_user_dev *dev) } } -#ifdef CONFIG_SCST_EXTRACHECKS -{ - int i; - - for (i = 0; i < (int)ARRAY_SIZE(dev->ucmd_hash); i++) { - struct list_head *head = &dev->ucmd_hash[i]; - struct scst_user_cmd *ucmd2, *tmp; - - list_for_each_entry_safe(ucmd2, tmp, head, hash_list_entry) { - PRINT_ERROR("Lost ucmd %p (state %x, ref %d)", ucmd2, - ucmd2->state, atomic_read(&ucmd2->ucmd_ref)); - ucmd_put(ucmd2); - } - } -} -#endif + dev_user_check_lost_ucmds(dev); TRACE_DBG("Cleanuping done (dev %p)", dev); complete_all(&dev->cleanup_cmpl);