diff mbox series

[-next,SCSI] esas2r: Use list_for_each_entry() helper

Message ID 20230828123733.361547-1-ruanjinjie@huawei.com
State New
Headers show
Series [-next,SCSI] esas2r: Use list_for_each_entry() helper | expand

Commit Message

Jinjie Ruan Aug. 28, 2023, 12:37 p.m. UTC
Convert list_for_each() to list_for_each_entry() so that the element
list_head pointer and list_entry() call are no longer needed, which
can reduce a few lines of code. No functional changed.

Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
 drivers/scsi/esas2r/esas2r_disc.c |  4 +---
 drivers/scsi/esas2r/esas2r_int.c  | 10 ++--------
 2 files changed, 3 insertions(+), 11 deletions(-)
diff mbox series

Patch

diff --git a/drivers/scsi/esas2r/esas2r_disc.c b/drivers/scsi/esas2r/esas2r_disc.c
index ba42536d1e87..c32d45cc2192 100644
--- a/drivers/scsi/esas2r/esas2r_disc.c
+++ b/drivers/scsi/esas2r/esas2r_disc.c
@@ -1161,14 +1161,12 @@  static void esas2r_disc_fix_curr_requests(struct esas2r_adapter *a)
 	unsigned long flags;
 	struct esas2r_target *t;
 	struct esas2r_request *rq;
-	struct list_head *element;
 
 	/* update virt_targ_id in any outstanding esas2r_requests  */
 
 	spin_lock_irqsave(&a->queue_lock, flags);
 
-	list_for_each(element, &a->defer_list) {
-		rq = list_entry(element, struct esas2r_request, req_list);
+	list_for_each_entry(rq, &a->defer_list, req_list) {
 		if (rq->vrq->scsi.function == VDA_FUNC_SCSI) {
 			t = a->targetdb + rq->target_id;
 
diff --git a/drivers/scsi/esas2r/esas2r_int.c b/drivers/scsi/esas2r/esas2r_int.c
index 5281d9356327..8fbbd53319fc 100644
--- a/drivers/scsi/esas2r/esas2r_int.c
+++ b/drivers/scsi/esas2r/esas2r_int.c
@@ -390,9 +390,7 @@  void esas2r_process_adapter_reset(struct esas2r_adapter *a)
 	struct esas2r_request *rq = &a->general_req;
 	unsigned long flags;
 	struct esas2r_disc_context *dc;
-
 	LIST_HEAD(comp_list);
-	struct list_head *element;
 
 	esas2r_trace_enter();
 
@@ -429,9 +427,7 @@  void esas2r_process_adapter_reset(struct esas2r_adapter *a)
 	set_bit(AF_COMM_LIST_TOGGLE, &a->flags);
 
 	/* Kill all the requests on the active list */
-	list_for_each(element, &a->defer_list) {
-		rq = list_entry(element, struct esas2r_request, req_list);
-
+	list_for_each_entry(rq, &a->defer_list, req_list) {
 		if (rq->req_stat == RS_STARTED)
 			if (esas2r_ioreq_aborted(a, rq, RS_ABORTED))
 				list_add_tail(&rq->comp_list, &comp_list);
@@ -446,7 +442,6 @@  void esas2r_process_adapter_reset(struct esas2r_adapter *a)
 static void esas2r_process_bus_reset(struct esas2r_adapter *a)
 {
 	struct esas2r_request *rq;
-	struct list_head *element;
 	unsigned long flags;
 
 	LIST_HEAD(comp_list);
@@ -458,8 +453,7 @@  static void esas2r_process_bus_reset(struct esas2r_adapter *a)
 	spin_lock_irqsave(&a->queue_lock, flags);
 
 	/* kill all the requests on the deferred queue */
-	list_for_each(element, &a->defer_list) {
-		rq = list_entry(element, struct esas2r_request, req_list);
+	list_for_each_entry(rq, &a->defer_list, req_list) {
 		if (esas2r_ioreq_aborted(a, rq, RS_ABORTED))
 			list_add_tail(&rq->comp_list, &comp_list);
 	}