From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: linux-usb@vger.kernel.org,
Chunfeng Yun <chunfeng.yun@mediatek.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] usb: mtu3: cleanup with list_first_entry_or_null()
Date: Sat, 20 May 2017 21:19:40 +0200 [thread overview]
Message-ID: <20170520191940.GA29597@kroah.com> (raw)
In-Reply-To: <1495299931-10418-1-git-send-email-yamada.masahiro@socionext.com>
On Sun, May 21, 2017 at 02:05:31AM +0900, Masahiro Yamada wrote:
> The combo of list_empty() and list_first_entry() can be replaced with
> list_first_entry_or_null().
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
>
> drivers/usb/mtu3/mtu3.h | 8 ++------
> 1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/usb/mtu3/mtu3.h b/drivers/usb/mtu3/mtu3.h
> index aa6fd6a..7b6dc23 100644
> --- a/drivers/usb/mtu3/mtu3.h
> +++ b/drivers/usb/mtu3/mtu3.h
> @@ -356,12 +356,8 @@ static inline struct mtu3_ep *to_mtu3_ep(struct usb_ep *ep)
>
> static inline struct mtu3_request *next_request(struct mtu3_ep *mep)
> {
> - struct list_head *queue = &mep->req_list;
> -
> - if (list_empty(queue))
> - return NULL;
> -
> - return list_first_entry(queue, struct mtu3_request, list);
> + return list_first_entry_or_null(&mep->req_list, struct mtu3_request,
> + list);
Even better, why is this an inlined function at all? Why not just have
it "open coded" everywhere it is used?
thanks,
greg k-h
next prev parent reply other threads:[~2017-05-20 19:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-20 17:05 [PATCH] usb: mtu3: cleanup with list_first_entry_or_null() Masahiro Yamada
2017-05-20 19:19 ` Greg Kroah-Hartman [this message]
2017-05-22 1:21 ` Chunfeng Yun
2017-05-25 12:26 ` Greg Kroah-Hartman
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=20170520191940.GA29597@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=chunfeng.yun@mediatek.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=yamada.masahiro@socionext.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.