From 187d2d255ba5201614a174d1d7242ff0753e4082 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sat, 5 Oct 2013 16:48:43 +0000 Subject: [PATCH] Replace list_entry((a)->next, b, c) by list_first_entry(a, b, c) (merge r3965 from trunk) git-svn-id: http://svn.code.sf.net/p/scst/svn/branches/2.2.x@5030 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- iscsi-scst/kernel/conn.c | 2 +- iscsi-scst/kernel/iscsi.c | 10 +++++----- iscsi-scst/kernel/nthread.c | 6 +++--- qla2x00t/qla2x00-target/qla2x00t.c | 4 ++-- qla2x00t/qla_os.c | 2 +- scst/src/dev_handlers/scst_user.c | 6 +++--- scst/src/dev_handlers/scst_vdisk.c | 2 +- scst/src/scst_lib.c | 4 ++-- scst/src/scst_main.c | 2 +- scst/src/scst_mem.c | 14 +++++++------- scst/src/scst_sysfs.c | 2 +- scst/src/scst_targ.c | 8 ++++---- scst_local/scst_local.c | 2 +- 13 files changed, 32 insertions(+), 32 deletions(-) diff --git a/iscsi-scst/kernel/conn.c b/iscsi-scst/kernel/conn.c index c81975166..e2f384bd8 100644 --- a/iscsi-scst/kernel/conn.c +++ b/iscsi-scst/kernel/conn.c @@ -527,7 +527,7 @@ static void conn_rsp_timer_fn(unsigned long arg) if (!list_empty(&conn->write_timeout_list)) { unsigned long timeout_time; - cmnd = list_entry(conn->write_timeout_list.next, + cmnd = list_first_entry(&conn->write_timeout_list, struct iscsi_cmnd, write_timeout_list_entry); timeout_time = j + iscsi_get_timeout(cmnd) + ISCSI_ADD_SCHED_TIME; diff --git a/iscsi-scst/kernel/iscsi.c b/iscsi-scst/kernel/iscsi.c index 58b734df0..c8285844f 100644 --- a/iscsi-scst/kernel/iscsi.c +++ b/iscsi-scst/kernel/iscsi.c @@ -758,7 +758,7 @@ static inline struct iscsi_cmnd *iscsi_alloc_main_rsp(struct iscsi_cmnd *parent) static void iscsi_cmnds_init_write(struct list_head *send, int flags) { - struct iscsi_cmnd *rsp = list_entry(send->next, struct iscsi_cmnd, + struct iscsi_cmnd *rsp = list_first_entry(send, struct iscsi_cmnd, write_list_entry); struct iscsi_conn *conn = rsp->conn; struct list_head *pos, *next; @@ -2986,7 +2986,7 @@ static void iscsi_push_cmnd(struct iscsi_cmnd *cmnd) if (list_empty(&session->pending_list)) break; - cmnd = list_entry(session->pending_list.next, + cmnd = list_first_entry(&session->pending_list, struct iscsi_cmnd, pending_list_entry); if (cmnd->pdu.bhs.sn != cmd_sn) @@ -3390,9 +3390,9 @@ static int iscsi_xmit_response(struct scst_cmd *scst_cmd) * There's no need for protection, since we are not going to * dereference them. */ - wr_rsp = list_entry(conn->write_list.next, struct iscsi_cmnd, + wr_rsp = list_first_entry(&conn->write_list, struct iscsi_cmnd, write_list_entry); - our_rsp = list_entry(req->rsp_cmd_list.next, struct iscsi_cmnd, + our_rsp = list_first_entry(&req->rsp_cmd_list, struct iscsi_cmnd, rsp_cmd_list_entry); if (wr_rsp == our_rsp) { /* @@ -3930,7 +3930,7 @@ int iscsi_threads_pool_get(const cpumask_t *cpu_mask, if (!list_empty(&iscsi_thread_pools_list)) { PRINT_WARNING("%s", "Using global iSCSI thread pool " "instead"); - p = list_entry(iscsi_thread_pools_list.next, + p = list_first_entry(&iscsi_thread_pools_list, struct iscsi_thread_pool, thread_pools_list_entry); } else diff --git a/iscsi-scst/kernel/nthread.c b/iscsi-scst/kernel/nthread.c index 9b331c99f..ece666295 100644 --- a/iscsi-scst/kernel/nthread.c +++ b/iscsi-scst/kernel/nthread.c @@ -642,7 +642,7 @@ static struct iscsi_cmnd *iscsi_get_send_cmnd(struct iscsi_conn *conn) spin_lock_bh(&conn->write_list_lock); if (!list_empty(&conn->write_list)) { - cmnd = list_entry(conn->write_list.next, struct iscsi_cmnd, + cmnd = list_first_entry(&conn->write_list, struct iscsi_cmnd, write_list_entry); cmd_del_from_write_list(cmnd); cmnd->write_processing_started = 1; @@ -1017,7 +1017,7 @@ static void scst_do_job_rd(struct iscsi_thread_pool *p) while (!list_empty(&p->rd_list)) { int closed = 0, rc; - struct iscsi_conn *conn = list_entry(p->rd_list.next, + struct iscsi_conn *conn = list_first_entry(&p->rd_list, typeof(*conn), rd_list_entry); list_del(&conn->rd_list_entry); @@ -1786,7 +1786,7 @@ static void scst_do_job_wr(struct iscsi_thread_pool *p) while (!list_empty(&p->wr_list)) { int rc; - struct iscsi_conn *conn = list_entry(p->wr_list.next, + struct iscsi_conn *conn = list_first_entry(&p->wr_list, typeof(*conn), wr_list_entry); TRACE_DBG("conn %p, wr_state %x, wr_space_ready %d, " diff --git a/qla2x00t/qla2x00-target/qla2x00t.c b/qla2x00t/qla2x00-target/qla2x00t.c index 767cc4ac7..43c6bbc21 100644 --- a/qla2x00t/qla2x00-target/qla2x00t.c +++ b/qla2x00t/qla2x00-target/qla2x00t.c @@ -695,7 +695,7 @@ static int q2t_reset(scsi_qla_host_t *ha, void *iocb, int mcmd) atomic_inc(&ha->tgt->tgt_global_resets_count); q2t_clear_tgt_db(ha->tgt, 1); if (!list_empty(&ha->tgt->sess_list)) { - sess = list_entry(ha->tgt->sess_list.next, + sess = list_first_entry(&ha->tgt->sess_list, typeof(*sess), sess_list_entry); switch (mcmd) { case Q2T_NEXUS_LOSS_SESS: @@ -1038,7 +1038,7 @@ static void q2t_del_sess_work_fn(struct delayed_work *work) spin_lock_irqsave(&pha->hardware_lock, flags); while (!list_empty(&tgt->del_sess_list)) { - sess = list_entry(tgt->del_sess_list.next, typeof(*sess), + sess = list_first_entry(&tgt->del_sess_list, typeof(*sess), del_list_entry); if (time_after_eq(jiffies, sess->expires)) { bool cancel; diff --git a/qla2x00t/qla_os.c b/qla2x00t/qla_os.c index a06d558d7..5109cd3ae 100644 --- a/qla2x00t/qla_os.c +++ b/qla2x00t/qla_os.c @@ -2614,7 +2614,7 @@ qla2x00_do_work(struct scsi_qla_host *ha) spin_lock_irq(&pha->hardware_lock); while (!list_empty(&ha->work_list)) { - e = list_entry(ha->work_list.next, struct qla_work_evt, list); + e = list_first_entry(&ha->work_list, struct qla_work_evt, list); list_del_init(&e->list); spin_unlock_irq(&pha->hardware_lock); diff --git a/scst/src/dev_handlers/scst_user.c b/scst/src/dev_handlers/scst_user.c index cb023f0d6..d95951a87 100644 --- a/scst/src/dev_handlers/scst_user.c +++ b/scst/src/dev_handlers/scst_user.c @@ -1797,7 +1797,7 @@ static struct scst_user_cmd *__dev_user_get_next_cmd(struct list_head *cmd_list) again: u = NULL; if (!list_empty(cmd_list)) { - u = list_entry(cmd_list->next, typeof(*u), + u = list_first_entry(cmd_list, typeof(*u), ready_cmd_list_entry); TRACE_DBG("Found ready ucmd %p", u); @@ -3663,7 +3663,7 @@ static int dev_user_cleanup_thread(void *arg) while (!list_empty(&cleanup_list)) { int rc; - dev = list_entry(cleanup_list.next, + dev = list_first_entry(&cleanup_list, typeof(*dev), cleanup_list_entry); list_del(&dev->cleanup_list_entry); @@ -3684,7 +3684,7 @@ static int dev_user_cleanup_thread(void *arg) spin_lock(&cleanup_lock); while (!list_empty(&cl_devs)) { - dev = list_entry(cl_devs.next, typeof(*dev), + dev = list_first_entry(&cl_devs, typeof(*dev), cleanup_list_entry); list_move_tail(&dev->cleanup_list_entry, &cleanup_list); diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index 498b61224..5bef997a8 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -5309,7 +5309,7 @@ static void exit_scst_vdisk(struct scst_dev_type *devtype) if (list_empty(&vdev_list)) break; - virt_dev = list_entry(vdev_list.next, typeof(*virt_dev), + virt_dev = list_first_entry(&vdev_list, typeof(*virt_dev), vdev_list_entry); vdev_del_device(virt_dev); diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 686fed0de..e8c9038b8 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -1312,7 +1312,7 @@ void scst_set_initial_UA(struct scst_session *sess, int key, int asc, int ascq) if (!list_empty(&tgt_dev->UA_list)) { struct scst_tgt_dev_UA *ua; - ua = list_entry(tgt_dev->UA_list.next, + ua = list_first_entry(&tgt_dev->UA_list, typeof(*ua), UA_list_entry); if (scst_analyze_sense(ua->UA_sense_buffer, ua->UA_valid_sense_len, @@ -6192,7 +6192,7 @@ again: goto out_unlock; } - UA_entry = list_entry(cmd->tgt_dev->UA_list.next, typeof(*UA_entry), + UA_entry = list_first_entry(&cmd->tgt_dev->UA_list, typeof(*UA_entry), UA_list_entry); TRACE_DBG("next %p UA_entry %p", diff --git a/scst/src/scst_main.c b/scst/src/scst_main.c index 539ddb01f..d54613fd3 100644 --- a/scst/src/scst_main.c +++ b/scst/src/scst_main.c @@ -856,7 +856,7 @@ static void __scst_resume_activity(void) spin_lock_irq(&scst_mcmd_lock); if (!list_empty(&scst_delayed_mgmt_cmd_list)) { struct scst_mgmt_cmd *m; - m = list_entry(scst_delayed_mgmt_cmd_list.next, typeof(*m), + m = list_first_entry(&scst_delayed_mgmt_cmd_list, typeof(*m), mgmt_cmd_list_entry); TRACE_MGMT_DBG("Moving delayed mgmt cmd %p to head of active " "mgmt cmd list", m); diff --git a/scst/src/scst_mem.c b/scst/src/scst_mem.c index 7d5708a13..b9ec7bde7 100644 --- a/scst/src/scst_mem.c +++ b/scst/src/scst_mem.c @@ -236,8 +236,8 @@ static int sgv_shrink_pool(struct sgv_pool *pool, int nr, int min_interval, while (!list_empty(&pool->sorted_recycling_list) && (atomic_read(&sgv_pages_total) > sgv_lo_wmk)) { - struct sgv_pool_obj *obj = list_entry( - pool->sorted_recycling_list.next, + struct sgv_pool_obj *obj = list_first_entry( + &pool->sorted_recycling_list, struct sgv_pool_obj, sorted_recycling_list_entry); if (sgv_purge_from_cache(obj, min_interval, cur_time)) { @@ -295,7 +295,7 @@ static int __sgv_shrink(int nr, int min_interval) goto out_unlock; } - pool = list_entry(sgv_active_pools_list.next, + pool = list_first_entry(&sgv_active_pools_list, typeof(*pool), sgv_active_pools_list_entry); } @@ -400,8 +400,8 @@ static void sgv_purge_work_fn(struct delayed_work *work) pool->purge_work_scheduled = false; while (!list_empty(&pool->sorted_recycling_list)) { - struct sgv_pool_obj *obj = list_entry( - pool->sorted_recycling_list.next, + struct sgv_pool_obj *obj = list_first_entry( + &pool->sorted_recycling_list, struct sgv_pool_obj, sorted_recycling_list_entry); if (sgv_purge_from_cache(obj, pool->purge_interval, cur_time)) { @@ -719,7 +719,7 @@ static struct sgv_pool_obj *sgv_get_obj(struct sgv_pool *pool, int cache_num, } if (likely(!list_empty(&pool->recycling_lists[cache_num]))) { - obj = list_entry(pool->recycling_lists[cache_num].next, + obj = list_first_entry(&pool->recycling_lists[cache_num], struct sgv_pool_obj, recycling_list_entry); list_del(&obj->sorted_recycling_list_entry); @@ -1525,7 +1525,7 @@ void sgv_pool_flush(struct sgv_pool *pool) spin_lock_bh(&pool->sgv_pool_lock); while (!list_empty(&pool->recycling_lists[i])) { - obj = list_entry(pool->recycling_lists[i].next, + obj = list_first_entry(&pool->recycling_lists[i], struct sgv_pool_obj, recycling_list_entry); __sgv_purge_from_cache(obj); diff --git a/scst/src/scst_sysfs.c b/scst/src/scst_sysfs.c index 606aa04cb..421402bc0 100644 --- a/scst/src/scst_sysfs.c +++ b/scst/src/scst_sysfs.c @@ -424,7 +424,7 @@ static void scst_process_sysfs_works(void) TRACE_ENTRY(); while (!list_empty(&sysfs_work_list)) { - work = list_entry(sysfs_work_list.next, + work = list_first_entry(&sysfs_work_list, struct scst_sysfs_work_item, sysfs_work_list_entry); list_del(&work->sysfs_work_list_entry); spin_unlock(&sysfs_work_lock); diff --git a/scst/src/scst_targ.c b/scst/src/scst_targ.c index d6e11bcb9..1b1b1b98a 100644 --- a/scst/src/scst_targ.c +++ b/scst/src/scst_targ.c @@ -4350,7 +4350,7 @@ static void scst_do_job_active(struct list_head *cmd_list, TRACE_ENTRY(); while (!list_empty(cmd_list)) { - struct scst_cmd *cmd = list_entry(cmd_list->next, typeof(*cmd), + struct scst_cmd *cmd = list_first_entry(cmd_list, typeof(*cmd), cmd_list_entry); TRACE_DBG("Deleting cmd %p from active cmd list", cmd); list_del(&cmd->cmd_list_entry); @@ -5886,7 +5886,7 @@ int scst_tm_thread(void *arg) while (!list_empty(&scst_active_mgmt_cmd_list)) { int rc; struct scst_mgmt_cmd *mcmd; - mcmd = list_entry(scst_active_mgmt_cmd_list.next, + mcmd = list_first_entry(&scst_active_mgmt_cmd_list, typeof(*mcmd), mgmt_cmd_list_entry); TRACE_MGMT_DBG("Deleting mgmt cmd %p from active cmd " "list", mcmd); @@ -6715,7 +6715,7 @@ int scst_global_mgmt_thread(void *arg) } while (!list_empty(&scst_sess_init_list)) { - sess = list_entry(scst_sess_init_list.next, + sess = list_first_entry(&scst_sess_init_list, typeof(*sess), sess_init_list_entry); TRACE_DBG("Removing sess %p from scst_sess_init_list", sess); @@ -6736,7 +6736,7 @@ int scst_global_mgmt_thread(void *arg) } while (!list_empty(&scst_sess_shut_list)) { - sess = list_entry(scst_sess_shut_list.next, + sess = list_first_entry(&scst_sess_shut_list, typeof(*sess), sess_shut_list_entry); TRACE_DBG("Removing sess %p from scst_sess_shut_list", sess); diff --git a/scst_local/scst_local.c b/scst_local/scst_local.c index b982a76a7..c8a820ac2 100644 --- a/scst_local/scst_local.c +++ b/scst_local/scst_local.c @@ -1150,7 +1150,7 @@ static void scst_process_aens(struct scst_local_sess *sess, TRACE_DBG("Target work sess %p", sess); while (!list_empty(&sess->aen_work_list)) { - work_item = list_entry(sess->aen_work_list.next, + work_item = list_first_entry(&sess->aen_work_list, struct scst_aen_work_item, work_list_entry); list_del(&work_item->work_list_entry);