[PATCH] usb: fhci: use list_first_entry() instead of list_entry()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: chenqiwu <chenqiwu@xxxxxxxxxx>

To make the intention clearer, use list_first_entry() instead of
list_entry().

Signed-off-by: chenqiwu <chenqiwu@xxxxxxxxxx>
---
 drivers/usb/host/fhci-mem.c |  8 ++++----
 drivers/usb/host/fhci-q.c   | 24 ++++++++++++------------
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/host/fhci-mem.c b/drivers/usb/host/fhci-mem.c
index 658aedc..058cf7b 100644
--- a/drivers/usb/host/fhci-mem.c
+++ b/drivers/usb/host/fhci-mem.c
@@ -39,8 +39,8 @@ static struct td *get_empty_td(struct fhci_hcd *fhci)
 	struct td *td;
 
 	if (!list_empty(&fhci->empty_tds)) {
-		td = list_entry(fhci->empty_tds.next, struct td, node);
-		list_del(fhci->empty_tds.next);
+		td = list_fisrt_entry(fhci->empty_tds, struct td, node);
+		list_del(td->node);
 	} else {
 		td = kmalloc(sizeof(*td), GFP_ATOMIC);
 		if (!td)
@@ -63,8 +63,8 @@ struct ed *fhci_get_empty_ed(struct fhci_hcd *fhci)
 	struct ed *ed;
 
 	if (!list_empty(&fhci->empty_eds)) {
-		ed = list_entry(fhci->empty_eds.next, struct ed, node);
-		list_del(fhci->empty_eds.next);
+		ed = list_first_entry(fhci->empty_eds, struct ed, node);
+		list_del(ed->node);
 	} else {
 		ed = kmalloc(sizeof(*ed), GFP_ATOMIC);
 		if (!ed)
diff --git a/drivers/usb/host/fhci-q.c b/drivers/usb/host/fhci-q.c
index 669c2405..3673731 100644
--- a/drivers/usb/host/fhci-q.c
+++ b/drivers/usb/host/fhci-q.c
@@ -72,7 +72,7 @@ static struct td *peek_td_from_ed(struct ed *ed)
 	struct td *td;
 
 	if (!list_empty(&ed->td_list))
-		td = list_entry(ed->td_list.next, struct td, node);
+		td = list_first_entry(ed->td_list, struct td, node);
 	else
 		td = NULL;
 
@@ -84,8 +84,8 @@ struct td *fhci_remove_td_from_frame(struct fhci_time_frame *frame)
 	struct td *td;
 
 	if (!list_empty(&frame->tds_list)) {
-		td = list_entry(frame->tds_list.next, struct td, frame_lh);
-		list_del_init(frame->tds_list.next);
+		td = list_first_entry(frame->tds_list, struct td, frame_lh);
+		list_del_init(td->frame_lh);
 	} else
 		td = NULL;
 
@@ -97,7 +97,7 @@ struct td *fhci_peek_td_from_frame(struct fhci_time_frame *frame)
 	struct td *td;
 
 	if (!list_empty(&frame->tds_list))
-		td = list_entry(frame->tds_list.next, struct td, frame_lh);
+		td = list_first_entry(frame->tds_list, struct td, frame_lh);
 	else
 		td = NULL;
 
@@ -109,13 +109,13 @@ struct td *fhci_remove_td_from_ed(struct ed *ed)
 	struct td *td;
 
 	if (!list_empty(&ed->td_list)) {
-		td = list_entry(ed->td_list.next, struct td, node);
-		list_del_init(ed->td_list.next);
+		td = list_first_entry(ed->td_list, struct td, node);
+		list_del_init(td->node);
 
 		/* if this TD was the ED's head, find next TD */
 		if (!list_empty(&ed->td_list))
-			ed->td_head = list_entry(ed->td_list.next, struct td,
-						 node);
+			ed->td_head = list_first_entry(ed->td_list, struct td,
+						       node);
 		else
 			ed->td_head = NULL;
 	} else
@@ -129,8 +129,8 @@ struct td *fhci_remove_td_from_done_list(struct fhci_controller_list *p_list)
 	struct td *td;
 
 	if (!list_empty(&p_list->done_list)) {
-		td = list_entry(p_list->done_list.next, struct td, node);
-		list_del_init(p_list->done_list.next);
+		td = list_first_entry(p_list->done_list, struct td, node);
+		list_del_init(td->node);
 	} else
 		td = NULL;
 
@@ -146,7 +146,7 @@ void fhci_move_td_from_ed_to_done_list(struct fhci_usb *usb, struct ed *ed)
 
 	/* If this TD was the ED's head,find next TD */
 	if (!list_empty(&ed->td_list))
-		ed->td_head = list_entry(ed->td_list.next, struct td, node);
+		ed->td_head = list_first_entry(ed->td_list, struct td, node);
 	else {
 		ed->td_head = NULL;
 		ed->state = FHCI_ED_SKIP;
@@ -171,7 +171,7 @@ static void free_urb_priv(struct fhci_hcd *fhci, struct urb *urb)
 
 	/* if this TD was the ED's head,find the next TD */
 	if (!list_empty(&ed->td_list))
-		ed->td_head = list_entry(ed->td_list.next, struct td, node);
+		ed->td_head = list_first_entry(ed->td_list, struct td, node);
 	else
 		ed->td_head = NULL;
 
-- 
1.9.1




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux