From: qiwuchen55@gmail.com
To: gregkh@linuxfoundation.org
Cc: linux-usb@vger.kernel.org, chenqiwu <chenqiwu@xiaomi.com>
Subject: [PATCH] usb: fhci: use list_first_entry() instead of list_entry()
Date: Sun, 23 Feb 2020 22:35:43 +0800 [thread overview]
Message-ID: <1582468543-32343-1-git-send-email-qiwuchen55@gmail.com> (raw)
From: chenqiwu <chenqiwu@xiaomi.com>
To make the intention clearer, use list_first_entry() instead of
list_entry().
Signed-off-by: chenqiwu <chenqiwu@xiaomi.com>
---
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
next reply other threads:[~2020-02-23 14:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-23 14:35 qiwuchen55 [this message]
2020-02-23 17:53 ` [PATCH] usb: fhci: use list_first_entry() instead of list_entry() kbuild test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1582468543-32343-1-git-send-email-qiwuchen55@gmail.com \
--to=qiwuchen55@gmail.com \
--cc=chenqiwu@xiaomi.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox