The patch below fixes the following:
authorvlnb <vlnb@d57e44dd-8a1f-0410-8b47-8ef2f437770f>
Thu, 30 Oct 2008 20:17:42 +0000 (20:17 +0000)
committervlnb <vlnb@d57e44dd-8a1f-0410-8b47-8ef2f437770f>
Thu, 30 Oct 2008 20:17:42 +0000 (20:17 +0000)
* Lots of checkpatch warnings about lines over 80 characters.
* Checkpatch errors about code indent should use tabs where possible (same issues as reported by Dotan Barak).
* One checkpatch warning about braces {} are not necessary for single statement blocks.
* Sparse warnings about missing declarations.
* Sparse warnings about using 0 instead of NULL.

This patch has been verified by reviewing it carefully and by verifying the
output files of the command scripts/run-regression-tests -k 2.6.27.3.

Signed-off-by: Bart Van Assche <bart.vanassche@gmail.com>
With changes

git-svn-id: https://scst.svn.sourceforge.net/svnroot/scst/trunk@555 d57e44dd-8a1f-0410-8b47-8ef2f437770f

scst/src/scst_cdbprobe.h
scst/src/scst_debug.c
scst/src/scst_lib.c
scst/src/scst_main.c
scst/src/scst_mem.c
scst/src/scst_mem.h
scst/src/scst_priv.h
scst/src/scst_proc.c
scst/src/scst_targ.c

index 11f3555..51d4ded 100644 (file)
@@ -82,7 +82,8 @@ struct scst_sdbops {
                                 */
        uint8_t flags;          /* opcode --  various flags */
        uint8_t off;            /* length offset in cdb */
-       int (*get_trans_len)(struct scst_cmd *cmd, uint8_t off) __attribute__ ((aligned));
+       int (*get_trans_len)(struct scst_cmd *cmd, uint8_t off)
+               __attribute__ ((aligned));
 }  __attribute__((packed));
 
 static int scst_scsi_op_list[256];
@@ -120,7 +121,8 @@ static const struct scst_sdbops scst_scsi_op_table[] = {
        {0x03, "MMMMMMMMMMMMMMMM", "REQUEST SENSE",
         SCST_DATA_READ, SCST_SMALL_TIMEOUT, 4, get_trans_len_1},
        {0x04, "M    O O        ", "FORMAT UNIT",
-        SCST_DATA_WRITE, SCST_LONG_TIMEOUT|SCST_UNKNOWN_LENGTH, 0, get_trans_len_none},
+        SCST_DATA_WRITE, SCST_LONG_TIMEOUT|SCST_UNKNOWN_LENGTH,
+        0, get_trans_len_none},
        {0x04, "  O             ", "FORMAT",
         SCST_DATA_NONE, FLAG_NONE, 0, get_trans_len_none},
        {0x05, "VMVVVV  V       ", "READ BLOCK LIMITS",
@@ -175,7 +177,7 @@ static const struct scst_sdbops scst_scsi_op_table[] = {
         SCST_DATA_READ, SCST_SMALL_TIMEOUT, 4, get_trans_len_1},
        {0x13, "VOVVVV          ", "VERIFY(6)",
         SCST_DATA_NONE, SCST_TRANSFER_LEN_TYPE_FIXED|
-                        SCST_VERIFY_BYTCHK_MISMATCH_ALLOWED,
+                        SCST_VERIFY_BYTCHK_MISMATCH_ALLOWED,
         2, get_trans_len_3},
        {0x14, "VOOVVV          ", "RECOVER BUFFERED DATA",
         SCST_DATA_READ, SCST_TRANSFER_LEN_TYPE_FIXED, 2, get_trans_len_3},
@@ -253,7 +255,7 @@ static const struct scst_sdbops scst_scsi_op_table[] = {
         SCST_DATA_WRITE, SCST_TRANSFER_LEN_TYPE_FIXED, 7, get_trans_len_2},
        {0x2F, "O   OO O        ", "VERIFY(10)",
         SCST_DATA_NONE, SCST_TRANSFER_LEN_TYPE_FIXED|
-                        SCST_VERIFY_BYTCHK_MISMATCH_ALLOWED,
+                        SCST_VERIFY_BYTCHK_MISMATCH_ALLOWED,
         7, get_trans_len_2},
        {0x33, "O   OO O        ", "SET LIMITS(10)",
         SCST_DATA_NONE, FLAG_NONE, 0, get_trans_len_none},
@@ -280,7 +282,8 @@ static const struct scst_sdbops scst_scsi_op_table[] = {
        {0x3C, "OOOOOOOOOOOOOOOO", "READ BUFFER",
         SCST_DATA_READ, SCST_SMALL_TIMEOUT, 6, get_trans_len_3},
        {0x3D, "    O  O        ", "UPDATE BLOCK",
-        SCST_DATA_WRITE, SCST_TRANSFER_LEN_TYPE_FIXED, 0, get_trans_len_single},
+        SCST_DATA_WRITE, SCST_TRANSFER_LEN_TYPE_FIXED,
+        0, get_trans_len_single},
        {0x3E, "O   OO O        ", "READ LONG",
         SCST_DATA_READ, FLAG_NONE, 7, get_trans_len_2},
        {0x3F, "O   O  O        ", "WRITE LONG",
@@ -288,7 +291,8 @@ static const struct scst_sdbops scst_scsi_op_table[] = {
        {0x40, "OOOOOOOOOO      ", "CHANGE DEFINITION",
         SCST_DATA_WRITE, SCST_SMALL_TIMEOUT, 8, get_trans_len_1},
        {0x41, "O    O          ", "WRITE SAME",
-        SCST_DATA_WRITE, SCST_TRANSFER_LEN_TYPE_FIXED, 0, get_trans_len_single},
+        SCST_DATA_WRITE, SCST_TRANSFER_LEN_TYPE_FIXED,
+        0, get_trans_len_single},
        {0x42, "     O          ", "READ SUB-CHANNEL",
         SCST_DATA_READ, FLAG_NONE, 7, get_trans_len_2},
        {0x43, "     O          ", "READ TOC/PMA/ATIP",
@@ -383,7 +387,7 @@ static const struct scst_sdbops scst_scsi_op_table[] = {
         SCST_DATA_WRITE, SCST_TRANSFER_LEN_TYPE_FIXED, 10, get_trans_len_4},
        {0x8F, "O   OO O        ", "VERIFY(16)",
         SCST_DATA_NONE, SCST_TRANSFER_LEN_TYPE_FIXED|
-                        SCST_VERIFY_BYTCHK_MISMATCH_ALLOWED,
+                        SCST_VERIFY_BYTCHK_MISMATCH_ALLOWED,
         10, get_trans_len_4},
        {0x90, "O   OO O        ", "PRE-FETCH(16)",
         SCST_DATA_NONE, FLAG_NONE, 0, get_trans_len_none},
@@ -449,7 +453,7 @@ static const struct scst_sdbops scst_scsi_op_table[] = {
         SCST_DATA_WRITE, SCST_TRANSFER_LEN_TYPE_FIXED, 6, get_trans_len_4},
        {0xAF, "O   OO O        ", "VERIFY(12)",
         SCST_DATA_NONE, SCST_TRANSFER_LEN_TYPE_FIXED|
-                        SCST_VERIFY_BYTCHK_MISMATCH_ALLOWED,
+                        SCST_VERIFY_BYTCHK_MISMATCH_ALLOWED,
         6, get_trans_len_4},
 /* No need to support at all.
        {0xB0, "    OO O        ", "SEARCH DATA HIGH(12)",
@@ -509,6 +513,7 @@ static const struct scst_sdbops scst_scsi_op_table[] = {
        #define WRITE_LONG_2                    0xea
 */
 
-#define SCST_CDB_TBL_SIZE ((int)(sizeof(scst_scsi_op_table)/sizeof(struct scst_sdbops)))
+#define SCST_CDB_TBL_SIZE \
+       ((int)(sizeof(scst_scsi_op_table)/sizeof(struct scst_sdbops)))
 
 #endif /* __SCST_CDBPROBE_H */
index 68fb502..3ca5780 100644 (file)
@@ -58,7 +58,8 @@ int debug_print_prefix(unsigned long trace_flag, const char *log_level,
                i += snprintf(&trace_buf[i], TRACE_BUF_SIZE, "[%d]: ",
                              get_current_tid());
        if (prefix != NULL)
-               i += snprintf(&trace_buf[i], TRACE_BUF_SIZE - i, "%s: ", prefix);
+               i += snprintf(&trace_buf[i], TRACE_BUF_SIZE - i, "%s: ",
+                             prefix);
        if (trace_flag & TRACE_FUNCTION)
                i += snprintf(&trace_buf[i], TRACE_BUF_SIZE - i, "%s:", func);
        if (trace_flag & TRACE_LINE)
index 3fb7690..9ede835 100644 (file)
@@ -342,7 +342,7 @@ void scst_init_mem_lim(struct scst_mem_lim *mem_lim)
 }
 EXPORT_SYMBOL(scst_init_mem_lim);
 
-struct scst_acg_dev *scst_alloc_acg_dev(struct scst_acg *acg,
+static struct scst_acg_dev *scst_alloc_acg_dev(struct scst_acg *acg,
                                        struct scst_device *dev, uint64_t lun)
 {
        struct scst_acg_dev *res;
@@ -355,7 +355,8 @@ struct scst_acg_dev *scst_alloc_acg_dev(struct scst_acg *acg,
        res = kmem_cache_zalloc(scst_acgd_cachep, GFP_KERNEL);
 #endif
        if (res == NULL) {
-               TRACE(TRACE_OUT_OF_MEM, "%s", "Allocation of scst_acg_dev failed");
+               TRACE(TRACE_OUT_OF_MEM,
+                     "%s", "Allocation of scst_acg_dev failed");
                goto out;
        }
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 17)
@@ -372,7 +373,7 @@ out:
 }
 
 /* The activity supposed to be suspended and scst_mutex held */
-void scst_free_acg_dev(struct scst_acg_dev *acg_dev)
+static void scst_free_acg_dev(struct scst_acg_dev *acg_dev)
 {
        TRACE_ENTRY();
 
@@ -459,7 +460,10 @@ out:
        return res;
 }
 
-/* scst_mutex supposed to be held, there must not be parallel activity in this sess */
+/*
+ * scst_mutex supposed to be held, there must not be parallel activity in this
+ * session.
+ */
 static struct scst_tgt_dev *scst_alloc_add_tgt_dev(struct scst_session *sess,
        struct scst_acg_dev *acg_dev)
 {
@@ -510,9 +514,8 @@ static struct scst_tgt_dev *scst_alloc_add_tgt_dev(struct scst_session *sess,
            !sess->tgt->tgtt->no_clustering)
                scst_sgv_pool_use_norm_clust(tgt_dev);
 
-       if (sess->tgt->tgtt->unchecked_isa_dma || ini_unchecked_isa_dma) {
+       if (sess->tgt->tgtt->unchecked_isa_dma || ini_unchecked_isa_dma)
                scst_sgv_pool_use_dma(tgt_dev);
-       }
 
        if (dev->scsi_dev != NULL) {
                TRACE_MGMT_DBG("host=%d, channel=%d, id=%d, lun=%d, "
@@ -601,7 +604,8 @@ static struct scst_tgt_dev *scst_alloc_add_tgt_dev(struct scst_session *sess,
 
        sess_tgt_dev_list_head =
                &sess->sess_tgt_dev_list_hash[HASH_VAL(tgt_dev->lun)];
-       list_add_tail(&tgt_dev->sess_tgt_dev_list_entry, sess_tgt_dev_list_head);
+       list_add_tail(&tgt_dev->sess_tgt_dev_list_entry,
+                     sess_tgt_dev_list_head);
 
 out:
        TRACE_EXIT();
@@ -645,7 +649,10 @@ void scst_nexus_loss(struct scst_tgt_dev *tgt_dev)
        return;
 }
 
-/* scst_mutex supposed to be held, there must not be parallel activity in this sess */
+/*
+ * scst_mutex supposed to be held, there must not be parallel activity in this
+ * session.
+ */
 static void scst_free_tgt_dev(struct scst_tgt_dev *tgt_dev)
 {
        struct scst_device *dev = tgt_dev->dev;
@@ -711,7 +718,10 @@ out_free:
        goto out;
 }
 
-/* scst_mutex supposed to be held, there must not be parallel activity in this sess */
+/*
+ * scst_mutex supposed to be held, there must not be parallel activity in this
+ * session.
+ */
 void scst_sess_free_tgt_devs(struct scst_session *sess)
 {
        int i;
@@ -791,7 +801,8 @@ out:
                                read_only);
                } else {
                        PRINT_INFO("Added device %d:%d:%d:%d to group %s (LUN "
-                               "%lld, rd_only %d)", dev->scsi_dev->host->host_no,
+                               "%lld, rd_only %d)",
+                               dev->scsi_dev->host->host_no,
                                dev->scsi_dev->channel, dev->scsi_dev->id,
                                dev->scsi_dev->lun, acg->acg_name,
                                (long long unsigned int)lun,
@@ -1383,11 +1394,13 @@ out:
        return cmd;
 }
 
-void scst_destroy_put_cmd(struct scst_cmd *cmd)
+static void scst_destroy_put_cmd(struct scst_cmd *cmd)
 {
        scst_sess_put(cmd->sess);
 
-       /* At this point tgt_dev can be dead, but the pointer remains not-NULL */
+       /*
+        * At this point tgt_dev can be dead, but the pointer remains non-NULL
+        */
        if (likely(cmd->tgt_dev != NULL))
                __scst_put();
 
@@ -1461,10 +1474,10 @@ void scst_free_cmd(struct scst_cmd *cmd)
 #ifdef CONFIG_SCST_EXTRACHECKS
                if (unlikely(!cmd->sent_for_exec)) {
                        PRINT_ERROR("Finishing not executed cmd %p (opcode "
-                            "%d, target %s, lun %lld, sn %ld, expected_sn %ld)",
-                            cmd, cmd->cdb[0], cmd->tgtt->name,
-                            (long long unsigned int)cmd->lun,
-                            cmd->sn, cmd->tgt_dev->expected_sn);
+                           "%d, target %s, lun %lld, sn %ld, expected_sn %ld)",
+                           cmd, cmd->cdb[0], cmd->tgtt->name,
+                           (long long unsigned int)cmd->lun,
+                           cmd->sn, cmd->tgt_dev->expected_sn);
                        scst_unblock_deferred(cmd->tgt_dev, cmd);
                }
 #endif
@@ -1514,9 +1527,11 @@ void scst_check_retries(struct scst_tgt *tgt)
                        tgt->retry_cmds--;
 
                        TRACE_RETRY("Moving retry cmd %p to head of active "
-                               "cmd list (retry_cmds left %d)", c, tgt->retry_cmds);
+                               "cmd list (retry_cmds left %d)",
+                               c, tgt->retry_cmds);
                        spin_lock(&c->cmd_lists->cmd_list_lock);
-                       list_move(&c->cmd_list_entry, &c->cmd_lists->active_cmd_list);
+                       list_move(&c->cmd_list_entry,
+                                 &c->cmd_lists->active_cmd_list);
                        wake_up(&c->cmd_lists->cmd_list_waitQ);
                        spin_unlock(&c->cmd_lists->cmd_list_lock);
 
@@ -1952,7 +1967,7 @@ uint64_t scst_unpack_lun(const uint8_t *lun, int len)
        address_method = (*lun) >> 6;   /* high 2 bits of byte 0 */
        switch (address_method) {
        case 0: /* peripheral device addressing method */
-#if 0 /* Looks like it's legal to use it as flat space addressing method as well */
+#if 0
                if (*lun) {
                        PRINT_ERROR("Illegal BUS INDENTIFIER in LUN "
                             "peripheral device addressing method 0x%02x, "
@@ -1962,6 +1977,11 @@ uint64_t scst_unpack_lun(const uint8_t *lun, int len)
                res = *(lun + 1);
                break;
 #else
+               /*
+                * Looks like it's legal to use it as flat space addressing
+                * method as well
+                */
+
                /* go through */
 #endif
 
@@ -2316,9 +2336,9 @@ int scst_block_generic_dev_done(struct scst_cmd *cmd,
        TRACE_ENTRY();
 
        /*
-        * SCST sets good defaults for cmd->is_send_status and cmd->resp_data_len
-        * based on cmd->status and cmd->data_direction, therefore change
-        * them only if necessary
+        * SCST sets good defaults for cmd->is_send_status and
+        * cmd->resp_data_len based on cmd->status and cmd->data_direction,
+        * therefore change them only if necessary
         */
 
        if ((status == SAM_STAT_GOOD) || (status == SAM_STAT_CONDITION_MET)) {
@@ -2332,8 +2352,8 @@ int scst_block_generic_dev_done(struct scst_cmd *cmd,
                        buffer_size = scst_get_buf_first(cmd, &buffer);
                        if (unlikely(buffer_size <= 0)) {
                                if (buffer_size < 0) {
-                                       PRINT_ERROR("%s: Unable to get the buffer "
-                                               "(%d)", __func__, buffer_size);
+                                       PRINT_ERROR("%s: Unable to get the"
+                                       " buffer (%d)", __func__, buffer_size);
                                }
                                goto out;
                        }
@@ -2376,9 +2396,9 @@ int scst_tape_generic_dev_done(struct scst_cmd *cmd,
        TRACE_ENTRY();
 
        /*
-        * SCST sets good defaults for cmd->is_send_status and cmd->resp_data_len
-        * based on cmd->status and cmd->data_direction, therefore change
-        * them only if necessary
+        * SCST sets good defaults for cmd->is_send_status and
+        * cmd->resp_data_len based on cmd->status and cmd->data_direction,
+        * therefore change them only if necessary
         */
 
        switch (opcode) {
@@ -2483,7 +2503,8 @@ int scst_obtain_device_parameters(struct scst_device *dev)
                if (scsi_status_is_good(res)) {
                        int q;
 
-                       PRINT_BUFF_FLAG(TRACE_SCSI, "Returned control mode page data",
+                       PRINT_BUFF_FLAG(TRACE_SCSI,
+                               "Returned control mode page data",
                                buffer, sizeof(buffer));
 
                        dev->tst = buffer[4+2] >> 5;
@@ -2491,7 +2512,8 @@ int scst_obtain_device_parameters(struct scst_device *dev)
                        if (q > SCST_CONTR_MODE_QUEUE_ALG_UNRESTRICTED_REORDER) {
                                PRINT_ERROR("Too big QUEUE ALG %x, dev "
                                        "%d:%d:%d:%d", dev->queue_alg,
-                                       dev->scsi_dev->host->host_no, dev->scsi_dev->channel,
+                                       dev->scsi_dev->host->host_no,
+                                       dev->scsi_dev->channel,
                                        dev->scsi_dev->id, dev->scsi_dev->lun);
                        }
                        dev->queue_alg = q;
@@ -2505,49 +2527,66 @@ int scst_obtain_device_parameters(struct scst_device *dev)
                         */
                        dev->has_own_order_mgmt = !dev->queue_alg;
 
-                       TRACE(TRACE_SCSI|TRACE_MGMT_MINOR, "Device %d:%d:%d:%d: TST %x, "
-                               "QUEUE ALG %x, SWP %x, TAS %x, has_own_order_mgmt "
-                               "%d", dev->scsi_dev->host->host_no,
+                       TRACE(TRACE_SCSI|TRACE_MGMT_MINOR,
+                               "Device %d:%d:%d:%d: TST %x, "
+                               "QUEUE ALG %x, SWP %x, TAS %x, "
+                               "has_own_order_mgmt %d",
+                               dev->scsi_dev->host->host_no,
                                dev->scsi_dev->channel, dev->scsi_dev->id,
                                dev->scsi_dev->lun, dev->tst, dev->queue_alg,
                                dev->swp, dev->tas, dev->has_own_order_mgmt);
 
                        goto out;
                } else {
-#if 0 /* 3ware controller is buggy and returns CONDITION_GOOD instead of CHECK_CONDITION */
+#if 0
                        if ((status_byte(res) == CHECK_CONDITION) &&
 #else
+                       /*
+                        * 3ware controller is buggy and returns CONDITION_GOOD
+                        * instead of CHECK_CONDITION
+                        */
                        if (
 #endif
                            SCST_SENSE_VALID(sense_buffer)) {
                                if (sense_buffer[2] == ILLEGAL_REQUEST) {
-                                       TRACE(TRACE_SCSI|TRACE_MGMT_MINOR, "Device "
-                                               "%d:%d:%d:%d doesn't support control "
-                                               "mode page, using defaults: TST "
-                                               "%x, QUEUE ALG %x, SWP %x, TAS %x, "
-                                               "has_own_order_mgmt %d",
+                                       TRACE(TRACE_SCSI|TRACE_MGMT_MINOR,
+                                               "Device %d:%d:%d:%d doesn't"
+                                               " support control mode page,"
+                                               " using defaults: TST %x,"
+                                               " QUEUE ALG %x, SWP %x, TAS %x,"
+                                               " has_own_order_mgmt %d",
                                                dev->scsi_dev->host->host_no,
-                                               dev->scsi_dev->channel, dev->scsi_dev->id,
-                                               dev->scsi_dev->lun, dev->tst, dev->queue_alg,
-                                               dev->swp, dev->tas, dev->has_own_order_mgmt);
+                                               dev->scsi_dev->channel,
+                                               dev->scsi_dev->id,
+                                               dev->scsi_dev->lun,
+                                               dev->tst,
+                                               dev->queue_alg,
+                                               dev->swp,
+                                               dev->tas,
+                                               dev->has_own_order_mgmt);
                                        res = 0;
                                        goto out;
                                } else if (sense_buffer[2] == NOT_READY) {
-                                       TRACE(TRACE_SCSI, "Device %d:%d:%d:%d not ready",
+                                       TRACE(TRACE_SCSI,
+                                               "Device %d:%d:%d:%d not ready",
                                                dev->scsi_dev->host->host_no,
-                                               dev->scsi_dev->channel, dev->scsi_dev->id,
+                                               dev->scsi_dev->channel,
+                                               dev->scsi_dev->id,
                                                dev->scsi_dev->lun);
                                        res = 0;
                                        goto out;
                                }
                        } else {
-                               TRACE(TRACE_SCSI|TRACE_MGMT_MINOR, "Internal MODE SENSE to "
+                               TRACE(TRACE_SCSI|TRACE_MGMT_MINOR,
+                                       "Internal MODE SENSE to "
                                        "device %d:%d:%d:%d failed: %x",
                                        dev->scsi_dev->host->host_no,
-                                       dev->scsi_dev->channel, dev->scsi_dev->id,
+                                       dev->scsi_dev->channel,
+                                       dev->scsi_dev->id,
                                        dev->scsi_dev->lun, res);
-                               PRINT_BUFF_FLAG(TRACE_SCSI|TRACE_MGMT_MINOR, "MODE SENSE "
-                                       "sense", sense_buffer, sizeof(sense_buffer));
+                               PRINT_BUFF_FLAG(TRACE_SCSI|TRACE_MGMT_MINOR,
+                                       "MODE SENSE sense",
+                                       sense_buffer, sizeof(sense_buffer));
                        }
                        scst_check_internal_sense(dev, res, sense_buffer,
                                        sizeof(sense_buffer));
@@ -2743,7 +2782,8 @@ void scst_check_set_UA(struct scst_tgt_dev *tgt_dev,
 
        list_for_each_entry(UA_entry_tmp, &tgt_dev->UA_list,
                            UA_list_entry) {
-               if (memcmp(sense, UA_entry_tmp->UA_sense_buffer, sense_len) == 0) {
+               if (memcmp(sense, UA_entry_tmp->UA_sense_buffer,
+                          sense_len) == 0) {
                        TRACE_MGMT_DBG("%s", "UA already exists");
                        skip_UA = 1;
                        break;
@@ -2790,8 +2830,9 @@ void __scst_dev_check_set_UA(struct scst_device *dev,
 
        /* Check for reset UA */
        if (sense[12] == SCST_SENSE_ASC_UA_RESET)
-               scst_process_reset(dev, (exclude != NULL) ? exclude->sess : NULL,
-                       exclude, NULL, false);
+               scst_process_reset(dev,
+                                  (exclude != NULL) ? exclude->sess : NULL,
+                                  exclude, NULL, false);
 
        scst_dev_check_set_local_UA(dev, exclude, sense, sense_len);
 
@@ -2806,7 +2847,8 @@ void scst_free_all_UA(struct scst_tgt_dev *tgt_dev)
 
        TRACE_ENTRY();
 
-       list_for_each_entry_safe(UA_entry, t, &tgt_dev->UA_list, UA_list_entry) {
+       list_for_each_entry_safe(UA_entry, t,
+                                &tgt_dev->UA_list, UA_list_entry) {
                TRACE_MGMT_DBG("Clearing UA for tgt_dev lun %lld",
                               (long long unsigned int)tgt_dev->lun);
                list_del(&UA_entry->UA_list_entry);
@@ -3137,7 +3179,8 @@ void scst_unblock_cmds(struct scst_device *dev)
                list_del(&cmd->blocked_cmd_list_entry);
                TRACE_MGMT_DBG("Adding cmd %p to head of active cmd list", cmd);
                spin_lock(&cmd->cmd_lists->cmd_list_lock);
-               list_add(&cmd->cmd_list_entry, &cmd->cmd_lists->active_cmd_list);
+               list_add(&cmd->cmd_list_entry,
+                        &cmd->cmd_lists->active_cmd_list);
                wake_up(&cmd->cmd_lists->cmd_list_waitQ);
                spin_unlock(&cmd->cmd_lists->cmd_list_lock);
                if (brk)
@@ -3186,8 +3229,8 @@ static void __scst_unblock_deferred(struct scst_tgt_dev *tgt_dev,
                tgt_dev->def_cmd_count++;
                list_add_tail(&out_of_sn_cmd->sn_cmd_list_entry,
                              &tgt_dev->skipped_sn_list);
-               TRACE_SN("out_of_sn_cmd %p with sn %ld added to skipped_sn_list "
-                       "(expected_sn %ld)", out_of_sn_cmd, out_of_sn_cmd->sn,
+               TRACE_SN("out_of_sn_cmd %p with sn %ld added to skipped_sn_list"
+                       " (expected_sn %ld)", out_of_sn_cmd, out_of_sn_cmd->sn,
                        tgt_dev->expected_sn);
                spin_unlock_irq(&tgt_dev->sn_lock);
        }
@@ -3345,7 +3388,7 @@ static void tm_dbg_timer_fn(unsigned long arg);
 
 static DEFINE_SPINLOCK(scst_tm_dbg_lock);
 /* All serialized by scst_tm_dbg_lock */
-struct {
+static struct {
        unsigned int tm_dbg_release:1;
        unsigned int tm_dbg_blocked:1;
 } tm_dbg_flags;
@@ -3404,8 +3447,8 @@ static void tm_dbg_delay_cmd(struct scst_cmd *cmd)
        case TM_DBG_STATE_ABORT:
                if (tm_dbg_delayed_cmds_count == 0) {
                        unsigned long d = 58*HZ + (scst_random() % (4*HZ));
-                       TRACE_MGMT_DBG("STATE ABORT: delaying cmd %p (tag %llu) "
-                               "for %ld.%ld seconds (%ld HZ), "
+                       TRACE_MGMT_DBG("STATE ABORT: delaying cmd %p (tag %llu)"
+                               " for %ld.%ld seconds (%ld HZ), "
                                "tm_dbg_on_state_passes=%d", cmd, cmd->tag,
                                d/HZ, (d%HZ)*100/HZ, d, tm_dbg_on_state_passes);
                        mod_timer(&tm_dbg_timer, jiffies + d);
@@ -3556,11 +3599,13 @@ void tm_dbg_release_cmd(struct scst_cmd *cmd)
                                "active cmd list (delayed_cmds_count=%d)",
                                c, c->tag, tm_dbg_delayed_cmds_count);
 
-                       if (!test_bit(SCST_CMD_ABORTED_OTHER, &cmd->cmd_flags)) {
+                       if (!test_bit(SCST_CMD_ABORTED_OTHER,
+                                           &cmd->cmd_flags)) {
                                /* Test how completed commands handled */
                                if (((scst_random() % 10) == 5)) {
                                        scst_set_cmd_error(cmd,
-                                          SCST_LOAD_SENSE(scst_sense_hardw_error));
+                                               SCST_LOAD_SENSE(
+                                               scst_sense_hardw_error));
                                        /* It's completed now */
                                }
                        }
index 126d50e..08aad2d 100644 (file)
        details."
 #endif
 
-#if !defined(SCSI_EXEC_REQ_FIFO_DEFINED) && !defined(CONFIG_SCST_STRICT_SERIALIZING)
+#if !defined(SCSI_EXEC_REQ_FIFO_DEFINED) && \
+    !defined(CONFIG_SCST_STRICT_SERIALIZING)
 #warning "Patch scst_exec_req_fifo-<kernel-version>.patch was not applied on \
-       your kernel and CONFIG_SCST_STRICT_SERIALIZING isn't defined. Pass-through dev \
-       handlers will not be supported."
+       your kernel and CONFIG_SCST_STRICT_SERIALIZING isn't defined. \
+       Pass-through dev handlers will not be supported."
 #endif
 
 /**
@@ -68,13 +69,13 @@ struct list_head scst_dev_type_list;
 
 spinlock_t scst_main_lock;
 
-struct kmem_cache *scst_mgmt_cachep;
+static struct kmem_cache *scst_mgmt_cachep;
 mempool_t *scst_mgmt_mempool;
-struct kmem_cache *scst_mgmt_stub_cachep;
+static struct kmem_cache *scst_mgmt_stub_cachep;
 mempool_t *scst_mgmt_stub_mempool;
-struct kmem_cache *scst_ua_cachep;
+static struct kmem_cache *scst_ua_cachep;
 mempool_t *scst_ua_mempool;
-struct kmem_cache *scst_sense_cachep;
+static struct kmem_cache *scst_sense_cachep;
 mempool_t *scst_sense_mempool;
 struct kmem_cache *scst_tgtd_cachep;
 struct kmem_cache *scst_sess_cachep;
@@ -454,7 +455,8 @@ static int scst_susp_wait(bool interruptible)
                } else
                        res = 0;
        } else
-               wait_event(scst_dev_cmd_waitQ, atomic_read(&scst_cmd_count) == 0);
+               wait_event(scst_dev_cmd_waitQ,
+                          atomic_read(&scst_cmd_count) == 0);
 
        TRACE_MGMT_DBG("wait_event() returned %d", res);
 
@@ -881,7 +883,8 @@ int __scst_register_dev_driver(struct scst_dev_type *dev_type,
        if (res != 0)
                goto out_error;
 
-#if !defined(SCSI_EXEC_REQ_FIFO_DEFINED) && !defined(CONFIG_SCST_STRICT_SERIALIZING)
+#if !defined(SCSI_EXEC_REQ_FIFO_DEFINED) && \
+    !defined(CONFIG_SCST_STRICT_SERIALIZING)
        if (dev_type->exec == NULL) {
                PRINT_ERROR("Pass-through dev handlers (handler \"%s\") not "
                        "supported. Consider applying on your kernel patch "
@@ -920,7 +923,7 @@ int __scst_register_dev_driver(struct scst_dev_type *dev_type,
        list_add_tail(&dev_type->dev_type_list_entry, &scst_dev_type_list);
 
        list_for_each_entry(dev, &scst_dev_list, dev_list_entry) {
-               if ((dev->scsi_dev == NULL) || (dev->handler != &scst_null_devtype))
+               if (dev->scsi_dev == NULL || dev->handler != &scst_null_devtype)
                        continue;
                if (dev->scsi_dev->type == dev_type->type)
                        scst_assign_dev_handler(dev, dev_type);
@@ -1280,7 +1283,9 @@ int scst_cmd_threads_count(void)
 {
        int i;
 
-       /* Just to lower the race window, when user can get just changed value */
+       /*
+        * Just to lower the race window, when user can get just changed value
+        */
        mutex_lock(&scst_threads_info.cmd_threads_mutex);
        i = scst_threads_info.nr_cmd_threads;
        mutex_unlock(&scst_threads_info.cmd_threads_mutex);
@@ -1583,7 +1588,8 @@ static void __init scst_print_config(void)
 #endif
 
 #ifdef CONFIG_SCST_ALLOW_PASSTHROUGH_IO_SUBMIT_IN_SIRQ
-       i += snprintf(&buf[i], sizeof(buf) - i, "%sALLOW_PASSTHROUGH_IO_SUBMIT_IN_SIRQ",
+       i += snprintf(&buf[i], sizeof(buf) - i,
+               "%sALLOW_PASSTHROUGH_IO_SUBMIT_IN_SIRQ",
                (j == i) ? "" : ", ");
 #endif
 
@@ -1691,7 +1697,8 @@ static int __init init_scst(void)
                        out_destroy_mgmt_stub_cache);
        {
                struct scst_sense { uint8_t s[SCST_SENSE_BUFFERSIZE]; };
-               INIT_CACHEP(scst_sense_cachep, scst_sense, out_destroy_ua_cache);
+               INIT_CACHEP(scst_sense_cachep, scst_sense,
+                           out_destroy_ua_cache);
        }
        INIT_CACHEP(scst_cmd_cachep, scst_cmd, out_destroy_sense_cache);
        INIT_CACHEP(scst_sess_cachep, scst_session, out_destroy_cmd_cache);
@@ -1719,7 +1726,9 @@ static int __init init_scst(void)
                goto out_destroy_mgmt_stub_mempool;
        }
 
-       /* Loosing sense may have fatal consequences, so let's have a big pool */
+       /*
+        * Loosing sense may have fatal consequences, so let's have a big pool
+        */
        scst_sense_mempool = mempool_create(128, mempool_alloc_slab,
                mempool_free_slab, scst_sense_cachep);
        if (scst_sense_mempool == NULL) {
@@ -1770,8 +1779,9 @@ static int __init init_scst(void)
        for (i = 0; i < (int)ARRAY_SIZE(scst_tasklets); i++) {
                spin_lock_init(&scst_tasklets[i].tasklet_lock);
                INIT_LIST_HEAD(&scst_tasklets[i].tasklet_cmd_list);
-               tasklet_init(&scst_tasklets[i].tasklet, (void *)scst_cmd_tasklet,
-                       (unsigned long)&scst_tasklets[i]);
+               tasklet_init(&scst_tasklets[i].tasklet,
+                            (void *)scst_cmd_tasklet,
+                            (unsigned long)&scst_tasklets[i]);
        }
 
        TRACE_DBG("%d CPUs found, starting %d threads", scst_num_cpus,
index 7d56537..1145537 100644 (file)
@@ -256,7 +256,8 @@ static int sgv_alloc_arrays(struct sgv_pool_obj *obj,
 
        if (obj->owner_pool->clustered) {
                if (order <= sgv_pools_mgr.sgv_max_trans_order) {
-                       obj->trans_tbl = (struct trans_tbl_ent *)obj->sg_entries_data;
+                       obj->trans_tbl =
+                               (struct trans_tbl_ent *)obj->sg_entries_data;
                        /*
                         * No need to clear trans_tbl, if needed, it will be
                         * fully rewritten in scst_alloc_sg_entries()
@@ -265,8 +266,8 @@ static int sgv_alloc_arrays(struct sgv_pool_obj *obj,
                        tsz = pages_to_alloc * sizeof(obj->trans_tbl[0]);
                        obj->trans_tbl = kzalloc(tsz, gfp_mask);
                        if (unlikely(obj->trans_tbl == NULL)) {
-                               TRACE(TRACE_OUT_OF_MEM, "Allocation of trans_tbl "
-                                       "failed (size %d)", tsz);
+                               TRACE(TRACE_OUT_OF_MEM, "Allocation of "
+                                       "trans_tbl failed (size %d)", tsz);
                                res = -ENOMEM;
                                goto out_free;
                        }
@@ -294,7 +295,8 @@ static void sgv_dtor_and_free(struct sgv_pool_obj *obj)
                        obj->sg_count, obj->allocator_priv);
        }
        if (obj->sg_entries != obj->sg_entries_data) {
-               if (obj->trans_tbl != (struct trans_tbl_ent *)obj->sg_entries_data) {
+               if (obj->trans_tbl !=
+                   (struct trans_tbl_ent *)obj->sg_entries_data) {
                        /* kfree() handles NULL parameter */
                        kfree(obj->trans_tbl);
                        obj->trans_tbl = NULL;
@@ -434,6 +436,8 @@ static int sgv_pool_cached_purge(struct sgv_pool_obj *e, int t,
 
 /* Called under pool_mgr_lock held, but drops/reaquires it inside */
 static int sgv_pool_oom_free_objs(int pgs)
+       __releases(sgv_pools_mgr.mgr.pool_mgr_lock)
+       __acquires(sgv_pools_mgr.mgr.pool_mgr_lock)
 {
        TRACE_MEM("Shrinking pools about %d pages", pgs);
        while ((sgv_pools_mgr.mgr.throttle.inactive_pages_total >
@@ -621,8 +625,9 @@ struct scatterlist *sgv_pool_alloc(struct sgv_pool *pool, unsigned int size,
                                        (obj->sg_entries + pages_to_alloc);
                                TRACE_MEM("trans_tbl %p", obj->trans_tbl);
                                /*
-                                * No need to clear trans_tbl, if needed, it will
-                                * be fully rewritten in scst_alloc_sg_entries()
+                                * No need to clear trans_tbl, if needed, it
+                                * will be fully rewritten in
+                                * scst_alloc_sg_entries(),
                                 */
                        }
                } else {
@@ -733,7 +738,8 @@ success:
        *sgv = obj;
 
        if (size & ~PAGE_MASK)
-               obj->sg_entries[cnt-1].length -= PAGE_SIZE - (size & ~PAGE_MASK);
+               obj->sg_entries[cnt-1].length -=
+                       PAGE_SIZE - (size & ~PAGE_MASK);
 
        TRACE_MEM("sgv_obj=%p, sg_entries %p (size=%d, pages=%d, sg_count=%d, "
                "count=%d, last_len=%d)", obj, obj->sg_entries, size, pages,
@@ -758,7 +764,8 @@ out_return2:
 
 out_fail_free_sg_entries:
        if (obj->sg_entries != obj->sg_entries_data) {
-               if (obj->trans_tbl != (struct trans_tbl_ent *)obj->sg_entries_data) {
+               if (obj->trans_tbl !=
+                       (struct trans_tbl_ent *)obj->sg_entries_data) {
                        /* kfree() handles NULL parameter */
                        kfree(obj->trans_tbl);
                        obj->trans_tbl = NULL;
@@ -933,8 +940,10 @@ int sgv_pool_init(struct sgv_pool *pool, const char *name, int clustered)
                                (sizeof(obj->sg_entries[0]) +
                                 (clustered ? sizeof(obj->trans_tbl[0]) : 0));
                } else if (i <= sgv_pools_mgr.sgv_max_trans_order) {
-                       /* sgv ie sg_entries is allocated outside object but ttbl
-                       is embedded still */
+                       /* 
+                        * sgv ie sg_entries is allocated outside object, but
+                        * ttbl is still embedded.
+                        */
                        size = sizeof(*obj) + (1 << i) *
                                ((clustered ? sizeof(obj->trans_tbl[0]) : 0));
                } else {
@@ -995,8 +1004,8 @@ static void sgv_pool_evaluate_local_order(struct scst_sgv_pools_manager *pmgr)
                        PAGE_SIZE) & PAGE_MASK)) - 1;
 
        pmgr->sgv_max_trans_order = get_order(
-               (((space4sgv_ttbl /
-                 (sizeof(struct trans_tbl_ent))) * PAGE_SIZE) & PAGE_MASK)) - 1;
+               (((space4sgv_ttbl / sizeof(struct trans_tbl_ent)) * PAGE_SIZE)
+                & PAGE_MASK)) - 1;
 
        TRACE_MEM("sgv_max_local_order %d, sgv_max_trans_order %d",
                pmgr->sgv_max_local_order, pmgr->sgv_max_trans_order);
@@ -1009,8 +1018,8 @@ static void sgv_pool_evaluate_local_order(struct scst_sgv_pools_manager *pmgr)
                (sizeof(struct scatterlist))
                + sizeof(struct sgv_pool_obj));
        TRACE_MEM("max object size with embedded ttbl %zd",
-               (1 << pmgr->sgv_max_trans_order) * sizeof(struct trans_tbl_ent) +
-               sizeof(struct sgv_pool_obj));
+               (1 << pmgr->sgv_max_trans_order) * sizeof(struct trans_tbl_ent)
+               sizeof(struct sgv_pool_obj));
 }
 
 void sgv_pool_deinit(struct sgv_pool *pool)
@@ -1117,7 +1126,8 @@ static int sgv_pool_cached_shrinker(int nr, gfp_t gfpm)
 
                        if (sgv_pool_cached_purge(e, SHRINK_TIME_AFTER, rt) == 0) {
                                nr -= 1 << e->order_or_pages;
-                               spin_unlock_bh(&sgv_pools_mgr.mgr.pool_mgr_lock);
+                               spin_unlock_bh(
+                                       &sgv_pools_mgr.mgr.pool_mgr_lock);
                                sgv_dtor_and_free(e);
                                spin_lock_bh(&sgv_pools_mgr.mgr.pool_mgr_lock);
                        } else
@@ -1319,7 +1329,8 @@ int sgv_pool_procinfo_show(struct seq_file *seq, void *v)
                sgv_pools_mgr.mgr.throttle.inactive_pages_total,
                sgv_pools_mgr.mgr.throttle.active_pages_total,
                "Hi/lo watermarks [pages]", sgv_pools_mgr.mgr.throttle.hi_wmk,
-               sgv_pools_mgr.mgr.throttle.lo_wmk, "Hi watermark releases/failures",
+               sgv_pools_mgr.mgr.throttle.lo_wmk,
+               "Hi watermark releases/failures",
                sgv_pools_mgr.mgr.throttle.releases_on_hiwmk,
                sgv_pools_mgr.mgr.throttle.releases_failed);
 
index c4ac12f..426145e 100644 (file)
@@ -37,7 +37,8 @@ struct sgv_pool_obj {
        int order_or_pages;
 
        struct {
-               unsigned long time_stamp; /* jiffies, protected by pool_mgr_lock */
+               /* jiffies, protected by pool_mgr_lock */
+               unsigned long time_stamp;
                struct list_head recycling_list_entry;
                struct list_head sorted_recycling_list_entry;
        } recycle_entry;
@@ -77,7 +78,8 @@ struct sgv_pool {
        /* 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048 */
        struct kmem_cache *caches[SGV_POOL_ELEMENTS];
 
-       struct list_head recycling_lists[SGV_POOL_ELEMENTS];  /* protected by pool_mgr_lock */
+       /* protected by pool_mgr_lock */
+       struct list_head recycling_lists[SGV_POOL_ELEMENTS];
 
        struct sgv_pool_acc acc;
        struct sgv_pool_cache_acc cache_acc[SGV_POOL_ELEMENTS];
@@ -95,15 +97,22 @@ struct scst_sgv_pools_manager {
 
        struct sgv_pool_mgr {
                spinlock_t pool_mgr_lock;
-               struct list_head sorted_recycling_list; /* protected by pool_mgr_lock */
-               int pitbool_running:1;          /* protected by pool_mgr_lock */
+               /* protected by pool_mgr_lock */
+               struct list_head sorted_recycling_list;
+               /* protected by pool_mgr_lock */
+               unsigned pitbool_running:1;
 
                struct sgv_mem_throttling {
                        u32 inactive_pages_total;
                        u32 active_pages_total;
 
-                       u32 hi_wmk; /* compared against inactive_pages_total + active_pages_total */
-                       u32 lo_wmk; /* compared against inactive_pages_total only */
+                       /*
+                        * compared against inactive_pages_total +
+                        *                  active_pages_total
+                        */
+                       u32 hi_wmk;
+                       /* compared against inactive_pages_total only */
+                       u32 lo_wmk;
 
                        u32 releases_on_hiwmk;
                        u32 releases_failed;
@@ -138,7 +147,8 @@ static inline struct scatterlist *sgv_pool_sg(struct sgv_pool_obj *obj)
        return obj->sg_entries;
 }
 
-extern int scst_sgv_pools_init(unsigned long mem_hwmark, unsigned long mem_lwmark);
+extern int scst_sgv_pools_init(unsigned long mem_hwmark,
+                              unsigned long mem_lwmark);
 extern void scst_sgv_pools_deinit(void);
 extern int sgv_pool_procinfo_show(struct seq_file *seq, void *v);
 
index 50d6562..21f8261 100644 (file)
 
 #define TRACE_RTRY              0x80000000
 #define TRACE_SCSI_SERIALIZING  0x40000000
-#define TRACE_SND_TOP          0x20000000 /** top being the edge away from the interupt */
+/** top being the edge away from the interupt */
+#define TRACE_SND_TOP          0x20000000
 #define TRACE_RCV_TOP          0x01000000
-#define TRACE_SND_BOT          0x08000000 /** bottom being the edge toward the interupt */
+/** bottom being the edge toward the interupt */
+#define TRACE_SND_BOT          0x08000000
 #define TRACE_RCV_BOT          0x04000000
 
 #if defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING)
@@ -165,7 +167,8 @@ extern struct list_head scst_dev_type_list; /* protected by scst_mutex */
 extern wait_queue_head_t scst_dev_cmd_waitQ;
 
 extern struct mutex scst_suspend_mutex;
-extern struct list_head scst_cmd_lists_list; /* protected by scst_suspend_mutex */
+/* protected by scst_suspend_mutex */
+extern struct list_head scst_cmd_lists_list;
 
 extern struct list_head scst_acg_list;
 extern struct scst_acg *scst_default_acg;
index 1483c92..28037d9 100644 (file)
@@ -128,8 +128,10 @@ static char *scst_proc_help_string =
 "   echo \"add_group GROUP\" >/proc/scsi_tgt/scsi_tgt\n"
 "   echo \"del_group GROUP\" >/proc/scsi_tgt/scsi_tgt\n"
 "\n"
-"   echo \"add|del H:C:I:L lun [READ_ONLY]\" >/proc/scsi_tgt/groups/GROUP/devices\n"
-"   echo \"add|del V_NAME lun [READ_ONLY]\" >/proc/scsi_tgt/groups/GROUP/devices\n"
+"   echo \"add|del H:C:I:L lun [READ_ONLY]\""
+" >/proc/scsi_tgt/groups/GROUP/devices\n"
+"   echo \"add|del V_NAME lun [READ_ONLY]\""
+" >/proc/scsi_tgt/groups/GROUP/devices\n"
 "   echo \"clear\" >/proc/scsi_tgt/groups/GROUP/devices\n"
 "\n"
 "   echo \"add|del NAME\" >/proc/scsi_tgt/groups/GROUP/names\n"
@@ -139,8 +141,10 @@ static char *scst_proc_help_string =
 #if defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING)
 "\n"
 "   echo \"all|none|default\" >/proc/scsi_tgt/[DEV_HANDLER_NAME/]trace_level\n"
-"   echo \"value DEC|0xHEX|0OCT\" >/proc/scsi_tgt/[DEV_HANDLER_NAME/]trace_level\n"
-"   echo \"set|add|del TOKEN\" >/proc/scsi_tgt/[DEV_HANDLER_NAME/]trace_level\n"
+"   echo \"value DEC|0xHEX|0OCT\""
+" >/proc/scsi_tgt/[DEV_HANDLER_NAME/]trace_level\n"
+"   echo \"set|add|del TOKEN\""
+" >/proc/scsi_tgt/[DEV_HANDLER_NAME/]trace_level\n"
 "     where TOKEN is one of [debug,function,line,pid,entryexit,\n"
 "                            buff,mem,sg,out_of_mem,special,scsi,mgmt,minor]\n"
 "     Additionally for /proc/scsi_tgt/trace_level there are these TOKENs\n"
@@ -357,7 +361,8 @@ out:
 }
 EXPORT_SYMBOL(scst_proc_log_entry_write);
 
-static ssize_t scst_proc_scsi_tgt_gen_write_log(struct file *file, const char __user *buf,
+static ssize_t scst_proc_scsi_tgt_gen_write_log(struct file *file,
+                                       const char __user *buf,
                                        size_t length, loff_t *off)
 {
        int res;
@@ -370,7 +375,8 @@ static ssize_t scst_proc_scsi_tgt_gen_write_log(struct file *file, const char __
        }
 
        res = scst_proc_log_entry_write(file, buf, length,
-               &trace_flag, SCST_DEFAULT_LOG_FLAGS, scst_proc_local_trace_tbl);
+               &trace_flag, SCST_DEFAULT_LOG_FLAGS,
+               scst_proc_local_trace_tbl);
 
        mutex_unlock(&scst_log_mutex);
 
@@ -396,11 +402,15 @@ static int lat_info_show(struct seq_file *seq, void *v)
                goto out;
        }
 
-       seq_printf(seq, "%-20s %-45s %-15s %15s\n", "Target name", "Initiator name",
-                      "SCST latency", "Processing latency (us)");
+       seq_printf(seq, "%-20s %-45s %-15s %15s\n",
+                  "Target name",
+                  "Initiator name",
+                  "SCST latency",
+                  "Processing latency (us)");
 
        list_for_each_entry(acg, &scst_acg_list, scst_acg_list_entry) {
-               list_for_each_entry(sess, &acg->acg_sess_list, acg_sess_list_entry) {
+               list_for_each_entry(sess, &acg->acg_sess_list,
+                               acg_sess_list_entry) {
                        unsigned long proc_lat = 0, scst_lat = 0;
                        uint64_t proc_time, scst_time;
                        unsigned int processed_cmds;
@@ -427,8 +437,10 @@ static int lat_info_show(struct seq_file *seq, void *v)
 #endif
 
                        if (sess->processed_cmds != 0) {
-                               proc_lat = (unsigned long)proc_time / processed_cmds;
-                               scst_lat = (unsigned long)scst_time / processed_cmds;
+                               proc_lat = (unsigned long)proc_time /
+                                               processed_cmds;
+                               scst_lat = (unsigned long)scst_time /
+                                               processed_cmds;
                        }
 
                        seq_printf(seq, "%-20s %-45s %-15ld %-15ld\n",
@@ -445,7 +457,8 @@ out:
        return res;
 }
 
-static ssize_t scst_proc_scsi_tgt_gen_write_lat(struct file *file, const char __user *buf,
+static ssize_t scst_proc_scsi_tgt_gen_write_lat(struct file *file,
+                                       const char __user *buf,
                                        size_t length, loff_t *off)
 {
        int res = length;
@@ -460,8 +473,10 @@ static ssize_t scst_proc_scsi_tgt_gen_write_lat(struct file *file, const char __
        }
 
        list_for_each_entry(acg, &scst_acg_list, scst_acg_list_entry) {
-               list_for_each_entry(sess, &acg->acg_sess_list, acg_sess_list_entry) {
-                       PRINT_INFO("Zeroing latency statistics for initiator %s",
+               list_for_each_entry(sess, &acg->acg_sess_list,
+                               acg_sess_list_entry) {
+                       PRINT_INFO("Zeroing latency statistics for initiator"
+                               " %s",
                                sess->initiator_name);
                        spin_lock_bh(&sess->meas_lock);
                        sess->processing_time = 0;
@@ -488,7 +503,8 @@ static struct scst_proc_data scst_lat_proc_data = {
 static int __init scst_proc_init_module_log(void)
 {
        int res = 0;
-#if defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING) || defined(CONFIG_SCST_MEASURE_LATENCY)
+#if defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING) || \
+    defined(CONFIG_SCST_MEASURE_LATENCY)
        struct proc_dir_entry *generic;
 #endif
 
@@ -512,7 +528,8 @@ static int __init scst_proc_init_module_log(void)
                                         &scst_lat_proc_data);
                if (!generic) {
                        PRINT_ERROR("cannot init /proc/%s/%s",
-                                   SCST_PROC_ENTRY_NAME, SCST_PROC_LAT_ENTRY_NAME);
+                                   SCST_PROC_ENTRY_NAME,
+                                   SCST_PROC_LAT_ENTRY_NAME);
                        res = -ENOMEM;
                }
        }
@@ -731,7 +748,8 @@ static int __init scst_proc_init_sgv(void)
 
        TRACE_ENTRY();
 
-       pr = scst_create_proc_entry(scst_proc_scsi_tgt, "sgv", &scst_sgv_proc_data);
+       pr = scst_create_proc_entry(scst_proc_scsi_tgt, "sgv",
+                               &scst_sgv_proc_data);
        if (pr == NULL) {
                PRINT_ERROR("%s", "cannot create sgv /proc entry");
                res = -ENOMEM;
@@ -755,7 +773,7 @@ int __init scst_proc_init_module(void)
 
        TRACE_ENTRY();
 
-       scst_proc_scsi_tgt = proc_mkdir(SCST_PROC_ENTRY_NAME, 0);
+       scst_proc_scsi_tgt = proc_mkdir(SCST_PROC_ENTRY_NAME, NULL);
        if (!scst_proc_scsi_tgt) {
                PRINT_ERROR("cannot init /proc/%s", SCST_PROC_ENTRY_NAME);
                goto out_nomem;
@@ -770,7 +788,8 @@ int __init scst_proc_init_module(void)
                goto out_remove;
        }
 
-       generic = scst_create_proc_entry(scst_proc_scsi_tgt, SCST_PROC_VERSION_NAME,
+       generic = scst_create_proc_entry(scst_proc_scsi_tgt,
+                                        SCST_PROC_VERSION_NAME,
                                         &scst_version_proc_data);
        if (!generic) {
                PRINT_ERROR("cannot init /proc/%s/%s",
@@ -778,7 +797,8 @@ int __init scst_proc_init_module(void)
                goto out_remove1;
        }
 
-       generic = scst_create_proc_entry(scst_proc_scsi_tgt, SCST_PROC_SESSIONS_NAME,
+       generic = scst_create_proc_entry(scst_proc_scsi_tgt,
+                                        SCST_PROC_SESSIONS_NAME,
                                         &scst_sessions_proc_data);
        if (!generic) {
                PRINT_ERROR("cannot init /proc/%s/%s",
@@ -786,7 +806,8 @@ int __init scst_proc_init_module(void)
                goto out_remove2;
        }
 
-       generic = scst_create_proc_entry(scst_proc_scsi_tgt, SCST_PROC_HELP_NAME,
+       generic = scst_create_proc_entry(scst_proc_scsi_tgt,
+                                        SCST_PROC_HELP_NAME,
                                         &scst_help_proc_data);
        if (!generic) {
                PRINT_ERROR("cannot init /proc/%s/%s",
@@ -838,7 +859,7 @@ out_remove1:
        remove_proc_entry(SCST_PROC_ENTRY_NAME, scst_proc_scsi_tgt);
 
 out_remove:
-       remove_proc_entry(SCST_PROC_ENTRY_NAME, 0);
+       remove_proc_entry(SCST_PROC_ENTRY_NAME, NULL);
 
 out_nomem:
        res = -ENOMEM;
@@ -858,13 +879,14 @@ void __exit scst_proc_cleanup_module(void)
        remove_proc_entry(SCST_PROC_SESSIONS_NAME, scst_proc_scsi_tgt);
        remove_proc_entry(SCST_PROC_VERSION_NAME, scst_proc_scsi_tgt);
        remove_proc_entry(SCST_PROC_ENTRY_NAME, scst_proc_scsi_tgt);
-       remove_proc_entry(SCST_PROC_ENTRY_NAME, 0);
+       remove_proc_entry(SCST_PROC_ENTRY_NAME, NULL);
 
        TRACE_EXIT();
 }
 
-static ssize_t scst_proc_threads_write(struct file *file, const char __user *buf,
-                                  size_t length, loff_t *off)
+static ssize_t scst_proc_threads_write(struct file *file,
+                                      const char __user *buf,
+                                      size_t length, loff_t *off)
 {
        int res = length;
        int oldtn, newtn, delta;
@@ -1010,10 +1032,12 @@ void scst_cleanup_proc_target_entries(struct scst_tgt *vtt)
        return;
 }
 
-static ssize_t scst_proc_scsi_tgt_write(struct file *file, const char __user *buf,
-                                   size_t length, loff_t *off)
+static ssize_t scst_proc_scsi_tgt_write(struct file *file,
+                                       const char __user *buf,
+                                       size_t length, loff_t *off)
 {
-       struct scst_tgt *vtt = (struct scst_tgt *)PDE(file->f_dentry->d_inode)->data;
+       struct scst_tgt *vtt =
+               (struct scst_tgt *)PDE(file->f_dentry->d_inode)->data;
        ssize_t res = 0;
        char *buffer;
        char *start;
@@ -1150,10 +1174,12 @@ void scst_cleanup_proc_dev_handler_dir_entries(struct scst_dev_type *dev_type)
        return;
 }
 
-static ssize_t scst_proc_scsi_dev_handler_write(struct file *file, const char __user *buf,
-                                           size_t length, loff_t *off)
+static ssize_t scst_proc_scsi_dev_handler_write(struct file *file,
+                                               const char __user *buf,
+                                               size_t length, loff_t *off)
 {
-       struct scst_dev_type *dev_type = (struct scst_dev_type *)PDE(file->f_dentry->d_inode)->data;
+       struct scst_dev_type *dev_type =
+               (struct scst_dev_type *)PDE(file->f_dentry->d_inode)->data;
        ssize_t res = 0;
        char *buffer;
        char *start;
@@ -1211,7 +1237,8 @@ out:
        return res;
 }
 
-static ssize_t scst_proc_scsi_tgt_gen_write(struct file *file, const char __user *buf,
+static ssize_t scst_proc_scsi_tgt_gen_write(struct file *file,
+                                       const char __user *buf,
                                        size_t length, loff_t *off)
 {
        int res, rc = 0, action;
@@ -1432,13 +1459,15 @@ out_synt_err:
        goto out;
 }
 
-static ssize_t scst_proc_groups_devices_write(struct file *file, const char __user *buf,
-                                         size_t length, loff_t *off)
+static ssize_t scst_proc_groups_devices_write(struct file *file,
+                                       const char __user *buf,
+                                       size_t length, loff_t *off)
 {
        int res, action, virt = 0, rc, read_only = 0;
        char *buffer, *p, *e = NULL;
        unsigned int host, channel = 0, id = 0, lun = 0, virt_lun;
-       struct scst_acg *acg = (struct scst_acg *)PDE(file->f_dentry->d_inode)->data;
+       struct scst_acg *acg =
+               (struct scst_acg *)PDE(file->f_dentry->d_inode)->data;
        struct scst_acg_dev *acg_dev = NULL, *acg_dev_tmp;
        struct scst_device *d, *dev = NULL;
 
@@ -1469,8 +1498,10 @@ static ssize_t scst_proc_groups_devices_write(struct file *file, const char __us
        }
 
        /*
-        * Usage: echo "add|del H:C:I:L lun [READ_ONLY]" >/proc/scsi_tgt/groups/GROUP/devices
-        *   or   echo "add|del V_NAME lun [READ_ONLY]" >/proc/scsi_tgt/groups/GROUP/devices
+        * Usage: echo "add|del H:C:I:L lun [READ_ONLY]" \
+        *          >/proc/scsi_tgt/groups/GROUP/devices
+        *   or   echo "add|del V_NAME lun [READ_ONLY]" \
+        *          >/proc/scsi_tgt/groups/GROUP/devices
         *   or   echo "clear" >/proc/scsi_tgt/groups/GROUP/devices
         */
        p = buffer;
@@ -1632,12 +1663,14 @@ out:
        return res;
 }
 
-static ssize_t scst_proc_groups_names_write(struct file *file, const char __user *buf,
+static ssize_t scst_proc_groups_names_write(struct file *file,
+                                       const char __user *buf,
                                        size_t length, loff_t *off)
 {
        int res = length, action;
        char *buffer, *p, *e;
-       struct scst_acg *acg = (struct scst_acg *)PDE(file->f_dentry->d_inode)->data;
+       struct scst_acg *acg =
+               (struct scst_acg *)PDE(file->f_dentry->d_inode)->data;
        struct scst_acn *n, *nn;
 
        TRACE_ENTRY();
@@ -1811,8 +1844,8 @@ static int scst_dev_handler_type_info_show(struct seq_file *seq, void *v)
        TRACE_ENTRY();
 
        seq_printf(seq, "%d - %s\n", dev_type->type,
-                   dev_type->type > (int)ARRAY_SIZE(scst_proc_dev_handler_type) ?
-                   "unknown" : scst_proc_dev_handler_type[dev_type->type]);
+                  dev_type->type > (int)ARRAY_SIZE(scst_proc_dev_handler_type)
+                  ? "unknown" : scst_proc_dev_handler_type[dev_type->type]);
 
        TRACE_EXIT();
        return 0;
@@ -1836,11 +1869,13 @@ static int scst_sessions_info_show(struct seq_file *seq, void *v)
                goto out;
        }
 
-       seq_printf(seq, "%-20s %-45s %-35s %-15s\n", "Target name", "Initiator name",
-                      "Group name", "Command Count");
+       seq_printf(seq, "%-20s %-45s %-35s %-15s\n",
+                  "Target name", "Initiator name",
+                  "Group name", "Command Count");
 
        list_for_each_entry(acg, &scst_acg_list, scst_acg_list_entry) {
-               list_for_each_entry(sess, &acg->acg_sess_list, acg_sess_list_entry) {
+               list_for_each_entry(sess, &acg->acg_sess_list,
+                       acg_sess_list_entry) {
                        seq_printf(seq, "%-20s %-45s %-35s %-15d\n",
                                        sess->tgt->tgtt->name,
                                        sess->initiator_name,
@@ -1955,7 +1990,8 @@ static struct scst_proc_data scst_groups_devices_proc_data = {
 
 #if defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING)
 
-int scst_proc_read_tlb(const struct scst_proc_log *tbl, struct seq_file *seq,
+static int scst_proc_read_tlb(const struct scst_proc_log *tbl,
+                             struct seq_file *seq,
        unsigned long log_level, int *first)
 {
        const struct scst_proc_log *t = tbl;
@@ -2001,7 +2037,8 @@ static int log_info_show(struct seq_file *seq, void *v)
                goto out;
        }
 
-       res = scst_proc_log_entry_read(seq, trace_flag, scst_proc_local_trace_tbl);
+       res = scst_proc_log_entry_read(seq, trace_flag,
+                                      scst_proc_local_trace_tbl);
 
        mutex_unlock(&scst_log_mutex);
 
@@ -2030,7 +2067,8 @@ static int scst_tgt_info_show(struct seq_file *seq, void *v)
                goto out;
        }
 
-       seq_printf(seq, "%-60s%s\n", "Device (host:ch:id:lun or name)", "Device handler");
+       seq_printf(seq, "%-60s%s\n", "Device (host:ch:id:lun or name)",
+                  "Device handler");
        list_for_each_entry(dev, &scst_dev_list, dev_list_entry) {
                if (dev->virt_id == 0) {
                        char conv[60];
@@ -2042,9 +2080,10 @@ static int scst_tgt_info_show(struct seq_file *seq, void *v)
                        seq_printf(seq, "%s", conv);
                        sprintf(conv, "%%-%dd%%s\n", 60 - size);
                        seq_printf(seq, conv, dev->scsi_dev->lun,
-                                       dev->handler ? dev->handler->name : "-");
+                                  dev->handler ? dev->handler->name : "-");
                } else
-                       seq_printf(seq, "%-60s%s\n", dev->virt_name, dev->handler->name);
+                       seq_printf(seq, "%-60s%s\n",
+                                  dev->virt_name, dev->handler->name);
        }
 
        mutex_unlock(&scst_mutex);
@@ -2137,7 +2176,7 @@ struct proc_dir_entry *scst_create_proc_entry(struct proc_dir_entry *root,
        if (root) {
                mode_t mode;
 
-               mode  = S_IFREG | S_IRUGO | ((pdata->seq_op.write) ? S_IWUSR : 0);
+               mode = S_IFREG | S_IRUGO | (pdata->seq_op.write ? S_IWUSR : 0);
                p = create_proc_entry(name, mode, root);
                if (p == NULL) {
                        PRINT_ERROR("Fail to create entry %s in /proc", name);
index a4f5e4f..48740d9 100644 (file)
@@ -64,7 +64,8 @@ struct scst_cmd *scst_rx_cmd(struct scst_session *sess,
 
 #ifdef CONFIG_SCST_EXTRACHECKS
        if (unlikely(sess->shut_phase != SCST_SESS_SPH_READY)) {
-               PRINT_CRIT_ERROR("%s", "New cmd while shutting down the session");
+               PRINT_CRIT_ERROR("%s",
+                       "New cmd while shutting down the session");
                sBUG();
        }
 #endif
@@ -229,7 +230,8 @@ void scst_cmd_init_done(struct scst_cmd *cmd, int pref_context)
                case SCST_SESS_IPH_SUCCESS:
                        break;
                case SCST_SESS_IPH_INITING:
-                       TRACE_DBG("Adding cmd %p to init deferred cmd list", cmd);
+                       TRACE_DBG("Adding cmd %p to init deferred cmd list",
+                                 cmd);
                        list_add_tail(&cmd->cmd_list_entry,
                                &sess->init_deferred_cmd_list);
                        spin_unlock_irqrestore(&sess->sess_list_lock, flags);
@@ -243,7 +245,8 @@ void scst_cmd_init_done(struct scst_cmd *cmd, int pref_context)
                        sBUG();
                }
        } else
-               list_add_tail(&cmd->search_cmd_list_entry, &sess->search_cmd_list);
+               list_add_tail(&cmd->search_cmd_list_entry,
+                             &sess->search_cmd_list);
 
        spin_unlock_irqrestore(&sess->sess_list_lock, flags);
 
@@ -323,9 +326,9 @@ static int scst_pre_parse(struct scst_cmd *cmd)
        TRACE_ENTRY();
 
        cmd->inc_expected_sn_on_done = dev->handler->exec_sync ||
-               (!dev->has_own_order_mgmt &&
-                ((dev->queue_alg == SCST_CONTR_MODE_QUEUE_ALG_RESTRICTED_REORDER) ||
-                 (cmd->queue_type == SCST_CMD_QUEUE_ORDERED)));
+            (!dev->has_own_order_mgmt &&
+             (dev->queue_alg == SCST_CONTR_MODE_QUEUE_ALG_RESTRICTED_REORDER ||
+              cmd->queue_type == SCST_CMD_QUEUE_ORDERED));
 
        /*
         * Expected transfer data supplied by the SCSI transport via the
@@ -382,7 +385,8 @@ static int scst_pre_parse(struct scst_cmd *cmd)
                        cmd->op_name, cmd->data_direction,
                        cmd->expected_data_direction,
                        scst_cmd_is_expected_set(cmd) ? "yes" : "no",
-                       cmd->bufflen, cmd->expected_transfer_len, cmd->op_flags);
+                       cmd->bufflen, cmd->expected_transfer_len,
+                       cmd->op_flags);
 
                if (unlikely((cmd->op_flags & SCST_UNKNOWN_LENGTH) != 0)) {
                        if (scst_cmd_is_expected_set(cmd)) {
@@ -445,7 +449,7 @@ static bool scst_is_allowed_to_mismatch_cmd(struct scst_cmd *cmd)
        case VERIFY_12:
        case VERIFY_16:
                /* VERIFY commands with BYTCHK unset shouldn't fail here */
-               if (((cmd->op_flags & SCST_VERIFY_BYTCHK_MISMATCH_ALLOWED) != 0) &&
+               if ((cmd->op_flags & SCST_VERIFY_BYTCHK_MISMATCH_ALLOWED) &&
                    (cmd->cdb[1] & BYTCHK) == 0)
                        res = true;
                break;
@@ -479,7 +483,8 @@ static int scst_parse_cmd(struct scst_cmd *cmd)
 
                TRACE_DBG("Calling dev handler %s parse(%p)",
                      dev->handler->name, cmd);
-               TRACE_BUFF_FLAG(TRACE_SND_BOT, "Parsing: ", cmd->cdb, cmd->cdb_len);
+               TRACE_BUFF_FLAG(TRACE_SND_BOT, "Parsing: ",
+                               cmd->cdb, cmd->cdb_len);
                state = dev->handler->parse(cmd);
                /* Caution: cmd can be already dead here */
                TRACE_DBG("Dev handler %s parse() returned %d",
@@ -546,10 +551,12 @@ static int scst_parse_cmd(struct scst_cmd *cmd)
 #      ifdef CONFIG_SCST_EXTRACHECKS
                if ((cmd->data_direction != cmd->expected_data_direction) ||
                    (cmd->bufflen != cmd->expected_transfer_len)) {
-                       PRINT_WARNING("Expected values don't match decoded ones: "
-                               "data_direction %d, expected_data_direction %d, "
+                       PRINT_WARNING("Expected values don't match decoded "
+                               "ones: data_direction %d, "
+                               "expected_data_direction %d, "
                                "bufflen %d, expected_transfer_len %d",
-                               cmd->data_direction, cmd->expected_data_direction,
+                               cmd->data_direction,
+                               cmd->expected_data_direction,
                                cmd->bufflen, cmd->expected_transfer_len);
                        PRINT_BUFFER("Suspicious CDB", cmd->cdb, cmd->cdb_len);
                }
@@ -557,18 +564,22 @@ static int scst_parse_cmd(struct scst_cmd *cmd)
                cmd->data_direction = cmd->expected_data_direction;
                cmd->bufflen = cmd->expected_transfer_len;
 #else
-               if (unlikely(cmd->data_direction != cmd->expected_data_direction)) {
+               if (unlikely(cmd->data_direction !=
+                               cmd->expected_data_direction)) {
                        if (((cmd->expected_data_direction != SCST_DATA_NONE) ||
                             (cmd->bufflen != 0)) &&
                            !scst_is_allowed_to_mismatch_cmd(cmd)) {
-                               PRINT_ERROR("Expected data direction %d for opcode "
-                                       "0x%02x (handler %s, target %s) doesn't match "
-                                       "decoded value %d", cmd->expected_data_direction,
+                               PRINT_ERROR("Expected data direction %d for "
+                                       "opcode 0x%02x (handler %s, target %s) "
+                                       "doesn't match "
+                                       "decoded value %d",
+                                       cmd->expected_data_direction,
                                        cmd->cdb[0], dev->handler->name,
                                        cmd->tgtt->name, cmd->data_direction);
-                               PRINT_BUFFER("Failed CDB", cmd->cdb, cmd->cdb_len);
+                               PRINT_BUFFER("Failed CDB",
+                                       cmd->cdb, cmd->cdb_len);
                                scst_set_cmd_error(cmd,
-                                       SCST_LOAD_SENSE(scst_sense_invalid_message));
+                                  SCST_LOAD_SENSE(scst_sense_invalid_message));
                                goto out_dev_done;
                        }
                }
@@ -1102,7 +1113,8 @@ static int scst_tgt_pre_exec(struct scst_cmd *cmd)
                        break;
                case SCST_PREPROCESS_STATUS_NEED_THREAD:
                        TRACE_DBG("Target driver's %s pre_exec() requested "
-                               "thread context, rescheduling", cmd->tgtt->name);
+                               "thread context, rescheduling",
+                               cmd->tgtt->name);
                        res = SCST_CMD_STATE_RES_NEED_THREAD;
                        cmd->state = SCST_CMD_STATE_TGT_PRE_EXEC;
                        break;
@@ -1128,8 +1140,8 @@ static void scst_do_cmd_done(struct scst_cmd *cmd, int result,
                getnstimeofday(&ts);
                cmd->post_exec_start = scst_sec_to_nsec(ts.tv_sec) + ts.tv_nsec;
                TRACE_DBG("cmd %p (sess %p): post_exec_start %lld (tv_sec %ld, "
-                       "tv_nsec %ld)", cmd, cmd->sess, cmd->post_exec_start, ts.tv_sec,
-                       ts.tv_nsec);
+                       "tv_nsec %ld)", cmd, cmd->sess, cmd->post_exec_start,
+                       ts.tv_sec, ts.tv_nsec);
        }
 #endif
 
@@ -1268,8 +1280,8 @@ static void scst_cmd_done_local(struct scst_cmd *cmd, int next_state)
                getnstimeofday(&ts);
                cmd->post_exec_start = scst_sec_to_nsec(ts.tv_sec) + ts.tv_nsec;
                TRACE_DBG("cmd %p (sess %p): post_exec_start %lld (tv_sec %ld, "
-                       "tv_nsec %ld)", cmd, cmd->sess, cmd->post_exec_start, ts.tv_sec,
-                       ts.tv_nsec);
+                       "tv_nsec %ld)", cmd, cmd->sess, cmd->post_exec_start,
+                       ts.tv_sec, ts.tv_nsec);
        }
 #endif
 
@@ -1362,7 +1374,8 @@ static int scst_report_luns_local(struct scst_cmd *cmd)
                        if (!overflow) {
                                if (offs >= buffer_size) {
                                        scst_put_buf(cmd, buffer);
-                                       buffer_size = scst_get_buf_next(cmd, &buffer);
+                                       buffer_size = scst_get_buf_next(cmd,
+                                                                      &buffer);
                                        if (buffer_size > 0) {
                                                memset(buffer, 0, buffer_size);
                                                offs = 0;
@@ -1372,9 +1385,10 @@ static int scst_report_luns_local(struct scst_cmd *cmd)
                                        }
                                }
                                if ((buffer_size - offs) < 8) {
-                                       PRINT_ERROR("Buffer allocated for REPORT "
-                                               "LUNS command doesn't allow to fit 8 "
-                                               "byte entry (buffer_size=%d)",
+                                       PRINT_ERROR("Buffer allocated for "
+                                               "REPORT LUNS command doesn't "
+                                               "allow to fit 8 byte entry "
+                                               "(buffer_size=%d)",
                                                buffer_size);
                                        goto out_put_hw_err;
                                }
@@ -1595,13 +1609,19 @@ int scst_check_local_events(struct scst_cmd *cmd)
        }
 
        /* Reserve check before Unit Attention */
-       if (unlikely(test_bit(SCST_TGT_DEV_RESERVED, &tgt_dev->tgt_dev_flags))) {
-               if ((cmd->cdb[0] != INQUIRY) && (cmd->cdb[0] != REPORT_LUNS) &&
-                   (cmd->cdb[0] != RELEASE) && (cmd->cdb[0] != RELEASE_10) &&
-                   (cmd->cdb[0] != REPORT_DEVICE_IDENTIFIER) &&
-                   (cmd->cdb[0] != ALLOW_MEDIUM_REMOVAL || (cmd->cdb[4] & 3)) &&
-                   (cmd->cdb[0] != LOG_SENSE) && (cmd->cdb[0] != REQUEST_SENSE)) {
-                       scst_set_cmd_error_status(cmd, SAM_STAT_RESERVATION_CONFLICT);
+       if (unlikely(test_bit(SCST_TGT_DEV_RESERVED,
+                             &tgt_dev->tgt_dev_flags))) {
+               if (cmd->cdb[0] != INQUIRY &&
+                   cmd->cdb[0] != REPORT_LUNS &&
+                   cmd->cdb[0] != RELEASE &&
+                   cmd->cdb[0] != RELEASE_10 &&
+                   cmd->cdb[0] != REPORT_DEVICE_IDENTIFIER &&
+                   (cmd->cdb[0] != ALLOW_MEDIUM_REMOVAL ||
+                    (cmd->cdb[4] & 3)) &&
+                   cmd->cdb[0] != LOG_SENSE &&
+                   cmd->cdb[0] != REQUEST_SENSE) {
+                       scst_set_cmd_error_status(cmd,
+                               SAM_STAT_RESERVATION_CONFLICT);
                        goto out_complete;
                }
        }
@@ -1611,14 +1631,20 @@ int scst_check_local_events(struct scst_cmd *cmd)
            unlikely(dev->scsi_dev->was_reset)) {
                if (scst_is_ua_command(cmd)) {
                        int done = 0;
-                       /* Prevent more than 1 cmd to be triggered by was_reset */
+                       /*
+                        * Prevent more than 1 cmd to be triggered by
+                        * was_reset.
+                        */
                        spin_lock_bh(&dev->dev_lock);
                        barrier(); /* to reread was_reset */
                        if (dev->scsi_dev->was_reset) {
                                TRACE(TRACE_MGMT, "was_reset is %d", 1);
                                scst_set_cmd_error(cmd,
-                                          SCST_LOAD_SENSE(scst_sense_reset_UA));
-                               /* It looks like it is safe to clear was_reset here */
+                                         SCST_LOAD_SENSE(scst_sense_reset_UA));
+                               /*
+                                * It looks like it is safe to clear was_reset
+                                * here.
+                                */
                                dev->scsi_dev->was_reset = 0;
                                done = 1;
                        }
@@ -1676,7 +1702,10 @@ void scst_inc_expected_sn(struct scst_tgt_dev *tgt_dev, atomic_t *slot)
                if (likely(tgt_dev->num_free_sn_slots < (int)ARRAY_SIZE(tgt_dev->sn_slots)-1)) {
                        if (tgt_dev->num_free_sn_slots < 0)
                                tgt_dev->cur_sn_slot = slot;
-                       smp_mb(); /* to be in-sync with SIMPLE case in scst_cmd_set_sn() */
+                       /*
+                        * To be in-sync with SIMPLE case in scst_cmd_set_sn()
+                        */
+                       smp_mb();
                        tgt_dev->num_free_sn_slots++;
                        TRACE_SN("Incremented num_free_sn_slots (%d)",
                                tgt_dev->num_free_sn_slots);
@@ -1868,7 +1897,8 @@ static inline int scst_real_exec(struct scst_cmd *cmd)
        if (likely(res == SCST_EXEC_COMPLETED)) {
                scst_post_exec_sn(cmd, true);
                if (cmd->dev->scsi_dev != NULL)
-                       generic_unplug_device(cmd->dev->scsi_dev->request_queue);
+                       generic_unplug_device(
+                               cmd->dev->scsi_dev->request_queue);
        } else
                sBUG_ON(res != SCST_EXEC_NEED_THREAD);
 
@@ -2090,7 +2120,8 @@ static int scst_send_for_exec(struct scst_cmd **active_cmd)
 
                expected_sn = tgt_dev->expected_sn;
                if ((cmd->sn != expected_sn) || (tgt_dev->hq_cmd_count > 0)) {
-                       if (unlikely(test_bit(SCST_CMD_ABORTED, &cmd->cmd_flags))) {
+                       if (unlikely(test_bit(SCST_CMD_ABORTED,
+                                             &cmd->cmd_flags))) {
                                /* Necessary to allow aborting out of sn cmds */
                                TRACE_MGMT_DBG("Aborting out of sn cmd %p "
                                        "(tag %llu, sn %lu)", cmd,
@@ -2157,8 +2188,8 @@ static int scst_check_sense(struct scst_cmd *cmd)
                                if (cmd->double_ua_possible) {
                                        TRACE(TRACE_MGMT_MINOR, "Double UA "
                                                "detected for device %p", dev);
-                                       TRACE(TRACE_MGMT_MINOR, "Retrying cmd %p "
-                                               "(tag %llu)", cmd,
+                                       TRACE(TRACE_MGMT_MINOR, "Retrying cmd"
+                                               " %p (tag %llu)", cmd,
                                                (long long unsigned)cmd->tag);
 
                                        cmd->status = 0;
@@ -2166,7 +2197,8 @@ static int scst_check_sense(struct scst_cmd *cmd)
                                        cmd->host_status = DID_OK;
                                        cmd->driver_status = 0;
 
-                                       mempool_free(cmd->sense, scst_sense_mempool);
+                                       mempool_free(cmd->sense,
+                                                    scst_sense_mempool);
                                        cmd->sense = NULL;
 
                                        scst_check_restore_sg_buff(cmd);
@@ -2234,7 +2266,8 @@ static int scst_check_auto_sense(struct scst_cmd *cmd)
                        TRACE(TRACE_SCSI|TRACE_MINOR, "Host status %x "
                                "received, returning HARDWARE ERROR instead",
                                cmd->host_status);
-                       scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_hardw_error));
+                       scst_set_cmd_error(cmd,
+                               SCST_LOAD_SENSE(scst_sense_hardw_error));
                }
        }
 
@@ -2270,7 +2303,9 @@ static int scst_pre_dev_done(struct scst_cmd *cmd)
                if (unlikely((cmd->cdb[0] == MODE_SENSE ||
                              cmd->cdb[0] == MODE_SENSE_10)) &&
                    cmd->tgt_dev->acg_dev->rd_only_flag &&
-                   (type == TYPE_DISK || type == TYPE_WORM || type == TYPE_MOD ||
+                   (type == TYPE_DISK ||
+                    type == TYPE_WORM ||
+                    type == TYPE_MOD ||
                     type == TYPE_TAPE)) {
                        int32_t length;
                        uint8_t *address;
@@ -2299,7 +2334,8 @@ static int scst_pre_dev_done(struct scst_cmd *cmd)
                 * since we don't support ACA
                 */
                if (unlikely((cmd->cdb[0] == INQUIRY)) &&
-                   !(cmd->cdb[1] & SCST_INQ_EVPD/* Std INQUIRY data (no EVPD) */) &&
+                   /* Std INQUIRY data (no EVPD) */
+                   !(cmd->cdb[1] & SCST_INQ_EVPD) &&
                    (cmd->resp_data_len > SCST_INQ_BYTE3)) {
                        uint8_t *buffer;
                        int buflen;
@@ -2322,7 +2358,7 @@ static int scst_pre_dev_done(struct scst_cmd *cmd)
                                PRINT_ERROR("%s", "Unable to get INQUIRY "
                                    "buffer");
                                scst_set_cmd_error(cmd,
-                                       SCST_LOAD_SENSE(scst_sense_hardw_error));
+                                      SCST_LOAD_SENSE(scst_sense_hardw_error));
                                err = true;
                        }
                        if (buflen > 0)
@@ -2335,7 +2371,8 @@ static int scst_pre_dev_done(struct scst_cmd *cmd)
                if (unlikely((cmd->cdb[0] == MODE_SELECT) ||
                    (cmd->cdb[0] == MODE_SELECT_10) ||
                    (cmd->cdb[0] == LOG_SELECT))) {
-                       TRACE(TRACE_SCSI, "MODE/LOG SELECT succeeded (LUN %lld)",
+                       TRACE(TRACE_SCSI,
+                               "MODE/LOG SELECT succeeded (LUN %lld)",
                                (long long unsigned int)cmd->lun);
                        cmd->state = SCST_CMD_STATE_MODE_SELECT_CHECKS;
                        goto out;
@@ -2347,7 +2384,8 @@ static int scst_pre_dev_done(struct scst_cmd *cmd)
                                struct scst_tgt_dev *tgt_dev_tmp;
                                struct scst_device *dev = cmd->dev;
 
-                               TRACE(TRACE_SCSI, "Real RESERVE failed lun=%lld, "
+                               TRACE(TRACE_SCSI,
+                                       "Real RESERVE failed lun=%lld, "
                                        "status=%x",
                                        (long long unsigned int)cmd->lun,
                                        cmd->status);
@@ -2356,7 +2394,8 @@ static int scst_pre_dev_done(struct scst_cmd *cmd)
 
                                /* Clearing the reservation */
                                spin_lock_bh(&dev->dev_lock);
-                               list_for_each_entry(tgt_dev_tmp, &dev->dev_tgt_dev_list,
+                               list_for_each_entry(tgt_dev_tmp,
+                                                   &dev->dev_tgt_dev_list,
                                                    dev_tgt_dev_list_entry) {
                                        clear_bit(SCST_TGT_DEV_RESERVED,
                                                &tgt_dev_tmp->tgt_dev_flags);
@@ -2435,7 +2474,8 @@ static int scst_mode_select_checks(struct scst_cmd *cmd)
                    (((cmd->sense[12] == 0x2a) && (cmd->sense[13] == 0x01)) ||
                     (cmd->sense[12] == 0x29) /* reset */ ||
                     (cmd->sense[12] == 0x28) /* medium changed */ ||
-                    (cmd->sense[12] == 0x2F) /* cleared by another ini (just in case) */)) {
+                    /* cleared by another ini (just in case) */
+                    (cmd->sense[12] == 0x2F))) {
                if (atomic) {
                        TRACE_DBG("Possible parameters changed UA %x: "
                                "thread context required", cmd->sense[12]);
@@ -2567,9 +2607,11 @@ static int scst_pre_xmit_response(struct scst_cmd *cmd)
        TRACE_ENTRY();
 
 #ifdef CONFIG_SCST_DEBUG_TM
-       if (cmd->tm_dbg_delayed && !test_bit(SCST_CMD_ABORTED, &cmd->cmd_flags)) {
+       if (cmd->tm_dbg_delayed &&
+                       !test_bit(SCST_CMD_ABORTED, &cmd->cmd_flags)) {
                if (scst_cmd_atomic(cmd)) {
-                       TRACE_MGMT_DBG("%s", "DEBUG_TM delayed cmd needs a thread");
+                       TRACE_MGMT_DBG("%s",
+                               "DEBUG_TM delayed cmd needs a thread");
                        res = SCST_CMD_STATE_RES_NEED_THREAD;
                        return res;
                }
@@ -2590,7 +2632,8 @@ static int scst_pre_xmit_response(struct scst_cmd *cmd)
                        scst_on_hq_cmd_response(cmd);
 
                if (unlikely(!cmd->sent_for_exec)) {
-                       TRACE_SN("cmd %p was not sent to mid-lev (sn %ld, set %d)",
+                       TRACE_SN("cmd %p was not sent to mid-lev"
+                               " (sn %ld, set %d)",
                                cmd, cmd->sn, cmd->sn_set);
                        scst_unblock_deferred(cmd->tgt_dev, cmd);
                        cmd->sent_for_exec = 1;
@@ -2615,8 +2658,9 @@ static int scst_pre_xmit_response(struct scst_cmd *cmd)
                scst_xmit_process_aborted_cmd(cmd);
 
        if (unlikely(test_bit(SCST_CMD_NO_RESP, &cmd->cmd_flags))) {
-               TRACE_MGMT_DBG("Flag NO_RESP set for cmd %p (tag %llu), skipping",
-                              cmd, (long long unsigned int)cmd->tag);
+               TRACE_MGMT_DBG("Flag NO_RESP set for cmd %p (tag %llu),"
+                               " skipping",
+                               cmd, (long long unsigned int)cmd->tag);
                cmd->state = SCST_CMD_STATE_FINISHED;
                res = SCST_CMD_STATE_RES_CONT_SAME;
                goto out;
@@ -2648,8 +2692,9 @@ out:
                spin_unlock_bh(&sess->meas_lock);
 
                TRACE_DBG("cmd %p (sess %p): finish %lld (tv_sec %ld, "
-                       "tv_nsec %ld), scst_time %lld, proc_time %lld", cmd, sess,
-                       finish, ts.tv_sec, ts.tv_nsec, scst_time, proc_time);
+                       "tv_nsec %ld), scst_time %lld, proc_time %lld",
+                       cmd, sess, finish, ts.tv_sec, ts.tv_nsec, scst_time,
+                       proc_time);
        }
 #endif
        TRACE_EXIT_HRES(res);
@@ -2686,8 +2731,8 @@ static int scst_xmit_response(struct scst_cmd *cmd)
                if (cmd->sg) {
                        int i;
                        struct scatterlist *sg = cmd->sg;
-                       TRACE_SEND_BOT("Xmitting %d S/G(s) at %p sg[0].page at %p",
-                             cmd->sg_cnt, sg, (void *)sg_page(&sg[0]));
+                       TRACE_SEND_BOT("Xmitting %d S/G(s) at %p sg[0].page at "
+                               "%p", cmd->sg_cnt, sg, (void *)sg_page(&sg[0]));
                        for (i = 0; i < cmd->sg_cnt; ++i) {
                                TRACE_BUFF_FLAG(TRACE_SND_BOT,
                                    "Xmitting sg", sg_virt(&sg[i]),
@@ -2813,7 +2858,8 @@ static void scst_cmd_set_sn(struct scst_cmd *cmd)
        TRACE_ENTRY();
 
        if (scst_is_implicit_hq(cmd)) {
-               TRACE(TRACE_SCSI|TRACE_SCSI_SERIALIZING, "Implicit HQ cmd %p", cmd);
+               TRACE(TRACE_SCSI|TRACE_SCSI_SERIALIZING,
+                       "Implicit HQ cmd %p", cmd);
                cmd->queue_type = SCST_CMD_QUEUE_HEAD_OF_QUEUE;
        }
 
@@ -2823,7 +2869,8 @@ static void scst_cmd_set_sn(struct scst_cmd *cmd)
 
        scst_check_debug_sn(cmd);
 
-       if (cmd->dev->queue_alg == SCST_CONTR_MODE_QUEUE_ALG_RESTRICTED_REORDER) {
+       if (cmd->dev->queue_alg ==
+                       SCST_CONTR_MODE_QUEUE_ALG_RESTRICTED_REORDER) {
                /*
                 * Not the best way, but well enough until there will be a
                 * possibility to specify queue type during pass-through
@@ -2874,14 +2921,13 @@ ordered:
                                tgt_dev->num_free_sn_slots--;
                                if (tgt_dev->num_free_sn_slots >= 0) {
                                        int i = 0;
-                                       /*
-                                        * Commands can finish in any order, so we don't
-                                        * know, which slot is empty.
+                                       /* Commands can finish in any order, so
+                                        * we don't know which slot is empty.
                                         */
                                        while (1) {
                                                tgt_dev->cur_sn_slot++;
-                                               if (tgt_dev->cur_sn_slot == tgt_dev->sn_slots +
-                                                               ARRAY_SIZE(tgt_dev->sn_slots))
+                                               if (tgt_dev->cur_sn_slot ==
+                                                     tgt_dev->sn_slots + ARRAY_SIZE(tgt_dev->sn_slots))
                                                        tgt_dev->cur_sn_slot = tgt_dev->sn_slots;
 
                                                if (atomic_read(tgt_dev->cur_sn_slot) == 0)
@@ -2891,7 +2937,8 @@ ordered:
                                                sBUG_ON(i == ARRAY_SIZE(tgt_dev->sn_slots));
                                        }
                                        TRACE_SN("New cur SN slot %zd",
-                                               tgt_dev->cur_sn_slot-tgt_dev->sn_slots);
+                                               tgt_dev->cur_sn_slot -
+                                               tgt_dev->sn_slots);
                                }
                        }
                        spin_unlock_irqrestore(&tgt_dev->sn_lock, flags);
@@ -2955,10 +3002,11 @@ static int scst_translate_lun(struct scst_cmd *cmd)
                        if (tgt_dev->lun == cmd->lun) {
                                TRACE_DBG("tgt_dev %p found", tgt_dev);
 
-                               if (unlikely(tgt_dev->dev->handler == &scst_null_devtype)) {
+                               if (unlikely(tgt_dev->dev->handler ==
+                                               &scst_null_devtype)) {
                                        PRINT_INFO("Dev handler for device "
-                                         "%lld is NULL, the device will not be "
-                                         "visible remotely",
+                                         "%lld is NULL, the device will not "
+                                         "be visible remotely",
                                           (long long unsigned int)cmd->lun);
                                        break;
                                }
@@ -2972,8 +3020,10 @@ static int scst_translate_lun(struct scst_cmd *cmd)
                        }
                }
                if (res != 0) {
-                       TRACE(TRACE_MINOR, "tgt_dev for lun %lld not found, command to "
-                               "unexisting LU?", (long long unsigned int)cmd->lun);
+                       TRACE(TRACE_MINOR,
+                               "tgt_dev for lun %lld not found, command to "
+                               "unexisting LU?",
+                               (long long unsigned int)cmd->lun);
                        __scst_put();
                }
        } else {
@@ -3007,7 +3057,8 @@ static int __scst_init_cmd(struct scst_cmd *cmd)
 
                cnt = atomic_inc_return(&cmd->tgt_dev->tgt_dev_cmd_count);
                if (unlikely(cnt > SCST_MAX_TGT_DEV_COMMANDS)) {
-                       TRACE(TRACE_MGMT_MINOR, "Too many pending commands (%d) in "
+                       TRACE(TRACE_MGMT_MINOR,
+                               "Too many pending commands (%d) in "
                                "session, returning BUSY to initiator \"%s\"",
                                cnt, (cmd->sess->initiator_name[0] == '\0') ?
                                  "Anonymous" : cmd->sess->initiator_name);
@@ -3017,11 +3068,13 @@ static int __scst_init_cmd(struct scst_cmd *cmd)
                cnt = atomic_inc_return(&cmd->dev->dev_cmd_count);
                if (unlikely(cnt > SCST_MAX_DEV_COMMANDS)) {
                        if (!failure) {
-                               TRACE(TRACE_MGMT_MINOR, "Too many pending device "
+                               TRACE(TRACE_MGMT_MINOR,
+                                       "Too many pending device "
                                        "commands (%d), returning BUSY to "
                                        "initiator \"%s\"", cnt,
                                        (cmd->sess->initiator_name[0] == '\0') ?
-                                         "Anonymous" : cmd->sess->initiator_name);
+                                               "Anonymous" :
+                                               cmd->sess->initiator_name);
                                failure = true;
                        }
                }
@@ -3079,7 +3132,8 @@ restart:
                        rc = __scst_init_cmd(cmd);
                        spin_lock_irq(&scst_init_lock);
                        if (rc > 0) {
-                               TRACE_MGMT_DBG("%s", "FLAG SUSPENDED set, restarting");
+                               TRACE_MGMT_DBG("%s",
+                                       "FLAG SUSPENDED set, restarting");
                                goto restart;
                        }
                } else {
@@ -3232,17 +3286,26 @@ void scst_process_active_cmd(struct scst_cmd *cmd, int context)
                                break;
                        }
                        res = scst_send_for_exec(&cmd);
-                       /* !! At this point cmd, sess & tgt_dev can be already freed !! */
+                       /*
+                        * !! At this point cmd, sess & tgt_dev can already be
+                        * freed !!
+                        */
                        break;
 
                case SCST_CMD_STATE_LOCAL_EXEC:
                        res = scst_local_exec(cmd);
-                       /* !! At this point cmd, sess & tgt_dev can be already freed !! */
+                       /*
+                        * !! At this point cmd, sess & tgt_dev can already be
+                        * freed !!
+                        */
                        break;
 
                case SCST_CMD_STATE_REAL_EXEC:
                        res = scst_real_exec(cmd);
-                       /* !! At this point cmd, sess & tgt_dev can be already freed !! */
+                       /*
+                        * !! At this point cmd, sess & tgt_dev can already be
+                        * freed !!
+                        */
                        break;
 
                case SCST_CMD_STATE_PRE_DEV_DONE:
@@ -3303,7 +3366,8 @@ void scst_process_active_cmd(struct scst_cmd *cmd, int context)
                case SCST_CMD_STATE_PRE_XMIT_RESP:
                case SCST_CMD_STATE_XMIT_RESP:
                case SCST_CMD_STATE_FINISHED:
-                       TRACE_DBG("Adding cmd %p to head of active cmd list", cmd);
+                       TRACE_DBG("Adding cmd %p to head of active cmd list",
+                                 cmd);
                        list_add(&cmd->cmd_list_entry,
                                &cmd->cmd_lists->active_cmd_list);
                        break;
@@ -3311,8 +3375,7 @@ void scst_process_active_cmd(struct scst_cmd *cmd, int context)
                /* not very valid commands */
                case SCST_CMD_STATE_DEFAULT:
                case SCST_CMD_STATE_NEED_THREAD_CTX:
-                       PRINT_CRIT_ERROR("cmd %p is in state %d, not putting on "
-                               "useful list (left on scst cmd list)", cmd,
+                       PRINT_CRIT_ERROR("cmd %p is in invalid state %d)", cmd,
                                cmd->state);
                        spin_unlock_irq(&cmd->cmd_lists->cmd_list_lock);
                        sBUG();
@@ -3334,7 +3397,7 @@ EXPORT_SYMBOL(scst_process_active_cmd);
 
 /* Called under cmd_list_lock and IRQs disabled */
 static void scst_do_job_active(struct list_head *cmd_list,
-       spinlock_t *cmd_list_lock, int context)
+       spinlock_t *cmd_list_lock, int context)
 {
        TRACE_ENTRY();
 
@@ -3698,7 +3761,8 @@ void scst_abort_cmd(struct scst_cmd *cmd, struct scst_mgmt_cmd *mcmd,
 
        TRACE_ENTRY();
 
-       TRACE(((mcmd != NULL) && (mcmd->fn == SCST_ABORT_TASK)) ? TRACE_MGMT_MINOR : TRACE_MGMT,
+       TRACE((mcmd && mcmd->fn == SCST_ABORT_TASK)
+               ? TRACE_MGMT_MINOR : TRACE_MGMT,
                "Aborting cmd %p (tag %llu, op %x)",
                cmd, (long long unsigned int)cmd->tag, cmd->cdb[0]);
 
@@ -3727,7 +3791,6 @@ void scst_abort_cmd(struct scst_cmd *cmd, struct scst_mgmt_cmd *mcmd,
        smp_mb__after_set_bit();
 
        if (cmd->tgt_dev == NULL) {
-               unsigned long flags;
                spin_lock_irqsave(&scst_init_lock, flags);
                scst_init_poll_cnt++;
                spin_unlock_irqrestore(&scst_init_lock, flags);
@@ -3770,8 +3833,8 @@ void scst_abort_cmd(struct scst_cmd *cmd, struct scst_mgmt_cmd *mcmd,
                 * after this TM command completed.
                 */
                TRACE_MGMT_DBG("cmd %p (tag %llu, sn %lu) being "
-                       "executed/xmitted (state %d, op %x, proc time %ld sec., "
-                       "timeout %d sec.), deferring ABORT...", cmd,
+                       "executed/xmitted (state %d, op %x, proc time %ld "
+                       "sec., timeout %d sec.), deferring ABORT...", cmd,
                        (long long unsigned int)cmd->tag, cmd->sn, cmd->state,
                        cmd->cdb[0], (long)(jiffies - cmd->start_time) / HZ,
                        cmd->timeout / HZ);
@@ -3877,7 +3940,8 @@ static void scst_unblock_aborted_cmds(int scst_mutex_held)
                                if (__scst_check_unblock_aborted_cmd(cmd,
                                                &cmd->sn_cmd_list_entry)) {
                                        TRACE_MGMT_DBG("Unblocked aborted SN "
-                                               "cmd %p (sn %lu)", cmd, cmd->sn);
+                                               "cmd %p (sn %lu)",
+                                               cmd, cmd->sn);
                                        tgt_dev->def_cmd_count--;
                                }
                        }
@@ -4036,11 +4100,13 @@ static int scst_clear_task_set(struct scst_mgmt_cmd *mcmd)
        mutex_unlock(&scst_mutex);
 
        if (!dev->tas) {
-               list_for_each_entry(tgt_dev, &UA_tgt_devs, extra_tgt_dev_list_entry) {
+               list_for_each_entry(tgt_dev, &UA_tgt_devs,
+                       extra_tgt_dev_list_entry) {
                        spin_lock_bh(&scst_temp_UA_lock);
                        scst_set_sense(scst_temp_UA, sizeof(scst_temp_UA),
                                SCST_LOAD_SENSE(scst_sense_cleared_by_another_ini_UA));
-                       scst_check_set_UA(tgt_dev, scst_temp_UA, sizeof(scst_temp_UA), 0);
+                       scst_check_set_UA(tgt_dev, scst_temp_UA,
+                               sizeof(scst_temp_UA), 0);
                        spin_unlock_bh(&scst_temp_UA_lock);
                }
        }
@@ -4224,12 +4290,20 @@ static int scst_target_reset(struct scst_mgmt_cmd *mcmd)
                TRACE(TRACE_MGMT, "Result of host %d target reset: %s",
                      dev->scsi_dev->host->host_no,
                      (rc == SUCCESS) ? "SUCCESS" : "FAILED");
-#if 0 /* scsi_reset_provider() returns very weird status, so let's always succeed */
+#if 0
                if ((rc != SUCCESS) &&
                    (mcmd->status == SCST_MGMT_STATUS_SUCCESS)) {
-                       /* SCSI_TRY_RESET_BUS is also done by scsi_reset_provider() */
+                       /* 
+                        * SCSI_TRY_RESET_BUS is also done by
+                        * scsi_reset_provider()
+                        */
                        mcmd->status = SCST_MGMT_STATUS_FAILED;
                }
+#else
+       /*
+        * scsi_reset_provider() returns very weird status, so let's
+        * always succeed
+        */
 #endif
        }
 
@@ -4274,9 +4348,14 @@ static int scst_lun_reset(struct scst_mgmt_cmd *mcmd)
                TRACE(TRACE_MGMT, "Resetting host %d bus ",
                      dev->scsi_dev->host->host_no);
                rc = scsi_reset_provider(dev->scsi_dev, SCSI_TRY_RESET_DEVICE);
-#if 0 /* scsi_reset_provider() returns very weird status, so let's always succeed */
-               if ((rc != SUCCESS) && (mcmd->status == SCST_MGMT_STATUS_SUCCESS))
+#if 0
+               if (rc != SUCCESS && mcmd->status == SCST_MGMT_STATUS_SUCCESS)
                        mcmd->status = SCST_MGMT_STATUS_FAILED;
+#else
+       /*
+        * scsi_reset_provider() returns very weird status, so let's
+        * always succeed
+        */
 #endif
                dev->scsi_dev->was_reset = 0;
        }
@@ -4355,7 +4434,7 @@ static int scst_abort_all_nexus_loss_sess(struct scst_mgmt_cmd *mcmd,
                        __scst_abort_task_set(mcmd, tgt_dev, 0);
 
                        rc = scst_call_dev_task_mgmt_fn(mcmd, tgt_dev, 0);
-                       if ((rc < 0) && (mcmd->status == SCST_MGMT_STATUS_SUCCESS))
+                       if (rc < 0 && mcmd->status == SCST_MGMT_STATUS_SUCCESS)
                                mcmd->status = rc;
                }
        }
@@ -4441,7 +4520,8 @@ static int scst_abort_all_nexus_loss_tgt(struct scst_mgmt_cmd *mcmd,
                                if (nexus_loss)
                                        scst_nexus_loss(tgt_dev);
 
-                               rc = scst_call_dev_task_mgmt_fn(mcmd, tgt_dev, 0);
+                               rc = scst_call_dev_task_mgmt_fn(mcmd, tgt_dev,
+                                                               0);
                                if ((rc < 0) &&
                                    (mcmd->status == SCST_MGMT_STATUS_SUCCESS))
                                        mcmd->status = rc;
@@ -4474,7 +4554,8 @@ static int scst_mgmt_cmd_exec(struct scst_mgmt_cmd *mcmd)
                break;
 
        case SCST_CLEAR_TASK_SET:
-               if (mcmd->mcmd_tgt_dev->dev->tst == SCST_CONTR_MODE_SEP_TASK_SETS)
+               if (mcmd->mcmd_tgt_dev->dev->tst ==
+                               SCST_CONTR_MODE_SEP_TASK_SETS)
                        res = scst_abort_task_set(mcmd);
                else
                        res = scst_clear_task_set(mcmd);
@@ -4588,7 +4669,8 @@ static void scst_mgmt_cmd_send_done(struct scst_mgmt_cmd *mcmd)
                if (sess->unreg_cmds_done_fn != NULL) {
                        TRACE_MGMT_DBG("Calling unreg_cmds_done_fn(%p)", sess);
                        sess->unreg_cmds_done_fn(sess);
-                       TRACE_MGMT_DBG("task_mgmt_all_cmds_done(%p) returned", sess);
+                       TRACE_MGMT_DBG("task_mgmt_all_cmds_done(%p) returned",
+                                       sess);
                }
        } else {
                if (sess->tgt->tgtt->task_mgmt_fn_done) {
@@ -4634,7 +4716,8 @@ static void scst_mgmt_cmd_send_done(struct scst_mgmt_cmd *mcmd)
                        for (i = 0; i < TGT_DEV_HASH_SIZE; i++) {
                                struct list_head *sess_tgt_dev_list_head =
                                        &mcmd->sess->sess_tgt_dev_list_hash[i];
-                               list_for_each_entry(tgt_dev, sess_tgt_dev_list_head,
+                               list_for_each_entry(tgt_dev,
+                                               sess_tgt_dev_list_head,
                                                sess_tgt_dev_list_entry) {
                                        scst_unblock_dev(tgt_dev->dev);
                                }
@@ -4757,14 +4840,17 @@ int scst_mgmt_cmd_thread(void *arg)
                        spin_lock_irq(&scst_mcmd_lock);
                        if (rc > 0) {
                                if (test_bit(SCST_FLAG_SUSPENDED, &scst_flags) &&
-                                   !test_bit(SCST_FLAG_SUSPENDING, &scst_flags)) {
-                                       TRACE_MGMT_DBG("Adding mgmt cmd %p to head "
-                                               "of delayed mgmt cmd list", mcmd);
+                                   !test_bit(SCST_FLAG_SUSPENDING,
+                                                &scst_flags)) {
+                                       TRACE_MGMT_DBG("Adding mgmt cmd %p to "
+                                               "head of delayed mgmt cmd list",
+                                               mcmd);
                                        list_add(&mcmd->mgmt_cmd_list_entry,
                                                &scst_delayed_mgmt_cmd_list);
                                } else {
-                                       TRACE_MGMT_DBG("Adding mgmt cmd %p to head "
-                                               "of active mgmt cmd list", mcmd);
+                                       TRACE_MGMT_DBG("Adding mgmt cmd %p to "
+                                               "head of active mgmt cmd list",
+                                               mcmd);
                                        list_add(&mcmd->mgmt_cmd_list_entry,
                                               &scst_active_mgmt_cmd_list);
                                }
@@ -4826,8 +4912,8 @@ static int scst_post_rx_mgmt_cmd(struct scst_session *sess,
        scst_sess_get(sess);
 
        if (unlikely(sess->shut_phase != SCST_SESS_SPH_READY)) {
-               PRINT_CRIT_ERROR("New mgmt cmd while shutting down the session %p "
-                       "shut_phase %ld", sess, sess->shut_phase);
+               PRINT_CRIT_ERROR("New mgmt cmd while shutting down the "
+                       "session %p shut_phase %ld", sess, sess->shut_phase);
                sBUG();
        }