diff --git a/iscsi-scst/include/iscsi_scst.h b/iscsi-scst/include/iscsi_scst.h index eec6f0c19..242ad07b8 100644 --- a/iscsi-scst/include/iscsi_scst.h +++ b/iscsi-scst/include/iscsi_scst.h @@ -141,8 +141,7 @@ struct iscsi_event { static inline int iscsi_is_key_declarative(int key) { - switch (key) - { + switch (key) { case key_max_xmit_data_length: return 1; default: diff --git a/iscsi-scst/kernel/event.c b/iscsi-scst/kernel/event.c index 458a76e2e..4dbd6d466 100644 --- a/iscsi-scst/kernel/event.c +++ b/iscsi-scst/kernel/event.c @@ -56,9 +56,9 @@ static void event_recv_skb(struct sk_buff *skb) rlen = NLMSG_ALIGN(nlh->nlmsg_len); if (rlen > skb->len) rlen = skb->len; - if ((err = event_recv_msg(skb, nlh))) { + if ((err = event_recv_msg(skb, nlh))) netlink_ack(skb, nlh, -err); - } else if (nlh->nlmsg_flags & NLM_F_ACK) + else if (nlh->nlmsg_flags & NLM_F_ACK) netlink_ack(skb, nlh, 0); skb_pull(skb, rlen); } diff --git a/iscsi-scst/kernel/iscsi.c b/iscsi-scst/kernel/iscsi.c index 1b709db9a..14c6fb600 100644 --- a/iscsi-scst/kernel/iscsi.c +++ b/iscsi-scst/kernel/iscsi.c @@ -24,9 +24,9 @@ #include "digest.h" #ifndef NET_PAGE_CALLBACKS_DEFINED -#warning Patch put_page_callback-.patch not applied on your \ +#warning "Patch put_page_callback-.patch not applied on your \ kernel. ISCSI-SCST will run in the performance degraded mode. Refer \ - README file for details. + README file for details." #endif #define ISCSI_INIT_WRITE_WAKE 0x1 @@ -668,7 +668,7 @@ static struct iscsi_cmnd *create_status_rsp(struct iscsi_cmnd *req, int status, sg = rsp->sg = scst_alloc(PAGE_SIZE, GFP_KERNEL|__GFP_NOFAIL, &rsp->sg_cnt); if (sg == NULL) { - /* ToDo(); */ + /* ToDo */ } rsp->own_sg = 1; sense = (struct iscsi_sense_data *)page_address(sg_page(&sg[0])); @@ -731,7 +731,7 @@ static void iscsi_cmnd_reject(struct iscsi_cmnd *req, int reason) sg = rsp->sg = scst_alloc(PAGE_SIZE, GFP_KERNEL|__GFP_NOFAIL, &rsp->sg_cnt); if (sg == NULL) { - /* ToDo(); */ + /* ToDo */ } rsp->own_sg = 1; addr = page_address(sg_page(&sg[0])); @@ -940,7 +940,7 @@ static void cmnd_prepare_get_rejected_cmd_data(struct iscsi_cmnd *cmnd) sg = cmnd->sg = scst_alloc(PAGE_SIZE, GFP_KERNEL|__GFP_NOFAIL, &cmnd->sg_cnt); if (sg == NULL) { - /* ToDo(); */ + /* ToDo */ } cmnd->own_sg = 1; cmnd->bufflen = PAGE_SIZE; @@ -1226,10 +1226,10 @@ static int noop_out_start(struct iscsi_cmnd *cmnd) cmnd->sg = sg = scst_alloc(size, GFP_KERNEL|__GFP_NOFAIL, &cmnd->sg_cnt); if (sg == NULL) { - /* ToDo(); */ + /* ToDo */ } if (cmnd->sg_cnt > ISCSI_CONN_IOV_MAX) { - /* ToDo(); */ + /* ToDo */ } cmnd->own_sg = 1; cmnd->bufflen = size; @@ -2516,9 +2516,8 @@ static void iscsi_try_local_processing(struct iscsi_conn *conn, int rc = 1; while (test_write_ready(conn)) { rc = iscsi_send(conn); - if ((rc <= 0) || single_only) { + if ((rc <= 0) || single_only) break; - } } spin_lock_bh(&iscsi_wr_lock); @@ -2881,9 +2880,8 @@ static void iscsi_stop_threads(void) list_for_each_entry_safe(t, tmp, &iscsi_threads_list, threads_list_entry) { int rc = kthread_stop(t->thr); - if (rc < 0) { + if (rc < 0) TRACE_MGMT_DBG("kthread_stop() failed: %d", rc); - } list_del(&t->threads_list_entry); kfree(t); } diff --git a/iscsi-scst/kernel/nthread.c b/iscsi-scst/kernel/nthread.c index c13c87e0d..d5df1ef6e 100644 --- a/iscsi-scst/kernel/nthread.c +++ b/iscsi-scst/kernel/nthread.c @@ -253,18 +253,18 @@ static void close_conn(struct iscsi_conn *conn) if (!list_empty(&session->pending_list)) { struct list_head *pending_list = &session->pending_list; int req_freed; - + TRACE_CONN_CLOSE_DBG("Disposing pending commands on " "connection %p (conn_ref_cnt=%d)", conn, atomic_read(&conn->conn_ref_cnt)); - + /* * Such complicated approach currently isn't necessary, * but it will be necessary for MC/S, if we won't want * to reestablish the whole session on a connection * failure. */ - + spin_lock(&session->sn_lock); do { req_freed = 0; @@ -976,46 +976,51 @@ static int write_data(struct iscsi_conn *conn) iop = conn->write_iop; count = conn->write_iop_used; - if (iop) while (1) { - loff_t off = 0; - int rest; + if (iop) { + while (1) { + loff_t off = 0; + int rest; - sBUG_ON(count > sizeof(conn->write_iov)/sizeof(conn->write_iov[0])); -retry: - oldfs = get_fs(); - set_fs(KERNEL_DS); - res = vfs_writev(file, (struct iovec __user *)iop, count, &off); - set_fs(oldfs); - TRACE_WRITE("%#Lx:%u: %d(%ld)", conn->session->sid, conn->cid, - res, (long)iop->iov_len); - if (unlikely(res <= 0)) { - if (res == -EAGAIN) { - conn->write_iop = iop; - conn->write_iop_used = count; + sBUG_ON(count > sizeof(conn->write_iov) + / sizeof(conn->write_iov[0])); + retry: + oldfs = get_fs(); + set_fs(KERNEL_DS); + res = vfs_writev(file, (struct iovec __user *)iop, + count, &off); + set_fs(oldfs); + TRACE_WRITE("%#Lx:%u: %d(%ld)", conn->session->sid, + conn->cid, + res, (long)iop->iov_len); + if (unlikely(res <= 0)) { + if (res == -EAGAIN) { + conn->write_iop = iop; + conn->write_iop_used = count; + goto out_iov; + } else if (res == -EINTR) + goto retry; + goto out_err; + } + + rest = res; + size -= res; + while (iop->iov_len <= rest && rest) { + rest -= iop->iov_len; + iop++; + count--; + } + if (count == 0) { + conn->write_iop = NULL; + conn->write_iop_used = 0; + if (size) + break; goto out_iov; - } else if (res == -EINTR) - goto retry; - goto out_err; + } + sBUG_ON(iop > conn->write_iov + sizeof(conn->write_iov) + /sizeof(conn->write_iov[0])); + iop->iov_base += rest; + iop->iov_len -= rest; } - - rest = res; - size -= res; - while (iop->iov_len <= rest && rest) { - rest -= iop->iov_len; - iop++; - count--; - } - if (count == 0) { - conn->write_iop = NULL; - conn->write_iop_used = 0; - if (size) - break; - goto out_iov; - } - sBUG_ON(iop > conn->write_iov + - sizeof(conn->write_iov)/sizeof(conn->write_iov[0])); - iop->iov_base += rest; - iop->iov_len -= rest; } sg = write_cmnd->sg; diff --git a/scst/include/scst.h b/scst/include/scst.h index b95f73e06..9d61efef3 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -411,8 +411,7 @@ typedef uint64_t lun_t; typedef enum dma_data_direction scst_data_direction; -enum scst_cdb_flags -{ +enum scst_cdb_flags { SCST_TRANSFER_LEN_TYPE_FIXED = 0x01, /* must be equviv 1 (FIXED_BIT in cdb) */ SCST_SMALL_TIMEOUT = 0x02, SCST_LONG_TIMEOUT = 0x04, @@ -438,8 +437,7 @@ enum scst_cdb_flags * SCST_TGT_RES_NEED_THREAD_CTX, and it will be recalled in the thread context, * where sleeping is allowed. */ -struct scst_tgt_template -{ +struct scst_tgt_template { /* public: */ /* @@ -683,8 +681,7 @@ struct scst_tgt_template int proc_dev_num; }; -struct scst_dev_type -{ +struct scst_dev_type { /* SCSI type of the supported device. MUST HAVE */ int type; @@ -843,8 +840,7 @@ struct scst_dev_type struct proc_dir_entry *proc_dev_type_root; }; -struct scst_tgt -{ +struct scst_tgt { /* List of remote sessions per target, protected by scst_mutex */ struct list_head sess_list; @@ -889,8 +885,7 @@ struct scst_tgt #define TGT_DEV_HASH_SIZE (1<mgmt_cmd_list */ struct list_head cmd_mgmt_cmd_list_entry; }; -struct scst_mgmt_cmd -{ +struct scst_mgmt_cmd { /* List entry for *_mgmt_cmd_list */ struct list_head mgmt_cmd_list_entry; @@ -1321,8 +1311,7 @@ struct scst_mgmt_cmd void *tgt_priv; }; -struct scst_device -{ +struct scst_device { struct scst_dev_type *handler; /* corresponding dev handler */ /* Pointer to lists of commands with the lock */ @@ -1437,8 +1426,7 @@ struct scst_device /* * Used to store threads local tgt_dev specific data */ -struct scst_thr_data_hdr -{ +struct scst_thr_data_hdr { /* List entry in tgt_dev->thr_data_list */ struct list_head thr_data_list_entry; pid_t pid; /* PID of the owner thread */ @@ -1450,8 +1438,7 @@ struct scst_thr_data_hdr /* * Used to store per-session specific device information */ -struct scst_tgt_dev -{ +struct scst_tgt_dev { /* List entry in sess->sess_tgt_dev_list_hash */ struct list_head sess_tgt_dev_list_entry; @@ -1518,8 +1505,7 @@ struct scst_tgt_dev /* * Used to store ACG-specific device information, like LUN */ -struct scst_acg_dev -{ +struct scst_acg_dev { struct scst_device *dev; /* corresponding device */ lun_t lun; /* device's LUN in this acg */ unsigned int rd_only_flag:1; /* if != 0, then read only */ @@ -1536,8 +1522,7 @@ struct scst_acg_dev * ACG - access control group. Used to store group related * control information. */ -struct scst_acg -{ +struct scst_acg { /* List of acg_dev's in this acg, protected by scst_mutex */ struct list_head acg_dev_list; @@ -1561,8 +1546,7 @@ struct scst_acg * ACN - access control name. Used to store names, by which * incoming sessions will be assigned to appropriate ACG. */ -struct scst_acn -{ +struct scst_acn { /* Initiator's name */ const char *name; /* List entry in acg->acn_list */ @@ -1572,8 +1556,7 @@ struct scst_acn /* * Used to store per-session UNIT ATTENTIONs */ -struct scst_tgt_dev_UA -{ +struct scst_tgt_dev_UA { /* List entry in tgt_dev->UA_list */ struct list_head UA_list_entry; /* Unit Attention sense */ diff --git a/scst/include/scst_const.h b/scst/include/scst_const.h index efd584bf3..fa2182c92 100644 --- a/scst/include/scst_const.h +++ b/scst/include/scst_const.h @@ -92,8 +92,7 @@ /************************************************************* ** SCSI task attribute queue types *************************************************************/ -enum scst_cmd_queue_type -{ +enum scst_cmd_queue_type { SCST_CMD_QUEUE_UNTAGGED = 0, SCST_CMD_QUEUE_SIMPLE, SCST_CMD_QUEUE_ORDERED, diff --git a/scst/include/scst_debug.h b/scst/include/scst_debug.h index 93b41eb8a..c04015c6d 100644 --- a/scst/include/scst_debug.h +++ b/scst/include/scst_debug.h @@ -148,12 +148,10 @@ extern void debug_print_buffer(const char *log_level, const void *data, #define TRACE(trace, format, args...) \ do { \ - if (___unlikely(trace_flag & (trace))) \ - { \ + if (___unlikely(trace_flag & (trace))) { \ char *__tflag = LOG_FLAG; \ if (debug_print_prefix(trace_flag, __tflag, __LOG_PREFIX, \ - __FUNCTION__, __LINE__) > 0) \ - { \ + __FUNCTION__, __LINE__) > 0) { \ __tflag = NO_FLAG; \ } \ PRINT(NO_FLAG, "%s" format, __tflag, args); \ @@ -168,12 +166,10 @@ do { \ #define PRINT_BUFF_FLAG(flag, message, buff, len) \ do { \ - if (___unlikely(trace_flag & (flag))) \ - { \ + if (___unlikely(trace_flag & (flag))) { \ char *__tflag = INFO_FLAG; \ if (debug_print_prefix(trace_flag, __tflag, NULL, __FUNCTION__,\ - __LINE__) > 0) \ - { \ + __LINE__) > 0) { \ __tflag = NO_FLAG; \ } \ PRINT(NO_FLAG, "%s%s:", __tflag, message); \ @@ -193,12 +189,10 @@ do { \ #define __TRACE(trace, format, args...) \ do { \ - if (trace_flag & (trace)) \ - { \ + if (trace_flag & (trace)) { \ char *__tflag = LOG_FLAG; \ if (debug_print_prefix(trace_flag, __tflag, NULL, __FUNCTION__,\ - __LINE__) > 0) \ - { \ + __LINE__) > 0) { \ __tflag = NO_FLAG; \ } \ PRINT(NO_FLAG, "%s" format, __tflag, args); \ @@ -214,12 +208,10 @@ do { \ #define TRACE_BUFFER(message, buff, len) \ do { \ - if (trace_flag & TRACE_BUFF) \ - { \ + if (trace_flag & TRACE_BUFF) { \ char *__tflag = LOG_FLAG; \ if (debug_print_prefix(trace_flag, __tflag, NULL, __FUNCTION__, \ - __LINE__) > 0) \ - { \ + __LINE__) > 0) { \ __tflag = NO_FLAG; \ } \ PRINT(NO_FLAG, "%s%s:", __tflag, message); \ @@ -229,12 +221,10 @@ do { \ #define TRACE_BUFF_FLAG(flag, message, buff, len) \ do { \ - if (trace_flag & (flag)) \ - { \ + if (trace_flag & (flag)) { \ char *__tflag = LOG_FLAG; \ if (debug_print_prefix(trace_flag, __tflag, NULL, __FUNCTION__, \ - __LINE__) > 0) \ - { \ + __LINE__) > 0) { \ __tflag = NO_FLAG; \ } \ PRINT(NO_FLAG, "%s%s:", __tflag, message); \ @@ -246,8 +236,7 @@ do { \ do { \ char *__tflag = log_flag; \ if (debug_print_prefix(trace_flag, __tflag, __LOG_PREFIX, \ - __FUNCTION__, __LINE__) > 0) \ - { \ + __FUNCTION__, __LINE__) > 0) { \ __tflag = NO_FLAG; \ } \ PRINT(NO_FLAG, "%s" format, __tflag, args); \ @@ -255,8 +244,7 @@ do { \ #define PRINT_ERROR(format, args...) \ do { \ - if (strcmp(ERROR_FLAG, LOG_FLAG)) \ - { \ + if (strcmp(ERROR_FLAG, LOG_FLAG)) { \ PRINT_LOG_FLAG(LOG_FLAG, "***ERROR*** " format, args); \ } \ PRINT_LOG_FLAG(ERROR_FLAG, "***ERROR*** " format, args); \ @@ -273,8 +261,7 @@ do { \ #define PRINT_INFO(format, args...) \ do { \ - if (strcmp(INFO_FLAG, LOG_FLAG)) \ - { \ + if (strcmp(INFO_FLAG, LOG_FLAG)) { \ PRINT_LOG_FLAG(LOG_FLAG, format, args); \ } \ PRINT_LOG_FLAG(INFO_FLAG, format, args); \ @@ -282,14 +269,12 @@ do { \ #define TRACE_ENTRY() \ do { \ - if (trace_flag & TRACE_ENTRYEXIT) \ - { \ - if (trace_flag & TRACE_PID) \ - { \ + if (trace_flag & TRACE_ENTRYEXIT) { \ + if (trace_flag & TRACE_PID) { \ PRINT(LOG_FLAG, "[%d]: ENTRY %s", current->pid, \ __FUNCTION__); \ } \ - else \ + else { \ { \ PRINT(LOG_FLAG, "ENTRY %s", __FUNCTION__); \ } \ @@ -298,15 +283,12 @@ do { \ #define TRACE_EXIT() \ do { \ - if (trace_flag & TRACE_ENTRYEXIT) \ - { \ - if (trace_flag & TRACE_PID) \ - { \ + if (trace_flag & TRACE_ENTRYEXIT) { \ + if (trace_flag & TRACE_PID) { \ PRINT(LOG_FLAG, "[%d]: EXIT %s", current->pid, \ __FUNCTION__); \ } \ - else \ - { \ + else { \ PRINT(LOG_FLAG, "EXIT %s", __FUNCTION__); \ } \ } \ @@ -314,15 +296,12 @@ do { \ #define TRACE_EXIT_RES(res) \ do { \ - if (trace_flag & TRACE_ENTRYEXIT) \ - { \ - if (trace_flag & TRACE_PID) \ - { \ + if (trace_flag & TRACE_ENTRYEXIT) { \ + if (trace_flag & TRACE_PID) { \ PRINT(LOG_FLAG, "[%d]: EXIT %s: %ld", current->pid, \ __FUNCTION__, (long)(res)); \ } \ - else \ - { \ + else { \ PRINT(LOG_FLAG, "EXIT %s: %ld", __FUNCTION__, (long)(res)); \ } \ } \ @@ -330,15 +309,12 @@ do { \ #define TRACE_EXIT_HRES(res) \ do { \ - if (trace_flag & TRACE_ENTRYEXIT) \ - { \ - if (trace_flag & TRACE_PID) \ - { \ + if (trace_flag & TRACE_ENTRYEXIT) { \ + if (trace_flag & TRACE_PID) { \ PRINT(LOG_FLAG, "[%d]: EXIT %s: 0x%lx", current->pid, \ __FUNCTION__, (long)(res)); \ } \ - else \ - { \ + else { \ PRINT(LOG_FLAG, "EXIT %s: %lx", __FUNCTION__, (long)(res)); \ } \ } \ diff --git a/scst/include/scst_user.h b/scst/include/scst_user.h index 0f0ce6fed..0e1352426 100644 --- a/scst/include/scst_user.h +++ b/scst/include/scst_user.h @@ -86,8 +86,7 @@ UCMD_STATE_RECV_MASK | \ UCMD_STATE_JAMMED_MASK) -struct scst_user_opt -{ +struct scst_user_opt { uint8_t parse_type; uint8_t on_free_cmd_type; uint8_t memory_reuse_type; @@ -104,8 +103,7 @@ struct scst_user_opt uint8_t has_own_order_mgmt; }; -struct scst_user_dev_desc -{ +struct scst_user_dev_desc { aligned_u64 version_str; uint8_t type; struct scst_user_opt opt; @@ -113,8 +111,7 @@ struct scst_user_dev_desc char name[SCST_MAX_NAME]; }; -struct scst_user_sess -{ +struct scst_user_sess { aligned_u64 sess_h; aligned_u64 lun; uint16_t threads_num; @@ -122,8 +119,7 @@ struct scst_user_sess char initiator_name[SCST_MAX_NAME]; }; -struct scst_user_scsi_cmd_parse -{ +struct scst_user_scsi_cmd_parse { aligned_u64 sess_h; uint8_t cdb[SCST_MAX_CDB_SIZE]; @@ -142,8 +138,7 @@ struct scst_user_scsi_cmd_parse uint32_t sn; }; -struct scst_user_scsi_cmd_alloc_mem -{ +struct scst_user_scsi_cmd_alloc_mem { aligned_u64 sess_h; uint8_t cdb[SCST_MAX_CDB_SIZE]; @@ -157,8 +152,7 @@ struct scst_user_scsi_cmd_alloc_mem uint32_t sn; }; -struct scst_user_scsi_cmd_exec -{ +struct scst_user_scsi_cmd_exec { aligned_u64 sess_h; uint8_t cdb[SCST_MAX_CDB_SIZE]; @@ -180,8 +174,7 @@ struct scst_user_scsi_cmd_exec uint32_t partial_offset; }; -struct scst_user_scsi_on_free_cmd -{ +struct scst_user_scsi_on_free_cmd { aligned_u64 pbuf; int32_t resp_data_len; uint8_t buffer_cached; @@ -190,13 +183,11 @@ struct scst_user_scsi_on_free_cmd uint8_t delivery_status; }; -struct scst_user_on_cached_mem_free -{ +struct scst_user_on_cached_mem_free { aligned_u64 pbuf; }; -struct scst_user_tm -{ +struct scst_user_tm { aligned_u64 sess_h; uint32_t fn; uint32_t cmd_h_to_abort; @@ -204,8 +195,7 @@ struct scst_user_tm uint8_t cmd_sn_set; }; -struct scst_user_get_cmd -{ +struct scst_user_get_cmd { aligned_u64 preply; uint32_t cmd_h; uint32_t subcode; @@ -220,21 +210,18 @@ struct scst_user_get_cmd }; }; -struct scst_user_scsi_cmd_reply_parse -{ +struct scst_user_scsi_cmd_reply_parse { uint8_t queue_type; uint8_t data_direction; int32_t data_len; int32_t bufflen; }; -struct scst_user_scsi_cmd_reply_alloc_mem -{ +struct scst_user_scsi_cmd_reply_alloc_mem { aligned_u64 pbuf; }; -struct scst_user_scsi_cmd_reply_exec -{ +struct scst_user_scsi_cmd_reply_exec { int32_t resp_data_len; aligned_u64 pbuf; @@ -247,8 +234,7 @@ struct scst_user_scsi_cmd_reply_exec aligned_u64 psense_buffer; }; -struct scst_user_reply_cmd -{ +struct scst_user_reply_cmd { uint32_t cmd_h; uint32_t subcode; union { diff --git a/scst/src/dev_handlers/scst_cdrom.c b/scst/src/dev_handlers/scst_cdrom.c index f69acf9ab..ca9198907 100644 --- a/scst/src/dev_handlers/scst_cdrom.c +++ b/scst/src/dev_handlers/scst_cdrom.c @@ -44,8 +44,7 @@ #define CDROM_DEF_BLOCK_SHIFT 11 -struct cdrom_params -{ +struct cdrom_params { int block_shift; }; diff --git a/scst/src/dev_handlers/scst_changer.c b/scst/src/dev_handlers/scst_changer.c index 08cbad928..d65c997c4 100644 --- a/scst/src/dev_handlers/scst_changer.c +++ b/scst/src/dev_handlers/scst_changer.c @@ -76,8 +76,7 @@ int changer_attach(struct scst_device *dev) * If the device is offline, don't try to read capacity or any * of the other stuff */ - if (dev->scsi_dev->sdev_state == SDEV_OFFLINE) - { + if (dev->scsi_dev->sdev_state == SDEV_OFFLINE) { TRACE_DBG("%s", "Device is offline"); res = -ENODEV; goto out; @@ -150,11 +149,10 @@ int changer_parse(struct scst_cmd *cmd) cmd->retries = SCST_PASSTHROUGH_RETRIES; - if (cmd->op_flags & SCST_LONG_TIMEOUT) { + if (cmd->op_flags & SCST_LONG_TIMEOUT) cmd->timeout = CHANGER_LONG_TIMEOUT; - } else { + else cmd->timeout = CHANGER_TIMEOUT; - } return res; } diff --git a/scst/src/dev_handlers/scst_dev_handler.h b/scst/src/dev_handlers/scst_dev_handler.h index 6c1b2b6ae..a704353b5 100644 --- a/scst/src/dev_handlers/scst_dev_handler.h +++ b/scst/src/dev_handlers/scst_dev_handler.h @@ -96,9 +96,8 @@ static void scst_dev_handler_destroy_std_proc(struct scst_dev_type *dev_type) TRACE_ENTRY(); root = scst_proc_get_dev_type_root(dev_type); - if (root) { + if (root) remove_proc_entry(DEV_HANDLER_LOG_ENTRY_NAME, root); - } TRACE_EXIT(); #endif diff --git a/scst/src/dev_handlers/scst_disk.c b/scst/src/dev_handlers/scst_disk.c index 0ff56115d..1c759c005 100644 --- a/scst/src/dev_handlers/scst_disk.c +++ b/scst/src/dev_handlers/scst_disk.c @@ -63,8 +63,7 @@ #define DISK_DEF_BLOCK_SHIFT 9 -struct disk_params -{ +struct disk_params { int block_shift; }; @@ -196,9 +195,7 @@ int disk_attach(struct scst_device *dev) TRACE_DBG("READ_CAPACITY done: %x", res); if (!res || (sbuff[12] != 0x28 && sbuff[12] != 0x29)) - { break; - } if (!--retries) { PRINT_ERROR("UA not clear after %d retries", SCST_DEV_UA_RETRIES); diff --git a/scst/src/dev_handlers/scst_modisk.c b/scst/src/dev_handlers/scst_modisk.c index a2446333a..ea333fcd6 100644 --- a/scst/src/dev_handlers/scst_modisk.c +++ b/scst/src/dev_handlers/scst_modisk.c @@ -63,8 +63,7 @@ #define MODISK_DEF_BLOCK_SHIFT 10 -struct modisk_params -{ +struct modisk_params { int block_shift; }; @@ -175,8 +174,7 @@ int modisk_attach(struct scst_device *dev) * If the device is offline, don't try to read capacity or any * of the other stuff */ - if (dev->scsi_dev->sdev_state == SDEV_OFFLINE) - { + if (dev->scsi_dev->sdev_state == SDEV_OFFLINE) { TRACE_DBG("%s", "Device is offline"); res = -ENODEV; goto out_free_params; diff --git a/scst/src/dev_handlers/scst_processor.c b/scst/src/dev_handlers/scst_processor.c index e81d0a347..fe48887f2 100644 --- a/scst/src/dev_handlers/scst_processor.c +++ b/scst/src/dev_handlers/scst_processor.c @@ -76,8 +76,7 @@ int processor_attach(struct scst_device *dev) * If the device is offline, don't try to read capacity or any * of the other stuff */ - if (dev->scsi_dev->sdev_state == SDEV_OFFLINE) - { + if (dev->scsi_dev->sdev_state == SDEV_OFFLINE) { TRACE_DBG("%s", "Device is offline"); res = -ENODEV; goto out; @@ -150,11 +149,10 @@ int processor_parse(struct scst_cmd *cmd) cmd->retries = SCST_PASSTHROUGH_RETRIES; - if (cmd->op_flags & SCST_LONG_TIMEOUT) { + if (cmd->op_flags & SCST_LONG_TIMEOUT) cmd->timeout = PROCESSOR_LONG_TIMEOUT; - } else { + else cmd->timeout = PROCESSOR_TIMEOUT; - } return res; } diff --git a/scst/src/dev_handlers/scst_raid.c b/scst/src/dev_handlers/scst_raid.c index 2f93cb43b..83e41cb04 100644 --- a/scst/src/dev_handlers/scst_raid.c +++ b/scst/src/dev_handlers/scst_raid.c @@ -76,8 +76,7 @@ int raid_attach(struct scst_device *dev) * If the device is offline, don't try to read capacity or any * of the other stuff */ - if (dev->scsi_dev->sdev_state == SDEV_OFFLINE) - { + if (dev->scsi_dev->sdev_state == SDEV_OFFLINE) { TRACE_DBG("%s", "Device is offline"); res = -ENODEV; goto out; @@ -150,11 +149,10 @@ int raid_parse(struct scst_cmd *cmd) cmd->retries = SCST_PASSTHROUGH_RETRIES; - if (cmd->op_flags & SCST_LONG_TIMEOUT) { + if (cmd->op_flags & SCST_LONG_TIMEOUT) cmd->timeout = RAID_LONG_TIMEOUT; - } else { + else cmd->timeout = RAID_TIMEOUT; - } return res; } diff --git a/scst/src/dev_handlers/scst_tape.c b/scst/src/dev_handlers/scst_tape.c index 0fe55710b..b954224fa 100644 --- a/scst/src/dev_handlers/scst_tape.c +++ b/scst/src/dev_handlers/scst_tape.c @@ -68,8 +68,7 @@ /* The fixed bit in READ/WRITE/VERIFY */ #define SILI_BIT 2 -struct tape_params -{ +struct tape_params { int block_size; }; @@ -342,19 +341,18 @@ int tape_done(struct scst_cmd *cmd) TRACE_ENTRY(); - if ((status == SAM_STAT_GOOD) || (status == SAM_STAT_CONDITION_MET)) { + if ((status == SAM_STAT_GOOD) || (status == SAM_STAT_CONDITION_MET)) res = scst_tape_generic_dev_done(cmd, tape_set_block_size); - } else if ((status == SAM_STAT_CHECK_CONDITION) && - SCST_SENSE_VALID(cmd->sense)) - { + else if ((status == SAM_STAT_CHECK_CONDITION) && + SCST_SENSE_VALID(cmd->sense)) { struct tape_params *params; TRACE_DBG("%s", "Extended sense"); if (opcode == READ_6 && !(cmd->cdb[1] & SILI_BIT) && - (cmd->sense[2] & 0xe0)) { /* EOF, EOM, or ILI */ + (cmd->sense[2] & 0xe0)) { + /* EOF, EOM, or ILI */ int TransferLength, Residue = 0; - if ((cmd->sense[2] & 0x0f) == BLANK_CHECK) { + if ((cmd->sense[2] & 0x0f) == BLANK_CHECK) cmd->sense[2] &= 0xcf; /* No need for EOM in this case */ - } TransferLength = ((cmd->cdb[2] << 16) | (cmd->cdb[3] << 8) | cmd->cdb[4]); /* Compute the residual count */ diff --git a/scst/src/dev_handlers/scst_user.c b/scst/src/dev_handlers/scst_user.c index 1434b3009..82891c9b3 100644 --- a/scst/src/dev_handlers/scst_user.c +++ b/scst/src/dev_handlers/scst_user.c @@ -40,8 +40,7 @@ #define DEV_USER_DETACH_TIMEOUT (5*HZ) #define DEV_USER_PRE_UNREG_POLL_TIME (HZ/10) -struct scst_user_dev -{ +struct scst_user_dev { struct rw_semaphore dev_rwsem; struct scst_cmd_lists cmd_lists; @@ -101,8 +100,7 @@ struct scst_user_dev struct completion cleanup_cmpl; }; -struct scst_user_pre_unreg_sess_obj -{ +struct scst_user_pre_unreg_sess_obj { struct scst_tgt_dev *tgt_dev; unsigned int active:1; unsigned int exit:1; @@ -115,8 +113,7 @@ struct scst_user_pre_unreg_sess_obj }; /* Most fields are unprotected, since only one thread at time can access them */ -struct scst_user_cmd -{ +struct scst_user_cmd { struct scst_cmd *cmd; struct scst_user_dev *dev; @@ -444,9 +441,9 @@ static inline int is_buff_cached(struct scst_user_cmd *ucmd) ((ucmd->cmd->data_direction == SCST_DATA_READ) && (mem_reuse_type == SCST_USER_MEM_REUSE_READ)) || ((ucmd->cmd->data_direction == SCST_DATA_WRITE) && - (mem_reuse_type == SCST_USER_MEM_REUSE_WRITE))) { + (mem_reuse_type == SCST_USER_MEM_REUSE_WRITE))) return 1; - } else + else return 0; } @@ -3175,9 +3172,8 @@ static void __exit exit_scst_user(void) TRACE_ENTRY(); rc = kthread_stop(cleanup_thread); - if (rc < 0) { + if (rc < 0) TRACE_MGMT_DBG("kthread_stop() failed: %d", rc); - } unregister_chrdev(DEV_USER_MAJOR, DEV_USER_NAME); class_device_destroy(dev_user_sysfs_class, MKDEV(DEV_USER_MAJOR, 0)); diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index e02e5081c..6fc0bdf90 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -1125,13 +1125,15 @@ static void vdisk_exec_inquiry(struct scst_cmd *cmd) len = scnprintf(dev_id_str, 6, "%d", dev_id_num); TRACE_DBG("num %d, str <%s>, len %d", dev_id_num, dev_id_str, len); - if (0 == cmd->cdb[2]) { /* supported vital product data pages */ + if (0 == cmd->cdb[2]) { + /* supported vital product data pages */ buf[3] = 3; buf[4] = 0x0; /* this page */ buf[5] = 0x80; /* unit serial number */ buf[6] = 0x83; /* device identification */ resp_len = buf[3] + 4; - } else if (0x80 == cmd->cdb[2]) { /* unit serial number */ + } else if (0x80 == cmd->cdb[2]) { + /* unit serial number */ buf[1] = 0x80; if (virt_dev->usn == NULL) { buf[3] = MAX_USN_LEN; @@ -1147,7 +1149,8 @@ static void vdisk_exec_inquiry(struct scst_cmd *cmd) strncpy(&buf[4], virt_dev->usn, usn_len); } resp_len = buf[3] + 4; - } else if (0x83 == cmd->cdb[2]) { /* device identification */ + } else if (0x83 == cmd->cdb[2]) { + /* device identification */ int num = 4; buf[1] = 0x83; @@ -1439,7 +1442,8 @@ static void vdisk_exec_mode_sense(struct scst_cmd *cmd) offset = 8; } - if (0 != subpcode) { /* TODO: Control Extension page */ + if (0 != subpcode) { + /* TODO: Control Extension page */ TRACE_DBG("%s", "MODE SENSE: Only subpage 0 is supported"); scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_invalid_field_in_cdb)); @@ -1583,11 +1587,10 @@ static void vdisk_exec_mode_select(struct scst_cmd *cmd) goto out_put; } - if (mselect_6) { + if (mselect_6) offset = 4; - } else { + else offset = 8; - } if (address[offset - 1] == 8) { offset += 8; @@ -1606,7 +1609,8 @@ static void vdisk_exec_mode_select(struct scst_cmd *cmd) scst_sense_invalid_field_in_parm_list)); goto out_put; } - if ((address[offset] & 0x3f) == 0x8) { /* Caching page */ + if ((address[offset] & 0x3f) == 0x8) { + /* Caching page */ if (address[offset + 1] != 18) { PRINT_ERROR("%s", "MODE SELECT: Invalid " "caching page request"); @@ -1625,7 +1629,8 @@ static void vdisk_exec_mode_select(struct scst_cmd *cmd) * It's too early to implement it, since we can't control the backstorage * device parameters. ToDo */ - } else if ((address[offset] & 0x3f) == 0xA) { /* Control page */ + } else if ((address[offset] & 0x3f) == 0xA) { + /* Control page */ if (address[offset + 1] != 0xA) { PRINT_ERROR("%s", "MODE SELECT: Invalid " "control page request"); @@ -1742,7 +1747,7 @@ static void vdisk_exec_read_capacity16(struct scst_cmd *cmd) buffer[4] = (nblocks >> 24) & 0xFF; buffer[5] = (nblocks >> 16) & 0xFF; buffer[6] = (nblocks >> 8) & 0xFF; - buffer[7] = nblocks& 0xFF; + buffer[7] = nblocks & 0xFF; buffer[8] = (blocksize >> (BYTE * 3)) & 0xFF; buffer[9] = (blocksize >> (BYTE * 2)) & 0xFF; @@ -1822,16 +1827,14 @@ static void vdisk_exec_read_toc(struct scst_cmd *cmd) buffer[2] = 0x01; /* First Track/Session */ buffer[3] = 0x01; /* Last Track/Session */ off = 4; - if (cmd->cdb[6] <= 1) - { + if (cmd->cdb[6] <= 1) { /* Fistr TOC Track Descriptor */ buffer[off+1] = 0x14; /* ADDR 0x10 - Q Sub-channel encodes current position data CONTROL 0x04 - Data track, recoreded uninterrupted */ buffer[off+2] = 0x01; /* Track Number */ off += 8; } - if (!(cmd->cdb[2] & 0x01)) - { + if (!(cmd->cdb[2] & 0x01)) { /* Lead-out area TOC Track Descriptor */ buffer[off+1] = 0x14; buffer[off+2] = 0xAA; /* Track Number */ @@ -2021,11 +2024,10 @@ static void vdisk_exec_read(struct scst_cmd *cmd, err = full_len; else { /* SEEK */ - if (fd->f_op->llseek) { + if (fd->f_op->llseek) err = fd->f_op->llseek(fd, loff, 0/*SEEK_SET*/); - } else { + else err = default_llseek(fd, loff, 0/*SEEK_SET*/); - } if (err != loff) { PRINT_ERROR("lseek trouble %Ld != %Ld", (uint64_t)err, (uint64_t)loff); @@ -2112,11 +2114,10 @@ restart: err = full_len; else { /* SEEK */ - if (fd->f_op->llseek) { + if (fd->f_op->llseek) err = fd->f_op->llseek(fd, loff, 0 /*SEEK_SET */); - } else { + else err = default_llseek(fd, loff, 0 /*SEEK_SET */); - } if (err != loff) { PRINT_ERROR("lseek trouble %Ld != %Ld", (uint64_t)err, (uint64_t)loff); @@ -2404,11 +2405,10 @@ static void vdisk_exec_verify(struct scst_cmd *cmd, set_fs(get_ds()); if (!virt_dev->nullio) { - if (fd->f_op->llseek) { + if (fd->f_op->llseek) err = fd->f_op->llseek(fd, loff, 0/*SEEK_SET*/); - } else { + else err = default_llseek(fd, loff, 0/*SEEK_SET*/); - } if (err != loff) { PRINT_ERROR("lseek trouble %Ld != %Ld", (uint64_t)err, (uint64_t)loff); @@ -2658,9 +2658,8 @@ static int vdisk_write_proc(char *buffer, char **start, off_t offset, } p = buffer; - if (p[strlen(p) - 1] == '\n') { + if (p[strlen(p) - 1] == '\n') p[strlen(p) - 1] = '\0'; - } if (!strncmp("close ", p, 6)) { p += 6; action = 0; @@ -2690,7 +2689,8 @@ static int vdisk_write_proc(char *buffer, char **start, off_t offset, goto out_up; } - if (action) { /* open */ + if (action) { + /* open */ virt_dev = NULL; list_for_each_entry(vv, &vdisk_dev_list, vdisk_dev_list_entry) @@ -3089,11 +3089,10 @@ static int vcdrom_change(char *p, char *name) /* seek to end */ old_fs = get_fs(); set_fs(get_ds()); - if (fd->f_op->llseek) { + if (fd->f_op->llseek) err = fd->f_op->llseek(fd, 0, 2/*SEEK_END*/); - } else { + else err = default_llseek(fd, 0, 2/*SEEK_END*/); - } set_fs(old_fs); filp_close(fd, NULL); if (err < 0) { @@ -3207,9 +3206,8 @@ static int vcdrom_write_proc(char *buffer, char **start, off_t offset, } p = buffer; - if (p[strlen(p) - 1] == '\n') { + if (p[strlen(p) - 1] == '\n') p[strlen(p) - 1] = '\0'; - } if (!strncmp("close ", p, 6)) { p += 6; action = 0; @@ -3242,15 +3240,18 @@ static int vcdrom_write_proc(char *buffer, char **start, off_t offset, goto out_up; } - if (action == 2) { /* open */ + if (action == 2) { + /* open */ res = vcdrom_open(p, name); if (res != 0) goto out_up; - } else if (action == 1) { /* change */ + } else if (action == 1) { + /* change */ res = vcdrom_change(p, name); if (res != 0) goto out_up; - } else { /* close */ + } else { + /* close */ res = vcdrom_close(name); if (res != 0) goto out_up; diff --git a/scst/src/scst_cdbprobe.h b/scst/src/scst_cdbprobe.h index d9dc26662..5f0237a92 100644 --- a/scst/src/scst_cdbprobe.h +++ b/scst/src/scst_cdbprobe.h @@ -54,8 +54,7 @@ static int get_trans_len_read_pos(struct scst_cmd *cmd, uint8_t off); #define SCST_CDB_RESERVED 'R' /* reserved */ #define SCST_CDB_NOTSUPP ' ' /* don't use */ -struct scst_sdbops -{ +struct scst_sdbops { uint8_t ops; /* SCSI-2 op codes */ uint8_t devkey[16]; /* Key for every device type M,O,V,R * type_disk devkey[0] diff --git a/scst/src/scst_debug.c b/scst/src/scst_debug.c index 2c0c449e5..d76ac568c 100644 --- a/scst/src/scst_debug.c +++ b/scst/src/scst_debug.c @@ -109,11 +109,10 @@ void debug_print_buffer(const char *log_level, const void *data, int len) trace_buf[i++] = '.'; } trace_buf[i] = '\0'; - if (f) { - PRINT(log_level, "%s", trace_buf) - } else { + if (f) + PRINT(log_level, "%s", trace_buf); + else PRINT(NO_FLAG, "%s", trace_buf); - } spin_unlock_irqrestore(&trace_buf_lock, flags); return; diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index f5613240d..5925c30c2 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -438,9 +438,8 @@ static struct scst_tgt_dev *scst_alloc_add_tgt_dev(struct scst_session *sess, tgt_dev->max_sg_cnt = min(ini_sg, sess->tgt->sg_tablesize); if ((sess->tgt->tgtt->use_clustering || ini_use_clustering) && - !sess->tgt->tgtt->no_clustering) { + !sess->tgt->tgtt->no_clustering) scst_sgv_pool_use_norm_clust(tgt_dev); - } if (sess->tgt->tgtt->unchecked_isa_dma || ini_unchecked_isa_dma) { scst_sgv_pool_use_dma(tgt_dev); @@ -455,8 +454,7 @@ static struct scst_tgt_dev *scst_alloc_add_tgt_dev(struct scst_session *sess, "SCST lun=%Ld", dev->scsi_dev->host->host_no, dev->scsi_dev->channel, dev->scsi_dev->id, dev->scsi_dev->lun, (uint64_t)tgt_dev->lun); - } - else { + } else { TRACE_MGMT_DBG("Virtual device %s on SCST lun=%Ld", dev->virt_name, (uint64_t)tgt_dev->lun); } @@ -834,9 +832,8 @@ int scst_acg_add_name(struct scst_acg *acg, const char *name) list_add_tail(&n->acn_list_entry, &acg->acn_list); out: - if (res == 0) { + if (res == 0) PRINT_INFO("Added name %s to group %s", name, acg->acg_name); - } TRACE_EXIT_RES(res); return res; @@ -1424,8 +1421,7 @@ void scst_check_retries(struct scst_tgt *tgt) */ atomic_inc(&tgt->finished_cmds); smp_mb__after_atomic_inc(); - if (unlikely(tgt->retry_cmds > 0)) - { + if (unlikely(tgt->retry_cmds > 0)) { struct scst_cmd *c, *tc; unsigned long flags; @@ -2729,9 +2725,8 @@ restart: list_del(&cmd->sn_cmd_list_entry); spin_unlock_irq(&tgt_dev->sn_lock); if (test_and_set_bit(SCST_CMD_CAN_BE_DESTROYED, - &cmd->cmd_flags)) { + &cmd->cmd_flags)) scst_destroy_put_cmd(cmd); - } scst_inc_expected_sn(tgt_dev, slot); expected_sn = tgt_dev->expected_sn; spin_lock_irq(&tgt_dev->sn_lock); @@ -3163,7 +3158,8 @@ unsigned long scst_random(void) hi = rv / 127773; lo = rv % 127773; rv = 16807 * lo - 2836 * hi; - if (rv <= 0) rv += 2147483647; + if (rv <= 0) + rv += 2147483647; RandomValue = rv; spin_unlock_irqrestore(&lock, flags); return rv; @@ -3182,8 +3178,7 @@ static void tm_dbg_timer_fn(unsigned long arg); static spinlock_t scst_tm_dbg_lock = SPIN_LOCK_UNLOCKED; /* All serialized by scst_tm_dbg_lock */ -struct -{ +struct { unsigned int tm_dbg_release:1; unsigned int tm_dbg_blocked:1; } tm_dbg_flags; diff --git a/scst/src/scst_main.c b/scst/src/scst_main.c index fee41c16f..a98d94029 100644 --- a/scst/src/scst_main.c +++ b/scst/src/scst_main.c @@ -147,8 +147,7 @@ module_param_named(scst_max_cmd_mem, scst_max_cmd_mem, long, 0); MODULE_PARM_DESC(scst_max_cmd_mem, "Maximum memory allowed to be consumed by " "the SCST commands at any given time in MB"); -struct scst_dev_type scst_null_devtype = -{ +struct scst_dev_type scst_null_devtype = { .name = "none", }; @@ -542,8 +541,7 @@ out_up: "scsi%d, channel %d, id %d, lun %d, type %d", scsidp->host->host_no, scsidp->channel, scsidp->id, scsidp->lun, scsidp->type); - } - else { + } else { PRINT_ERROR("Failed to attach SCSI target mid-level " "at scsi%d, channel %d, id %d, lun %d, type %d", scsidp->host->host_no, scsidp->channel, scsidp->id, @@ -696,8 +694,7 @@ out: if (res > 0) { PRINT_INFO("Attached SCSI target mid-level to virtual " "device %s (id %d)", dev_name, dev->virt_id); - } - else { + } else { PRINT_INFO("Failed to attach SCSI target mid-level to " "virtual device %s", dev_name); } @@ -807,9 +804,8 @@ int __scst_register_dev_driver(struct scst_dev_type *dev_type, goto out_up; res = scst_build_proc_dev_handler_dir_entries(dev_type); - if (res < 0) { + if (res < 0) goto out_up; - } list_add_tail(&dev_type->dev_type_list_entry, &scst_dev_type_list); @@ -1033,9 +1029,8 @@ void scst_del_dev_threads(struct scst_device *dev, int num) list_for_each_entry_safe(ct, tmp, &dev->threads_list, thread_list_entry) { int rc = kthread_stop(ct->cmd_thread); - if (rc < 0) { + if (rc < 0) TRACE_MGMT_DBG("kthread_stop() failed: %d", rc); - } list_del(&ct->thread_list_entry); kfree(ct); if ((num > 0) && (++i >= num)) @@ -1204,9 +1199,8 @@ void __scst_del_cmd_threads(int num) int res; res = kthread_stop(ct->cmd_thread); - if (res < 0) { + if (res < 0) TRACE_MGMT_DBG("kthread_stop() failed: %d", res); - } list_del(&ct->thread_list_entry); kfree(ct); scst_threads_info.nr_cmd_threads--; @@ -1553,7 +1547,10 @@ static int __init init_scst(void) p = KMEM_CACHE(s, SCST_SLAB_FLAGS); \ TRACE_MEM("Slab create: %s at %p size %zd", #s, p, \ sizeof(struct s)); \ - if (p == NULL) { res = -ENOMEM; goto o; } \ + if (p == NULL) { \ + res = -ENOMEM; \ + goto o; \ + } \ } while (0) INIT_CACHEP(scst_mgmt_cachep, scst_mgmt_cmd, out); diff --git a/scst/src/scst_mem.c b/scst/src/scst_mem.c index be8218173..0da172782 100644 --- a/scst/src/scst_mem.c +++ b/scst/src/scst_mem.c @@ -809,9 +809,8 @@ void scst_free(struct scatterlist *sg, int count) static void sgv_pool_cached_init(struct sgv_pool *pool) { int i; - for (i = 0; i < SGV_POOL_ELEMENTS; i++) { + for (i = 0; i < SGV_POOL_ELEMENTS; i++) INIT_LIST_HEAD(&pool->recycling_lists[i]); - } } int sgv_pool_init(struct sgv_pool *pool, const char *name, int clustered) diff --git a/scst/src/scst_mem.h b/scst/src/scst_mem.h index 8294dd8db..308384ffb 100644 --- a/scst/src/scst_mem.h +++ b/scst/src/scst_mem.h @@ -30,8 +30,7 @@ struct trans_tbl_ent { unsigned short pg_count; }; -struct sgv_pool_obj -{ +struct sgv_pool_obj { int order; struct { @@ -50,30 +49,26 @@ struct sgv_pool_obj struct scatterlist sg_entries_data[0]; }; -struct sgv_pool_acc -{ +struct sgv_pool_acc { u32 cached_pages, cached_entries; atomic_t big_alloc, other_alloc; atomic_t big_pages, other_pages; atomic_t big_merged, other_merged; }; -struct sgv_pool_cache_acc -{ +struct sgv_pool_cache_acc { atomic_t total_alloc, hit_alloc; atomic_t merged; }; -struct sgv_pool_alloc_fns -{ +struct sgv_pool_alloc_fns { struct page *(*alloc_pages_fn)(struct scatterlist *sg, gfp_t gfp_mask, void *priv); void (*free_pages_fn)(struct scatterlist *sg, int sg_count, void *priv); }; -struct sgv_pool -{ +struct sgv_pool { unsigned int clustered; struct sgv_pool_alloc_fns alloc_fns; /* 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048 */ @@ -89,8 +84,7 @@ struct sgv_pool struct list_head sgv_pool_list_entry; }; -struct scst_sgv_pools_manager -{ +struct scst_sgv_pools_manager { struct { struct sgv_pool norm_clust, norm; struct sgv_pool dma; diff --git a/scst/src/scst_priv.h b/scst/src/scst_priv.h index 78247abea..253e82586 100644 --- a/scst/src/scst_priv.h +++ b/scst/src/scst_priv.h @@ -181,8 +181,7 @@ extern struct list_head scst_active_mgmt_cmd_list; extern struct list_head scst_delayed_mgmt_cmd_list; extern wait_queue_head_t scst_mgmt_cmd_list_waitQ; -struct scst_tasklet -{ +struct scst_tasklet { spinlock_t tasklet_lock; struct list_head tasklet_cmd_list; struct tasklet_struct tasklet; diff --git a/scst/src/scst_proc.c b/scst/src/scst_proc.c index fb8143f5d..e66c40807 100644 --- a/scst/src/scst_proc.c +++ b/scst/src/scst_proc.c @@ -268,9 +268,8 @@ int scst_proc_log_entry_write(struct file *file, const char *buf, p += 6; action = SCST_PROC_ACTION_VALUE; } else { - if (p[strlen(p) - 1] == '\n') { + if (p[strlen(p) - 1] == '\n') p[strlen(p) - 1] = '\0'; - } PRINT_ERROR("Unknown action \"%s\"", p); res = -EINVAL; goto out_free; @@ -289,13 +288,11 @@ int scst_proc_log_entry_write(struct file *file, const char *buf, case SCST_PROC_ACTION_SET: case SCST_PROC_ACTION_ADD: case SCST_PROC_ACTION_DEL: - while (isspace(*p) && *p != '\0') { + while (isspace(*p) && *p != '\0') p++; - } e = p; - while (!isspace(*e) && *e != '\0') { + while (!isspace(*e) && *e != '\0') e++; - } *e = 0; if (tbl) { t = tbl; @@ -324,9 +321,8 @@ int scst_proc_log_entry_write(struct file *file, const char *buf, } break; case SCST_PROC_ACTION_VALUE: - while (isspace(*p) && *p != '\0') { + while (isspace(*p) && *p != '\0') p++; - } level = simple_strtoul(p, NULL, 0); break; } @@ -802,17 +798,14 @@ int __init scst_proc_init_module(void) goto out_remove4; } - if (scst_proc_init_module_log() < 0) { + if (scst_proc_init_module_log() < 0) goto out_remove5; - } - if (scst_proc_init_groups() < 0) { + if (scst_proc_init_groups() < 0) goto out_remove6; - } - if (scst_proc_init_sgv() < 0) { + if (scst_proc_init_sgv() < 0) goto out_remove7; - } out: TRACE_EXIT_RES(res); @@ -1251,9 +1244,8 @@ static ssize_t scst_proc_scsi_tgt_gen_write(struct file *file, const char __user * or echo "assign H:C:I:L HANDLER_NAME" >/proc/scsi_tgt/scsi_tgt */ p = buffer; - if (p[strlen(p) - 1] == '\n') { + if (p[strlen(p) - 1] == '\n') p[strlen(p) - 1] = '\0'; - } if (!strncasecmp("assign ", p, 7)) { p += 7; action = SCST_PROC_ACTION_ASSIGN; @@ -1345,9 +1337,8 @@ static int scst_proc_assign_handler(char *buf) TRACE_ENTRY(); - while (isspace(*p) && *p != '\0') { + while (isspace(*p) && *p != '\0') p++; - } host = simple_strtoul(p, &p, 0); if ((host == ULONG_MAX) || (*p != ':')) @@ -1367,13 +1358,11 @@ static int scst_proc_assign_handler(char *buf) e = p; e++; - while (isspace(*e) && *e != '\0') { + while (isspace(*e) && *e != '\0') e++; - } ee = e; - while (!isspace(*ee) && *ee != '\0') { + while (!isspace(*ee) && *ee != '\0') ee++; - } *ee = '\0'; TRACE_DBG("Dev %ld:%ld:%ld:%ld, handler %s", host, channel, id, lun, e); @@ -1383,8 +1372,7 @@ static int scst_proc_assign_handler(char *buf) d->scsi_dev->host->host_no == host && d->scsi_dev->channel == channel && d->scsi_dev->id == id && - d->scsi_dev->lun == lun) - { + d->scsi_dev->lun == lun) { dev = d; TRACE_DBG("Dev %p (%ld:%ld:%ld:%ld) found", dev, host, channel, id, lun); @@ -1476,9 +1464,8 @@ static ssize_t scst_proc_groups_devices_write(struct file *file, const char __us * or echo "clear" >/proc/scsi_tgt/groups/GROUP/devices */ p = buffer; - if (p[strlen(p) - 1] == '\n') { + if (p[strlen(p) - 1] == '\n') p[strlen(p) - 1] = '\0'; - } if (!strncasecmp("clear", p, 5)) { action = SCST_PROC_ACTION_CLEAR; } else if (!strncasecmp("add ", p, 4)) { @@ -1503,9 +1490,8 @@ static ssize_t scst_proc_groups_devices_write(struct file *file, const char __us switch (action) { case SCST_PROC_ACTION_ADD: case SCST_PROC_ACTION_DEL: - while (isspace(*p) && *p != '\0') { + while (isspace(*p) && *p != '\0') p++; - } e = p; /* save p */ host = simple_strtoul(p, &p, 0); if (*p == ':') { @@ -1516,9 +1502,8 @@ static ssize_t scst_proc_groups_devices_write(struct file *file, const char __us } else { virt++; p = e; /* restore p */ - while (!isspace(*e) && *e != '\0') { + while (!isspace(*e) && *e != '\0') e++; - } *e = 0; } @@ -1561,17 +1546,14 @@ static ssize_t scst_proc_groups_devices_write(struct file *file, const char __us switch (action) { case SCST_PROC_ACTION_ADD: e++; - while (isspace(*e) && *e != '\0') { + while (isspace(*e) && *e != '\0') e++; - } virt_lun = simple_strtoul(e, &e, 0); - while (isspace(*e) && *e != '\0') { + while (isspace(*e) && *e != '\0') e++; - } - if (!strncasecmp("READ_ONLY", e, 9)) { + if (!strncasecmp("READ_ONLY", e, 9)) read_only = 1; - } list_for_each_entry(acg_dev_tmp, &acg->acg_dev_list, acg_dev_list_entry) { @@ -1667,9 +1649,8 @@ static ssize_t scst_proc_groups_names_write(struct file *file, const char __user * or echo "clear" >/proc/scsi_tgt/groups/GROUP/names */ p = buffer; - if (p[strlen(p) - 1] == '\n') { + if (p[strlen(p) - 1] == '\n') p[strlen(p) - 1] = '\0'; - } if (!strncasecmp("clear", p, 5)) { action = SCST_PROC_ACTION_CLEAR; } else if (!strncasecmp("add ", p, 4)) { @@ -1687,13 +1668,11 @@ static ssize_t scst_proc_groups_names_write(struct file *file, const char __user switch (action) { case SCST_PROC_ACTION_ADD: case SCST_PROC_ACTION_DEL: - while (isspace(*p) && *p != '\0') { + while (isspace(*p) && *p != '\0') p++; - } e = p; - while (!isspace(*e) && *e != '\0') { + while (!isspace(*e) && *e != '\0') e++; - } *e = 0; break; } @@ -1976,9 +1955,8 @@ int scst_proc_log_entry_read(struct seq_file *seq, unsigned long log_level, scst_proc_read_tlb(scst_proc_trace_tbl, seq, log_level, &first); - if (tbl) { + if (tbl) scst_proc_read_tlb(tbl, seq, log_level, &first); - } seq_printf(seq, "%s\n", first ? "none" : ""); diff --git a/scst/src/scst_targ.c b/scst/src/scst_targ.c index 67ddc2a6d..186dbf017 100644 --- a/scst/src/scst_targ.c +++ b/scst/src/scst_targ.c @@ -201,8 +201,7 @@ void scst_cmd_init_done(struct scst_cmd *cmd, int pref_context) #ifdef EXTRACHECKS if (unlikely(in_irq()) && ((pref_context == SCST_CONTEXT_DIRECT) || - (pref_context == SCST_CONTEXT_DIRECT_ATOMIC))) - { + (pref_context == SCST_CONTEXT_DIRECT_ATOMIC))) { PRINT_ERROR("Wrong context %d in IRQ from target %s, use " "SCST_CONTEXT_TASKLET instead\n", pref_context, cmd->tgtt->name); @@ -962,8 +961,7 @@ void scst_rx_data(struct scst_cmd *cmd, int status, int pref_context) #ifdef EXTRACHECKS if (in_irq() && ((pref_context == SCST_CONTEXT_DIRECT) || - (pref_context == SCST_CONTEXT_DIRECT_ATOMIC))) - { + (pref_context == SCST_CONTEXT_DIRECT_ATOMIC))) { PRINT_ERROR("Wrong context %d in IRQ from target %s, use " "SCST_CONTEXT_TASKLET instead\n", pref_context, cmd->tgtt->name); @@ -1228,8 +1226,7 @@ static void scst_cmd_done_local(struct scst_cmd *cmd, int next_state) #ifdef EXTRACHECKS if ((next_state != SCST_CMD_STATE_PRE_DEV_DONE) && (next_state != SCST_CMD_STATE_PRE_XMIT_RESP) && - (next_state != SCST_CMD_STATE_FINISHED)) - { + (next_state != SCST_CMD_STATE_FINISHED)) { PRINT_ERROR("scst_cmd_done_local() received invalid cmd " "state %d (opcode %d)", next_state, cmd->cdb[0]); scst_set_cmd_error(cmd, @@ -2390,8 +2387,7 @@ static int scst_dev_done(struct scst_cmd *cmd) state = SCST_CMD_STATE_PRE_XMIT_RESP; if (likely(!scst_is_cmd_local(cmd)) && - likely(cmd->dev->handler->dev_done != NULL)) - { + likely(cmd->dev->handler->dev_done != NULL)) { int rc; TRACE_DBG("Calling dev handler %s dev_done(%p)", cmd->dev->handler->name, cmd);