Skip to contentSkip to conversation

Staging: rtl8192u: Use list_entry in ieee80211_wx_sync_scan_wq()

PATCH In review Madhumitha Prabakaran 3 participants 5 messages Apr 1, 2019 – Apr 2, 2019 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: rtl8192u: Use list_entry in ieee80211_wx_sync_scan_wq()

Use list_entry() instead of container_of() in function, ieee80211_wx_sync_scan_wq(), as the function to return the parent structure containing any list_head is defined to use list_entry() as per the definition in include/linux/list.h#L348.

---
 drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c +3 -1
index 81020fbcdc20..76daec98212e 100644
@@ -300,7 +300,9 @@ EXPORT_SYMBOL(ieee80211_wx_set_mode);
 
 void ieee80211_wx_sync_scan_wq(struct work_struct *work)
 {
-	struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, wx_sync_scan_wq);
+	struct ieee80211_device *ieee = list_entry(work,
+						   struct ieee80211_device,
+						   wx_sync_scan_wq);
 	short chan;
 	enum ht_extension_chan_offset chan_offset = 0;
 	enum ht_channel_width bandwidth = 0;
Signature · 1 line
2.17.1
#1 lore raw
Quoted 4 lines · Madhumitha Prabakaran

Use list_entry() instead of container_of() in function, ieee80211_wx_sync_scan_wq(), as the function to return the parent structure containing any list_head is defined to use list_entry() as per the definition in include/linux/list.h#L348.

list_entry is for lists. The wx_sync_scan_wq field has type work_struct.

julia

Quoted 31 lines
---
 drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c +3 -2
index 81020fbcdc20..76daec98212e 100644
@@ -300,7 +300,9 @@ EXPORT_SYMBOL(ieee80211_wx_set_mode);
 
 void ieee80211_wx_sync_scan_wq(struct work_struct *work)
 {
-	struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, wx_sync_scan_wq);
+	struct ieee80211_device *ieee = list_entry(work,
+						   struct ieee80211_device,
+						   wx_sync_scan_wq);
 	short chan;
 	enum ht_extension_chan_offset chan_offset = 0;
 	enum ht_channel_width bandwidth = 0;
--

2.17.1

--
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 visit https://groups.google.com/d/msgid/outreachy-kernel/20190401165827.18731-1-madhumithabiw%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

#2 lore raw
Quoted 10 lines · Julia Lawall
Quoted 4 lines · Madhumitha Prabakaran

Use list_entry() instead of container_of() in function, ieee80211_wx_sync_scan_wq(), as the function to return the parent structure containing any list_head is defined to use list_entry() as per the definition in include/linux/list.h#L348.

list_entry is for lists. The wx_sync_scan_wq field has type work_struct.

Thats true. Though the wx_sync_scan_wq has type work_struct, the structure work_struct has a member of struct list_head in it.

thanks

Quoted 41 lines

julia

Quoted 31 lines
---
 drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c +3 -2
index 81020fbcdc20..76daec98212e 100644
@@ -300,7 +300,9 @@ EXPORT_SYMBOL(ieee80211_wx_set_mode);
 
 void ieee80211_wx_sync_scan_wq(struct work_struct *work)
 {
-	struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, wx_sync_scan_wq);
+	struct ieee80211_device *ieee = list_entry(work,
+						   struct ieee80211_device,
+						   wx_sync_scan_wq);
 	short chan;
 	enum ht_extension_chan_offset chan_offset = 0;
 	enum ht_channel_width bandwidth = 0;
--

2.17.1

--
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 visit https://groups.google.com/d/msgid/outreachy-kernel/20190401165827.18731-1-madhumithabiw%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Signature · 5 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 visit https://groups.google.com/d/msgid/outreachy-kernel/alpine.DEB.2.21.1904012138510.2530%40hadrien.
For more options, visit https://groups.google.com/d/optout.
#3 lore raw
Quoted 10 lines · Madhumthia Prabakaran
Quoted 9 lines · Julia Lawall
Quoted 4 lines · Madhumitha Prabakaran

Use list_entry() instead of container_of() in function, ieee80211_wx_sync_scan_wq(), as the function to return the parent structure containing any list_head is defined to use list_entry() as per the definition in include/linux/list.h#L348.

Quoted 4 lines
Quoted 1 line

list_entry is for lists. The wx_sync_scan_wq field has type work_struct.

Thats true. Though the wx_sync_scan_wq has type work_struct, the structure work_struct has a member of struct list_head in it.

The field name itself should have type list_head. You can write your Coccinelle script to check for this. Since structure types are often defined in header files, you may need to use the command line argument --all-includes (try to include all mentioned header files).

julia

Quoted 53 lines

thanks

Quoted 27 lines

julia

Quoted 24 lines
---
 drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c +3 -2
index 81020fbcdc20..76daec98212e 100644
@@ -300,7 +300,9 @@ EXPORT_SYMBOL(ieee80211_wx_set_mode);
 
 void ieee80211_wx_sync_scan_wq(struct work_struct *work)
 {
-	struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, wx_sync_scan_wq);
+	struct ieee80211_device *ieee = list_entry(work,
+						   struct ieee80211_device,
+						   wx_sync_scan_wq);
 	short chan;
 	enum ht_extension_chan_offset chan_offset = 0;
 	enum ht_channel_width bandwidth = 0;
--

2.17.1

Quoted 14 lines
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 visit https://groups.google.com/d/msgid/outreachy-kernel/20190401165827.18731-1-madhumithabiw%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
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 visit https://groups.google.com/d/msgid/outreachy-kernel/alpine.DEB.2.21.1904012138510.2530%40hadrien.
For more options, visit https://groups.google.com/d/optout.

--
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 visit https://groups.google.com/d/msgid/outreachy-kernel/20190401215305.GB11046%40madhuleo.
For more options, visit https://groups.google.com/d/optout.

maintainer
#4 lore raw
Quoted 16 lines · Julia Lawall
Quoted 12 lines · Madhumthia Prabakaran
Quoted 10 lines · Julia Lawall
Quoted 4 lines · Madhumitha Prabakaran

Use list_entry() instead of container_of() in function, ieee80211_wx_sync_scan_wq(), as the function to return the parent structure containing any list_head is defined to use list_entry() as per the definition in include/linux/list.h#L348.

list_entry is for lists. The wx_sync_scan_wq field has type work_struct.

Quoted 7 lines
Quoted 2 lines

Thats true. Though the wx_sync_scan_wq has type work_struct, the structure work_struct has a member of struct list_head in it.

The field name itself should have type list_head. You can write your Coccinelle script to check for this. Since structure types are often defined in header files, you may need to use the command line argument --all-includes (try to include all mentioned header files).

Yes, do not use list_entry() for things that are not a list. I'll go drop this patch from my tree now.

thanks,

greg k-h