public inbox for linux-staging@lists.linux.dev
 help / color / mirror / Atom feed
From: Philipp Hortmann <philipp.g.hortmann@gmail.com>
To: Martin Kaiser <martin@kaiser.cx>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Larry Finger <Larry.Finger@lwfinger.net>,
	Phillip Potter <phil@philpotter.co.uk>,
	Michael Straube <straube.linux@gmail.com>,
	Pavel Skripkin <paskripkin@gmail.com>,
	linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: r8188eu: replace hand coded loop with list_for_each_entry
Date: Mon, 13 Feb 2023 20:24:00 +0100	[thread overview]
Message-ID: <d463a482-03c8-db3b-e3ac-935eb12c82bf@gmail.com> (raw)
In-Reply-To: <20230211170223.419205-1-martin@kaiser.cx>

On 2/11/23 18:02, Martin Kaiser wrote:
> In function rtw_get_stainfo, we can use list_for_each_entry to iterate
> over the list of stations and make the code a bit simpler.
> 
> Signed-off-by: Martin Kaiser <martin@kaiser.cx>
> ---
>   drivers/staging/r8188eu/core/rtw_sta_mgt.c | 16 ++++------------
>   1 file changed, 4 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/staging/r8188eu/core/rtw_sta_mgt.c b/drivers/staging/r8188eu/core/rtw_sta_mgt.c
> index a9c29b2bf230..e1ae1859686e 100644
> --- a/drivers/staging/r8188eu/core/rtw_sta_mgt.c
> +++ b/drivers/staging/r8188eu/core/rtw_sta_mgt.c
> @@ -391,8 +391,7 @@ void rtw_free_all_stainfo(struct adapter *padapter)
>   /* any station allocated can be searched by hash list */
>   struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr)
>   {
> -	struct list_head *plist, *phead;
> -	struct sta_info *psta = NULL;
> +	struct sta_info *ploop, *psta = NULL;
>   	u32	index;
>   	u8 *addr;
>   	u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
> @@ -409,18 +408,11 @@ struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr)
>   
>   	spin_lock_bh(&pstapriv->sta_hash_lock);
>   
> -	phead = &pstapriv->sta_hash[index];
> -	plist = phead->next;
> -
> -	while (phead != plist) {
> -		psta = container_of(plist, struct sta_info, hash_list);
> -
> -		if ((!memcmp(psta->hwaddr, addr, ETH_ALEN))) {
> -			/*  if found the matched address */
> +	list_for_each_entry(ploop, &pstapriv->sta_hash[index], hash_list) {
> +		if (!memcmp(ploop->hwaddr, addr, ETH_ALEN)) {
> +			psta = ploop;
>   			break;
>   		}
> -		psta = NULL;
> -		plist = plist->next;
>   	}
>   
>   	spin_unlock_bh(&pstapriv->sta_hash_lock);

Tested-by: Philipp Hortmann <philipp.g.hortmann@gmail.com> # Edimax N150

      reply	other threads:[~2023-02-13 19:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-11 17:02 [PATCH] staging: r8188eu: replace hand coded loop with list_for_each_entry Martin Kaiser
2023-02-13 19:24 ` Philipp Hortmann [this message]

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=d463a482-03c8-db3b-e3ac-935eb12c82bf@gmail.com \
    --to=philipp.g.hortmann@gmail.com \
    --cc=Larry.Finger@lwfinger.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=martin@kaiser.cx \
    --cc=paskripkin@gmail.com \
    --cc=phil@philpotter.co.uk \
    --cc=straube.linux@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox