Skip to contentSkip to conversation

Staging: rtl8188eu: core: rtw_ap: Use list_for_each_entry_safe

PATCH Superseded Srishti Sharma 3 participants 6 messages Oct 5, 2017 – Oct 18, 2017 Staging

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Staging: rtl8188eu: core: rtw_ap: Use list_for_each_entry_safe

This is a cleanup patch and doesn't change runtime behavior. It changes an open coded list traversal to use list_for_each_entry_safe. Done using the following semantic patch by coccinelle.

@r@
struct list_head* l;
expression e;
identifier m, list_del_init, f;
type T1;
T1* pos;
iterator name list_for_each_entry_safe;
@@

f(...){

+T1* tmp;
...
-while(...)
+list_for_each_entry_safe(pos,tmp,l,m)
{
...
-pos = container_of(l,T1,m);
...
-l=e;
<+...
list_del_init(&pos->m)
...+>
}
...
}

---
Changes in v2
-Make commit message clear.
-Add file name to subject.

 drivers/staging/rtl8188eu/core/rtw_ap.c | 22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)
drivers/staging/rtl8188eu/core/rtw_ap.c +6 -16
index 32a4837..a2c599f 100644
@@ -1196,7 +1196,7 @@ int rtw_acl_add_sta(struct adapter *padapter, u8 *addr)
 int rtw_acl_remove_sta(struct adapter *padapter, u8 *addr)
 {
 	struct list_head *plist, *phead;
-	struct rtw_wlan_acl_node *paclnode;
+	struct rtw_wlan_acl_node *paclnode, *tmp;
 	struct sta_priv *pstapriv = &padapter->stapriv;
 	struct wlan_acl_pool *pacl_list = &pstapriv->acl_list;
 	struct __queue *pacl_node_q = &pacl_list->acl_node_q;
@@ -1208,10 +1208,7 @@ int rtw_acl_remove_sta(struct adapter *padapter, u8 *addr)
 	phead = get_list_head(pacl_node_q);
 	plist = phead->next;
 
-	while (phead != plist) {
-		paclnode = container_of(plist, struct rtw_wlan_acl_node, list);
-		plist = plist->next;
-
+	list_for_each_entry_safe(paclnode, tmp, plist, list) {
 		if (!memcmp(paclnode->addr, addr, ETH_ALEN)) {
 			if (paclnode->valid) {
 				paclnode->valid = false;
@@ -1711,7 +1708,7 @@ u8 ap_free_sta(struct adapter *padapter, struct sta_info *psta,
 int rtw_sta_flush(struct adapter *padapter)
 {
 	struct list_head *phead, *plist;
-	struct sta_info *psta = NULL;
+	struct sta_info *psta = NULL, *tmp;
 	struct sta_priv *pstapriv = &padapter->stapriv;
 	struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
 	struct mlme_ext_info	*pmlmeinfo = &pmlmeext->mlmext_info;
@@ -1727,11 +1724,7 @@ int rtw_sta_flush(struct adapter *padapter)
 	plist = phead->next;
 
 	/* free sta asoc_queue */
-	while (phead != plist) {
-		psta = container_of(plist, struct sta_info, asoc_list);
-
-		plist = plist->next;
-
+	list_for_each_entry_safe(psta, tmp, plist, asoc_list) {
 		list_del_init(&psta->asoc_list);
 		pstapriv->asoc_list_cnt--;
 
@@ -1833,7 +1826,7 @@ void start_ap_mode(struct adapter *padapter)
 void stop_ap_mode(struct adapter *padapter)
 {
 	struct list_head *phead, *plist;
-	struct rtw_wlan_acl_node *paclnode;
+	struct rtw_wlan_acl_node *paclnode, *tmp;
 	struct sta_info *psta = NULL;
 	struct sta_priv *pstapriv = &padapter->stapriv;
 	struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
@@ -1855,10 +1848,7 @@ void stop_ap_mode(struct adapter *padapter)
 	spin_lock_bh(&pacl_node_q->lock);
 	phead = get_list_head(pacl_node_q);
 	plist = phead->next;
-	while (phead != plist) {
-		paclnode = container_of(plist, struct rtw_wlan_acl_node, list);
-		plist = plist->next;
-
+	list_for_each_entry_safe(paclnode, tmp, plist, list) {
 		if (paclnode->valid) {
 			paclnode->valid = false;
 
Signature · 1 line
2.7.4
maintainer
#1 lore raw
Quoted 3 lines · Srishti Sharma

This is a cleanup patch and doesn't change runtime behavior. It changes an open coded list traversal to use list_for_each_entry_safe. Done using the following semantic patch by coccinelle.

You have sent me two different patches, with this same subject.

And you have sent me lots of different patches for this same driver, I don't have any idea which order to apply them in. Please resend them all, in an ordered patch series, properly numbered, so I know what to do here.

thanks,

greg k-h

#2 lore raw
Quoted 5 lines · Greg KH
Quoted 3 lines · Srishti Sharma

This is a cleanup patch and doesn't change runtime behavior. It changes an open coded list traversal to use list_for_each_entry_safe. Done using the following semantic patch by coccinelle.

Quoted 7 lines

You have sent me two different patches, with this same subject.

And you have sent me lots of different patches for this same driver, I don't have any idea which order to apply them in. Please resend them all, in an ordered patch series, properly numbered, so I know what to do here.

I had sent them individually because in a patch series they would have the same subject, as all of them are making similar changes in different files of the driver. One patch for all files would probably be too long, What do you suggest I do in this situation ?

Regards,
Srishti

Quoted 5 lines

thanks,

greg k-h

#3 lore raw
Quoted 21 lines · Srishti Sharma

On Wed, Oct 18, 2017 at 6:01 PM, Greg KH <[email protected]> wrote:
On Thu, Oct 05, 2017 at 03:16:42PM +0530, Srishti Sharma wrote:
> This is a cleanup patch and doesn't change runtime behavior. It
> changes an open coded list traversal to use list_for_each_entry_safe.
> Done using the following semantic patch by coccinelle.

You have sent me two different patches, with this same subject.

And you have sent me lots of different patches for this same driver, I
don't have any idea which order to apply them in.ᅵ Please resend them
all, in an ordered patch series, properly numbered, so I know what to do
here.

Quoted 4 lines

I had sent them individually because in a patch series they would have the same subject, as all of them are making similar changes in different files of the driver. One patch for all files would probably be too long, What do you suggest I do in this situation ?

I don't have the specific change handy, but maybe you can incorporate more information about the affected file or about the change itself in teh subject line. All subject lines need to be unique.

julia

Quoted 20 lines

Regards,ᅵ
Srishtiᅵ

thanks,

greg k-h

--
You received this message because you are subscribed to the Google Groups
"outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visithttps://groups.google.com/d/msgid/outreachy-kernel/CAB3L5ozhby6izgNjoBZS6Bw zOgpVcoH1fErt8PN3JhptFv0FGA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

#4 lore raw
Quoted 29 lines · Julia Lawall
Quoted 3 lines · Srishti Sharma

On Wed, Oct 18, 2017 at 6:01 PM, Greg KH <[email protected]>

Quoted 18 lines · wrote:

On Thu, Oct 05, 2017 at 03:16:42PM +0530, Srishti Sharma wrote:
> This is a cleanup patch and doesn't change runtime behavior. It
> changes an open coded list traversal to use list_for_each_entry_safe.
> Done using the following semantic patch by coccinelle.

You have sent me two different patches, with this same subject.

And you have sent me lots of different patches for this same driver, I
don't have any idea which order to apply them in. Please resend them
all, in an ordered patch series, properly numbered, so I know what to do
here.

Quoted 1 line

I had sent them individually because in a patch series they would have

the

Quoted 1 line

same subject, as all of them are making similar changes in different

Quoted 8 lines

files

Quoted 1 line

of the driver. One patch for all files would probably be too long, What

do

Quoted 1 line

you suggest I do in this situation ?

I don't have the specific change handy, but maybe you can incorporate more information about the affected file or about the change itself in teh subject line. All subject lines need to be unique.

I think if I add the file name for every file in the subject, even after saying use list_for_each_entry_safe for all of them, that should make them unique , right ? As this is what we did last time to make it unique, but I should have then sent them as a patch set.

Regards,
Srishti

Quoted 2 lines

julia

Quoted 23 lines
Quoted 11 lines

Regards,
Srishti

thanks,

greg k-h

Quoted 7 lines

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected]. To view this discussion on the web visithttps://groups.google.

com/d/msgid/outreachy-kernel/CAB3L5ozhby6izgNjoBZS6Bw

Quoted 4 lines

zOgpVcoH1fErt8PN3JhptFv0FGA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

#5 lore raw
Quoted 50 lines · Srishti Sharma

On Wed, Oct 18, 2017 at 8:29 PM, Julia Lawall <[email protected]> wrote:

On Wed, 18 Oct 2017, Srishti Sharma wrote:

>
>
> On Wed, Oct 18, 2017 at 6:01 PM, Greg KH <[email protected]> wrote:
>ᅵ ᅵ ᅵ ᅵOn Thu, Oct 05, 2017 at 03:16:42PM +0530, Srishti Sharma wrote:
>ᅵ ᅵ ᅵ ᅵ> This is a cleanup patch and doesn't change runtime behavior.
>ᅵ ᅵ ᅵ ᅵIt
>ᅵ ᅵ ᅵ ᅵ> changes an open coded list traversal to use >ᅵ ᅵ ᅵ ᅵlist_for_each_entry_safe.
>ᅵ ᅵ ᅵ ᅵ> Done using the following semantic patch by coccinelle. >
>ᅵ ᅵ ᅵ ᅵYou have sent me two different patches, with this same subject.
>
>ᅵ ᅵ ᅵ ᅵAnd you have sent me lots of different patches for this same
>ᅵ ᅵ ᅵ ᅵdriver, I
>ᅵ ᅵ ᅵ ᅵdon't have any idea which order to apply them in.ᅵ Please resend
>ᅵ ᅵ ᅵ ᅵthem
>ᅵ ᅵ ᅵ ᅵall, in an ordered patch series, properly numbered, so I know
>ᅵ ᅵ ᅵ ᅵwhat to do
>ᅵ ᅵ ᅵ ᅵhere.
>
>
> I had sent them individually because in a patch series they would have the
> same subject, as all of them are making similar changes in different files
> of the driver. One patch for all files would probably be too long, What do
> you suggest I do in this situation ?

I don't have the specific change handy, but maybe you can incorporate
more information about the affected file or about the change itself in teh
subject line.ᅵ All subject lines need to be unique.

Quoted 4 lines

I think if I add the file name for every file in the subject, even after saying use list_for_each_entry_safe for all of them, that should make them unique , right ? As this is what we did last time to make it unique, but I should have then sent them as ᅵa patch set.

A patch set is essential when there are multiple changes to the same file, because one change ight affect how the others apply.

All commits should have unique subject lines, patch series or not.

julia

Quoted 38 lines

Regards,
Srishti

ᅵ

      ᅵ

      julia


      >
      > Regards,ᅵ
      > Srishtiᅵ
      >
      >ᅵ ᅵ ᅵ ᅵthanks,
      >
      >ᅵ ᅵ ᅵ ᅵgreg k-h
      >
      >
Quoted 2 lines

--
You received this message because you are subscribed to the Google

Groups

Quoted 2 lines

"outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it,

send an

Quoted 2 lines

email to [email protected]. To post to this group, send email to

[email protected].

Quoted 1 line

To view this discussion on the webvisithttps://groups.google.com/d/msgid/outreachy-kernel/CAB3L5ozhby6izgNjoB

ZS6Bw

Quoted 4 lines

zOgpVcoH1fErt8PN3JhptFv0FGA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.