Re: Unknown symbols in module (iio)

2018-03-18 Thread Srishti Sharma
On Sun, Mar 18, 2018 at 4:34 PM, Jonathan Cameron
<ji...@jic23.retrosnub.co.uk> wrote:
> On Sat, 17 Mar 2018 13:42:24 -0700
> Randy Dunlap <rdun...@infradead.org> wrote:
>
>> [adding linux-iio mailing list]
>>
>> Hi,
>>
>> It's always a good idea to include the kernel version in a problem report.
>>
>>
>> On 03/05/2018 03:17 AM, Srishti Sharma wrote:
>> > Hello,
>> > I was trying to work with the iio dummy driver, and when I try to load
>> > the iio_dummy_evgen.ko module I am getting unknown symbols found in
>> > module error on running modprobe.
>> >
>> > These variables are unknown
>> > iio_bus_type>>> in industrialio-core
>> > irq_sim_init>>> in iio_dummy_evgen
>> > irq_sim_fini>>> same
>> > irq_sim_fire>>> same
>> > irq_sim_fini>>> [duplicate]
>>
>> I tested this using Linux 4.16-rc5.  As long as I manually load all
>> modules in the needed order, they will all load with no symbol problems.
>>
>>
>> > All of these variables are present in the Module.symvers file in the
>> > /lib/modules//build directory. The kernel and the
>> > modules versions match. I ran make clean, make, and make
>> > modules_install before trying to load them. I am unable to figure out
>> > the problem. Where I might be going wrong any ideas ?
>>
>> Were you expecting some module autoloading based on their internal
>> dependencies?  If so, maybe someone on the linux-iio mailing list
>> could comment on that.
>>
>>
> Hi Randy,
>
> Thanks for following up on this. Looks like Srishti followed this
> with an email to the linux-iio list.  I sent a quick reply but haven't
> heard back yet.
>
> https://marc.info/?l=linux-iio=152024876720954=2
>
> Superficially I was guessing that Srishti had missed the fact that irqsim
> is built into the kernel rather than as a module, so a reboot would have
> been required as well.
>
> Srishti, if you do try a message on multiple lists, please do it by
> replying to the original thread and cc'ing the new one.  That way we save
> time by avoiding duplication of efforts on different lists.
> (at least I am assuming you sent it to one list then the other?)

Hey,
I am sorry for the late reply, the solution Jonathan had proposed i.e;
reinstalling the kernel after configuring it for loading the required
modules worked for me, Thank you so much.

Regards,
Srishti

>
> Thanks,
>
> Jonathan


Re: Unknown symbols in module (iio)

2018-03-18 Thread Srishti Sharma
On Sun, Mar 18, 2018 at 4:34 PM, Jonathan Cameron
 wrote:
> On Sat, 17 Mar 2018 13:42:24 -0700
> Randy Dunlap  wrote:
>
>> [adding linux-iio mailing list]
>>
>> Hi,
>>
>> It's always a good idea to include the kernel version in a problem report.
>>
>>
>> On 03/05/2018 03:17 AM, Srishti Sharma wrote:
>> > Hello,
>> > I was trying to work with the iio dummy driver, and when I try to load
>> > the iio_dummy_evgen.ko module I am getting unknown symbols found in
>> > module error on running modprobe.
>> >
>> > These variables are unknown
>> > iio_bus_type>>> in industrialio-core
>> > irq_sim_init>>> in iio_dummy_evgen
>> > irq_sim_fini>>> same
>> > irq_sim_fire>>> same
>> > irq_sim_fini>>> [duplicate]
>>
>> I tested this using Linux 4.16-rc5.  As long as I manually load all
>> modules in the needed order, they will all load with no symbol problems.
>>
>>
>> > All of these variables are present in the Module.symvers file in the
>> > /lib/modules//build directory. The kernel and the
>> > modules versions match. I ran make clean, make, and make
>> > modules_install before trying to load them. I am unable to figure out
>> > the problem. Where I might be going wrong any ideas ?
>>
>> Were you expecting some module autoloading based on their internal
>> dependencies?  If so, maybe someone on the linux-iio mailing list
>> could comment on that.
>>
>>
> Hi Randy,
>
> Thanks for following up on this. Looks like Srishti followed this
> with an email to the linux-iio list.  I sent a quick reply but haven't
> heard back yet.
>
> https://marc.info/?l=linux-iio=152024876720954=2
>
> Superficially I was guessing that Srishti had missed the fact that irqsim
> is built into the kernel rather than as a module, so a reboot would have
> been required as well.
>
> Srishti, if you do try a message on multiple lists, please do it by
> replying to the original thread and cc'ing the new one.  That way we save
> time by avoiding duplication of efforts on different lists.
> (at least I am assuming you sent it to one list then the other?)

Hey,
I am sorry for the late reply, the solution Jonathan had proposed i.e;
reinstalling the kernel after configuring it for loading the required
modules worked for me, Thank you so much.

Regards,
Srishti

>
> Thanks,
>
> Jonathan


Unknown symbols in module

2018-03-05 Thread Srishti Sharma
Hello,
I was trying to work with the iio dummy driver, and when I try to load
the iio_dummy_evgen.ko module I am getting unknown symbols found in
module error on running modprobe.

These variables are unknown
iio_bus_type
irq_sim_init
irq_sim_fini
irq_sim_fire
irq_sim_fini

All of these variables are present in the Module.symvers file in the
/lib/modules//build directory. The kernel and the
modules versions match. I ran make clean, make, and make
modules_install before trying to load them. I am unable to figure out
the problem. Where I might be going wrong any ideas ?

Thanks,
Srishti


Unknown symbols in module

2018-03-05 Thread Srishti Sharma
Hello,
I was trying to work with the iio dummy driver, and when I try to load
the iio_dummy_evgen.ko module I am getting unknown symbols found in
module error on running modprobe.

These variables are unknown
iio_bus_type
irq_sim_init
irq_sim_fini
irq_sim_fire
irq_sim_fini

All of these variables are present in the Module.symvers file in the
/lib/modules//build directory. The kernel and the
modules versions match. I ran make clean, make, and make
modules_install before trying to load them. I am unable to figure out
the problem. Where I might be going wrong any ideas ?

Thanks,
Srishti


[PATCH 4/4] Staging: rtl8188eu: core: Use list_entry instead of container_of

2017-10-18 Thread Srishti Sharma
For variables of the struct list_head* use list_entry to access
current list element instead of using container_of.
Done using the following semantic patch by coccinelle.

@r@
struct list_head* l;
@@

-container_of
+list_entry
   (l,...)

Signed-off-by: Srishti Sharma <srishtis...@gmail.com>
---
 drivers/staging/rtl8188eu/core/rtw_ap.c   |  4 ++--
 drivers/staging/rtl8188eu/core/rtw_mlme.c |  8 
 drivers/staging/rtl8188eu/core/rtw_mlme_ext.c |  2 +-
 drivers/staging/rtl8188eu/core/rtw_sta_mgt.c  | 12 ++--
 drivers/staging/rtl8188eu/core/rtw_xmit.c |  8 
 5 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c 
b/drivers/staging/rtl8188eu/core/rtw_ap.c
index 551af9e..c968472 100644
--- a/drivers/staging/rtl8188eu/core/rtw_ap.c
+++ b/drivers/staging/rtl8188eu/core/rtw_ap.c
@@ -1143,7 +1143,7 @@ int rtw_acl_add_sta(struct adapter *padapter, u8 *addr)
plist = phead->next;
 
while (phead != plist) {
-   paclnode = container_of(plist, struct rtw_wlan_acl_node, list);
+   paclnode = list_entry(plist, struct rtw_wlan_acl_node, list);
plist = plist->next;
 
if (!memcmp(paclnode->addr, addr, ETH_ALEN)) {
@@ -1447,7 +1447,7 @@ void associated_clients_update(struct adapter *padapter, 
u8 updated)
 
/* check asoc_queue */
while (phead != plist) {
-   psta = container_of(plist, struct sta_info, asoc_list);
+   psta = list_entry(plist, struct sta_info, asoc_list);
 
plist = plist->next;
 
diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c 
b/drivers/staging/rtl8188eu/core/rtw_mlme.c
index b15cf17..82f25b6 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c
@@ -198,7 +198,7 @@ struct wlan_network *rtw_find_network(struct __queue 
*scanned_queue, u8 *addr)
plist = phead->next;
 
while (plist != phead) {
-   pnetwork = container_of(plist, struct wlan_network, list);
+   pnetwork = list_entry(plist, struct wlan_network, list);
if (!memcmp(addr, pnetwork->network.MacAddress, ETH_ALEN))
break;
plist = plist->next;
@@ -223,7 +223,7 @@ void rtw_free_network_queue(struct adapter *padapter, u8 
isfreeall)
plist = phead->next;
 
while (phead != plist) {
-   pnetwork = container_of(plist, struct wlan_network, list);
+   pnetwork = list_entry(plist, struct wlan_network, list);
 
plist = plist->next;
 
@@ -342,7 +342,7 @@ struct  wlan_network
*rtw_get_oldest_wlan_network(struct __queue *scanned_queue)
phead = get_list_head(scanned_queue);
 
for (plist = phead->next; plist != phead; plist = plist->next) {
-   pwlan = container_of(plist, struct wlan_network, list);
+   pwlan = list_entry(plist, struct wlan_network, list);
 
if (!pwlan->fixed) {
if (!oldest || time_after(oldest->last_scanned, 
pwlan->last_scanned))
@@ -421,7 +421,7 @@ void rtw_update_scanned_network(struct adapter *adapter, 
struct wlan_bssid_ex *t
plist = phead->next;
 
while (phead != plist) {
-   pnetwork= container_of(plist, struct wlan_network, 
list);
+   pnetwork= list_entry(plist, struct wlan_network, list);
 
if (is_same_network(&(pnetwork->network), target))
break;
diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
index cf85fb4..5b38f63 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
@@ -1798,7 +1798,7 @@ static void issue_action_BSSCoexistPacket(struct adapter 
*padapter)
u8 *p;
struct wlan_bssid_ex *pbss_network;
 
-   pnetwork = container_of(plist, struct wlan_network, 
list);
+   pnetwork = list_entry(plist, struct wlan_network, list);
 
plist = plist->next;
 
diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c 
b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
index 2fd2a9e..aab2895 100644
--- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
+++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
@@ -152,8 +152,8 @@ u32 _rtw_free_sta_priv(struct   sta_priv *pstapriv)
while (phead != plist) {
int i;
 
-   psta = container_of(plist, struct sta_info,
-   hash_list);
+   psta = list_entry(plist, struct sta_info,
+ ha

[PATCH 4/4] Staging: rtl8188eu: core: Use list_entry instead of container_of

2017-10-18 Thread Srishti Sharma
For variables of the struct list_head* use list_entry to access
current list element instead of using container_of.
Done using the following semantic patch by coccinelle.

@r@
struct list_head* l;
@@

-container_of
+list_entry
   (l,...)

Signed-off-by: Srishti Sharma 
---
 drivers/staging/rtl8188eu/core/rtw_ap.c   |  4 ++--
 drivers/staging/rtl8188eu/core/rtw_mlme.c |  8 
 drivers/staging/rtl8188eu/core/rtw_mlme_ext.c |  2 +-
 drivers/staging/rtl8188eu/core/rtw_sta_mgt.c  | 12 ++--
 drivers/staging/rtl8188eu/core/rtw_xmit.c |  8 
 5 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c 
b/drivers/staging/rtl8188eu/core/rtw_ap.c
index 551af9e..c968472 100644
--- a/drivers/staging/rtl8188eu/core/rtw_ap.c
+++ b/drivers/staging/rtl8188eu/core/rtw_ap.c
@@ -1143,7 +1143,7 @@ int rtw_acl_add_sta(struct adapter *padapter, u8 *addr)
plist = phead->next;
 
while (phead != plist) {
-   paclnode = container_of(plist, struct rtw_wlan_acl_node, list);
+   paclnode = list_entry(plist, struct rtw_wlan_acl_node, list);
plist = plist->next;
 
if (!memcmp(paclnode->addr, addr, ETH_ALEN)) {
@@ -1447,7 +1447,7 @@ void associated_clients_update(struct adapter *padapter, 
u8 updated)
 
/* check asoc_queue */
while (phead != plist) {
-   psta = container_of(plist, struct sta_info, asoc_list);
+   psta = list_entry(plist, struct sta_info, asoc_list);
 
plist = plist->next;
 
diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c 
b/drivers/staging/rtl8188eu/core/rtw_mlme.c
index b15cf17..82f25b6 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c
@@ -198,7 +198,7 @@ struct wlan_network *rtw_find_network(struct __queue 
*scanned_queue, u8 *addr)
plist = phead->next;
 
while (plist != phead) {
-   pnetwork = container_of(plist, struct wlan_network, list);
+   pnetwork = list_entry(plist, struct wlan_network, list);
if (!memcmp(addr, pnetwork->network.MacAddress, ETH_ALEN))
break;
plist = plist->next;
@@ -223,7 +223,7 @@ void rtw_free_network_queue(struct adapter *padapter, u8 
isfreeall)
plist = phead->next;
 
while (phead != plist) {
-   pnetwork = container_of(plist, struct wlan_network, list);
+   pnetwork = list_entry(plist, struct wlan_network, list);
 
plist = plist->next;
 
@@ -342,7 +342,7 @@ struct  wlan_network
*rtw_get_oldest_wlan_network(struct __queue *scanned_queue)
phead = get_list_head(scanned_queue);
 
for (plist = phead->next; plist != phead; plist = plist->next) {
-   pwlan = container_of(plist, struct wlan_network, list);
+   pwlan = list_entry(plist, struct wlan_network, list);
 
if (!pwlan->fixed) {
if (!oldest || time_after(oldest->last_scanned, 
pwlan->last_scanned))
@@ -421,7 +421,7 @@ void rtw_update_scanned_network(struct adapter *adapter, 
struct wlan_bssid_ex *t
plist = phead->next;
 
while (phead != plist) {
-   pnetwork= container_of(plist, struct wlan_network, 
list);
+   pnetwork= list_entry(plist, struct wlan_network, list);
 
if (is_same_network(&(pnetwork->network), target))
break;
diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
index cf85fb4..5b38f63 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
@@ -1798,7 +1798,7 @@ static void issue_action_BSSCoexistPacket(struct adapter 
*padapter)
u8 *p;
struct wlan_bssid_ex *pbss_network;
 
-   pnetwork = container_of(plist, struct wlan_network, 
list);
+   pnetwork = list_entry(plist, struct wlan_network, list);
 
plist = plist->next;
 
diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c 
b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
index 2fd2a9e..aab2895 100644
--- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
+++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
@@ -152,8 +152,8 @@ u32 _rtw_free_sta_priv(struct   sta_priv *pstapriv)
while (phead != plist) {
int i;
 
-   psta = container_of(plist, struct sta_info,
-   hash_list);
+   psta = list_entry(plist, struct sta_info,
+ hash_list);
plist 

[PATCH 2/4] Staging: rtl8188eu: core: rtw_ap: Use list_for_each_entry_safe

2017-10-18 Thread Srishti Sharma
This is a cleanup patch and doesn't change runtime behaviour. 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(>m)
 ...+>
}
...+>

}

Signed-off-by: Srishti Sharma <srishtis...@gmail.com>
---
 drivers/staging/rtl8188eu/core/rtw_ap.c | 34 +
 1 file changed, 9 insertions(+), 25 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c 
b/drivers/staging/rtl8188eu/core/rtw_ap.c
index 32a4837..551af9e 100644
--- a/drivers/staging/rtl8188eu/core/rtw_ap.c
+++ b/drivers/staging/rtl8188eu/core/rtw_ap.c
@@ -280,7 +280,7 @@ voidexpire_timeout_chk(struct adapter *padapter)
 {
struct list_head *phead, *plist;
u8 updated = 0;
-   struct sta_info *psta = NULL;
+   struct sta_info *psta = NULL, *tmp;
struct sta_priv *pstapriv = >stapriv;
u8 chk_alive_num = 0;
char chk_alive_list[NUM_STA];
@@ -292,10 +292,7 @@ void   expire_timeout_chk(struct adapter *padapter)
plist = phead->next;
 
/* check auth_queue */
-   while (phead != plist) {
-   psta = container_of(plist, struct sta_info, auth_list);
-   plist = plist->next;
-
+   list_for_each_entry_safe(psta, tmp, plist, auth_list) {
if (psta->expire_to > 0) {
psta->expire_to--;
if (psta->expire_to == 0) {
@@ -326,10 +323,7 @@ void   expire_timeout_chk(struct adapter *padapter)
plist = phead->next;
 
/* check 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) {
if (chk_sta_is_alive(psta) || !psta->expire_to) {
psta->expire_to = pstapriv->expire_to;
psta->keep_alive_trycnt = 0;
@@ -1196,7 +1190,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 = >stapriv;
struct wlan_acl_pool *pacl_list = >acl_list;
struct __queue *pacl_node_q = _list->acl_node_q;
@@ -1208,10 +1202,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 +1702,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 = >stapriv;
struct mlme_ext_priv *pmlmeext = >mlmeextpriv;
struct mlme_ext_info*pmlmeinfo = >mlmext_info;
@@ -1727,11 +1718,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(>asoc_list);
pstapriv->asoc_list_cnt--;
 
@@ -1833,7 +1820,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 = >stapriv;
struct mlme_priv *pmlmepriv = >mlmepriv;
@@ -1855,10 +1842,7 @@ void stop_ap_mode(struct adapter *padapter)
spin_lock_bh(_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;
 
-- 
2.7.4



[PATCH 2/4] Staging: rtl8188eu: core: rtw_ap: Use list_for_each_entry_safe

2017-10-18 Thread Srishti Sharma
This is a cleanup patch and doesn't change runtime behaviour. 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(>m)
 ...+>
}
...+>

}

Signed-off-by: Srishti Sharma 
---
 drivers/staging/rtl8188eu/core/rtw_ap.c | 34 +
 1 file changed, 9 insertions(+), 25 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c 
b/drivers/staging/rtl8188eu/core/rtw_ap.c
index 32a4837..551af9e 100644
--- a/drivers/staging/rtl8188eu/core/rtw_ap.c
+++ b/drivers/staging/rtl8188eu/core/rtw_ap.c
@@ -280,7 +280,7 @@ voidexpire_timeout_chk(struct adapter *padapter)
 {
struct list_head *phead, *plist;
u8 updated = 0;
-   struct sta_info *psta = NULL;
+   struct sta_info *psta = NULL, *tmp;
struct sta_priv *pstapriv = >stapriv;
u8 chk_alive_num = 0;
char chk_alive_list[NUM_STA];
@@ -292,10 +292,7 @@ void   expire_timeout_chk(struct adapter *padapter)
plist = phead->next;
 
/* check auth_queue */
-   while (phead != plist) {
-   psta = container_of(plist, struct sta_info, auth_list);
-   plist = plist->next;
-
+   list_for_each_entry_safe(psta, tmp, plist, auth_list) {
if (psta->expire_to > 0) {
psta->expire_to--;
if (psta->expire_to == 0) {
@@ -326,10 +323,7 @@ void   expire_timeout_chk(struct adapter *padapter)
plist = phead->next;
 
/* check 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) {
if (chk_sta_is_alive(psta) || !psta->expire_to) {
psta->expire_to = pstapriv->expire_to;
psta->keep_alive_trycnt = 0;
@@ -1196,7 +1190,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 = >stapriv;
struct wlan_acl_pool *pacl_list = >acl_list;
struct __queue *pacl_node_q = _list->acl_node_q;
@@ -1208,10 +1202,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 +1702,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 = >stapriv;
struct mlme_ext_priv *pmlmeext = >mlmeextpriv;
struct mlme_ext_info*pmlmeinfo = >mlmext_info;
@@ -1727,11 +1718,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(>asoc_list);
pstapriv->asoc_list_cnt--;
 
@@ -1833,7 +1820,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 = >stapriv;
struct mlme_priv *pmlmepriv = >mlmepriv;
@@ -1855,10 +1842,7 @@ void stop_ap_mode(struct adapter *padapter)
spin_lock_bh(_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;
 
-- 
2.7.4



[PATCH 3/4] Staging: rtl8188eu: core: rtw_mlme_ext: Use list_for_each_entry_safe

2017-10-18 Thread Srishti Sharma
This is a cleanup patch and doesn't change runtime behaviour. 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(>m)
 ...+>
}
...+>

}

Signed-off-by: Srishti Sharma <srishtis...@gmail.com>
---
 drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
index 685c071..cf85fb4 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
@@ -5463,6 +5463,8 @@ u8 mlme_evt_hdl(struct adapter *padapter, unsigned char 
*pbuf)
 
 u8 tx_beacon_hdl(struct adapter *padapter, unsigned char *pbuf)
 {
+   struct xmit_frame *tmp;
+
if (send_beacon(padapter) == _FAIL) {
DBG_88E("issue_beacon, fail!\n");
return H2C_PARAMETERS_ERROR;
@@ -5486,11 +5488,8 @@ u8 tx_beacon_hdl(struct adapter *padapter, unsigned char 
*pbuf)
xmitframe_phead = get_list_head(_bmc->sleep_q);
xmitframe_plist = xmitframe_phead->next;
 
-   while (xmitframe_phead != xmitframe_plist) {
-   pxmitframe = container_of(xmitframe_plist, 
struct xmit_frame, list);
-
-   xmitframe_plist = xmitframe_plist->next;
-
+   list_for_each_entry_safe(pxmitframe, tmp,
+xmitframe_plist, list) {
list_del_init(>list);
 
psta_bmc->sleepq_len--;
-- 
2.7.4



[PATCH 3/4] Staging: rtl8188eu: core: rtw_mlme_ext: Use list_for_each_entry_safe

2017-10-18 Thread Srishti Sharma
This is a cleanup patch and doesn't change runtime behaviour. 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(>m)
 ...+>
}
...+>

}

Signed-off-by: Srishti Sharma 
---
 drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
index 685c071..cf85fb4 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
@@ -5463,6 +5463,8 @@ u8 mlme_evt_hdl(struct adapter *padapter, unsigned char 
*pbuf)
 
 u8 tx_beacon_hdl(struct adapter *padapter, unsigned char *pbuf)
 {
+   struct xmit_frame *tmp;
+
if (send_beacon(padapter) == _FAIL) {
DBG_88E("issue_beacon, fail!\n");
return H2C_PARAMETERS_ERROR;
@@ -5486,11 +5488,8 @@ u8 tx_beacon_hdl(struct adapter *padapter, unsigned char 
*pbuf)
xmitframe_phead = get_list_head(_bmc->sleep_q);
xmitframe_plist = xmitframe_phead->next;
 
-   while (xmitframe_phead != xmitframe_plist) {
-   pxmitframe = container_of(xmitframe_plist, 
struct xmit_frame, list);
-
-   xmitframe_plist = xmitframe_plist->next;
-
+   list_for_each_entry_safe(pxmitframe, tmp,
+xmitframe_plist, list) {
list_del_init(>list);
 
psta_bmc->sleepq_len--;
-- 
2.7.4



[PATCH 1/4] Staging: rtl8188eu: core: rtw_xmit: Use list_for_each_entry_safe

2017-10-18 Thread Srishti Sharma
This is a cleanup patch and doesn't change runtime behaviour. 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(>m)
 ...+>
}

...+>

}

Signed-off-by: Srishti Sharma <srishtis...@gmail.com>
---
 drivers/staging/rtl8188eu/core/rtw_xmit.c | 22 ++
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c 
b/drivers/staging/rtl8188eu/core/rtw_xmit.c
index e8d9858..5255c27 100644
--- a/drivers/staging/rtl8188eu/core/rtw_xmit.c
+++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c
@@ -1866,6 +1866,7 @@ void stop_sta_xmit(struct adapter *padapter, struct 
sta_info *psta)
 
 void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta)
 {
+   struct xmit_frame *tmp;
u8 update_mask = 0, wmmps_ac = 0;
struct sta_info *psta_bmc;
struct list_head *xmitframe_plist, *xmitframe_phead;
@@ -1877,11 +1878,7 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct 
sta_info *psta)
xmitframe_phead = get_list_head(>sleep_q);
xmitframe_plist = xmitframe_phead->next;
 
-   while (xmitframe_phead != xmitframe_plist) {
-   pxmitframe = container_of(xmitframe_plist, struct xmit_frame, 
list);
-
-   xmitframe_plist = xmitframe_plist->next;
-
+   list_for_each_entry_safe(pxmitframe, tmp, xmitframe_plist, list) {
list_del_init(>list);
 
switch (pxmitframe->attrib.priority) {
@@ -1958,11 +1955,8 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct 
sta_info *psta)
xmitframe_phead = get_list_head(_bmc->sleep_q);
xmitframe_plist = xmitframe_phead->next;
 
-   while (xmitframe_phead != xmitframe_plist) {
-   pxmitframe = container_of(xmitframe_plist, struct 
xmit_frame, list);
-
-   xmitframe_plist = xmitframe_plist->next;
-
+   list_for_each_entry_safe(pxmitframe, tmp, xmitframe_plist,
+list) {
list_del_init(>list);
 
psta_bmc->sleepq_len--;
@@ -1997,7 +1991,7 @@ void xmit_delivery_enabled_frames(struct adapter 
*padapter, struct sta_info *pst
 {
u8 wmmps_ac = 0;
struct list_head *xmitframe_plist, *xmitframe_phead;
-   struct xmit_frame *pxmitframe = NULL;
+   struct xmit_frame *pxmitframe = NULL, *tmp;
struct sta_priv *pstapriv = >stapriv;
 
spin_lock_bh(>sleep_q.lock);
@@ -2005,11 +1999,7 @@ void xmit_delivery_enabled_frames(struct adapter 
*padapter, struct sta_info *pst
xmitframe_phead = get_list_head(>sleep_q);
xmitframe_plist = xmitframe_phead->next;
 
-   while (xmitframe_phead != xmitframe_plist) {
-   pxmitframe = container_of(xmitframe_plist, struct xmit_frame, 
list);
-
-   xmitframe_plist = xmitframe_plist->next;
-
+   list_for_each_entry_safe(pxmitframe, tmp, xmitframe_plist, list) {
switch (pxmitframe->attrib.priority) {
case 1:
case 2:
-- 
2.7.4



[PATCH 1/4] Staging: rtl8188eu: core: rtw_xmit: Use list_for_each_entry_safe

2017-10-18 Thread Srishti Sharma
This is a cleanup patch and doesn't change runtime behaviour. 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(>m)
 ...+>
}

...+>

}

Signed-off-by: Srishti Sharma 
---
 drivers/staging/rtl8188eu/core/rtw_xmit.c | 22 ++
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c 
b/drivers/staging/rtl8188eu/core/rtw_xmit.c
index e8d9858..5255c27 100644
--- a/drivers/staging/rtl8188eu/core/rtw_xmit.c
+++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c
@@ -1866,6 +1866,7 @@ void stop_sta_xmit(struct adapter *padapter, struct 
sta_info *psta)
 
 void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta)
 {
+   struct xmit_frame *tmp;
u8 update_mask = 0, wmmps_ac = 0;
struct sta_info *psta_bmc;
struct list_head *xmitframe_plist, *xmitframe_phead;
@@ -1877,11 +1878,7 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct 
sta_info *psta)
xmitframe_phead = get_list_head(>sleep_q);
xmitframe_plist = xmitframe_phead->next;
 
-   while (xmitframe_phead != xmitframe_plist) {
-   pxmitframe = container_of(xmitframe_plist, struct xmit_frame, 
list);
-
-   xmitframe_plist = xmitframe_plist->next;
-
+   list_for_each_entry_safe(pxmitframe, tmp, xmitframe_plist, list) {
list_del_init(>list);
 
switch (pxmitframe->attrib.priority) {
@@ -1958,11 +1955,8 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct 
sta_info *psta)
xmitframe_phead = get_list_head(_bmc->sleep_q);
xmitframe_plist = xmitframe_phead->next;
 
-   while (xmitframe_phead != xmitframe_plist) {
-   pxmitframe = container_of(xmitframe_plist, struct 
xmit_frame, list);
-
-   xmitframe_plist = xmitframe_plist->next;
-
+   list_for_each_entry_safe(pxmitframe, tmp, xmitframe_plist,
+list) {
list_del_init(>list);
 
psta_bmc->sleepq_len--;
@@ -1997,7 +1991,7 @@ void xmit_delivery_enabled_frames(struct adapter 
*padapter, struct sta_info *pst
 {
u8 wmmps_ac = 0;
struct list_head *xmitframe_plist, *xmitframe_phead;
-   struct xmit_frame *pxmitframe = NULL;
+   struct xmit_frame *pxmitframe = NULL, *tmp;
struct sta_priv *pstapriv = >stapriv;
 
spin_lock_bh(>sleep_q.lock);
@@ -2005,11 +1999,7 @@ void xmit_delivery_enabled_frames(struct adapter 
*padapter, struct sta_info *pst
xmitframe_phead = get_list_head(>sleep_q);
xmitframe_plist = xmitframe_phead->next;
 
-   while (xmitframe_phead != xmitframe_plist) {
-   pxmitframe = container_of(xmitframe_plist, struct xmit_frame, 
list);
-
-   xmitframe_plist = xmitframe_plist->next;
-
+   list_for_each_entry_safe(pxmitframe, tmp, xmitframe_plist, list) {
switch (pxmitframe->attrib.priority) {
case 1:
case 2:
-- 
2.7.4



[PATCH 0/4] Code cleanup

2017-10-18 Thread Srishti Sharma
This patch series performs code cleanup like using list_for_each_entry_safe
to make code more compact and using list_entry instead of container_of for 
struct list_head* variable types. 

Srishti Sharma (4):
  Staging: rtl8188eu: core: rtw_xmit: Use list_for_each_entry_safe
  Staging: rtl8188eu: core: rtw_ap: Use list_for_each_entry_safe
  Staging: rtl8188eu: core: rtw_mlme_ext: Use list_for_each_entry_safe
  Staging: rtl8188eu: core: Use list_entry instead of container_of

 drivers/staging/rtl8188eu/core/rtw_ap.c   | 38 ---
 drivers/staging/rtl8188eu/core/rtw_mlme.c |  8 +++---
 drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 11 
 drivers/staging/rtl8188eu/core/rtw_sta_mgt.c  | 12 -
 drivers/staging/rtl8188eu/core/rtw_xmit.c | 30 +++--
 5 files changed, 36 insertions(+), 63 deletions(-)

-- 
2.7.4



[PATCH 0/4] Code cleanup

2017-10-18 Thread Srishti Sharma
This patch series performs code cleanup like using list_for_each_entry_safe
to make code more compact and using list_entry instead of container_of for 
struct list_head* variable types. 

Srishti Sharma (4):
  Staging: rtl8188eu: core: rtw_xmit: Use list_for_each_entry_safe
  Staging: rtl8188eu: core: rtw_ap: Use list_for_each_entry_safe
  Staging: rtl8188eu: core: rtw_mlme_ext: Use list_for_each_entry_safe
  Staging: rtl8188eu: core: Use list_entry instead of container_of

 drivers/staging/rtl8188eu/core/rtw_ap.c   | 38 ---
 drivers/staging/rtl8188eu/core/rtw_mlme.c |  8 +++---
 drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 11 
 drivers/staging/rtl8188eu/core/rtw_sta_mgt.c  | 12 -
 drivers/staging/rtl8188eu/core/rtw_xmit.c | 30 +++--
 5 files changed, 36 insertions(+), 63 deletions(-)

-- 
2.7.4



[PATCH v2] Staging: rtl8723bs: core: rtw_cmd: Remove cast to pointer types in kfree

2017-10-07 Thread Srishti Sharma
The cast to pointer types in kfree is not needed and can be dropped.
This was done using the following semantic patch by coccinelle,
except kfree((unsigned char*) pcmd->parmbuf) which was transformed by
hand because coccinelle didn't have enough type information.

@r@
type T,P;
T* x;
@@

kfree(
-(P *)
x )

Signed-off-by: Srishti Sharma <srishtis...@gmail.com>
---
Changes in v2:
 -Do transformation left out by coccinelle
 -Improve commit message

 drivers/staging/rtl8723bs/core/rtw_cmd.c | 60 
 1 file changed, 30 insertions(+), 30 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c 
b/drivers/staging/rtl8723bs/core/rtw_cmd.c
index 1843c44..9ac2dea 100644
--- a/drivers/staging/rtl8723bs/core/rtw_cmd.c
+++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c
@@ -408,7 +408,7 @@ void rtw_free_cmd_obj(struct cmd_obj *pcmd)
}
 
/* free cmd_obj */
-   kfree((unsigned char *)pcmd);
+   kfree(pcmd);
 }
 
 
@@ -619,7 +619,7 @@ u8 rtw_sitesurvey_cmd(struct adapter  *padapter, struct 
ndis_802_11_ssid *ssid,
 
psurveyPara = rtw_zmalloc(sizeof(struct sitesurvey_parm));
if (psurveyPara == NULL) {
-   kfree((unsigned char *) ph2c);
+   kfree(ph2c);
return _FAIL;
}
 
@@ -689,7 +689,7 @@ u8 rtw_setdatarate_cmd(struct adapter *padapter, u8 
*rateset)
 
pbsetdataratepara = rtw_zmalloc(sizeof(struct setdatarate_parm));
if (pbsetdataratepara == NULL) {
-   kfree((u8 *) ph2c);
+   kfree(ph2c);
res = _FAIL;
goto exit;
}
@@ -706,8 +706,8 @@ u8 rtw_setdatarate_cmd(struct adapter *padapter, u8 
*rateset)
 void rtw_getbbrfreg_cmdrsp_callback(struct adapter *padapter,  struct cmd_obj 
*pcmd)
 {
/* rtw_free_cmd_obj(pcmd); */
-   kfree((unsigned char *) pcmd->parmbuf);
-   kfree((unsigned char *) pcmd);
+   kfree(pcmd->parmbuf);
+   kfree(pcmd);
 }
 
 u8 rtw_createbss_cmd(struct adapter  *padapter)
@@ -847,7 +847,7 @@ u8 rtw_joinbss_cmd(struct adapter  *padapter, struct 
wlan_network *pnetwork)
psecnetwork = (struct wlan_bssid_ex *)>sec_bss;
if (psecnetwork == NULL) {
if (pcmd != NULL)
-   kfree((unsigned char *)pcmd);
+   kfree(pcmd);
 
res = _FAIL;
 
@@ -955,7 +955,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 
deauth_timeout_ms, bool enqueu
cmdobj = rtw_zmalloc(sizeof(*cmdobj));
if (cmdobj == NULL) {
res = _FAIL;
-   kfree((u8 *)param);
+   kfree(param);
goto exit;
}
init_h2fwcmd_w_parm_no_rsp(cmdobj, param, _DisConnect_CMD_);
@@ -964,7 +964,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 
deauth_timeout_ms, bool enqueu
/* no need to enqueue, do the cmd hdl directly and free cmd 
parameter */
if (H2C_SUCCESS != disconnect_hdl(padapter, (u8 *)param))
res = _FAIL;
-   kfree((u8 *)param);
+   kfree(param);
}
 
 exit:
@@ -990,7 +990,7 @@ u8 rtw_setopmode_cmd(struct adapter  *padapter, enum 
NDIS_802_11_NETWORK_INFRAST
if (enqueue) {
ph2c = rtw_zmalloc(sizeof(struct cmd_obj));
if (ph2c == NULL) {
-   kfree((u8 *)psetop);
+   kfree(psetop);
res = _FAIL;
goto exit;
}
@@ -999,7 +999,7 @@ u8 rtw_setopmode_cmd(struct adapter  *padapter, enum 
NDIS_802_11_NETWORK_INFRAST
res = rtw_enqueue_cmd(pcmdpriv, ph2c);
} else{
setopmode_hdl(padapter, (u8 *)psetop);
-   kfree((u8 *)psetop);
+   kfree(psetop);
}
 exit:
return res;
@@ -1042,15 +1042,15 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct 
sta_info *sta, u8 unicast_
if (enqueue) {
ph2c = rtw_zmalloc(sizeof(struct cmd_obj));
if (ph2c == NULL) {
-   kfree((u8 *) psetstakey_para);
+   kfree(psetstakey_para);
res = _FAIL;
goto exit;
}
 
psetstakey_rsp = rtw_zmalloc(sizeof(struct set_stakey_rsp));
if (psetstakey_rsp == NULL) {
-   kfree((u8 *) ph2c);
-   kfree((u8 *) psetstakey_para);
+   kfree(ph2c);
+   kfree(psetstakey_para);
res = _FAIL;
goto exit;
}
@@ -1061,7 +1061,7 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct 
sta_info *sta, u8 unicast_
res = rtw_enqueue_cmd(pcmdpriv, ph2c);
} else{
set_stakey_hdl(padapter, (u8

[PATCH v2] Staging: rtl8723bs: core: rtw_cmd: Remove cast to pointer types in kfree

2017-10-07 Thread Srishti Sharma
The cast to pointer types in kfree is not needed and can be dropped.
This was done using the following semantic patch by coccinelle,
except kfree((unsigned char*) pcmd->parmbuf) which was transformed by
hand because coccinelle didn't have enough type information.

@r@
type T,P;
T* x;
@@

kfree(
-(P *)
x )

Signed-off-by: Srishti Sharma 
---
Changes in v2:
 -Do transformation left out by coccinelle
 -Improve commit message

 drivers/staging/rtl8723bs/core/rtw_cmd.c | 60 
 1 file changed, 30 insertions(+), 30 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c 
b/drivers/staging/rtl8723bs/core/rtw_cmd.c
index 1843c44..9ac2dea 100644
--- a/drivers/staging/rtl8723bs/core/rtw_cmd.c
+++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c
@@ -408,7 +408,7 @@ void rtw_free_cmd_obj(struct cmd_obj *pcmd)
}
 
/* free cmd_obj */
-   kfree((unsigned char *)pcmd);
+   kfree(pcmd);
 }
 
 
@@ -619,7 +619,7 @@ u8 rtw_sitesurvey_cmd(struct adapter  *padapter, struct 
ndis_802_11_ssid *ssid,
 
psurveyPara = rtw_zmalloc(sizeof(struct sitesurvey_parm));
if (psurveyPara == NULL) {
-   kfree((unsigned char *) ph2c);
+   kfree(ph2c);
return _FAIL;
}
 
@@ -689,7 +689,7 @@ u8 rtw_setdatarate_cmd(struct adapter *padapter, u8 
*rateset)
 
pbsetdataratepara = rtw_zmalloc(sizeof(struct setdatarate_parm));
if (pbsetdataratepara == NULL) {
-   kfree((u8 *) ph2c);
+   kfree(ph2c);
res = _FAIL;
goto exit;
}
@@ -706,8 +706,8 @@ u8 rtw_setdatarate_cmd(struct adapter *padapter, u8 
*rateset)
 void rtw_getbbrfreg_cmdrsp_callback(struct adapter *padapter,  struct cmd_obj 
*pcmd)
 {
/* rtw_free_cmd_obj(pcmd); */
-   kfree((unsigned char *) pcmd->parmbuf);
-   kfree((unsigned char *) pcmd);
+   kfree(pcmd->parmbuf);
+   kfree(pcmd);
 }
 
 u8 rtw_createbss_cmd(struct adapter  *padapter)
@@ -847,7 +847,7 @@ u8 rtw_joinbss_cmd(struct adapter  *padapter, struct 
wlan_network *pnetwork)
psecnetwork = (struct wlan_bssid_ex *)>sec_bss;
if (psecnetwork == NULL) {
if (pcmd != NULL)
-   kfree((unsigned char *)pcmd);
+   kfree(pcmd);
 
res = _FAIL;
 
@@ -955,7 +955,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 
deauth_timeout_ms, bool enqueu
cmdobj = rtw_zmalloc(sizeof(*cmdobj));
if (cmdobj == NULL) {
res = _FAIL;
-   kfree((u8 *)param);
+   kfree(param);
goto exit;
}
init_h2fwcmd_w_parm_no_rsp(cmdobj, param, _DisConnect_CMD_);
@@ -964,7 +964,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 
deauth_timeout_ms, bool enqueu
/* no need to enqueue, do the cmd hdl directly and free cmd 
parameter */
if (H2C_SUCCESS != disconnect_hdl(padapter, (u8 *)param))
res = _FAIL;
-   kfree((u8 *)param);
+   kfree(param);
}
 
 exit:
@@ -990,7 +990,7 @@ u8 rtw_setopmode_cmd(struct adapter  *padapter, enum 
NDIS_802_11_NETWORK_INFRAST
if (enqueue) {
ph2c = rtw_zmalloc(sizeof(struct cmd_obj));
if (ph2c == NULL) {
-   kfree((u8 *)psetop);
+   kfree(psetop);
res = _FAIL;
goto exit;
}
@@ -999,7 +999,7 @@ u8 rtw_setopmode_cmd(struct adapter  *padapter, enum 
NDIS_802_11_NETWORK_INFRAST
res = rtw_enqueue_cmd(pcmdpriv, ph2c);
} else{
setopmode_hdl(padapter, (u8 *)psetop);
-   kfree((u8 *)psetop);
+   kfree(psetop);
}
 exit:
return res;
@@ -1042,15 +1042,15 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct 
sta_info *sta, u8 unicast_
if (enqueue) {
ph2c = rtw_zmalloc(sizeof(struct cmd_obj));
if (ph2c == NULL) {
-   kfree((u8 *) psetstakey_para);
+   kfree(psetstakey_para);
res = _FAIL;
goto exit;
}
 
psetstakey_rsp = rtw_zmalloc(sizeof(struct set_stakey_rsp));
if (psetstakey_rsp == NULL) {
-   kfree((u8 *) ph2c);
-   kfree((u8 *) psetstakey_para);
+   kfree(ph2c);
+   kfree(psetstakey_para);
res = _FAIL;
goto exit;
}
@@ -1061,7 +1061,7 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct 
sta_info *sta, u8 unicast_
res = rtw_enqueue_cmd(pcmdpriv, ph2c);
} else{
set_stakey_hdl(padapter, (u8 *)psetstakey_para);
-

Re: [Outreachy kernel] [PATCH] Staging: rtl8723bs: core: rtw_cmd: Remove cast to pointer types in kfree

2017-10-07 Thread Srishti Sharma
On Sun, Oct 8, 2017 at 1:36 AM, Julia Lawall <julia.law...@lip6.fr> wrote:
>
>
> On Sun, 8 Oct 2017, Srishti Sharma wrote:
>
>> On Sat, Oct 7, 2017 at 11:42 PM, Julia Lawall <julia.law...@lip6.fr> wrote:
>> >
>> >
>> > On Sat, 7 Oct 2017, Srishti Sharma wrote:
>> >
>> >> The cast to pointer types in kfree is not needed and can be dropped.
>> >> Done using the following semantic by coccinelle.
>> >>
>> >> @r@
>> >> type T,P;
>> >> T* x;
>> >> @@
>> >>
>> >> kfree(
>> >> -(P *)
>> >> x )
>> >>
>> >> Signed-off-by: Srishti Sharma <srishtis...@gmail.com>
>> >> ---
>> >>  drivers/staging/rtl8723bs/core/rtw_cmd.c | 58 
>> >> 
>> >>  1 file changed, 29 insertions(+), 29 deletions(-)
>> >>
>> >> diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c 
>> >> b/drivers/staging/rtl8723bs/core/rtw_cmd.c
>> >> index 1843c44..e71e3ab 100644
>> >> --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c
>> >> +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c
>> >> @@ -408,7 +408,7 @@ void rtw_free_cmd_obj(struct cmd_obj *pcmd)
>> >>   }
>> >>
>> >>   /* free cmd_obj */
>> >> - kfree((unsigned char *)pcmd);
>> >> + kfree(pcmd);
>> >>  }
>> >>
>> >>
>> >> @@ -619,7 +619,7 @@ u8 rtw_sitesurvey_cmd(struct adapter  *padapter, 
>> >> struct ndis_802_11_ssid *ssid,
>> >>
>> >>   psurveyPara = rtw_zmalloc(sizeof(struct sitesurvey_parm));
>> >>   if (psurveyPara == NULL) {
>> >> - kfree((unsigned char *) ph2c);
>> >> + kfree(ph2c);
>> >>   return _FAIL;
>> >>   }
>> >>
>> >> @@ -689,7 +689,7 @@ u8 rtw_setdatarate_cmd(struct adapter *padapter, u8 
>> >> *rateset)
>> >>
>> >>   pbsetdataratepara = rtw_zmalloc(sizeof(struct setdatarate_parm));
>> >>   if (pbsetdataratepara == NULL) {
>> >> - kfree((u8 *) ph2c);
>> >> + kfree(ph2c);
>> >>   res = _FAIL;
>> >>   goto exit;
>> >>   }
>> >> @@ -707,7 +707,7 @@ void rtw_getbbrfreg_cmdrsp_callback(struct adapter 
>> >> *padapter,  struct cmd_obj *p
>> >>  {
>> >>   /* rtw_free_cmd_obj(pcmd); */
>> >>   kfree((unsigned char *) pcmd->parmbuf);
>> >
>> > This case didn't get updated, probably because Coccinelle didn't have
>> > access to enough type information.  Try rerunning with --all-includes or
>> > --recursive-includes.  You may also need to give some include path
>> > information (-I argument).
>> I tried doing this but it is still not detecting this particular case,
>> for the include path I gave the path of the directory which contains
>> the header file in which struct cmd_obj is defined.
>
> OK, just check the field type manually, and then put a note in your commit
> log saying that you have done that case by hand, due to Coccinelle's not
> having sufficient type information.
Yes, I have checked it , it is a pointer.

Thanks,
Srishti
>
> julia
>
>>
>> Regards,
>> Srishti
>> >
>> > julia
>> >
>> >> - kfree((unsigned char *) pcmd);
>> >> + kfree(pcmd);
>> >>  }
>> >>
>> >>  u8 rtw_createbss_cmd(struct adapter  *padapter)
>> >> @@ -847,7 +847,7 @@ u8 rtw_joinbss_cmd(struct adapter  *padapter, struct 
>> >> wlan_network *pnetwork)
>> >>   psecnetwork = (struct wlan_bssid_ex *)>sec_bss;
>> >>   if (psecnetwork == NULL) {
>> >>   if (pcmd != NULL)
>> >> - kfree((unsigned char *)pcmd);
>> >> + kfree(pcmd);
>> >>
>> >>   res = _FAIL;
>> >>
>> >> @@ -955,7 +955,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 
>> >> deauth_timeout_ms, bool enqueu
>> >>   cmdobj = rtw_zmalloc(sizeof(*cmdobj));
>> >>   if (cmdobj == NULL) {
>> >>   res = _FAIL;
>> >> - kfree((u8 *)param);
>> >> + kfree(param);
>> >>   

Re: [Outreachy kernel] [PATCH] Staging: rtl8723bs: core: rtw_cmd: Remove cast to pointer types in kfree

2017-10-07 Thread Srishti Sharma
On Sun, Oct 8, 2017 at 1:36 AM, Julia Lawall  wrote:
>
>
> On Sun, 8 Oct 2017, Srishti Sharma wrote:
>
>> On Sat, Oct 7, 2017 at 11:42 PM, Julia Lawall  wrote:
>> >
>> >
>> > On Sat, 7 Oct 2017, Srishti Sharma wrote:
>> >
>> >> The cast to pointer types in kfree is not needed and can be dropped.
>> >> Done using the following semantic by coccinelle.
>> >>
>> >> @r@
>> >> type T,P;
>> >> T* x;
>> >> @@
>> >>
>> >> kfree(
>> >> -(P *)
>> >> x )
>> >>
>> >> Signed-off-by: Srishti Sharma 
>> >> ---
>> >>  drivers/staging/rtl8723bs/core/rtw_cmd.c | 58 
>> >> 
>> >>  1 file changed, 29 insertions(+), 29 deletions(-)
>> >>
>> >> diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c 
>> >> b/drivers/staging/rtl8723bs/core/rtw_cmd.c
>> >> index 1843c44..e71e3ab 100644
>> >> --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c
>> >> +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c
>> >> @@ -408,7 +408,7 @@ void rtw_free_cmd_obj(struct cmd_obj *pcmd)
>> >>   }
>> >>
>> >>   /* free cmd_obj */
>> >> - kfree((unsigned char *)pcmd);
>> >> + kfree(pcmd);
>> >>  }
>> >>
>> >>
>> >> @@ -619,7 +619,7 @@ u8 rtw_sitesurvey_cmd(struct adapter  *padapter, 
>> >> struct ndis_802_11_ssid *ssid,
>> >>
>> >>   psurveyPara = rtw_zmalloc(sizeof(struct sitesurvey_parm));
>> >>   if (psurveyPara == NULL) {
>> >> - kfree((unsigned char *) ph2c);
>> >> + kfree(ph2c);
>> >>   return _FAIL;
>> >>   }
>> >>
>> >> @@ -689,7 +689,7 @@ u8 rtw_setdatarate_cmd(struct adapter *padapter, u8 
>> >> *rateset)
>> >>
>> >>   pbsetdataratepara = rtw_zmalloc(sizeof(struct setdatarate_parm));
>> >>   if (pbsetdataratepara == NULL) {
>> >> - kfree((u8 *) ph2c);
>> >> + kfree(ph2c);
>> >>   res = _FAIL;
>> >>   goto exit;
>> >>   }
>> >> @@ -707,7 +707,7 @@ void rtw_getbbrfreg_cmdrsp_callback(struct adapter 
>> >> *padapter,  struct cmd_obj *p
>> >>  {
>> >>   /* rtw_free_cmd_obj(pcmd); */
>> >>   kfree((unsigned char *) pcmd->parmbuf);
>> >
>> > This case didn't get updated, probably because Coccinelle didn't have
>> > access to enough type information.  Try rerunning with --all-includes or
>> > --recursive-includes.  You may also need to give some include path
>> > information (-I argument).
>> I tried doing this but it is still not detecting this particular case,
>> for the include path I gave the path of the directory which contains
>> the header file in which struct cmd_obj is defined.
>
> OK, just check the field type manually, and then put a note in your commit
> log saying that you have done that case by hand, due to Coccinelle's not
> having sufficient type information.
Yes, I have checked it , it is a pointer.

Thanks,
Srishti
>
> julia
>
>>
>> Regards,
>> Srishti
>> >
>> > julia
>> >
>> >> - kfree((unsigned char *) pcmd);
>> >> + kfree(pcmd);
>> >>  }
>> >>
>> >>  u8 rtw_createbss_cmd(struct adapter  *padapter)
>> >> @@ -847,7 +847,7 @@ u8 rtw_joinbss_cmd(struct adapter  *padapter, struct 
>> >> wlan_network *pnetwork)
>> >>   psecnetwork = (struct wlan_bssid_ex *)>sec_bss;
>> >>   if (psecnetwork == NULL) {
>> >>   if (pcmd != NULL)
>> >> - kfree((unsigned char *)pcmd);
>> >> + kfree(pcmd);
>> >>
>> >>   res = _FAIL;
>> >>
>> >> @@ -955,7 +955,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 
>> >> deauth_timeout_ms, bool enqueu
>> >>   cmdobj = rtw_zmalloc(sizeof(*cmdobj));
>> >>   if (cmdobj == NULL) {
>> >>   res = _FAIL;
>> >> - kfree((u8 *)param);
>> >> + kfree(param);
>> >>   goto exit;
>> >>   }
>> >>   init_h2fwcmd_w_p

Re: [Outreachy kernel] [PATCH] Staging: rtl8723bs: core: rtw_cmd: Remove cast to pointer types in kfree

2017-10-07 Thread Srishti Sharma
On Sat, Oct 7, 2017 at 11:42 PM, Julia Lawall <julia.law...@lip6.fr> wrote:
>
>
> On Sat, 7 Oct 2017, Srishti Sharma wrote:
>
>> The cast to pointer types in kfree is not needed and can be dropped.
>> Done using the following semantic by coccinelle.
>>
>> @r@
>> type T,P;
>> T* x;
>> @@
>>
>> kfree(
>> -(P *)
>> x )
>>
>> Signed-off-by: Srishti Sharma <srishtis...@gmail.com>
>> ---
>>  drivers/staging/rtl8723bs/core/rtw_cmd.c | 58 
>> 
>>  1 file changed, 29 insertions(+), 29 deletions(-)
>>
>> diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c 
>> b/drivers/staging/rtl8723bs/core/rtw_cmd.c
>> index 1843c44..e71e3ab 100644
>> --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c
>> +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c
>> @@ -408,7 +408,7 @@ void rtw_free_cmd_obj(struct cmd_obj *pcmd)
>>   }
>>
>>   /* free cmd_obj */
>> - kfree((unsigned char *)pcmd);
>> + kfree(pcmd);
>>  }
>>
>>
>> @@ -619,7 +619,7 @@ u8 rtw_sitesurvey_cmd(struct adapter  *padapter, struct 
>> ndis_802_11_ssid *ssid,
>>
>>   psurveyPara = rtw_zmalloc(sizeof(struct sitesurvey_parm));
>>   if (psurveyPara == NULL) {
>> - kfree((unsigned char *) ph2c);
>> + kfree(ph2c);
>>   return _FAIL;
>>   }
>>
>> @@ -689,7 +689,7 @@ u8 rtw_setdatarate_cmd(struct adapter *padapter, u8 
>> *rateset)
>>
>>   pbsetdataratepara = rtw_zmalloc(sizeof(struct setdatarate_parm));
>>   if (pbsetdataratepara == NULL) {
>> - kfree((u8 *) ph2c);
>> + kfree(ph2c);
>>   res = _FAIL;
>>   goto exit;
>>   }
>> @@ -707,7 +707,7 @@ void rtw_getbbrfreg_cmdrsp_callback(struct adapter 
>> *padapter,  struct cmd_obj *p
>>  {
>>   /* rtw_free_cmd_obj(pcmd); */
>>   kfree((unsigned char *) pcmd->parmbuf);
>
> This case didn't get updated, probably because Coccinelle didn't have
> access to enough type information.  Try rerunning with --all-includes or
> --recursive-includes.  You may also need to give some include path
> information (-I argument).
I tried doing this but it is still not detecting this particular case,
for the include path I gave the path of the directory which contains
the header file in which struct cmd_obj is defined.

Regards,
Srishti
>
> julia
>
>> - kfree((unsigned char *) pcmd);
>> + kfree(pcmd);
>>  }
>>
>>  u8 rtw_createbss_cmd(struct adapter  *padapter)
>> @@ -847,7 +847,7 @@ u8 rtw_joinbss_cmd(struct adapter  *padapter, struct 
>> wlan_network *pnetwork)
>>   psecnetwork = (struct wlan_bssid_ex *)>sec_bss;
>>   if (psecnetwork == NULL) {
>>   if (pcmd != NULL)
>> - kfree((unsigned char *)pcmd);
>> + kfree(pcmd);
>>
>>   res = _FAIL;
>>
>> @@ -955,7 +955,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 
>> deauth_timeout_ms, bool enqueu
>>   cmdobj = rtw_zmalloc(sizeof(*cmdobj));
>>   if (cmdobj == NULL) {
>>   res = _FAIL;
>> - kfree((u8 *)param);
>> + kfree(param);
>>   goto exit;
>>   }
>>   init_h2fwcmd_w_parm_no_rsp(cmdobj, param, _DisConnect_CMD_);
>> @@ -964,7 +964,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 
>> deauth_timeout_ms, bool enqueu
>>   /* no need to enqueue, do the cmd hdl directly and free cmd 
>> parameter */
>>   if (H2C_SUCCESS != disconnect_hdl(padapter, (u8 *)param))
>>   res = _FAIL;
>> - kfree((u8 *)param);
>> + kfree(param);
>>   }
>>
>>  exit:
>> @@ -990,7 +990,7 @@ u8 rtw_setopmode_cmd(struct adapter  *padapter, enum 
>> NDIS_802_11_NETWORK_INFRAST
>>   if (enqueue) {
>>   ph2c = rtw_zmalloc(sizeof(struct cmd_obj));
>>   if (ph2c == NULL) {
>> - kfree((u8 *)psetop);
>> + kfree(psetop);
>>   res = _FAIL;
>>   goto exit;
>>   }
>> @@ -999,7 +999,7 @@ u8 rtw_setopmode_cmd(struct adapter  *padapter, enum 
>> NDIS_802_11_NETWORK_INFRAST
>>   res = rtw_enqueue_cmd(pcmdpriv, ph2c);
>>   } else{
>>   setopmode_hdl(padapter, (u8 *)psetop);

Re: [Outreachy kernel] [PATCH] Staging: rtl8723bs: core: rtw_cmd: Remove cast to pointer types in kfree

2017-10-07 Thread Srishti Sharma
On Sat, Oct 7, 2017 at 11:42 PM, Julia Lawall  wrote:
>
>
> On Sat, 7 Oct 2017, Srishti Sharma wrote:
>
>> The cast to pointer types in kfree is not needed and can be dropped.
>> Done using the following semantic by coccinelle.
>>
>> @r@
>> type T,P;
>> T* x;
>> @@
>>
>> kfree(
>> -(P *)
>> x )
>>
>> Signed-off-by: Srishti Sharma 
>> ---
>>  drivers/staging/rtl8723bs/core/rtw_cmd.c | 58 
>> 
>>  1 file changed, 29 insertions(+), 29 deletions(-)
>>
>> diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c 
>> b/drivers/staging/rtl8723bs/core/rtw_cmd.c
>> index 1843c44..e71e3ab 100644
>> --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c
>> +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c
>> @@ -408,7 +408,7 @@ void rtw_free_cmd_obj(struct cmd_obj *pcmd)
>>   }
>>
>>   /* free cmd_obj */
>> - kfree((unsigned char *)pcmd);
>> + kfree(pcmd);
>>  }
>>
>>
>> @@ -619,7 +619,7 @@ u8 rtw_sitesurvey_cmd(struct adapter  *padapter, struct 
>> ndis_802_11_ssid *ssid,
>>
>>   psurveyPara = rtw_zmalloc(sizeof(struct sitesurvey_parm));
>>   if (psurveyPara == NULL) {
>> - kfree((unsigned char *) ph2c);
>> + kfree(ph2c);
>>   return _FAIL;
>>   }
>>
>> @@ -689,7 +689,7 @@ u8 rtw_setdatarate_cmd(struct adapter *padapter, u8 
>> *rateset)
>>
>>   pbsetdataratepara = rtw_zmalloc(sizeof(struct setdatarate_parm));
>>   if (pbsetdataratepara == NULL) {
>> - kfree((u8 *) ph2c);
>> + kfree(ph2c);
>>   res = _FAIL;
>>   goto exit;
>>   }
>> @@ -707,7 +707,7 @@ void rtw_getbbrfreg_cmdrsp_callback(struct adapter 
>> *padapter,  struct cmd_obj *p
>>  {
>>   /* rtw_free_cmd_obj(pcmd); */
>>   kfree((unsigned char *) pcmd->parmbuf);
>
> This case didn't get updated, probably because Coccinelle didn't have
> access to enough type information.  Try rerunning with --all-includes or
> --recursive-includes.  You may also need to give some include path
> information (-I argument).
I tried doing this but it is still not detecting this particular case,
for the include path I gave the path of the directory which contains
the header file in which struct cmd_obj is defined.

Regards,
Srishti
>
> julia
>
>> - kfree((unsigned char *) pcmd);
>> + kfree(pcmd);
>>  }
>>
>>  u8 rtw_createbss_cmd(struct adapter  *padapter)
>> @@ -847,7 +847,7 @@ u8 rtw_joinbss_cmd(struct adapter  *padapter, struct 
>> wlan_network *pnetwork)
>>   psecnetwork = (struct wlan_bssid_ex *)>sec_bss;
>>   if (psecnetwork == NULL) {
>>   if (pcmd != NULL)
>> - kfree((unsigned char *)pcmd);
>> + kfree(pcmd);
>>
>>   res = _FAIL;
>>
>> @@ -955,7 +955,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 
>> deauth_timeout_ms, bool enqueu
>>   cmdobj = rtw_zmalloc(sizeof(*cmdobj));
>>   if (cmdobj == NULL) {
>>   res = _FAIL;
>> - kfree((u8 *)param);
>> + kfree(param);
>>   goto exit;
>>   }
>>   init_h2fwcmd_w_parm_no_rsp(cmdobj, param, _DisConnect_CMD_);
>> @@ -964,7 +964,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 
>> deauth_timeout_ms, bool enqueu
>>   /* no need to enqueue, do the cmd hdl directly and free cmd 
>> parameter */
>>   if (H2C_SUCCESS != disconnect_hdl(padapter, (u8 *)param))
>>   res = _FAIL;
>> - kfree((u8 *)param);
>> + kfree(param);
>>   }
>>
>>  exit:
>> @@ -990,7 +990,7 @@ u8 rtw_setopmode_cmd(struct adapter  *padapter, enum 
>> NDIS_802_11_NETWORK_INFRAST
>>   if (enqueue) {
>>   ph2c = rtw_zmalloc(sizeof(struct cmd_obj));
>>   if (ph2c == NULL) {
>> - kfree((u8 *)psetop);
>> + kfree(psetop);
>>   res = _FAIL;
>>   goto exit;
>>   }
>> @@ -999,7 +999,7 @@ u8 rtw_setopmode_cmd(struct adapter  *padapter, enum 
>> NDIS_802_11_NETWORK_INFRAST
>>   res = rtw_enqueue_cmd(pcmdpriv, ph2c);
>>   } else{
>>   setopmode_hdl(padapter, (u8 *)psetop);
>> - kfree((u8 *)psetop);
>> +   

[PATCH v2] Staging: pi433: Fix the position of brace after if

2017-10-07 Thread Srishti Sharma
Fix the position of the brace after if when it is on the next line. 
Done using the following semantic patch by coccinelle.

@r1@
position p1, p2;
@@

if(...)@p1 {@p2
...
}

@script: python r2@
p1 << r1.p1;
p2 << r1.p2;
@@

l1 = int (p1[0].line)
l2 = int (p2[0].line)
c1 = int (p1[0].column_end)
c2 = int (p2[0].column)

if l1 == l2 and c1+1 == c2:
cocci.include_match(False)

@r3@
position r1.p1, r1.p2;
@@

if(...
- )@p1
-{@p2
+) {
...
}

Signed-off-by: Srishti Sharma <srishtis...@gmail.com>
---
Changes in v2:
 -Improve commit message.

 drivers/staging/pi433/pi433_if.c | 54 ++--
 1 file changed, 18 insertions(+), 36 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index d82c74d..d946838 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -285,8 +285,7 @@ rf69_set_tx_cfg(struct pi433_device *dev, struct 
pi433_tx_cfg *tx_cfg)
SET_CHECKED(rf69_set_crc_enable   (dev->spi, tx_cfg->enable_crc));
 
/* configure sync, if enabled */
-   if (tx_cfg->enable_sync == optionOn)
-   {
+   if (tx_cfg->enable_sync == optionOn) {
SET_CHECKED(rf69_set_sync_size(dev->spi, tx_cfg->sync_length));
SET_CHECKED(rf69_set_sync_values(dev->spi, 
tx_cfg->sync_pattern));
}
@@ -408,8 +407,7 @@ pi433_receive(void *data)
if (retval) goto abort; /* wait was interrupted */
 
rf69_read_fifo(spi, (u8 *)_total, 1);
-   if (bytes_total > dev->rx_buffer_size)
-   {
+   if (bytes_total > dev->rx_buffer_size) {
retval = -1;
goto abort;
}
@@ -509,16 +507,14 @@ pi433_tx_thread(void *data)
mutex_lock(>tx_fifo_lock);
 
retval = kfifo_out(>tx_fifo, _cfg, sizeof(tx_cfg));
-   if (retval != sizeof(tx_cfg))
-   {
+   if (retval != sizeof(tx_cfg)) {
dev_dbg(device->dev, "reading tx_cfg from fifo failed: 
got %d byte(s), expected %d", retval, (unsigned int)sizeof(tx_cfg) );
mutex_unlock(>tx_fifo_lock);
continue;
}
 
retval = kfifo_out(>tx_fifo, , sizeof(size_t));
-   if (retval != sizeof(size_t))
-   {
+   if (retval != sizeof(size_t)) {
dev_dbg(device->dev, "reading msg size from fifo 
failed: got %d, expected %d", retval, (unsigned int)sizeof(size_t) );
mutex_unlock(>tx_fifo_lock);
continue;
@@ -650,8 +646,7 @@ pi433_tx_thread(void *data)
SET_CHECKED(rf69_set_mode(spi, standby));
 
/* everything sent? */
-   if ( kfifo_is_empty(>tx_fifo) )
-   {
+   if (kfifo_is_empty(>tx_fifo)) {
 abort:
if (rx_interrupted)
{
@@ -705,8 +700,7 @@ pi433_read(struct file *filp, char __user *buf, size_t 
size, loff_t *f_pos)
mutex_unlock(>rx_lock);
 
/* if read was successful copy to user space*/
-   if (bytes_received > 0)
-   {
+   if (bytes_received > 0) {
retval = copy_to_user(buf, device->rx_buffer, bytes_received);
if (retval)
return -EFAULT;
@@ -806,8 +800,7 @@ pi433_ioctl(struct file *filp, unsigned int cmd, unsigned 
long arg)
switch (cmd) {
case PI433_IOC_RD_TX_CFG:
tmp = _IOC_SIZE(cmd);
-   if ( (tmp == 0) || ((tmp % sizeof(struct pi433_tx_cfg)) != 0) )
-   {
+   if ((tmp == 0) || ((tmp % sizeof(struct pi433_tx_cfg)) != 0)) {
retval = -EINVAL;
break;
}
@@ -823,8 +816,7 @@ pi433_ioctl(struct file *filp, unsigned int cmd, unsigned 
long arg)
break;
case PI433_IOC_WR_TX_CFG:
tmp = _IOC_SIZE(cmd);
-   if ( (tmp == 0) || ((tmp % sizeof(struct pi433_tx_cfg)) != 0) )
-   {
+   if ((tmp == 0) || ((tmp % sizeof(struct pi433_tx_cfg)) != 0)) {
retval = -EINVAL;
break;
}
@@ -917,8 +909,7 @@ static int pi433_open(struct inode *inode, struct file 
*filp)
 
if (!device->rx_buffer) {
device->rx_buffer = kmalloc(MAX_MSG_SIZE, GFP_KERNEL);
-   if (!device->rx_buffer)
-   {
+   if (!device->rx_buffer) {
dev_dbg(device->dev, "open/ENOMEM\n");
return -ENOMEM;
}
@@ -926,8 +917,7 @@ static int pi433_open(struct inode *inode, struct file 
*filp)
 
device->users+

[PATCH v2] Staging: pi433: Fix the position of brace after if

2017-10-07 Thread Srishti Sharma
Fix the position of the brace after if when it is on the next line. 
Done using the following semantic patch by coccinelle.

@r1@
position p1, p2;
@@

if(...)@p1 {@p2
...
}

@script: python r2@
p1 << r1.p1;
p2 << r1.p2;
@@

l1 = int (p1[0].line)
l2 = int (p2[0].line)
c1 = int (p1[0].column_end)
c2 = int (p2[0].column)

if l1 == l2 and c1+1 == c2:
cocci.include_match(False)

@r3@
position r1.p1, r1.p2;
@@

if(...
- )@p1
-{@p2
+) {
...
}

Signed-off-by: Srishti Sharma 
---
Changes in v2:
 -Improve commit message.

 drivers/staging/pi433/pi433_if.c | 54 ++--
 1 file changed, 18 insertions(+), 36 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index d82c74d..d946838 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -285,8 +285,7 @@ rf69_set_tx_cfg(struct pi433_device *dev, struct 
pi433_tx_cfg *tx_cfg)
SET_CHECKED(rf69_set_crc_enable   (dev->spi, tx_cfg->enable_crc));
 
/* configure sync, if enabled */
-   if (tx_cfg->enable_sync == optionOn)
-   {
+   if (tx_cfg->enable_sync == optionOn) {
SET_CHECKED(rf69_set_sync_size(dev->spi, tx_cfg->sync_length));
SET_CHECKED(rf69_set_sync_values(dev->spi, 
tx_cfg->sync_pattern));
}
@@ -408,8 +407,7 @@ pi433_receive(void *data)
if (retval) goto abort; /* wait was interrupted */
 
rf69_read_fifo(spi, (u8 *)_total, 1);
-   if (bytes_total > dev->rx_buffer_size)
-   {
+   if (bytes_total > dev->rx_buffer_size) {
retval = -1;
goto abort;
}
@@ -509,16 +507,14 @@ pi433_tx_thread(void *data)
mutex_lock(>tx_fifo_lock);
 
retval = kfifo_out(>tx_fifo, _cfg, sizeof(tx_cfg));
-   if (retval != sizeof(tx_cfg))
-   {
+   if (retval != sizeof(tx_cfg)) {
dev_dbg(device->dev, "reading tx_cfg from fifo failed: 
got %d byte(s), expected %d", retval, (unsigned int)sizeof(tx_cfg) );
mutex_unlock(>tx_fifo_lock);
continue;
}
 
retval = kfifo_out(>tx_fifo, , sizeof(size_t));
-   if (retval != sizeof(size_t))
-   {
+   if (retval != sizeof(size_t)) {
dev_dbg(device->dev, "reading msg size from fifo 
failed: got %d, expected %d", retval, (unsigned int)sizeof(size_t) );
mutex_unlock(>tx_fifo_lock);
continue;
@@ -650,8 +646,7 @@ pi433_tx_thread(void *data)
SET_CHECKED(rf69_set_mode(spi, standby));
 
/* everything sent? */
-   if ( kfifo_is_empty(>tx_fifo) )
-   {
+   if (kfifo_is_empty(>tx_fifo)) {
 abort:
if (rx_interrupted)
{
@@ -705,8 +700,7 @@ pi433_read(struct file *filp, char __user *buf, size_t 
size, loff_t *f_pos)
mutex_unlock(>rx_lock);
 
/* if read was successful copy to user space*/
-   if (bytes_received > 0)
-   {
+   if (bytes_received > 0) {
retval = copy_to_user(buf, device->rx_buffer, bytes_received);
if (retval)
return -EFAULT;
@@ -806,8 +800,7 @@ pi433_ioctl(struct file *filp, unsigned int cmd, unsigned 
long arg)
switch (cmd) {
case PI433_IOC_RD_TX_CFG:
tmp = _IOC_SIZE(cmd);
-   if ( (tmp == 0) || ((tmp % sizeof(struct pi433_tx_cfg)) != 0) )
-   {
+   if ((tmp == 0) || ((tmp % sizeof(struct pi433_tx_cfg)) != 0)) {
retval = -EINVAL;
break;
}
@@ -823,8 +816,7 @@ pi433_ioctl(struct file *filp, unsigned int cmd, unsigned 
long arg)
break;
case PI433_IOC_WR_TX_CFG:
tmp = _IOC_SIZE(cmd);
-   if ( (tmp == 0) || ((tmp % sizeof(struct pi433_tx_cfg)) != 0) )
-   {
+   if ((tmp == 0) || ((tmp % sizeof(struct pi433_tx_cfg)) != 0)) {
retval = -EINVAL;
break;
}
@@ -917,8 +909,7 @@ static int pi433_open(struct inode *inode, struct file 
*filp)
 
if (!device->rx_buffer) {
device->rx_buffer = kmalloc(MAX_MSG_SIZE, GFP_KERNEL);
-   if (!device->rx_buffer)
-   {
+   if (!device->rx_buffer) {
dev_dbg(device->dev, "open/ENOMEM\n");
return -ENOMEM;
}
@@ -926,8 +917,7 @@ static int pi433_open(struct inode *inode, struct file 
*filp)
 
device->users++;
instance = kz

[PATCH] Staging: rtlwifi: phydm: Use setup_timer

2017-10-07 Thread Srishti Sharma
Use setup_timer to combine initialization of a timer with the
initialization of the timer's function and data fields. Done
using the following semantic patch by coccinelle.

@r@
struct timer_list *l;
expression f, d;
@@

-init_timer(l);
+setup_timer(l,f,d);
...

(
- l->function = f;
...
- l->data = d;
|
- l->data = d;
...
- l->function = f;
)

Signed-off-by: Srishti Sharma <srishtis...@gmail.com>
---
 drivers/staging/rtlwifi/phydm/phydm_interface.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/rtlwifi/phydm/phydm_interface.c 
b/drivers/staging/rtlwifi/phydm/phydm_interface.c
index 102576a..aa1fb75 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_interface.c
+++ b/drivers/staging/rtlwifi/phydm/phydm_interface.c
@@ -189,9 +189,7 @@ void odm_initialize_timer(struct phy_dm_struct *dm, struct 
timer_list *timer,
  void *call_back_func, void *context,
  const char *sz_id)
 {
-   init_timer(timer);
-   timer->function = call_back_func;
-   timer->data = (unsigned long)dm;
+   setup_timer(timer, call_back_func, (unsigned long)dm);
/*mod_timer(timer, jiffies+RTL_MILISECONDS_TO_JIFFIES(10)); */
 }
 
-- 
2.7.4



[PATCH] Staging: rtlwifi: phydm: Use setup_timer

2017-10-07 Thread Srishti Sharma
Use setup_timer to combine initialization of a timer with the
initialization of the timer's function and data fields. Done
using the following semantic patch by coccinelle.

@r@
struct timer_list *l;
expression f, d;
@@

-init_timer(l);
+setup_timer(l,f,d);
...

(
- l->function = f;
...
- l->data = d;
|
- l->data = d;
...
- l->function = f;
)

Signed-off-by: Srishti Sharma 
---
 drivers/staging/rtlwifi/phydm/phydm_interface.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/rtlwifi/phydm/phydm_interface.c 
b/drivers/staging/rtlwifi/phydm/phydm_interface.c
index 102576a..aa1fb75 100644
--- a/drivers/staging/rtlwifi/phydm/phydm_interface.c
+++ b/drivers/staging/rtlwifi/phydm/phydm_interface.c
@@ -189,9 +189,7 @@ void odm_initialize_timer(struct phy_dm_struct *dm, struct 
timer_list *timer,
  void *call_back_func, void *context,
  const char *sz_id)
 {
-   init_timer(timer);
-   timer->function = call_back_func;
-   timer->data = (unsigned long)dm;
+   setup_timer(timer, call_back_func, (unsigned long)dm);
/*mod_timer(timer, jiffies+RTL_MILISECONDS_TO_JIFFIES(10)); */
 }
 
-- 
2.7.4



[PATCH] Staging: pi433: Fix the position of brace after if

2017-10-07 Thread Srishti Sharma
Fix the position of the brace after if when it is on the next line
or when there is no space between them. Done using the following
semantic patch by coccinelle.

@r1@
position p1, p2;
identifier x,f;
expression e;
@@

(
x=e;
|
f(...)
)

if(...)@p1 {@p2
...
}

@script: python r2@
p1 << r1.p1;
p2 << r1.p2;
@@

l1 = int (p1[0].line)
l2 = int (p2[0].line)
c1 = int (p1[0].column_end)
c2 = int (p2[0].column)

if l1 == l2 and c1+1 == c2:
cocci.include_match(False)

@r3@
position r1.p1, r1.p2;
@@

if(...
- )@p1
-{@p2
+) {
...
}

Signed-off-by: Srishti Sharma <srishtis...@gmail.com>
---
 drivers/staging/pi433/pi433_if.c | 54 ++--
 1 file changed, 18 insertions(+), 36 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index d82c74d..d946838 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -285,8 +285,7 @@ rf69_set_tx_cfg(struct pi433_device *dev, struct 
pi433_tx_cfg *tx_cfg)
SET_CHECKED(rf69_set_crc_enable   (dev->spi, tx_cfg->enable_crc));
 
/* configure sync, if enabled */
-   if (tx_cfg->enable_sync == optionOn)
-   {
+   if (tx_cfg->enable_sync == optionOn) {
SET_CHECKED(rf69_set_sync_size(dev->spi, tx_cfg->sync_length));
SET_CHECKED(rf69_set_sync_values(dev->spi, 
tx_cfg->sync_pattern));
}
@@ -408,8 +407,7 @@ pi433_receive(void *data)
if (retval) goto abort; /* wait was interrupted */
 
rf69_read_fifo(spi, (u8 *)_total, 1);
-   if (bytes_total > dev->rx_buffer_size)
-   {
+   if (bytes_total > dev->rx_buffer_size) {
retval = -1;
goto abort;
}
@@ -509,16 +507,14 @@ pi433_tx_thread(void *data)
mutex_lock(>tx_fifo_lock);
 
retval = kfifo_out(>tx_fifo, _cfg, sizeof(tx_cfg));
-   if (retval != sizeof(tx_cfg))
-   {
+   if (retval != sizeof(tx_cfg)) {
dev_dbg(device->dev, "reading tx_cfg from fifo failed: 
got %d byte(s), expected %d", retval, (unsigned int)sizeof(tx_cfg) );
mutex_unlock(>tx_fifo_lock);
continue;
}
 
retval = kfifo_out(>tx_fifo, , sizeof(size_t));
-   if (retval != sizeof(size_t))
-   {
+   if (retval != sizeof(size_t)) {
dev_dbg(device->dev, "reading msg size from fifo 
failed: got %d, expected %d", retval, (unsigned int)sizeof(size_t) );
mutex_unlock(>tx_fifo_lock);
continue;
@@ -650,8 +646,7 @@ pi433_tx_thread(void *data)
SET_CHECKED(rf69_set_mode(spi, standby));
 
/* everything sent? */
-   if ( kfifo_is_empty(>tx_fifo) )
-   {
+   if (kfifo_is_empty(>tx_fifo)) {
 abort:
if (rx_interrupted)
{
@@ -705,8 +700,7 @@ pi433_read(struct file *filp, char __user *buf, size_t 
size, loff_t *f_pos)
mutex_unlock(>rx_lock);
 
/* if read was successful copy to user space*/
-   if (bytes_received > 0)
-   {
+   if (bytes_received > 0) {
retval = copy_to_user(buf, device->rx_buffer, bytes_received);
if (retval)
return -EFAULT;
@@ -806,8 +800,7 @@ pi433_ioctl(struct file *filp, unsigned int cmd, unsigned 
long arg)
switch (cmd) {
case PI433_IOC_RD_TX_CFG:
tmp = _IOC_SIZE(cmd);
-   if ( (tmp == 0) || ((tmp % sizeof(struct pi433_tx_cfg)) != 0) )
-   {
+   if ((tmp == 0) || ((tmp % sizeof(struct pi433_tx_cfg)) != 0)) {
retval = -EINVAL;
break;
}
@@ -823,8 +816,7 @@ pi433_ioctl(struct file *filp, unsigned int cmd, unsigned 
long arg)
break;
case PI433_IOC_WR_TX_CFG:
tmp = _IOC_SIZE(cmd);
-   if ( (tmp == 0) || ((tmp % sizeof(struct pi433_tx_cfg)) != 0) )
-   {
+   if ((tmp == 0) || ((tmp % sizeof(struct pi433_tx_cfg)) != 0)) {
retval = -EINVAL;
break;
}
@@ -917,8 +909,7 @@ static int pi433_open(struct inode *inode, struct file 
*filp)
 
if (!device->rx_buffer) {
device->rx_buffer = kmalloc(MAX_MSG_SIZE, GFP_KERNEL);
-   if (!device->rx_buffer)
-   {
+   if (!device->rx_buffer) {
dev_dbg(device->dev, "open/ENOMEM\n");
return -ENOMEM;
}
@@ -926,8 +917,7 @@ static int pi433_open(struct ino

[PATCH] Staging: pi433: Fix the position of brace after if

2017-10-07 Thread Srishti Sharma
Fix the position of the brace after if when it is on the next line
or when there is no space between them. Done using the following
semantic patch by coccinelle.

@r1@
position p1, p2;
identifier x,f;
expression e;
@@

(
x=e;
|
f(...)
)

if(...)@p1 {@p2
...
}

@script: python r2@
p1 << r1.p1;
p2 << r1.p2;
@@

l1 = int (p1[0].line)
l2 = int (p2[0].line)
c1 = int (p1[0].column_end)
c2 = int (p2[0].column)

if l1 == l2 and c1+1 == c2:
cocci.include_match(False)

@r3@
position r1.p1, r1.p2;
@@

if(...
- )@p1
-{@p2
+) {
...
}

Signed-off-by: Srishti Sharma 
---
 drivers/staging/pi433/pi433_if.c | 54 ++--
 1 file changed, 18 insertions(+), 36 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index d82c74d..d946838 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -285,8 +285,7 @@ rf69_set_tx_cfg(struct pi433_device *dev, struct 
pi433_tx_cfg *tx_cfg)
SET_CHECKED(rf69_set_crc_enable   (dev->spi, tx_cfg->enable_crc));
 
/* configure sync, if enabled */
-   if (tx_cfg->enable_sync == optionOn)
-   {
+   if (tx_cfg->enable_sync == optionOn) {
SET_CHECKED(rf69_set_sync_size(dev->spi, tx_cfg->sync_length));
SET_CHECKED(rf69_set_sync_values(dev->spi, 
tx_cfg->sync_pattern));
}
@@ -408,8 +407,7 @@ pi433_receive(void *data)
if (retval) goto abort; /* wait was interrupted */
 
rf69_read_fifo(spi, (u8 *)_total, 1);
-   if (bytes_total > dev->rx_buffer_size)
-   {
+   if (bytes_total > dev->rx_buffer_size) {
retval = -1;
goto abort;
}
@@ -509,16 +507,14 @@ pi433_tx_thread(void *data)
mutex_lock(>tx_fifo_lock);
 
retval = kfifo_out(>tx_fifo, _cfg, sizeof(tx_cfg));
-   if (retval != sizeof(tx_cfg))
-   {
+   if (retval != sizeof(tx_cfg)) {
dev_dbg(device->dev, "reading tx_cfg from fifo failed: 
got %d byte(s), expected %d", retval, (unsigned int)sizeof(tx_cfg) );
mutex_unlock(>tx_fifo_lock);
continue;
}
 
retval = kfifo_out(>tx_fifo, , sizeof(size_t));
-   if (retval != sizeof(size_t))
-   {
+   if (retval != sizeof(size_t)) {
dev_dbg(device->dev, "reading msg size from fifo 
failed: got %d, expected %d", retval, (unsigned int)sizeof(size_t) );
mutex_unlock(>tx_fifo_lock);
continue;
@@ -650,8 +646,7 @@ pi433_tx_thread(void *data)
SET_CHECKED(rf69_set_mode(spi, standby));
 
/* everything sent? */
-   if ( kfifo_is_empty(>tx_fifo) )
-   {
+   if (kfifo_is_empty(>tx_fifo)) {
 abort:
if (rx_interrupted)
{
@@ -705,8 +700,7 @@ pi433_read(struct file *filp, char __user *buf, size_t 
size, loff_t *f_pos)
mutex_unlock(>rx_lock);
 
/* if read was successful copy to user space*/
-   if (bytes_received > 0)
-   {
+   if (bytes_received > 0) {
retval = copy_to_user(buf, device->rx_buffer, bytes_received);
if (retval)
return -EFAULT;
@@ -806,8 +800,7 @@ pi433_ioctl(struct file *filp, unsigned int cmd, unsigned 
long arg)
switch (cmd) {
case PI433_IOC_RD_TX_CFG:
tmp = _IOC_SIZE(cmd);
-   if ( (tmp == 0) || ((tmp % sizeof(struct pi433_tx_cfg)) != 0) )
-   {
+   if ((tmp == 0) || ((tmp % sizeof(struct pi433_tx_cfg)) != 0)) {
retval = -EINVAL;
break;
}
@@ -823,8 +816,7 @@ pi433_ioctl(struct file *filp, unsigned int cmd, unsigned 
long arg)
break;
case PI433_IOC_WR_TX_CFG:
tmp = _IOC_SIZE(cmd);
-   if ( (tmp == 0) || ((tmp % sizeof(struct pi433_tx_cfg)) != 0) )
-   {
+   if ((tmp == 0) || ((tmp % sizeof(struct pi433_tx_cfg)) != 0)) {
retval = -EINVAL;
break;
}
@@ -917,8 +909,7 @@ static int pi433_open(struct inode *inode, struct file 
*filp)
 
if (!device->rx_buffer) {
device->rx_buffer = kmalloc(MAX_MSG_SIZE, GFP_KERNEL);
-   if (!device->rx_buffer)
-   {
+   if (!device->rx_buffer) {
dev_dbg(device->dev, "open/ENOMEM\n");
return -ENOMEM;
}
@@ -926,8 +917,7 @@ static int pi433_open(struct inode *inode, struct file 
*filp)
 
  

[PATCH] Staging: media: atomisp: pci: Eliminate use of typedefs for struct

2017-10-07 Thread Srishti Sharma
The use of typedefs for struct is discouraged, and hence can be
eliminated. Done using the following semantic patch by coccinelle.

@r1@
type T;
@@

typedef struct {...} T;

@script: python p@
T << r1.T;
T1;
@@

if T[-2:] == "_t" or T[-2:] == "_T":
coccinelle.T1 = T[:-2]
else:
coccinelle.T1 = T

print T, T1
@r2@
type r1.T;
identifier p.T1;
@@

- typedef
struct
+ T1
{
...
}
- T
;

@r3@
type r1.T;
identifier p.T1;
@@

- T
+ struct T1

Signed-off-by: Srishti Sharma <srishtis...@gmail.com>
---
 .../media/atomisp/pci/atomisp2/css2400/runtime/spctrl/src/spctrl.c  | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/spctrl/src/spctrl.c
 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/spctrl/src/spctrl.c
index d9178e8..6d9bceb 100644
--- 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/spctrl/src/spctrl.c
+++ 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/spctrl/src/spctrl.c
@@ -37,7 +37,7 @@ more details.
 #include "ia_css_spctrl.h"
 #include "ia_css_debug.h"
 
-typedef struct {
+struct spctrl_context_info {
struct ia_css_sp_init_dmem_cfg dmem_config;
uint32_tspctrl_config_dmem_addr; /** location of dmem_cfg  in 
SP dmem */
uint32_tspctrl_state_dmem_addr;
@@ -45,9 +45,9 @@ typedef struct {
hrt_vaddresscode_addr;  /* sp firmware location in host 
mem-DDR*/
uint32_tcode_size;
char   *program_name;   /* used in case of PLATFORM_SIM */
-} spctrl_context_info;
+};
 
-static spctrl_context_info spctrl_cofig_info[N_SP_ID];
+static struct spctrl_context_info spctrl_cofig_info[N_SP_ID];
 static bool spctrl_loaded[N_SP_ID] = {0};
 
 /* Load firmware */
-- 
2.7.4



[PATCH] Staging: media: atomisp: pci: Eliminate use of typedefs for struct

2017-10-07 Thread Srishti Sharma
The use of typedefs for struct is discouraged, and hence can be
eliminated. Done using the following semantic patch by coccinelle.

@r1@
type T;
@@

typedef struct {...} T;

@script: python p@
T << r1.T;
T1;
@@

if T[-2:] == "_t" or T[-2:] == "_T":
coccinelle.T1 = T[:-2]
else:
coccinelle.T1 = T

print T, T1
@r2@
type r1.T;
identifier p.T1;
@@

- typedef
struct
+ T1
{
...
}
- T
;

@r3@
type r1.T;
identifier p.T1;
@@

- T
+ struct T1

Signed-off-by: Srishti Sharma 
---
 .../media/atomisp/pci/atomisp2/css2400/runtime/spctrl/src/spctrl.c  | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/spctrl/src/spctrl.c
 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/spctrl/src/spctrl.c
index d9178e8..6d9bceb 100644
--- 
a/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/spctrl/src/spctrl.c
+++ 
b/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/spctrl/src/spctrl.c
@@ -37,7 +37,7 @@ more details.
 #include "ia_css_spctrl.h"
 #include "ia_css_debug.h"
 
-typedef struct {
+struct spctrl_context_info {
struct ia_css_sp_init_dmem_cfg dmem_config;
uint32_tspctrl_config_dmem_addr; /** location of dmem_cfg  in 
SP dmem */
uint32_tspctrl_state_dmem_addr;
@@ -45,9 +45,9 @@ typedef struct {
hrt_vaddresscode_addr;  /* sp firmware location in host 
mem-DDR*/
uint32_tcode_size;
char   *program_name;   /* used in case of PLATFORM_SIM */
-} spctrl_context_info;
+};
 
-static spctrl_context_info spctrl_cofig_info[N_SP_ID];
+static struct spctrl_context_info spctrl_cofig_info[N_SP_ID];
 static bool spctrl_loaded[N_SP_ID] = {0};
 
 /* Load firmware */
-- 
2.7.4



[PATCH] Staging: rtl8723bs: core: rtw_cmd: Remove cast to pointer types in kfree

2017-10-07 Thread Srishti Sharma
The cast to pointer types in kfree is not needed and can be dropped.
Done using the following semantic by coccinelle.

@r@
type T,P;
T* x;
@@

kfree(
-(P *)
x )

Signed-off-by: Srishti Sharma <srishtis...@gmail.com>
---
 drivers/staging/rtl8723bs/core/rtw_cmd.c | 58 
 1 file changed, 29 insertions(+), 29 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c 
b/drivers/staging/rtl8723bs/core/rtw_cmd.c
index 1843c44..e71e3ab 100644
--- a/drivers/staging/rtl8723bs/core/rtw_cmd.c
+++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c
@@ -408,7 +408,7 @@ void rtw_free_cmd_obj(struct cmd_obj *pcmd)
}
 
/* free cmd_obj */
-   kfree((unsigned char *)pcmd);
+   kfree(pcmd);
 }
 
 
@@ -619,7 +619,7 @@ u8 rtw_sitesurvey_cmd(struct adapter  *padapter, struct 
ndis_802_11_ssid *ssid,
 
psurveyPara = rtw_zmalloc(sizeof(struct sitesurvey_parm));
if (psurveyPara == NULL) {
-   kfree((unsigned char *) ph2c);
+   kfree(ph2c);
return _FAIL;
}
 
@@ -689,7 +689,7 @@ u8 rtw_setdatarate_cmd(struct adapter *padapter, u8 
*rateset)
 
pbsetdataratepara = rtw_zmalloc(sizeof(struct setdatarate_parm));
if (pbsetdataratepara == NULL) {
-   kfree((u8 *) ph2c);
+   kfree(ph2c);
res = _FAIL;
goto exit;
}
@@ -707,7 +707,7 @@ void rtw_getbbrfreg_cmdrsp_callback(struct adapter 
*padapter,  struct cmd_obj *p
 {
/* rtw_free_cmd_obj(pcmd); */
kfree((unsigned char *) pcmd->parmbuf);
-   kfree((unsigned char *) pcmd);
+   kfree(pcmd);
 }
 
 u8 rtw_createbss_cmd(struct adapter  *padapter)
@@ -847,7 +847,7 @@ u8 rtw_joinbss_cmd(struct adapter  *padapter, struct 
wlan_network *pnetwork)
psecnetwork = (struct wlan_bssid_ex *)>sec_bss;
if (psecnetwork == NULL) {
if (pcmd != NULL)
-   kfree((unsigned char *)pcmd);
+   kfree(pcmd);
 
res = _FAIL;
 
@@ -955,7 +955,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 
deauth_timeout_ms, bool enqueu
cmdobj = rtw_zmalloc(sizeof(*cmdobj));
if (cmdobj == NULL) {
res = _FAIL;
-   kfree((u8 *)param);
+   kfree(param);
goto exit;
}
init_h2fwcmd_w_parm_no_rsp(cmdobj, param, _DisConnect_CMD_);
@@ -964,7 +964,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 
deauth_timeout_ms, bool enqueu
/* no need to enqueue, do the cmd hdl directly and free cmd 
parameter */
if (H2C_SUCCESS != disconnect_hdl(padapter, (u8 *)param))
res = _FAIL;
-   kfree((u8 *)param);
+   kfree(param);
}
 
 exit:
@@ -990,7 +990,7 @@ u8 rtw_setopmode_cmd(struct adapter  *padapter, enum 
NDIS_802_11_NETWORK_INFRAST
if (enqueue) {
ph2c = rtw_zmalloc(sizeof(struct cmd_obj));
if (ph2c == NULL) {
-   kfree((u8 *)psetop);
+   kfree(psetop);
res = _FAIL;
goto exit;
}
@@ -999,7 +999,7 @@ u8 rtw_setopmode_cmd(struct adapter  *padapter, enum 
NDIS_802_11_NETWORK_INFRAST
res = rtw_enqueue_cmd(pcmdpriv, ph2c);
} else{
setopmode_hdl(padapter, (u8 *)psetop);
-   kfree((u8 *)psetop);
+   kfree(psetop);
}
 exit:
return res;
@@ -1042,15 +1042,15 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct 
sta_info *sta, u8 unicast_
if (enqueue) {
ph2c = rtw_zmalloc(sizeof(struct cmd_obj));
if (ph2c == NULL) {
-   kfree((u8 *) psetstakey_para);
+   kfree(psetstakey_para);
res = _FAIL;
goto exit;
}
 
psetstakey_rsp = rtw_zmalloc(sizeof(struct set_stakey_rsp));
if (psetstakey_rsp == NULL) {
-   kfree((u8 *) ph2c);
-   kfree((u8 *) psetstakey_para);
+   kfree(ph2c);
+   kfree(psetstakey_para);
res = _FAIL;
goto exit;
}
@@ -1061,7 +1061,7 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct 
sta_info *sta, u8 unicast_
res = rtw_enqueue_cmd(pcmdpriv, ph2c);
} else{
set_stakey_hdl(padapter, (u8 *)psetstakey_para);
-   kfree((u8 *) psetstakey_para);
+   kfree(psetstakey_para);
}
 exit:
return res;
@@ -1091,15 +1091,15 @@ u8 rtw_clearstakey_cmd(struct adapter *padapter, struct 
sta_info *sta, u8 enqueu
 
psetstakey_para = rtw_zmalloc(sizeof(struct set

[PATCH] Staging: rtl8723bs: core: rtw_cmd: Remove cast to pointer types in kfree

2017-10-07 Thread Srishti Sharma
The cast to pointer types in kfree is not needed and can be dropped.
Done using the following semantic by coccinelle.

@r@
type T,P;
T* x;
@@

kfree(
-(P *)
x )

Signed-off-by: Srishti Sharma 
---
 drivers/staging/rtl8723bs/core/rtw_cmd.c | 58 
 1 file changed, 29 insertions(+), 29 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c 
b/drivers/staging/rtl8723bs/core/rtw_cmd.c
index 1843c44..e71e3ab 100644
--- a/drivers/staging/rtl8723bs/core/rtw_cmd.c
+++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c
@@ -408,7 +408,7 @@ void rtw_free_cmd_obj(struct cmd_obj *pcmd)
}
 
/* free cmd_obj */
-   kfree((unsigned char *)pcmd);
+   kfree(pcmd);
 }
 
 
@@ -619,7 +619,7 @@ u8 rtw_sitesurvey_cmd(struct adapter  *padapter, struct 
ndis_802_11_ssid *ssid,
 
psurveyPara = rtw_zmalloc(sizeof(struct sitesurvey_parm));
if (psurveyPara == NULL) {
-   kfree((unsigned char *) ph2c);
+   kfree(ph2c);
return _FAIL;
}
 
@@ -689,7 +689,7 @@ u8 rtw_setdatarate_cmd(struct adapter *padapter, u8 
*rateset)
 
pbsetdataratepara = rtw_zmalloc(sizeof(struct setdatarate_parm));
if (pbsetdataratepara == NULL) {
-   kfree((u8 *) ph2c);
+   kfree(ph2c);
res = _FAIL;
goto exit;
}
@@ -707,7 +707,7 @@ void rtw_getbbrfreg_cmdrsp_callback(struct adapter 
*padapter,  struct cmd_obj *p
 {
/* rtw_free_cmd_obj(pcmd); */
kfree((unsigned char *) pcmd->parmbuf);
-   kfree((unsigned char *) pcmd);
+   kfree(pcmd);
 }
 
 u8 rtw_createbss_cmd(struct adapter  *padapter)
@@ -847,7 +847,7 @@ u8 rtw_joinbss_cmd(struct adapter  *padapter, struct 
wlan_network *pnetwork)
psecnetwork = (struct wlan_bssid_ex *)>sec_bss;
if (psecnetwork == NULL) {
if (pcmd != NULL)
-   kfree((unsigned char *)pcmd);
+   kfree(pcmd);
 
res = _FAIL;
 
@@ -955,7 +955,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 
deauth_timeout_ms, bool enqueu
cmdobj = rtw_zmalloc(sizeof(*cmdobj));
if (cmdobj == NULL) {
res = _FAIL;
-   kfree((u8 *)param);
+   kfree(param);
goto exit;
}
init_h2fwcmd_w_parm_no_rsp(cmdobj, param, _DisConnect_CMD_);
@@ -964,7 +964,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 
deauth_timeout_ms, bool enqueu
/* no need to enqueue, do the cmd hdl directly and free cmd 
parameter */
if (H2C_SUCCESS != disconnect_hdl(padapter, (u8 *)param))
res = _FAIL;
-   kfree((u8 *)param);
+   kfree(param);
}
 
 exit:
@@ -990,7 +990,7 @@ u8 rtw_setopmode_cmd(struct adapter  *padapter, enum 
NDIS_802_11_NETWORK_INFRAST
if (enqueue) {
ph2c = rtw_zmalloc(sizeof(struct cmd_obj));
if (ph2c == NULL) {
-   kfree((u8 *)psetop);
+   kfree(psetop);
res = _FAIL;
goto exit;
}
@@ -999,7 +999,7 @@ u8 rtw_setopmode_cmd(struct adapter  *padapter, enum 
NDIS_802_11_NETWORK_INFRAST
res = rtw_enqueue_cmd(pcmdpriv, ph2c);
} else{
setopmode_hdl(padapter, (u8 *)psetop);
-   kfree((u8 *)psetop);
+   kfree(psetop);
}
 exit:
return res;
@@ -1042,15 +1042,15 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct 
sta_info *sta, u8 unicast_
if (enqueue) {
ph2c = rtw_zmalloc(sizeof(struct cmd_obj));
if (ph2c == NULL) {
-   kfree((u8 *) psetstakey_para);
+   kfree(psetstakey_para);
res = _FAIL;
goto exit;
}
 
psetstakey_rsp = rtw_zmalloc(sizeof(struct set_stakey_rsp));
if (psetstakey_rsp == NULL) {
-   kfree((u8 *) ph2c);
-   kfree((u8 *) psetstakey_para);
+   kfree(ph2c);
+   kfree(psetstakey_para);
res = _FAIL;
goto exit;
}
@@ -1061,7 +1061,7 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct 
sta_info *sta, u8 unicast_
res = rtw_enqueue_cmd(pcmdpriv, ph2c);
} else{
set_stakey_hdl(padapter, (u8 *)psetstakey_para);
-   kfree((u8 *) psetstakey_para);
+   kfree(psetstakey_para);
}
 exit:
return res;
@@ -1091,15 +1091,15 @@ u8 rtw_clearstakey_cmd(struct adapter *padapter, struct 
sta_info *sta, u8 enqueu
 
psetstakey_para = rtw_zmalloc(sizeof(struct set_stakey_parm));
if (psetstakey_para =

[PATCH v3] Staging: rtl8188eu: core: rtw_mlme_ext: Use list_for_each_entry_safe

2017-10-05 Thread Srishti Sharma
This is a cleanup patch and doesn't change runtime behaviour. 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(>m)
 ...+>
}
...+>
}

Signed-off-by: Srishti Sharma <srishtis...@gmail.com>
---
Changes in v3
 -Add a blank line after declaration.
Changes in v2
 -Make the commit message more clear.
 -Add file name to the subject.

 drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
index 52f31c7..b986cc8 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
@@ -5446,6 +5446,8 @@ u8 mlme_evt_hdl(struct adapter *padapter, unsigned char 
*pbuf)
 
 u8 tx_beacon_hdl(struct adapter *padapter, unsigned char *pbuf)
 {
+   struct xmit_frame *tmp;
+
if (send_beacon(padapter) == _FAIL) {
DBG_88E("issue_beacon, fail!\n");
return H2C_PARAMETERS_ERROR;
@@ -5469,11 +5471,8 @@ u8 tx_beacon_hdl(struct adapter *padapter, unsigned char 
*pbuf)
xmitframe_phead = get_list_head(_bmc->sleep_q);
xmitframe_plist = xmitframe_phead->next;
 
-   while (xmitframe_phead != xmitframe_plist) {
-   pxmitframe = container_of(xmitframe_plist, 
struct xmit_frame, list);
-
-   xmitframe_plist = xmitframe_plist->next;
-
+   list_for_each_entry_safe(pxmitframe, tmp,
+xmitframe_plist, list) {
list_del_init(>list);
 
psta_bmc->sleepq_len--;
-- 
2.7.4



[PATCH v3] Staging: rtl8188eu: core: rtw_mlme_ext: Use list_for_each_entry_safe

2017-10-05 Thread Srishti Sharma
This is a cleanup patch and doesn't change runtime behaviour. 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(>m)
 ...+>
}
...+>
}

Signed-off-by: Srishti Sharma 
---
Changes in v3
 -Add a blank line after declaration.
Changes in v2
 -Make the commit message more clear.
 -Add file name to the subject.

 drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
index 52f31c7..b986cc8 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
@@ -5446,6 +5446,8 @@ u8 mlme_evt_hdl(struct adapter *padapter, unsigned char 
*pbuf)
 
 u8 tx_beacon_hdl(struct adapter *padapter, unsigned char *pbuf)
 {
+   struct xmit_frame *tmp;
+
if (send_beacon(padapter) == _FAIL) {
DBG_88E("issue_beacon, fail!\n");
return H2C_PARAMETERS_ERROR;
@@ -5469,11 +5471,8 @@ u8 tx_beacon_hdl(struct adapter *padapter, unsigned char 
*pbuf)
xmitframe_phead = get_list_head(_bmc->sleep_q);
xmitframe_plist = xmitframe_phead->next;
 
-   while (xmitframe_phead != xmitframe_plist) {
-   pxmitframe = container_of(xmitframe_plist, 
struct xmit_frame, list);
-
-   xmitframe_plist = xmitframe_plist->next;
-
+   list_for_each_entry_safe(pxmitframe, tmp,
+xmitframe_plist, list) {
list_del_init(>list);
 
psta_bmc->sleepq_len--;
-- 
2.7.4



[PATCH v2] Staging: rtl8188eu: core: rtw_ap: Use list_for_each_entry_safe

2017-10-05 Thread 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.

@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(>m)
 ...+>
}
...
}

Signed-off-by: Srishti Sharma <srishtis...@gmail.com>
---
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(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c 
b/drivers/staging/rtl8188eu/core/rtw_ap.c
index 32a4837..a2c599f 100644
--- a/drivers/staging/rtl8188eu/core/rtw_ap.c
+++ b/drivers/staging/rtl8188eu/core/rtw_ap.c
@@ -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 = >stapriv;
struct wlan_acl_pool *pacl_list = >acl_list;
struct __queue *pacl_node_q = _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 = >stapriv;
struct mlme_ext_priv *pmlmeext = >mlmeextpriv;
struct mlme_ext_info*pmlmeinfo = >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(>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 = >stapriv;
struct mlme_priv *pmlmepriv = >mlmepriv;
@@ -1855,10 +1848,7 @@ void stop_ap_mode(struct adapter *padapter)
spin_lock_bh(_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;
 
-- 
2.7.4



[PATCH v2] Staging: rtl8188eu: core: rtw_ap: Use list_for_each_entry_safe

2017-10-05 Thread 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.

@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(>m)
 ...+>
}
...
}

Signed-off-by: Srishti Sharma 
---
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(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c 
b/drivers/staging/rtl8188eu/core/rtw_ap.c
index 32a4837..a2c599f 100644
--- a/drivers/staging/rtl8188eu/core/rtw_ap.c
+++ b/drivers/staging/rtl8188eu/core/rtw_ap.c
@@ -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 = >stapriv;
struct wlan_acl_pool *pacl_list = >acl_list;
struct __queue *pacl_node_q = _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 = >stapriv;
struct mlme_ext_priv *pmlmeext = >mlmeextpriv;
struct mlme_ext_info*pmlmeinfo = >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(>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 = >stapriv;
struct mlme_priv *pmlmepriv = >mlmepriv;
@@ -1855,10 +1848,7 @@ void stop_ap_mode(struct adapter *padapter)
spin_lock_bh(_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;
 
-- 
2.7.4



[PATCH v2] Staging: rtl8188eu: core: rtw_mlme_ext: Use list_for_each_entry_safe

2017-10-04 Thread Srishti Sharma
This is a cleanup patch and doesn't change runtime behaviour. 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(>m)
 ...+>
}
...+>
}

Signed-off-by: Srishti Sharma <srishtis...@gmail.com>
---
Changes in v2
 -Make the commit message more clear.
 -Add file name to the subject.

 drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
index 52f31c7..4e1d06c 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
@@ -5446,6 +5446,7 @@ u8 mlme_evt_hdl(struct adapter *padapter, unsigned char 
*pbuf)
 
 u8 tx_beacon_hdl(struct adapter *padapter, unsigned char *pbuf)
 {
+   struct xmit_frame *tmp;
if (send_beacon(padapter) == _FAIL) {
DBG_88E("issue_beacon, fail!\n");
return H2C_PARAMETERS_ERROR;
@@ -5469,11 +5470,8 @@ u8 tx_beacon_hdl(struct adapter *padapter, unsigned char 
*pbuf)
xmitframe_phead = get_list_head(_bmc->sleep_q);
xmitframe_plist = xmitframe_phead->next;
 
-   while (xmitframe_phead != xmitframe_plist) {
-   pxmitframe = container_of(xmitframe_plist, 
struct xmit_frame, list);
-
-   xmitframe_plist = xmitframe_plist->next;
-
+   list_for_each_entry_safe(pxmitframe, tmp,
+xmitframe_plist, list) {
list_del_init(>list);
 
psta_bmc->sleepq_len--;
-- 
2.7.4



[PATCH v2] Staging: rtl8188eu: core: rtw_mlme_ext: Use list_for_each_entry_safe

2017-10-04 Thread Srishti Sharma
This is a cleanup patch and doesn't change runtime behaviour. 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(>m)
 ...+>
}
...+>
}

Signed-off-by: Srishti Sharma 
---
Changes in v2
 -Make the commit message more clear.
 -Add file name to the subject.

 drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
index 52f31c7..4e1d06c 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
@@ -5446,6 +5446,7 @@ u8 mlme_evt_hdl(struct adapter *padapter, unsigned char 
*pbuf)
 
 u8 tx_beacon_hdl(struct adapter *padapter, unsigned char *pbuf)
 {
+   struct xmit_frame *tmp;
if (send_beacon(padapter) == _FAIL) {
DBG_88E("issue_beacon, fail!\n");
return H2C_PARAMETERS_ERROR;
@@ -5469,11 +5470,8 @@ u8 tx_beacon_hdl(struct adapter *padapter, unsigned char 
*pbuf)
xmitframe_phead = get_list_head(_bmc->sleep_q);
xmitframe_plist = xmitframe_phead->next;
 
-   while (xmitframe_phead != xmitframe_plist) {
-   pxmitframe = container_of(xmitframe_plist, 
struct xmit_frame, list);
-
-   xmitframe_plist = xmitframe_plist->next;
-
+   list_for_each_entry_safe(pxmitframe, tmp,
+xmitframe_plist, list) {
list_del_init(>list);
 
psta_bmc->sleepq_len--;
-- 
2.7.4



[PATCH v2] Staging: rtl8188eu: core: rtw_xmit: Use list_for_each_entry_safe

2017-10-04 Thread Srishti Sharma
This is a cleanup patch and doesn't change runtime behaviour. 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(>m)
 ...+>
}

...+>

}

Signed-off-by: Srishti Sharma <srishtis...@gmail.com>
---
Changes in v2
 -Make commit message more clear.
 -Add file name to the subject.

 drivers/staging/rtl8188eu/core/rtw_xmit.c | 23 ++-
 1 file changed, 6 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c 
b/drivers/staging/rtl8188eu/core/rtw_xmit.c
index e8d9858..6d8820b 100644
--- a/drivers/staging/rtl8188eu/core/rtw_xmit.c
+++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c
@@ -1869,7 +1869,7 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct 
sta_info *psta)
u8 update_mask = 0, wmmps_ac = 0;
struct sta_info *psta_bmc;
struct list_head *xmitframe_plist, *xmitframe_phead;
-   struct xmit_frame *pxmitframe = NULL;
+   struct xmit_frame *pxmitframe = NULL, *tmp;
struct sta_priv *pstapriv = >stapriv;
 
spin_lock_bh(>sleep_q.lock);
@@ -1877,11 +1877,7 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct 
sta_info *psta)
xmitframe_phead = get_list_head(>sleep_q);
xmitframe_plist = xmitframe_phead->next;
 
-   while (xmitframe_phead != xmitframe_plist) {
-   pxmitframe = container_of(xmitframe_plist, struct xmit_frame, 
list);
-
-   xmitframe_plist = xmitframe_plist->next;
-
+   list_for_each_entry_safe(pxmitframe, tmp, xmitframe_plist, list) {
list_del_init(>list);
 
switch (pxmitframe->attrib.priority) {
@@ -1958,11 +1954,8 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct 
sta_info *psta)
xmitframe_phead = get_list_head(_bmc->sleep_q);
xmitframe_plist = xmitframe_phead->next;
 
-   while (xmitframe_phead != xmitframe_plist) {
-   pxmitframe = container_of(xmitframe_plist, struct 
xmit_frame, list);
-
-   xmitframe_plist = xmitframe_plist->next;
-
+   list_for_each_entry_safe(pxmitframe, tmp, xmitframe_plist,
+list) {
list_del_init(>list);
 
psta_bmc->sleepq_len--;
@@ -1997,7 +1990,7 @@ void xmit_delivery_enabled_frames(struct adapter 
*padapter, struct sta_info *pst
 {
u8 wmmps_ac = 0;
struct list_head *xmitframe_plist, *xmitframe_phead;
-   struct xmit_frame *pxmitframe = NULL;
+   struct xmit_frame *pxmitframe = NULL, *tmp;
struct sta_priv *pstapriv = >stapriv;
 
spin_lock_bh(>sleep_q.lock);
@@ -2005,11 +1998,7 @@ void xmit_delivery_enabled_frames(struct adapter 
*padapter, struct sta_info *pst
xmitframe_phead = get_list_head(>sleep_q);
xmitframe_plist = xmitframe_phead->next;
 
-   while (xmitframe_phead != xmitframe_plist) {
-   pxmitframe = container_of(xmitframe_plist, struct xmit_frame, 
list);
-
-   xmitframe_plist = xmitframe_plist->next;
-
+   list_for_each_entry_safe(pxmitframe, tmp, xmitframe_plist, list) {
switch (pxmitframe->attrib.priority) {
case 1:
case 2:
-- 
2.7.4



[PATCH v2] Staging: rtl8188eu: core: rtw_xmit: Use list_for_each_entry_safe

2017-10-04 Thread Srishti Sharma
This is a cleanup patch and doesn't change runtime behaviour. 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(>m)
 ...+>
}

...+>

}

Signed-off-by: Srishti Sharma 
---
Changes in v2
 -Make commit message more clear.
 -Add file name to the subject.

 drivers/staging/rtl8188eu/core/rtw_xmit.c | 23 ++-
 1 file changed, 6 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c 
b/drivers/staging/rtl8188eu/core/rtw_xmit.c
index e8d9858..6d8820b 100644
--- a/drivers/staging/rtl8188eu/core/rtw_xmit.c
+++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c
@@ -1869,7 +1869,7 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct 
sta_info *psta)
u8 update_mask = 0, wmmps_ac = 0;
struct sta_info *psta_bmc;
struct list_head *xmitframe_plist, *xmitframe_phead;
-   struct xmit_frame *pxmitframe = NULL;
+   struct xmit_frame *pxmitframe = NULL, *tmp;
struct sta_priv *pstapriv = >stapriv;
 
spin_lock_bh(>sleep_q.lock);
@@ -1877,11 +1877,7 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct 
sta_info *psta)
xmitframe_phead = get_list_head(>sleep_q);
xmitframe_plist = xmitframe_phead->next;
 
-   while (xmitframe_phead != xmitframe_plist) {
-   pxmitframe = container_of(xmitframe_plist, struct xmit_frame, 
list);
-
-   xmitframe_plist = xmitframe_plist->next;
-
+   list_for_each_entry_safe(pxmitframe, tmp, xmitframe_plist, list) {
list_del_init(>list);
 
switch (pxmitframe->attrib.priority) {
@@ -1958,11 +1954,8 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct 
sta_info *psta)
xmitframe_phead = get_list_head(_bmc->sleep_q);
xmitframe_plist = xmitframe_phead->next;
 
-   while (xmitframe_phead != xmitframe_plist) {
-   pxmitframe = container_of(xmitframe_plist, struct 
xmit_frame, list);
-
-   xmitframe_plist = xmitframe_plist->next;
-
+   list_for_each_entry_safe(pxmitframe, tmp, xmitframe_plist,
+list) {
list_del_init(>list);
 
psta_bmc->sleepq_len--;
@@ -1997,7 +1990,7 @@ void xmit_delivery_enabled_frames(struct adapter 
*padapter, struct sta_info *pst
 {
u8 wmmps_ac = 0;
struct list_head *xmitframe_plist, *xmitframe_phead;
-   struct xmit_frame *pxmitframe = NULL;
+   struct xmit_frame *pxmitframe = NULL, *tmp;
struct sta_priv *pstapriv = >stapriv;
 
spin_lock_bh(>sleep_q.lock);
@@ -2005,11 +1998,7 @@ void xmit_delivery_enabled_frames(struct adapter 
*padapter, struct sta_info *pst
xmitframe_phead = get_list_head(>sleep_q);
xmitframe_plist = xmitframe_phead->next;
 
-   while (xmitframe_phead != xmitframe_plist) {
-   pxmitframe = container_of(xmitframe_plist, struct xmit_frame, 
list);
-
-   xmitframe_plist = xmitframe_plist->next;
-
+   list_for_each_entry_safe(pxmitframe, tmp, xmitframe_plist, list) {
switch (pxmitframe->attrib.priority) {
case 1:
case 2:
-- 
2.7.4



[PATCH v2] Staging: rtl8188eu: core: rtw_ap: Use list_for_each_entry_safe

2017-10-04 Thread Srishti Sharma
This is a cleanup patch and doesn't change runtime behaviour. 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(>m)
 ...+>
}
...+>

}

Signed-off-by: Srishti Sharma <srishtis...@gmail.com>
---
Changes in v2
 -Make commit message more clear.
 -Add file name to the subject.

 drivers/staging/rtl8188eu/core/rtw_ap.c | 12 +++-
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c 
b/drivers/staging/rtl8188eu/core/rtw_ap.c
index a2c599f..551af9e 100644
--- a/drivers/staging/rtl8188eu/core/rtw_ap.c
+++ b/drivers/staging/rtl8188eu/core/rtw_ap.c
@@ -280,7 +280,7 @@ voidexpire_timeout_chk(struct adapter *padapter)
 {
struct list_head *phead, *plist;
u8 updated = 0;
-   struct sta_info *psta = NULL;
+   struct sta_info *psta = NULL, *tmp;
struct sta_priv *pstapriv = >stapriv;
u8 chk_alive_num = 0;
char chk_alive_list[NUM_STA];
@@ -292,10 +292,7 @@ void   expire_timeout_chk(struct adapter *padapter)
plist = phead->next;
 
/* check auth_queue */
-   while (phead != plist) {
-   psta = container_of(plist, struct sta_info, auth_list);
-   plist = plist->next;
-
+   list_for_each_entry_safe(psta, tmp, plist, auth_list) {
if (psta->expire_to > 0) {
psta->expire_to--;
if (psta->expire_to == 0) {
@@ -326,10 +323,7 @@ void   expire_timeout_chk(struct adapter *padapter)
plist = phead->next;
 
/* check 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) {
if (chk_sta_is_alive(psta) || !psta->expire_to) {
psta->expire_to = pstapriv->expire_to;
psta->keep_alive_trycnt = 0;
-- 
2.7.4



[PATCH v2] Staging: rtl8188eu: core: rtw_ap: Use list_for_each_entry_safe

2017-10-04 Thread Srishti Sharma
This is a cleanup patch and doesn't change runtime behaviour. 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(>m)
 ...+>
}
...+>

}

Signed-off-by: Srishti Sharma 
---
Changes in v2
 -Make commit message more clear.
 -Add file name to the subject.

 drivers/staging/rtl8188eu/core/rtw_ap.c | 12 +++-
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c 
b/drivers/staging/rtl8188eu/core/rtw_ap.c
index a2c599f..551af9e 100644
--- a/drivers/staging/rtl8188eu/core/rtw_ap.c
+++ b/drivers/staging/rtl8188eu/core/rtw_ap.c
@@ -280,7 +280,7 @@ voidexpire_timeout_chk(struct adapter *padapter)
 {
struct list_head *phead, *plist;
u8 updated = 0;
-   struct sta_info *psta = NULL;
+   struct sta_info *psta = NULL, *tmp;
struct sta_priv *pstapriv = >stapriv;
u8 chk_alive_num = 0;
char chk_alive_list[NUM_STA];
@@ -292,10 +292,7 @@ void   expire_timeout_chk(struct adapter *padapter)
plist = phead->next;
 
/* check auth_queue */
-   while (phead != plist) {
-   psta = container_of(plist, struct sta_info, auth_list);
-   plist = plist->next;
-
+   list_for_each_entry_safe(psta, tmp, plist, auth_list) {
if (psta->expire_to > 0) {
psta->expire_to--;
if (psta->expire_to == 0) {
@@ -326,10 +323,7 @@ void   expire_timeout_chk(struct adapter *padapter)
plist = phead->next;
 
/* check 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) {
if (chk_sta_is_alive(psta) || !psta->expire_to) {
psta->expire_to = pstapriv->expire_to;
psta->keep_alive_trycnt = 0;
-- 
2.7.4



Re: [Outreachy kernel] [PATCH] Staging: rtl8188eu: core: Use list_for_each_entry_safe

2017-10-04 Thread Srishti Sharma
On Wed, Oct 4, 2017 at 10:37 PM, Julia Lawall <julia.law...@lip6.fr> wrote:
>
>
> On Wed, 4 Oct 2017, Srishti Sharma wrote:
>
>> On Wed, Oct 4, 2017 at 8:38 PM, Dan Carpenter <dan.carpen...@oracle.com> 
>> wrote:
>> > On Wed, Oct 04, 2017 at 03:34:05PM +0200, Julia Lawall wrote:
>> >> Again, you have three patches on different files with the same subject
>> >> line.  You could add the file name eg rtw_ap: to the subject line to make
>> >> them unique.
>> >>
>> >
>> > And the subject needs to start with [PATCH v3] and then after the
>> > Signed off by line put:
>> Shouldn't it be only v2 as I haven't sent a v2 for this before.
>
> It should be ok.  There was a v1 that only did list_entry and where all
> the patches had the same subject, but Greg already dropped that one.

Yes, I have sent another patch where we only need to convert
container_of to list_entry, that is where there is no while loop
,since we now have much less cases of this type , I have sent only one
patch for it.

Regards,
Srishti
> julia
>
>>
>> Regards,
>> Srishti
>> >
>> > ---
>> > v2 and v3: Changes to the subjects and changelogs.
>> >
>> > regards,
>> > dan carpenter
>>


Re: [Outreachy kernel] [PATCH] Staging: rtl8188eu: core: Use list_for_each_entry_safe

2017-10-04 Thread Srishti Sharma
On Wed, Oct 4, 2017 at 10:37 PM, Julia Lawall  wrote:
>
>
> On Wed, 4 Oct 2017, Srishti Sharma wrote:
>
>> On Wed, Oct 4, 2017 at 8:38 PM, Dan Carpenter  
>> wrote:
>> > On Wed, Oct 04, 2017 at 03:34:05PM +0200, Julia Lawall wrote:
>> >> Again, you have three patches on different files with the same subject
>> >> line.  You could add the file name eg rtw_ap: to the subject line to make
>> >> them unique.
>> >>
>> >
>> > And the subject needs to start with [PATCH v3] and then after the
>> > Signed off by line put:
>> Shouldn't it be only v2 as I haven't sent a v2 for this before.
>
> It should be ok.  There was a v1 that only did list_entry and where all
> the patches had the same subject, but Greg already dropped that one.

Yes, I have sent another patch where we only need to convert
container_of to list_entry, that is where there is no while loop
,since we now have much less cases of this type , I have sent only one
patch for it.

Regards,
Srishti
> julia
>
>>
>> Regards,
>> Srishti
>> >
>> > ---
>> > v2 and v3: Changes to the subjects and changelogs.
>> >
>> > regards,
>> > dan carpenter
>>


Re: [Outreachy kernel] [PATCH] Staging: rtl8188eu: core: Use list_for_each_entry_safe

2017-10-04 Thread Srishti Sharma
On Wed, Oct 4, 2017 at 8:38 PM, Dan Carpenter  wrote:
> On Wed, Oct 04, 2017 at 03:34:05PM +0200, Julia Lawall wrote:
>> Again, you have three patches on different files with the same subject
>> line.  You could add the file name eg rtw_ap: to the subject line to make
>> them unique.
>>
>
> And the subject needs to start with [PATCH v3] and then after the
> Signed off by line put:
Shouldn't it be only v2 as I haven't sent a v2 for this before.

Regards,
Srishti
>
> ---
> v2 and v3: Changes to the subjects and changelogs.
>
> regards,
> dan carpenter


Re: [Outreachy kernel] [PATCH] Staging: rtl8188eu: core: Use list_for_each_entry_safe

2017-10-04 Thread Srishti Sharma
On Wed, Oct 4, 2017 at 8:38 PM, Dan Carpenter  wrote:
> On Wed, Oct 04, 2017 at 03:34:05PM +0200, Julia Lawall wrote:
>> Again, you have three patches on different files with the same subject
>> line.  You could add the file name eg rtw_ap: to the subject line to make
>> them unique.
>>
>
> And the subject needs to start with [PATCH v3] and then after the
> Signed off by line put:
Shouldn't it be only v2 as I haven't sent a v2 for this before.

Regards,
Srishti
>
> ---
> v2 and v3: Changes to the subjects and changelogs.
>
> regards,
> dan carpenter


Re: [Outreachy kernel] Re: [PATCH] Staging: rtl8188eu: core: Use list_for_each_entry_safe

2017-10-04 Thread Srishti Sharma
On Wed, Oct 4, 2017 at 8:11 PM, Julia Lawall <julia.law...@lip6.fr> wrote:
>
>
> On Wed, 4 Oct 2017, Dan Carpenter wrote:
>
>> On Wed, Oct 04, 2017 at 03:39:30PM +0200, Julia Lawall wrote:
>> >
>> >
>> > On Wed, 4 Oct 2017, Dan Carpenter wrote:
>> >
>> > > On Wed, Oct 04, 2017 at 01:58:32AM +0530, Srishti Sharma wrote:
>> > > > Use list_for_each_entry_safe when the list elements may get deleted
>> > > > during traversal.
>> > >
>> > > This patch is fine as a cleanup but none of these are actually buggy.
>> >
>> > I'm not sure what you are getting at with the comment.  The commit doesn't
>> > say that they were buggy.  Perhaps the commit message could have been more
>> > verbose, like "Use list operators on list_head values.
>> > List_for_each_entry_safe is needed because the list elements get deleted
>>^
>>
>> It is not *needed*, the original code works fine.  The problem with the
>> original code, is that it's ugly as sin.
>>
>> > during the traversal"?
>>
>> The changelog needs to say *why* we're applying the patch.  At first I
>> thought it was going to fix a use after free.  What I would prefer in
>> the changelog is something like:  "This patch is a cleanup and doesn't
>> change runtime behavior.  It changes an open coded list traversal to
>> use list_for_each_entry_safe."
>
> OK, Srishti, you can put that.  But change the subject lines too.
Ok will do ! Thanks again.
Regards,
Srishti
>
> julia
>
>>
>> regards,
>> dan carpenter
>>
>>
>> --
>> 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 outreachy-kernel+unsubscr...@googlegroups.com.
>> To post to this group, send email to outreachy-ker...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/outreachy-kernel/20171004144012.jciztelhwjdyzpwg%40mwanda.
>> For more options, visit https://groups.google.com/d/optout.
>>


Re: [Outreachy kernel] Re: [PATCH] Staging: rtl8188eu: core: Use list_for_each_entry_safe

2017-10-04 Thread Srishti Sharma
On Wed, Oct 4, 2017 at 8:11 PM, Julia Lawall  wrote:
>
>
> On Wed, 4 Oct 2017, Dan Carpenter wrote:
>
>> On Wed, Oct 04, 2017 at 03:39:30PM +0200, Julia Lawall wrote:
>> >
>> >
>> > On Wed, 4 Oct 2017, Dan Carpenter wrote:
>> >
>> > > On Wed, Oct 04, 2017 at 01:58:32AM +0530, Srishti Sharma wrote:
>> > > > Use list_for_each_entry_safe when the list elements may get deleted
>> > > > during traversal.
>> > >
>> > > This patch is fine as a cleanup but none of these are actually buggy.
>> >
>> > I'm not sure what you are getting at with the comment.  The commit doesn't
>> > say that they were buggy.  Perhaps the commit message could have been more
>> > verbose, like "Use list operators on list_head values.
>> > List_for_each_entry_safe is needed because the list elements get deleted
>>^
>>
>> It is not *needed*, the original code works fine.  The problem with the
>> original code, is that it's ugly as sin.
>>
>> > during the traversal"?
>>
>> The changelog needs to say *why* we're applying the patch.  At first I
>> thought it was going to fix a use after free.  What I would prefer in
>> the changelog is something like:  "This patch is a cleanup and doesn't
>> change runtime behavior.  It changes an open coded list traversal to
>> use list_for_each_entry_safe."
>
> OK, Srishti, you can put that.  But change the subject lines too.
Ok will do ! Thanks again.
Regards,
Srishti
>
> julia
>
>>
>> regards,
>> dan carpenter
>>
>>
>> --
>> 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 outreachy-kernel+unsubscr...@googlegroups.com.
>> To post to this group, send email to outreachy-ker...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/outreachy-kernel/20171004144012.jciztelhwjdyzpwg%40mwanda.
>> For more options, visit https://groups.google.com/d/optout.
>>


[PATCH] Staging: rtl8188eu: core: Use list_for_each_entry_safe

2017-10-04 Thread Srishti Sharma
Use list_for_each_entry_safe to make the code more compact. 
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(>m)
 ...+>
}
...+>
}

Signed-off-by: Srishti Sharma <srishtis...@gmail.com>
---
 drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
index 52f31c7..4e1d06c 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
@@ -5446,6 +5446,7 @@ u8 mlme_evt_hdl(struct adapter *padapter, unsigned char 
*pbuf)
 
 u8 tx_beacon_hdl(struct adapter *padapter, unsigned char *pbuf)
 {
+   struct xmit_frame *tmp;
if (send_beacon(padapter) == _FAIL) {
DBG_88E("issue_beacon, fail!\n");
return H2C_PARAMETERS_ERROR;
@@ -5469,11 +5470,8 @@ u8 tx_beacon_hdl(struct adapter *padapter, unsigned char 
*pbuf)
xmitframe_phead = get_list_head(_bmc->sleep_q);
xmitframe_plist = xmitframe_phead->next;
 
-   while (xmitframe_phead != xmitframe_plist) {
-   pxmitframe = container_of(xmitframe_plist, 
struct xmit_frame, list);
-
-   xmitframe_plist = xmitframe_plist->next;
-
+   list_for_each_entry_safe(pxmitframe, tmp,
+xmitframe_plist, list) {
list_del_init(>list);
 
psta_bmc->sleepq_len--;
-- 
2.7.4



[PATCH] Staging: rtl8188eu: core: Use list_for_each_entry_safe

2017-10-04 Thread Srishti Sharma
Use list_for_each_entry_safe to make the code more compact. 
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(>m)
 ...+>
}
...+>
}

Signed-off-by: Srishti Sharma 
---
 drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
index 52f31c7..4e1d06c 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
@@ -5446,6 +5446,7 @@ u8 mlme_evt_hdl(struct adapter *padapter, unsigned char 
*pbuf)
 
 u8 tx_beacon_hdl(struct adapter *padapter, unsigned char *pbuf)
 {
+   struct xmit_frame *tmp;
if (send_beacon(padapter) == _FAIL) {
DBG_88E("issue_beacon, fail!\n");
return H2C_PARAMETERS_ERROR;
@@ -5469,11 +5470,8 @@ u8 tx_beacon_hdl(struct adapter *padapter, unsigned char 
*pbuf)
xmitframe_phead = get_list_head(_bmc->sleep_q);
xmitframe_plist = xmitframe_phead->next;
 
-   while (xmitframe_phead != xmitframe_plist) {
-   pxmitframe = container_of(xmitframe_plist, 
struct xmit_frame, list);
-
-   xmitframe_plist = xmitframe_plist->next;
-
+   list_for_each_entry_safe(pxmitframe, tmp,
+xmitframe_plist, list) {
list_del_init(>list);
 
psta_bmc->sleepq_len--;
-- 
2.7.4



[PATCH] Staging: rtl8188eu: core: Use list_for_each_entry_safe

2017-10-04 Thread Srishti Sharma
Use list_for_each_entry_safe to make code more compact. 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(>m)
 ...+>
}

...+>

}

Signed-off-by: Srishti Sharma <srishtis...@gmail.com>
---
 drivers/staging/rtl8188eu/core/rtw_xmit.c | 23 ++-
 1 file changed, 6 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c 
b/drivers/staging/rtl8188eu/core/rtw_xmit.c
index e8d9858..6d8820b 100644
--- a/drivers/staging/rtl8188eu/core/rtw_xmit.c
+++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c
@@ -1869,7 +1869,7 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct 
sta_info *psta)
u8 update_mask = 0, wmmps_ac = 0;
struct sta_info *psta_bmc;
struct list_head *xmitframe_plist, *xmitframe_phead;
-   struct xmit_frame *pxmitframe = NULL;
+   struct xmit_frame *pxmitframe = NULL, *tmp;
struct sta_priv *pstapriv = >stapriv;
 
spin_lock_bh(>sleep_q.lock);
@@ -1877,11 +1877,7 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct 
sta_info *psta)
xmitframe_phead = get_list_head(>sleep_q);
xmitframe_plist = xmitframe_phead->next;
 
-   while (xmitframe_phead != xmitframe_plist) {
-   pxmitframe = container_of(xmitframe_plist, struct xmit_frame, 
list);
-
-   xmitframe_plist = xmitframe_plist->next;
-
+   list_for_each_entry_safe(pxmitframe, tmp, xmitframe_plist, list) {
list_del_init(>list);
 
switch (pxmitframe->attrib.priority) {
@@ -1958,11 +1954,8 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct 
sta_info *psta)
xmitframe_phead = get_list_head(_bmc->sleep_q);
xmitframe_plist = xmitframe_phead->next;
 
-   while (xmitframe_phead != xmitframe_plist) {
-   pxmitframe = container_of(xmitframe_plist, struct 
xmit_frame, list);
-
-   xmitframe_plist = xmitframe_plist->next;
-
+   list_for_each_entry_safe(pxmitframe, tmp, xmitframe_plist,
+list) {
list_del_init(>list);
 
psta_bmc->sleepq_len--;
@@ -1997,7 +1990,7 @@ void xmit_delivery_enabled_frames(struct adapter 
*padapter, struct sta_info *pst
 {
u8 wmmps_ac = 0;
struct list_head *xmitframe_plist, *xmitframe_phead;
-   struct xmit_frame *pxmitframe = NULL;
+   struct xmit_frame *pxmitframe = NULL, *tmp;
struct sta_priv *pstapriv = >stapriv;
 
spin_lock_bh(>sleep_q.lock);
@@ -2005,11 +1998,7 @@ void xmit_delivery_enabled_frames(struct adapter 
*padapter, struct sta_info *pst
xmitframe_phead = get_list_head(>sleep_q);
xmitframe_plist = xmitframe_phead->next;
 
-   while (xmitframe_phead != xmitframe_plist) {
-   pxmitframe = container_of(xmitframe_plist, struct xmit_frame, 
list);
-
-   xmitframe_plist = xmitframe_plist->next;
-
+   list_for_each_entry_safe(pxmitframe, tmp, xmitframe_plist, list) {
switch (pxmitframe->attrib.priority) {
case 1:
case 2:
-- 
2.7.4



[PATCH] Staging: rtl8188eu: core: Use list_for_each_entry_safe

2017-10-04 Thread Srishti Sharma
Use list_for_each_entry_safe to make code more compact. 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(>m)
 ...+>
}

...+>

}

Signed-off-by: Srishti Sharma 
---
 drivers/staging/rtl8188eu/core/rtw_xmit.c | 23 ++-
 1 file changed, 6 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c 
b/drivers/staging/rtl8188eu/core/rtw_xmit.c
index e8d9858..6d8820b 100644
--- a/drivers/staging/rtl8188eu/core/rtw_xmit.c
+++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c
@@ -1869,7 +1869,7 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct 
sta_info *psta)
u8 update_mask = 0, wmmps_ac = 0;
struct sta_info *psta_bmc;
struct list_head *xmitframe_plist, *xmitframe_phead;
-   struct xmit_frame *pxmitframe = NULL;
+   struct xmit_frame *pxmitframe = NULL, *tmp;
struct sta_priv *pstapriv = >stapriv;
 
spin_lock_bh(>sleep_q.lock);
@@ -1877,11 +1877,7 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct 
sta_info *psta)
xmitframe_phead = get_list_head(>sleep_q);
xmitframe_plist = xmitframe_phead->next;
 
-   while (xmitframe_phead != xmitframe_plist) {
-   pxmitframe = container_of(xmitframe_plist, struct xmit_frame, 
list);
-
-   xmitframe_plist = xmitframe_plist->next;
-
+   list_for_each_entry_safe(pxmitframe, tmp, xmitframe_plist, list) {
list_del_init(>list);
 
switch (pxmitframe->attrib.priority) {
@@ -1958,11 +1954,8 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct 
sta_info *psta)
xmitframe_phead = get_list_head(_bmc->sleep_q);
xmitframe_plist = xmitframe_phead->next;
 
-   while (xmitframe_phead != xmitframe_plist) {
-   pxmitframe = container_of(xmitframe_plist, struct 
xmit_frame, list);
-
-   xmitframe_plist = xmitframe_plist->next;
-
+   list_for_each_entry_safe(pxmitframe, tmp, xmitframe_plist,
+list) {
list_del_init(>list);
 
psta_bmc->sleepq_len--;
@@ -1997,7 +1990,7 @@ void xmit_delivery_enabled_frames(struct adapter 
*padapter, struct sta_info *pst
 {
u8 wmmps_ac = 0;
struct list_head *xmitframe_plist, *xmitframe_phead;
-   struct xmit_frame *pxmitframe = NULL;
+   struct xmit_frame *pxmitframe = NULL, *tmp;
struct sta_priv *pstapriv = >stapriv;
 
spin_lock_bh(>sleep_q.lock);
@@ -2005,11 +1998,7 @@ void xmit_delivery_enabled_frames(struct adapter 
*padapter, struct sta_info *pst
xmitframe_phead = get_list_head(>sleep_q);
xmitframe_plist = xmitframe_phead->next;
 
-   while (xmitframe_phead != xmitframe_plist) {
-   pxmitframe = container_of(xmitframe_plist, struct xmit_frame, 
list);
-
-   xmitframe_plist = xmitframe_plist->next;
-
+   list_for_each_entry_safe(pxmitframe, tmp, xmitframe_plist, list) {
switch (pxmitframe->attrib.priority) {
case 1:
case 2:
-- 
2.7.4



[PATCH] Staging: rtl8188eu: core: Use list_for_each_entry_safe

2017-10-04 Thread Srishti Sharma
Use list_for_each_entry_safe to make the code more compact. Done 
by 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(>m)
 ...+>
}
...+>

}

Signed-off-by: Srishti Sharma <srishtis...@gmail.com>
---
 drivers/staging/rtl8188eu/core/rtw_ap.c | 12 +++-
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c 
b/drivers/staging/rtl8188eu/core/rtw_ap.c
index a2c599f..551af9e 100644
--- a/drivers/staging/rtl8188eu/core/rtw_ap.c
+++ b/drivers/staging/rtl8188eu/core/rtw_ap.c
@@ -280,7 +280,7 @@ voidexpire_timeout_chk(struct adapter *padapter)
 {
struct list_head *phead, *plist;
u8 updated = 0;
-   struct sta_info *psta = NULL;
+   struct sta_info *psta = NULL, *tmp;
struct sta_priv *pstapriv = >stapriv;
u8 chk_alive_num = 0;
char chk_alive_list[NUM_STA];
@@ -292,10 +292,7 @@ void   expire_timeout_chk(struct adapter *padapter)
plist = phead->next;
 
/* check auth_queue */
-   while (phead != plist) {
-   psta = container_of(plist, struct sta_info, auth_list);
-   plist = plist->next;
-
+   list_for_each_entry_safe(psta, tmp, plist, auth_list) {
if (psta->expire_to > 0) {
psta->expire_to--;
if (psta->expire_to == 0) {
@@ -326,10 +323,7 @@ void   expire_timeout_chk(struct adapter *padapter)
plist = phead->next;
 
/* check 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) {
if (chk_sta_is_alive(psta) || !psta->expire_to) {
psta->expire_to = pstapriv->expire_to;
psta->keep_alive_trycnt = 0;
-- 
2.7.4



[PATCH] Staging: rtl8188eu: core: Use list_for_each_entry_safe

2017-10-04 Thread Srishti Sharma
Use list_for_each_entry_safe to make the code more compact. Done 
by 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(>m)
 ...+>
}
...+>

}

Signed-off-by: Srishti Sharma 
---
 drivers/staging/rtl8188eu/core/rtw_ap.c | 12 +++-
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c 
b/drivers/staging/rtl8188eu/core/rtw_ap.c
index a2c599f..551af9e 100644
--- a/drivers/staging/rtl8188eu/core/rtw_ap.c
+++ b/drivers/staging/rtl8188eu/core/rtw_ap.c
@@ -280,7 +280,7 @@ voidexpire_timeout_chk(struct adapter *padapter)
 {
struct list_head *phead, *plist;
u8 updated = 0;
-   struct sta_info *psta = NULL;
+   struct sta_info *psta = NULL, *tmp;
struct sta_priv *pstapriv = >stapriv;
u8 chk_alive_num = 0;
char chk_alive_list[NUM_STA];
@@ -292,10 +292,7 @@ void   expire_timeout_chk(struct adapter *padapter)
plist = phead->next;
 
/* check auth_queue */
-   while (phead != plist) {
-   psta = container_of(plist, struct sta_info, auth_list);
-   plist = plist->next;
-
+   list_for_each_entry_safe(psta, tmp, plist, auth_list) {
if (psta->expire_to > 0) {
psta->expire_to--;
if (psta->expire_to == 0) {
@@ -326,10 +323,7 @@ void   expire_timeout_chk(struct adapter *padapter)
plist = phead->next;
 
/* check 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) {
if (chk_sta_is_alive(psta) || !psta->expire_to) {
psta->expire_to = pstapriv->expire_to;
psta->keep_alive_trycnt = 0;
-- 
2.7.4



[PATCH] Staging: rtl8188eu: core: Use list_entry instead of container_of

2017-10-04 Thread Srishti Sharma
For variables of the struct list_head* use list_entry to access
current list element instead of using container_of.
Done using the following semantic patch by coccinelle.

@r@
struct list_head* l;
@@

-container_of
+list_entry
   (l,...)

Signed-off-by: Srishti Sharma <srishtis...@gmail.com>
---
 drivers/staging/rtl8188eu/core/rtw_ap.c   | 4 ++--
 drivers/staging/rtl8188eu/core/rtw_mlme.c | 8 
 drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 2 +-
 drivers/staging/rtl8188eu/core/rtw_sta_mgt.c  | 8 
 drivers/staging/rtl8188eu/core/rtw_xmit.c | 8 
 5 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c 
b/drivers/staging/rtl8188eu/core/rtw_ap.c
index 551af9e..c968472 100644
--- a/drivers/staging/rtl8188eu/core/rtw_ap.c
+++ b/drivers/staging/rtl8188eu/core/rtw_ap.c
@@ -1143,7 +1143,7 @@ int rtw_acl_add_sta(struct adapter *padapter, u8 *addr)
plist = phead->next;
 
while (phead != plist) {
-   paclnode = container_of(plist, struct rtw_wlan_acl_node, list);
+   paclnode = list_entry(plist, struct rtw_wlan_acl_node, list);
plist = plist->next;
 
if (!memcmp(paclnode->addr, addr, ETH_ALEN)) {
@@ -1447,7 +1447,7 @@ void associated_clients_update(struct adapter *padapter, 
u8 updated)
 
/* check asoc_queue */
while (phead != plist) {
-   psta = container_of(plist, struct sta_info, asoc_list);
+   psta = list_entry(plist, struct sta_info, asoc_list);
 
plist = plist->next;
 
diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c 
b/drivers/staging/rtl8188eu/core/rtw_mlme.c
index b15cf17..82f25b6 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c
@@ -198,7 +198,7 @@ struct wlan_network *rtw_find_network(struct __queue 
*scanned_queue, u8 *addr)
plist = phead->next;
 
while (plist != phead) {
-   pnetwork = container_of(plist, struct wlan_network, list);
+   pnetwork = list_entry(plist, struct wlan_network, list);
if (!memcmp(addr, pnetwork->network.MacAddress, ETH_ALEN))
break;
plist = plist->next;
@@ -223,7 +223,7 @@ void rtw_free_network_queue(struct adapter *padapter, u8 
isfreeall)
plist = phead->next;
 
while (phead != plist) {
-   pnetwork = container_of(plist, struct wlan_network, list);
+   pnetwork = list_entry(plist, struct wlan_network, list);
 
plist = plist->next;
 
@@ -342,7 +342,7 @@ struct  wlan_network
*rtw_get_oldest_wlan_network(struct __queue *scanned_queue)
phead = get_list_head(scanned_queue);
 
for (plist = phead->next; plist != phead; plist = plist->next) {
-   pwlan = container_of(plist, struct wlan_network, list);
+   pwlan = list_entry(plist, struct wlan_network, list);
 
if (!pwlan->fixed) {
if (!oldest || time_after(oldest->last_scanned, 
pwlan->last_scanned))
@@ -421,7 +421,7 @@ void rtw_update_scanned_network(struct adapter *adapter, 
struct wlan_bssid_ex *t
plist = phead->next;
 
while (phead != plist) {
-   pnetwork= container_of(plist, struct wlan_network, 
list);
+   pnetwork= list_entry(plist, struct wlan_network, list);
 
if (is_same_network(&(pnetwork->network), target))
break;
diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
index 4e1d06c..6ecc871 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
@@ -1790,7 +1790,7 @@ static void issue_action_BSSCoexistPacket(struct adapter 
*padapter)
u8 *p;
struct wlan_bssid_ex *pbss_network;
 
-   pnetwork = container_of(plist, struct wlan_network, 
list);
+   pnetwork = list_entry(plist, struct wlan_network, list);
 
plist = plist->next;
 
diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c 
b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
index 2fd2a9e..21c4d38 100644
--- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
+++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
@@ -152,8 +152,8 @@ u32 _rtw_free_sta_priv(struct   sta_priv *pstapriv)
while (phead != plist) {
int i;
 
-   psta = container_of(plist, struct sta_info,
-   hash_list);
+   psta = list_entry(plist, struct sta_info,
+ ha

[PATCH] Staging: rtl8188eu: core: Use list_entry instead of container_of

2017-10-04 Thread Srishti Sharma
For variables of the struct list_head* use list_entry to access
current list element instead of using container_of.
Done using the following semantic patch by coccinelle.

@r@
struct list_head* l;
@@

-container_of
+list_entry
   (l,...)

Signed-off-by: Srishti Sharma 
---
 drivers/staging/rtl8188eu/core/rtw_ap.c   | 4 ++--
 drivers/staging/rtl8188eu/core/rtw_mlme.c | 8 
 drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 2 +-
 drivers/staging/rtl8188eu/core/rtw_sta_mgt.c  | 8 
 drivers/staging/rtl8188eu/core/rtw_xmit.c | 8 
 5 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c 
b/drivers/staging/rtl8188eu/core/rtw_ap.c
index 551af9e..c968472 100644
--- a/drivers/staging/rtl8188eu/core/rtw_ap.c
+++ b/drivers/staging/rtl8188eu/core/rtw_ap.c
@@ -1143,7 +1143,7 @@ int rtw_acl_add_sta(struct adapter *padapter, u8 *addr)
plist = phead->next;
 
while (phead != plist) {
-   paclnode = container_of(plist, struct rtw_wlan_acl_node, list);
+   paclnode = list_entry(plist, struct rtw_wlan_acl_node, list);
plist = plist->next;
 
if (!memcmp(paclnode->addr, addr, ETH_ALEN)) {
@@ -1447,7 +1447,7 @@ void associated_clients_update(struct adapter *padapter, 
u8 updated)
 
/* check asoc_queue */
while (phead != plist) {
-   psta = container_of(plist, struct sta_info, asoc_list);
+   psta = list_entry(plist, struct sta_info, asoc_list);
 
plist = plist->next;
 
diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c 
b/drivers/staging/rtl8188eu/core/rtw_mlme.c
index b15cf17..82f25b6 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c
@@ -198,7 +198,7 @@ struct wlan_network *rtw_find_network(struct __queue 
*scanned_queue, u8 *addr)
plist = phead->next;
 
while (plist != phead) {
-   pnetwork = container_of(plist, struct wlan_network, list);
+   pnetwork = list_entry(plist, struct wlan_network, list);
if (!memcmp(addr, pnetwork->network.MacAddress, ETH_ALEN))
break;
plist = plist->next;
@@ -223,7 +223,7 @@ void rtw_free_network_queue(struct adapter *padapter, u8 
isfreeall)
plist = phead->next;
 
while (phead != plist) {
-   pnetwork = container_of(plist, struct wlan_network, list);
+   pnetwork = list_entry(plist, struct wlan_network, list);
 
plist = plist->next;
 
@@ -342,7 +342,7 @@ struct  wlan_network
*rtw_get_oldest_wlan_network(struct __queue *scanned_queue)
phead = get_list_head(scanned_queue);
 
for (plist = phead->next; plist != phead; plist = plist->next) {
-   pwlan = container_of(plist, struct wlan_network, list);
+   pwlan = list_entry(plist, struct wlan_network, list);
 
if (!pwlan->fixed) {
if (!oldest || time_after(oldest->last_scanned, 
pwlan->last_scanned))
@@ -421,7 +421,7 @@ void rtw_update_scanned_network(struct adapter *adapter, 
struct wlan_bssid_ex *t
plist = phead->next;
 
while (phead != plist) {
-   pnetwork= container_of(plist, struct wlan_network, 
list);
+   pnetwork= list_entry(plist, struct wlan_network, list);
 
if (is_same_network(&(pnetwork->network), target))
break;
diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
index 4e1d06c..6ecc871 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
@@ -1790,7 +1790,7 @@ static void issue_action_BSSCoexistPacket(struct adapter 
*padapter)
u8 *p;
struct wlan_bssid_ex *pbss_network;
 
-   pnetwork = container_of(plist, struct wlan_network, 
list);
+   pnetwork = list_entry(plist, struct wlan_network, list);
 
plist = plist->next;
 
diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c 
b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
index 2fd2a9e..21c4d38 100644
--- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
+++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
@@ -152,8 +152,8 @@ u32 _rtw_free_sta_priv(struct   sta_priv *pstapriv)
while (phead != plist) {
int i;
 
-   psta = container_of(plist, struct sta_info,
-   hash_list);
+   psta = list_entry(plist, struct sta_info,
+ hash_list);
plist = plist

[PATCH] Staging: rtl8188eu: core: Use list_for_each_entry_safe

2017-10-03 Thread Srishti Sharma
Use list_for_each_entry_safe when the list elements may get deleted
during traversal. 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(>m)
 ...+>
}
...
}

Signed-off-by: Srishti Sharma <srishtis...@gmail.com>
---
 drivers/staging/rtl8188eu/core/rtw_ap.c | 22 ++
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c 
b/drivers/staging/rtl8188eu/core/rtw_ap.c
index 32a4837..a2c599f 100644
--- a/drivers/staging/rtl8188eu/core/rtw_ap.c
+++ b/drivers/staging/rtl8188eu/core/rtw_ap.c
@@ -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 = >stapriv;
struct wlan_acl_pool *pacl_list = >acl_list;
struct __queue *pacl_node_q = _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 = >stapriv;
struct mlme_ext_priv *pmlmeext = >mlmeextpriv;
struct mlme_ext_info*pmlmeinfo = >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(>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 = >stapriv;
struct mlme_priv *pmlmepriv = >mlmepriv;
@@ -1855,10 +1848,7 @@ void stop_ap_mode(struct adapter *padapter)
spin_lock_bh(_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;
 
-- 
2.7.4



[PATCH] Staging: rtl8188eu: core: Use list_for_each_entry_safe

2017-10-03 Thread Srishti Sharma
Use list_for_each_entry_safe when the list elements may get deleted
during traversal. 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(>m)
 ...+>
}
...
}

Signed-off-by: Srishti Sharma 
---
 drivers/staging/rtl8188eu/core/rtw_ap.c | 22 ++
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c 
b/drivers/staging/rtl8188eu/core/rtw_ap.c
index 32a4837..a2c599f 100644
--- a/drivers/staging/rtl8188eu/core/rtw_ap.c
+++ b/drivers/staging/rtl8188eu/core/rtw_ap.c
@@ -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 = >stapriv;
struct wlan_acl_pool *pacl_list = >acl_list;
struct __queue *pacl_node_q = _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 = >stapriv;
struct mlme_ext_priv *pmlmeext = >mlmeextpriv;
struct mlme_ext_info*pmlmeinfo = >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(>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 = >stapriv;
struct mlme_priv *pmlmepriv = >mlmepriv;
@@ -1855,10 +1848,7 @@ void stop_ap_mode(struct adapter *padapter)
spin_lock_bh(_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;
 
-- 
2.7.4



Re: [PATCH 0/6] Replace container_of with list_entry

2017-10-03 Thread Srishti Sharma
On Tue, Oct 3, 2017 at 9:44 PM, Greg KH <gre...@linuxfoundation.org> wrote:
> On Sat, Sep 30, 2017 at 12:49:00PM +0530, Srishti Sharma wrote:
>> Replaces instances of container_of with list_entry to
>> access current list element.
>>
>> Srishti Sharma (6):
>>   Staging: rtl8188eu: core: Use list_entry instead of container_of
>>   Staging: rtl8188eu: core: Use list_entry instead of container_of
>>   Staging: rtl8188eu: core: Use list_entry instead of container_of
>>   Staging: rtl8188eu: core: Use list_entry instead of container_of
>>   Staging: rtl8188eu: core: Use list_entry instead of container_of
>>   Staging: rtl8188eu: core: Use list_entry instead of container_of
>
> As Tobin said, I can't take this series for the obvious reason of the
> same subject line, yet you are doing different things in the patches.
>
> Please fix up and resend.

Yes, some of these loops are to be re written using,
list_for_each_entry_safe, so I have to fix that too and then resend
them .

Regards,
Srishti
> thanks,
>
> greg k-h


Re: [PATCH 0/6] Replace container_of with list_entry

2017-10-03 Thread Srishti Sharma
On Tue, Oct 3, 2017 at 9:44 PM, Greg KH  wrote:
> On Sat, Sep 30, 2017 at 12:49:00PM +0530, Srishti Sharma wrote:
>> Replaces instances of container_of with list_entry to
>> access current list element.
>>
>> Srishti Sharma (6):
>>   Staging: rtl8188eu: core: Use list_entry instead of container_of
>>   Staging: rtl8188eu: core: Use list_entry instead of container_of
>>   Staging: rtl8188eu: core: Use list_entry instead of container_of
>>   Staging: rtl8188eu: core: Use list_entry instead of container_of
>>   Staging: rtl8188eu: core: Use list_entry instead of container_of
>>   Staging: rtl8188eu: core: Use list_entry instead of container_of
>
> As Tobin said, I can't take this series for the obvious reason of the
> same subject line, yet you are doing different things in the patches.
>
> Please fix up and resend.

Yes, some of these loops are to be re written using,
list_for_each_entry_safe, so I have to fix that too and then resend
them .

Regards,
Srishti
> thanks,
>
> greg k-h


[PATCH 6/6] Staging: rtl8188eu: core: Use list_entry instead of container_of

2017-09-30 Thread Srishti Sharma
For variables of type struct list_head* use list_entry to access
current list element instead of using container_of. Done by the
following semantic patch by coccinelle.

@r@
struct list_head* l;
@@

-container_of
+list_entry
  (l,...)

Signed-off-by: Srishti Sharma <srishtis...@gmail.com>
---
 drivers/staging/rtl8188eu/core/rtw_xmit.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c 
b/drivers/staging/rtl8188eu/core/rtw_xmit.c
index be2f46e..29e9ee9 100644
--- a/drivers/staging/rtl8188eu/core/rtw_xmit.c
+++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c
@@ -1401,7 +1401,7 @@ void rtw_free_xmitframe_queue(struct xmit_priv 
*pxmitpriv, struct __queue *pfram
plist = phead->next;
 
while (phead != plist) {
-   pxmitframe = container_of(plist, struct xmit_frame, list);
+   pxmitframe = list_entry(plist, struct xmit_frame, list);
 
plist = plist->next;
 
@@ -1432,7 +1432,7 @@ static struct xmit_frame *dequeue_one_xmitframe(struct 
xmit_priv *pxmitpriv, str
xmitframe_plist = xmitframe_phead->next;
 
if (xmitframe_phead != xmitframe_plist) {
-   pxmitframe = container_of(xmitframe_plist, struct xmit_frame, 
list);
+   pxmitframe = list_entry(xmitframe_plist, struct xmit_frame, 
list);
 
xmitframe_plist = xmitframe_plist->next;
 
@@ -1473,7 +1473,7 @@ struct xmit_frame *rtw_dequeue_xframe(struct xmit_priv 
*pxmitpriv, struct hw_xmi
sta_plist = sta_phead->next;
 
while (sta_phead != sta_plist) {
-   ptxservq = container_of(sta_plist, struct tx_servq, 
tx_pending);
+   ptxservq = list_entry(sta_plist, struct tx_servq, 
tx_pending);
 
pframe_queue = >sta_pending;
 
@@ -1811,7 +1811,7 @@ static void dequeue_xmitframes_to_sleeping_queue(struct 
adapter *padapter, struc
plist = phead->next;
 
while (phead != plist) {
-   pxmitframe = container_of(plist, struct xmit_frame, list);
+   pxmitframe = list_entry(plist, struct xmit_frame, list);
 
plist = plist->next;
 
@@ -1878,7 +1878,7 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct 
sta_info *psta)
xmitframe_plist = xmitframe_phead->next;
 
while (xmitframe_phead != xmitframe_plist) {
-   pxmitframe = container_of(xmitframe_plist, struct xmit_frame, 
list);
+   pxmitframe = list_entry(xmitframe_plist, struct xmit_frame, 
list);
 
xmitframe_plist = xmitframe_plist->next;
 
@@ -1959,7 +1959,7 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct 
sta_info *psta)
xmitframe_plist = xmitframe_phead->next;
 
while (xmitframe_phead != xmitframe_plist) {
-   pxmitframe = container_of(xmitframe_plist, struct 
xmit_frame, list);
+   pxmitframe = list_entry(xmitframe_plist, struct 
xmit_frame, list);
 
xmitframe_plist = xmitframe_plist->next;
 
@@ -2006,7 +2006,7 @@ void xmit_delivery_enabled_frames(struct adapter 
*padapter, struct sta_info *pst
xmitframe_plist = xmitframe_phead->next;
 
while (xmitframe_phead != xmitframe_plist) {
-   pxmitframe = container_of(xmitframe_plist, struct xmit_frame, 
list);
+   pxmitframe = list_entry(xmitframe_plist, struct xmit_frame, 
list);
 
xmitframe_plist = xmitframe_plist->next;
 
-- 
2.7.4



[PATCH 6/6] Staging: rtl8188eu: core: Use list_entry instead of container_of

2017-09-30 Thread Srishti Sharma
For variables of type struct list_head* use list_entry to access
current list element instead of using container_of. Done by the
following semantic patch by coccinelle.

@r@
struct list_head* l;
@@

-container_of
+list_entry
  (l,...)

Signed-off-by: Srishti Sharma 
---
 drivers/staging/rtl8188eu/core/rtw_xmit.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c 
b/drivers/staging/rtl8188eu/core/rtw_xmit.c
index be2f46e..29e9ee9 100644
--- a/drivers/staging/rtl8188eu/core/rtw_xmit.c
+++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c
@@ -1401,7 +1401,7 @@ void rtw_free_xmitframe_queue(struct xmit_priv 
*pxmitpriv, struct __queue *pfram
plist = phead->next;
 
while (phead != plist) {
-   pxmitframe = container_of(plist, struct xmit_frame, list);
+   pxmitframe = list_entry(plist, struct xmit_frame, list);
 
plist = plist->next;
 
@@ -1432,7 +1432,7 @@ static struct xmit_frame *dequeue_one_xmitframe(struct 
xmit_priv *pxmitpriv, str
xmitframe_plist = xmitframe_phead->next;
 
if (xmitframe_phead != xmitframe_plist) {
-   pxmitframe = container_of(xmitframe_plist, struct xmit_frame, 
list);
+   pxmitframe = list_entry(xmitframe_plist, struct xmit_frame, 
list);
 
xmitframe_plist = xmitframe_plist->next;
 
@@ -1473,7 +1473,7 @@ struct xmit_frame *rtw_dequeue_xframe(struct xmit_priv 
*pxmitpriv, struct hw_xmi
sta_plist = sta_phead->next;
 
while (sta_phead != sta_plist) {
-   ptxservq = container_of(sta_plist, struct tx_servq, 
tx_pending);
+   ptxservq = list_entry(sta_plist, struct tx_servq, 
tx_pending);
 
pframe_queue = >sta_pending;
 
@@ -1811,7 +1811,7 @@ static void dequeue_xmitframes_to_sleeping_queue(struct 
adapter *padapter, struc
plist = phead->next;
 
while (phead != plist) {
-   pxmitframe = container_of(plist, struct xmit_frame, list);
+   pxmitframe = list_entry(plist, struct xmit_frame, list);
 
plist = plist->next;
 
@@ -1878,7 +1878,7 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct 
sta_info *psta)
xmitframe_plist = xmitframe_phead->next;
 
while (xmitframe_phead != xmitframe_plist) {
-   pxmitframe = container_of(xmitframe_plist, struct xmit_frame, 
list);
+   pxmitframe = list_entry(xmitframe_plist, struct xmit_frame, 
list);
 
xmitframe_plist = xmitframe_plist->next;
 
@@ -1959,7 +1959,7 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct 
sta_info *psta)
xmitframe_plist = xmitframe_phead->next;
 
while (xmitframe_phead != xmitframe_plist) {
-   pxmitframe = container_of(xmitframe_plist, struct 
xmit_frame, list);
+   pxmitframe = list_entry(xmitframe_plist, struct 
xmit_frame, list);
 
xmitframe_plist = xmitframe_plist->next;
 
@@ -2006,7 +2006,7 @@ void xmit_delivery_enabled_frames(struct adapter 
*padapter, struct sta_info *pst
xmitframe_plist = xmitframe_phead->next;
 
while (xmitframe_phead != xmitframe_plist) {
-   pxmitframe = container_of(xmitframe_plist, struct xmit_frame, 
list);
+   pxmitframe = list_entry(xmitframe_plist, struct xmit_frame, 
list);
 
xmitframe_plist = xmitframe_plist->next;
 
-- 
2.7.4



[PATCH 5/6] Staging: rtl8188eu: core: Use list_entry instead of container_of

2017-09-30 Thread Srishti Sharma
For variables of type struct list_head* use list_entry to access
current list element instead of using container_of. Done using
the following semantic patch by coccinelle.

@r@
struct list_head* l;
@@

-container_of
+list_entry
   (l,...)

Signed-off-by: Srishti Sharma <srishtis...@gmail.com>
---
 drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
index 611c940..80fe6ae 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
@@ -1790,7 +1790,7 @@ static void issue_action_BSSCoexistPacket(struct adapter 
*padapter)
u8 *p;
struct wlan_bssid_ex *pbss_network;
 
-   pnetwork = container_of(plist, struct wlan_network, 
list);
+   pnetwork = list_entry(plist, struct wlan_network, list);
 
plist = plist->next;
 
@@ -5470,7 +5470,7 @@ u8 tx_beacon_hdl(struct adapter *padapter, unsigned char 
*pbuf)
xmitframe_plist = xmitframe_phead->next;
 
while (xmitframe_phead != xmitframe_plist) {
-   pxmitframe = container_of(xmitframe_plist, 
struct xmit_frame, list);
+   pxmitframe = list_entry(xmitframe_plist, struct 
xmit_frame, list);
 
xmitframe_plist = xmitframe_plist->next;
 
-- 
2.7.4



[PATCH 5/6] Staging: rtl8188eu: core: Use list_entry instead of container_of

2017-09-30 Thread Srishti Sharma
For variables of type struct list_head* use list_entry to access
current list element instead of using container_of. Done using
the following semantic patch by coccinelle.

@r@
struct list_head* l;
@@

-container_of
+list_entry
   (l,...)

Signed-off-by: Srishti Sharma 
---
 drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
index 611c940..80fe6ae 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
@@ -1790,7 +1790,7 @@ static void issue_action_BSSCoexistPacket(struct adapter 
*padapter)
u8 *p;
struct wlan_bssid_ex *pbss_network;
 
-   pnetwork = container_of(plist, struct wlan_network, 
list);
+   pnetwork = list_entry(plist, struct wlan_network, list);
 
plist = plist->next;
 
@@ -5470,7 +5470,7 @@ u8 tx_beacon_hdl(struct adapter *padapter, unsigned char 
*pbuf)
xmitframe_plist = xmitframe_phead->next;
 
while (xmitframe_phead != xmitframe_plist) {
-   pxmitframe = container_of(xmitframe_plist, 
struct xmit_frame, list);
+   pxmitframe = list_entry(xmitframe_plist, struct 
xmit_frame, list);
 
xmitframe_plist = xmitframe_plist->next;
 
-- 
2.7.4



[PATCH 4/6] Staging: rtl8188eu: core: Use list_entry instead of container_of

2017-09-30 Thread Srishti Sharma
For variables of the type struct list_head* use list_entry to access
current list element instead of using container_of. Done using the
following semantic patch by coccinelle.

@r@
struct list_head* l;
@@

-container_of
+list_entry
   (l,...)

Signed-off-by: Srishti Sharma <srishtis...@gmail.com>
---
 drivers/staging/rtl8188eu/core/rtw_ap.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c 
b/drivers/staging/rtl8188eu/core/rtw_ap.c
index 32a4837..35c03d8 100644
--- a/drivers/staging/rtl8188eu/core/rtw_ap.c
+++ b/drivers/staging/rtl8188eu/core/rtw_ap.c
@@ -293,7 +293,7 @@ voidexpire_timeout_chk(struct adapter *padapter)
 
/* check auth_queue */
while (phead != plist) {
-   psta = container_of(plist, struct sta_info, auth_list);
+   psta = list_entry(plist, struct sta_info, auth_list);
plist = plist->next;
 
if (psta->expire_to > 0) {
@@ -327,7 +327,7 @@ voidexpire_timeout_chk(struct adapter *padapter)
 
/* check asoc_queue */
while (phead != plist) {
-   psta = container_of(plist, struct sta_info, asoc_list);
+   psta = list_entry(plist, struct sta_info, asoc_list);
plist = plist->next;
 
if (chk_sta_is_alive(psta) || !psta->expire_to) {
@@ -1149,7 +1149,7 @@ int rtw_acl_add_sta(struct adapter *padapter, u8 *addr)
plist = phead->next;
 
while (phead != plist) {
-   paclnode = container_of(plist, struct rtw_wlan_acl_node, list);
+   paclnode = list_entry(plist, struct rtw_wlan_acl_node, list);
plist = plist->next;
 
if (!memcmp(paclnode->addr, addr, ETH_ALEN)) {
@@ -1209,7 +1209,7 @@ int rtw_acl_remove_sta(struct adapter *padapter, u8 *addr)
plist = phead->next;
 
while (phead != plist) {
-   paclnode = container_of(plist, struct rtw_wlan_acl_node, list);
+   paclnode = list_entry(plist, struct rtw_wlan_acl_node, list);
plist = plist->next;
 
if (!memcmp(paclnode->addr, addr, ETH_ALEN)) {
@@ -1456,7 +1456,7 @@ void associated_clients_update(struct adapter *padapter, 
u8 updated)
 
/* check asoc_queue */
while (phead != plist) {
-   psta = container_of(plist, struct sta_info, asoc_list);
+   psta = list_entry(plist, struct sta_info, asoc_list);
 
plist = plist->next;
 
@@ -1728,7 +1728,7 @@ int rtw_sta_flush(struct adapter *padapter)
 
/* free sta asoc_queue */
while (phead != plist) {
-   psta = container_of(plist, struct sta_info, asoc_list);
+   psta = list_entry(plist, struct sta_info, asoc_list);
 
plist = plist->next;
 
@@ -1856,7 +1856,7 @@ void stop_ap_mode(struct adapter *padapter)
phead = get_list_head(pacl_node_q);
plist = phead->next;
while (phead != plist) {
-   paclnode = container_of(plist, struct rtw_wlan_acl_node, list);
+   paclnode = list_entry(plist, struct rtw_wlan_acl_node, list);
plist = plist->next;
 
if (paclnode->valid) {
-- 
2.7.4



[PATCH 4/6] Staging: rtl8188eu: core: Use list_entry instead of container_of

2017-09-30 Thread Srishti Sharma
For variables of the type struct list_head* use list_entry to access
current list element instead of using container_of. Done using the
following semantic patch by coccinelle.

@r@
struct list_head* l;
@@

-container_of
+list_entry
   (l,...)

Signed-off-by: Srishti Sharma 
---
 drivers/staging/rtl8188eu/core/rtw_ap.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c 
b/drivers/staging/rtl8188eu/core/rtw_ap.c
index 32a4837..35c03d8 100644
--- a/drivers/staging/rtl8188eu/core/rtw_ap.c
+++ b/drivers/staging/rtl8188eu/core/rtw_ap.c
@@ -293,7 +293,7 @@ voidexpire_timeout_chk(struct adapter *padapter)
 
/* check auth_queue */
while (phead != plist) {
-   psta = container_of(plist, struct sta_info, auth_list);
+   psta = list_entry(plist, struct sta_info, auth_list);
plist = plist->next;
 
if (psta->expire_to > 0) {
@@ -327,7 +327,7 @@ voidexpire_timeout_chk(struct adapter *padapter)
 
/* check asoc_queue */
while (phead != plist) {
-   psta = container_of(plist, struct sta_info, asoc_list);
+   psta = list_entry(plist, struct sta_info, asoc_list);
plist = plist->next;
 
if (chk_sta_is_alive(psta) || !psta->expire_to) {
@@ -1149,7 +1149,7 @@ int rtw_acl_add_sta(struct adapter *padapter, u8 *addr)
plist = phead->next;
 
while (phead != plist) {
-   paclnode = container_of(plist, struct rtw_wlan_acl_node, list);
+   paclnode = list_entry(plist, struct rtw_wlan_acl_node, list);
plist = plist->next;
 
if (!memcmp(paclnode->addr, addr, ETH_ALEN)) {
@@ -1209,7 +1209,7 @@ int rtw_acl_remove_sta(struct adapter *padapter, u8 *addr)
plist = phead->next;
 
while (phead != plist) {
-   paclnode = container_of(plist, struct rtw_wlan_acl_node, list);
+   paclnode = list_entry(plist, struct rtw_wlan_acl_node, list);
plist = plist->next;
 
if (!memcmp(paclnode->addr, addr, ETH_ALEN)) {
@@ -1456,7 +1456,7 @@ void associated_clients_update(struct adapter *padapter, 
u8 updated)
 
/* check asoc_queue */
while (phead != plist) {
-   psta = container_of(plist, struct sta_info, asoc_list);
+   psta = list_entry(plist, struct sta_info, asoc_list);
 
plist = plist->next;
 
@@ -1728,7 +1728,7 @@ int rtw_sta_flush(struct adapter *padapter)
 
/* free sta asoc_queue */
while (phead != plist) {
-   psta = container_of(plist, struct sta_info, asoc_list);
+   psta = list_entry(plist, struct sta_info, asoc_list);
 
plist = plist->next;
 
@@ -1856,7 +1856,7 @@ void stop_ap_mode(struct adapter *padapter)
phead = get_list_head(pacl_node_q);
plist = phead->next;
while (phead != plist) {
-   paclnode = container_of(plist, struct rtw_wlan_acl_node, list);
+   paclnode = list_entry(plist, struct rtw_wlan_acl_node, list);
plist = plist->next;
 
if (paclnode->valid) {
-- 
2.7.4



[PATCH 3/6] Staging: rtl8188eu: core: Use list_entry instead of container_of

2017-09-30 Thread Srishti Sharma
For variables of the type struct list_head* use list_entry to access
current list element instead of using container_of.
Done using the following semantic patch by coccinelle.

@r@
struct list_head* l;
@@

-container_of
+list_entry
  (l,...)

Signed-off-by: Srishti Sharma <srishtis...@gmail.com>
---
 drivers/staging/rtl8188eu/core/rtw_mlme.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c 
b/drivers/staging/rtl8188eu/core/rtw_mlme.c
index f663e6c..71b1f8a 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c
@@ -198,7 +198,7 @@ struct wlan_network *rtw_find_network(struct __queue 
*scanned_queue, u8 *addr)
plist = phead->next;
 
while (plist != phead) {
-   pnetwork = container_of(plist, struct wlan_network, list);
+   pnetwork = list_entry(plist, struct wlan_network, list);
if (!memcmp(addr, pnetwork->network.MacAddress, ETH_ALEN))
break;
plist = plist->next;
@@ -223,7 +223,7 @@ void rtw_free_network_queue(struct adapter *padapter, u8 
isfreeall)
plist = phead->next;
 
while (phead != plist) {
-   pnetwork = container_of(plist, struct wlan_network, list);
+   pnetwork = list_entry(plist, struct wlan_network, list);
 
plist = plist->next;
 
@@ -342,7 +342,7 @@ struct  wlan_network
*rtw_get_oldest_wlan_network(struct __queue *scanned_queue)
phead = get_list_head(scanned_queue);
 
for (plist = phead->next; plist != phead; plist = plist->next) {
-   pwlan = container_of(plist, struct wlan_network, list);
+   pwlan = list_entry(plist, struct wlan_network, list);
 
if (!pwlan->fixed) {
if (!oldest || time_after(oldest->last_scanned, 
pwlan->last_scanned))
@@ -421,7 +421,7 @@ void rtw_update_scanned_network(struct adapter *adapter, 
struct wlan_bssid_ex *t
plist = phead->next;
 
while (phead != plist) {
-   pnetwork= container_of(plist, struct wlan_network, 
list);
+   pnetwork= list_entry(plist, struct wlan_network, list);
 
if (is_same_network(&(pnetwork->network), target))
break;
-- 
2.7.4



[PATCH 3/6] Staging: rtl8188eu: core: Use list_entry instead of container_of

2017-09-30 Thread Srishti Sharma
For variables of the type struct list_head* use list_entry to access
current list element instead of using container_of.
Done using the following semantic patch by coccinelle.

@r@
struct list_head* l;
@@

-container_of
+list_entry
  (l,...)

Signed-off-by: Srishti Sharma 
---
 drivers/staging/rtl8188eu/core/rtw_mlme.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c 
b/drivers/staging/rtl8188eu/core/rtw_mlme.c
index f663e6c..71b1f8a 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c
@@ -198,7 +198,7 @@ struct wlan_network *rtw_find_network(struct __queue 
*scanned_queue, u8 *addr)
plist = phead->next;
 
while (plist != phead) {
-   pnetwork = container_of(plist, struct wlan_network, list);
+   pnetwork = list_entry(plist, struct wlan_network, list);
if (!memcmp(addr, pnetwork->network.MacAddress, ETH_ALEN))
break;
plist = plist->next;
@@ -223,7 +223,7 @@ void rtw_free_network_queue(struct adapter *padapter, u8 
isfreeall)
plist = phead->next;
 
while (phead != plist) {
-   pnetwork = container_of(plist, struct wlan_network, list);
+   pnetwork = list_entry(plist, struct wlan_network, list);
 
plist = plist->next;
 
@@ -342,7 +342,7 @@ struct  wlan_network
*rtw_get_oldest_wlan_network(struct __queue *scanned_queue)
phead = get_list_head(scanned_queue);
 
for (plist = phead->next; plist != phead; plist = plist->next) {
-   pwlan = container_of(plist, struct wlan_network, list);
+   pwlan = list_entry(plist, struct wlan_network, list);
 
if (!pwlan->fixed) {
if (!oldest || time_after(oldest->last_scanned, 
pwlan->last_scanned))
@@ -421,7 +421,7 @@ void rtw_update_scanned_network(struct adapter *adapter, 
struct wlan_bssid_ex *t
plist = phead->next;
 
while (phead != plist) {
-   pnetwork= container_of(plist, struct wlan_network, 
list);
+   pnetwork= list_entry(plist, struct wlan_network, list);
 
if (is_same_network(&(pnetwork->network), target))
break;
-- 
2.7.4



[PATCH 2/6] Staging: rtl8188eu: core: Use list_entry instead of container_of

2017-09-30 Thread Srishti Sharma
For variables of the type struct list_head use list_entry to access
current list element instead of using container_of.
Done using the following semantic patch by coccinelle.

@r@
struct list_head* l;
@@

-container_of
+list_entry
   (l,...)

Signed-off-by: Srishti Sharma <srishtis...@gmail.com>
---
 drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c 
b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
index 22cf362..f9df4ac 100644
--- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
+++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
@@ -152,8 +152,8 @@ u32 _rtw_free_sta_priv(struct   sta_priv *pstapriv)
while (phead != plist) {
int i;
 
-   psta = container_of(plist, struct sta_info,
-   hash_list);
+   psta = list_entry(plist, struct sta_info,
+ hash_list);
plist = plist->next;
 
for (i = 0; i < 16; i++) {
@@ -323,7 +323,7 @@ u32 rtw_free_stainfo(struct adapter *padapter, struct 
sta_info *psta)
plist = phead->next;
 
while (!list_empty(phead)) {
-   prframe = container_of(plist, struct recv_frame, list);
+   prframe = list_entry(plist, struct recv_frame, list);
 
plist = plist->next;
 
@@ -399,7 +399,7 @@ void rtw_free_all_stainfo(struct adapter *padapter)
plist = phead->next;
 
while (phead != plist) {
-   psta = container_of(plist, struct sta_info, hash_list);
+   psta = list_entry(plist, struct sta_info, hash_list);
 
plist = plist->next;
 
@@ -435,7 +435,7 @@ struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, 
u8 *hwaddr)
plist = phead->next;
 
while (phead != plist) {
-   psta = container_of(plist, struct sta_info, hash_list);
+   psta = list_entry(plist, struct sta_info, hash_list);
 
if ((!memcmp(psta->hwaddr, addr, ETH_ALEN)) == true) {
/*  if found the matched address */
@@ -493,7 +493,7 @@ u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr)
phead = get_list_head(pacl_node_q);
plist = phead->next;
while (phead != plist) {
-   paclnode = container_of(plist, struct rtw_wlan_acl_node, list);
+   paclnode = list_entry(plist, struct rtw_wlan_acl_node, list);
plist = plist->next;
 
if (!memcmp(paclnode->addr, mac_addr, ETH_ALEN)) {
-- 
2.7.4



[PATCH 2/6] Staging: rtl8188eu: core: Use list_entry instead of container_of

2017-09-30 Thread Srishti Sharma
For variables of the type struct list_head use list_entry to access
current list element instead of using container_of.
Done using the following semantic patch by coccinelle.

@r@
struct list_head* l;
@@

-container_of
+list_entry
   (l,...)

Signed-off-by: Srishti Sharma 
---
 drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c 
b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
index 22cf362..f9df4ac 100644
--- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
+++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
@@ -152,8 +152,8 @@ u32 _rtw_free_sta_priv(struct   sta_priv *pstapriv)
while (phead != plist) {
int i;
 
-   psta = container_of(plist, struct sta_info,
-   hash_list);
+   psta = list_entry(plist, struct sta_info,
+ hash_list);
plist = plist->next;
 
for (i = 0; i < 16; i++) {
@@ -323,7 +323,7 @@ u32 rtw_free_stainfo(struct adapter *padapter, struct 
sta_info *psta)
plist = phead->next;
 
while (!list_empty(phead)) {
-   prframe = container_of(plist, struct recv_frame, list);
+   prframe = list_entry(plist, struct recv_frame, list);
 
plist = plist->next;
 
@@ -399,7 +399,7 @@ void rtw_free_all_stainfo(struct adapter *padapter)
plist = phead->next;
 
while (phead != plist) {
-   psta = container_of(plist, struct sta_info, hash_list);
+   psta = list_entry(plist, struct sta_info, hash_list);
 
plist = plist->next;
 
@@ -435,7 +435,7 @@ struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, 
u8 *hwaddr)
plist = phead->next;
 
while (phead != plist) {
-   psta = container_of(plist, struct sta_info, hash_list);
+   psta = list_entry(plist, struct sta_info, hash_list);
 
if ((!memcmp(psta->hwaddr, addr, ETH_ALEN)) == true) {
/*  if found the matched address */
@@ -493,7 +493,7 @@ u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr)
phead = get_list_head(pacl_node_q);
plist = phead->next;
while (phead != plist) {
-   paclnode = container_of(plist, struct rtw_wlan_acl_node, list);
+   paclnode = list_entry(plist, struct rtw_wlan_acl_node, list);
plist = plist->next;
 
if (!memcmp(paclnode->addr, mac_addr, ETH_ALEN)) {
-- 
2.7.4



[PATCH 1/6] Staging: rtl8188eu: core: Use list_entry instead of container_of

2017-09-30 Thread Srishti Sharma
For variables of the struct list_head* use list_entry to access
current list element instead of using container_of.
Done using the following semantic patch by coccinelle.

@r@
struct list_head* l;
@@

-container_of
+list_entry
   (l,...)

Signed-off-by: Srishti Sharma <srishtis...@gmail.com>
---
 drivers/staging/rtl8188eu/core/rtw_recv.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c 
b/drivers/staging/rtl8188eu/core/rtw_recv.c
index 3fd5f41..af59c16 100644
--- a/drivers/staging/rtl8188eu/core/rtw_recv.c
+++ b/drivers/staging/rtl8188eu/core/rtw_recv.c
@@ -193,7 +193,7 @@ void rtw_free_recvframe_queue(struct __queue *pframequeue,  
struct __queue *pfre
plist = phead->next;
 
while (phead != plist) {
-   hdr = container_of(plist, struct recv_frame, list);
+   hdr = list_entry(plist, struct recv_frame, list);
 
plist = plist->next;
 
@@ -943,7 +943,7 @@ static int validate_recv_ctrl_frame(struct adapter 
*padapter,
xmitframe_plist = xmitframe_phead->next;
 
if (xmitframe_phead != xmitframe_plist) {
-   pxmitframe = container_of(xmitframe_plist, 
struct xmit_frame, list);
+   pxmitframe = list_entry(xmitframe_plist, struct 
xmit_frame, list);
 
xmitframe_plist = xmitframe_plist->next;
 
@@ -1347,7 +1347,7 @@ static struct recv_frame *recvframe_defrag(struct adapter 
*adapter,
 
phead = get_list_head(defrag_q);
plist = phead->next;
-   pfhdr = container_of(plist, struct recv_frame, list);
+   pfhdr = list_entry(plist, struct recv_frame, list);
prframe = pfhdr;
list_del_init(&(prframe->list));
 
@@ -1367,7 +1367,7 @@ static struct recv_frame *recvframe_defrag(struct adapter 
*adapter,
plist = plist->next;
 
while (phead != plist) {
-   pnfhdr = container_of(plist, struct recv_frame, list);
+   pnfhdr = list_entry(plist, struct recv_frame, list);
pnextrframe = pnfhdr;
 
/* check the fragment sequence  (2nd ~n fragment frame) */
@@ -1655,7 +1655,7 @@ static int enqueue_reorder_recvframe(struct 
recv_reorder_ctrl *preorder_ctrl,
plist = phead->next;
 
while (phead != plist) {
-   hdr = container_of(plist, struct recv_frame, list);
+   hdr = list_entry(plist, struct recv_frame, list);
pnextattrib = >attrib;
 
if (SN_LESS(pnextattrib->seq_num, pattrib->seq_num))
@@ -1690,7 +1690,7 @@ static int recv_indicatepkts_in_order(struct adapter 
*padapter, struct recv_reor
if (list_empty(phead))
return true;
 
-   prhdr = container_of(plist, struct recv_frame, list);
+   prhdr = list_entry(plist, struct recv_frame, list);
pattrib = >attrib;
preorder_ctrl->indicate_seq = pattrib->seq_num;
}
@@ -1698,7 +1698,7 @@ static int recv_indicatepkts_in_order(struct adapter 
*padapter, struct recv_reor
/*  Prepare indication list and indication. */
/*  Check if there is any packet need indicate. */
while (!list_empty(phead)) {
-   prhdr = container_of(plist, struct recv_frame, list);
+   prhdr = list_entry(plist, struct recv_frame, list);
prframe = prhdr;
pattrib = >attrib;
 
-- 
2.7.4



[PATCH 1/6] Staging: rtl8188eu: core: Use list_entry instead of container_of

2017-09-30 Thread Srishti Sharma
For variables of the struct list_head* use list_entry to access
current list element instead of using container_of.
Done using the following semantic patch by coccinelle.

@r@
struct list_head* l;
@@

-container_of
+list_entry
   (l,...)

Signed-off-by: Srishti Sharma 
---
 drivers/staging/rtl8188eu/core/rtw_recv.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c 
b/drivers/staging/rtl8188eu/core/rtw_recv.c
index 3fd5f41..af59c16 100644
--- a/drivers/staging/rtl8188eu/core/rtw_recv.c
+++ b/drivers/staging/rtl8188eu/core/rtw_recv.c
@@ -193,7 +193,7 @@ void rtw_free_recvframe_queue(struct __queue *pframequeue,  
struct __queue *pfre
plist = phead->next;
 
while (phead != plist) {
-   hdr = container_of(plist, struct recv_frame, list);
+   hdr = list_entry(plist, struct recv_frame, list);
 
plist = plist->next;
 
@@ -943,7 +943,7 @@ static int validate_recv_ctrl_frame(struct adapter 
*padapter,
xmitframe_plist = xmitframe_phead->next;
 
if (xmitframe_phead != xmitframe_plist) {
-   pxmitframe = container_of(xmitframe_plist, 
struct xmit_frame, list);
+   pxmitframe = list_entry(xmitframe_plist, struct 
xmit_frame, list);
 
xmitframe_plist = xmitframe_plist->next;
 
@@ -1347,7 +1347,7 @@ static struct recv_frame *recvframe_defrag(struct adapter 
*adapter,
 
phead = get_list_head(defrag_q);
plist = phead->next;
-   pfhdr = container_of(plist, struct recv_frame, list);
+   pfhdr = list_entry(plist, struct recv_frame, list);
prframe = pfhdr;
list_del_init(&(prframe->list));
 
@@ -1367,7 +1367,7 @@ static struct recv_frame *recvframe_defrag(struct adapter 
*adapter,
plist = plist->next;
 
while (phead != plist) {
-   pnfhdr = container_of(plist, struct recv_frame, list);
+   pnfhdr = list_entry(plist, struct recv_frame, list);
pnextrframe = pnfhdr;
 
/* check the fragment sequence  (2nd ~n fragment frame) */
@@ -1655,7 +1655,7 @@ static int enqueue_reorder_recvframe(struct 
recv_reorder_ctrl *preorder_ctrl,
plist = phead->next;
 
while (phead != plist) {
-   hdr = container_of(plist, struct recv_frame, list);
+   hdr = list_entry(plist, struct recv_frame, list);
pnextattrib = >attrib;
 
if (SN_LESS(pnextattrib->seq_num, pattrib->seq_num))
@@ -1690,7 +1690,7 @@ static int recv_indicatepkts_in_order(struct adapter 
*padapter, struct recv_reor
if (list_empty(phead))
return true;
 
-   prhdr = container_of(plist, struct recv_frame, list);
+   prhdr = list_entry(plist, struct recv_frame, list);
pattrib = >attrib;
preorder_ctrl->indicate_seq = pattrib->seq_num;
}
@@ -1698,7 +1698,7 @@ static int recv_indicatepkts_in_order(struct adapter 
*padapter, struct recv_reor
/*  Prepare indication list and indication. */
/*  Check if there is any packet need indicate. */
while (!list_empty(phead)) {
-   prhdr = container_of(plist, struct recv_frame, list);
+   prhdr = list_entry(plist, struct recv_frame, list);
prframe = prhdr;
pattrib = >attrib;
 
-- 
2.7.4



[PATCH 0/6] Replace container_of with list_entry

2017-09-30 Thread Srishti Sharma
Replaces instances of container_of with list_entry to 
access current list element.

Srishti Sharma (6):
  Staging: rtl8188eu: core: Use list_entry instead of container_of
  Staging: rtl8188eu: core: Use list_entry instead of container_of
  Staging: rtl8188eu: core: Use list_entry instead of container_of
  Staging: rtl8188eu: core: Use list_entry instead of container_of
  Staging: rtl8188eu: core: Use list_entry instead of container_of
  Staging: rtl8188eu: core: Use list_entry instead of container_of

 drivers/staging/rtl8188eu/core/rtw_ap.c   | 14 +++---
 drivers/staging/rtl8188eu/core/rtw_mlme.c |  8 
 drivers/staging/rtl8188eu/core/rtw_mlme_ext.c |  4 ++--
 drivers/staging/rtl8188eu/core/rtw_recv.c | 14 +++---
 drivers/staging/rtl8188eu/core/rtw_sta_mgt.c  | 12 ++--
 drivers/staging/rtl8188eu/core/rtw_xmit.c | 14 +++---
 6 files changed, 33 insertions(+), 33 deletions(-)

-- 
2.7.4



[PATCH 0/6] Replace container_of with list_entry

2017-09-30 Thread Srishti Sharma
Replaces instances of container_of with list_entry to 
access current list element.

Srishti Sharma (6):
  Staging: rtl8188eu: core: Use list_entry instead of container_of
  Staging: rtl8188eu: core: Use list_entry instead of container_of
  Staging: rtl8188eu: core: Use list_entry instead of container_of
  Staging: rtl8188eu: core: Use list_entry instead of container_of
  Staging: rtl8188eu: core: Use list_entry instead of container_of
  Staging: rtl8188eu: core: Use list_entry instead of container_of

 drivers/staging/rtl8188eu/core/rtw_ap.c   | 14 +++---
 drivers/staging/rtl8188eu/core/rtw_mlme.c |  8 
 drivers/staging/rtl8188eu/core/rtw_mlme_ext.c |  4 ++--
 drivers/staging/rtl8188eu/core/rtw_recv.c | 14 +++---
 drivers/staging/rtl8188eu/core/rtw_sta_mgt.c  | 12 ++--
 drivers/staging/rtl8188eu/core/rtw_xmit.c | 14 +++---
 6 files changed, 33 insertions(+), 33 deletions(-)

-- 
2.7.4



Re: [Outreachy kernel] [PATCH] Staging: rtl8188eu: core: Use list_entry instead of container_of

2017-09-30 Thread Srishti Sharma
On Sat, Sep 30, 2017 at 11:51 AM, Julia Lawall <julia.law...@lip6.fr> wrote:
>
>
> On Sat, 30 Sep 2017, Srishti Sharma wrote:
>
>> On Sat, Sep 30, 2017 at 11:36 AM, Julia Lawall <julia.law...@lip6.fr> wrote:
>> >
>> >
>> > On Sat, 30 Sep 2017, Srishti Sharma wrote:
>> >
>> >> On Sat, Sep 30, 2017 at 10:35 AM, Julia Lawall <julia.law...@lip6.fr> 
>> >> wrote:
>> >> >
>> >> >
>> >> > On Sat, 30 Sep 2017, Srishti Sharma wrote:
>> >> >
>> >> >> For variables of the type struct list_head* use list_entry to access
>> >> >> the current list element instead of using container_of.
>> >> >> Done using the following semantic patch by coccinelle.
>> >> >>
>> >> >> @r@
>> >> >> identifier e;
>> >> >> struct list_head* l;
>> >> >> @@
>> >> >>
>> >> >> <... when != l == NULL
>> >> >> l;
>> >> >> ...>
>> >> > I don't see what is the goal of the above code.  The list_head variable 
>> >> > is
>> >> > not going to be in a statement by itself.  There is also no need to 
>> >> > check
>> >> > for l being NULL.  If it is NULL, the original code is incorrect too.
>> >>
>> >> Since only those container_of are to replaced with list_entry which
>> >> have a variable of type list_head*  , I wanted to check if it occurs
>> >> anywhere before
>> >> container_of ,
>> >
>> > Why?  If it is a list, then it seems appropriate to access it using
>> > list_head.
>> >
>> >> which it only does in it's declaration , because it
>> >> can't be in any
>> >> statement by itself . I think it will be better to write .
>> >>
>> >> @r@
>> >> identifier e;
>> >> struct list_head* l;
>> >> @@
>> >>
>> >> <...
>> >> container_of(l,...);
>> >> ...>
>> >
>> > This doesn't ensure that there is a preceding container_of, if that is
>> > what you are trying to do.  The problem is that <... P ...> finds 0 or
>> > more occurrences of pattern P, not 1 or more occurrences.  1 or more
>> > occurrences is <+... P ...+>.  But it would be simpler if you want an
>> > occurrence of container_of before the thing you are transforming to put
>> >
>> > container_of(l,...);
>> > ...
>> > e = ...
>> >
>> > But this doesn't make sense either, partly because the preceding
>> > container_of is just not needed, and also because a container_of would not
>> > be in a statement by itself.  In Coccinelle, when you put a ; after
>> > something is means that the thing is a complete statement, not just the
>> > end half of a statement.
>>
>> So , I guess we can simply write.
>>
>> e =
>> -container_of
>> +list_entry
>>  (l,...)
>
> Yes.  You don't even need the e =.  As long as there is a call to
> container_of on a list_head * value, you can change it.

Okay, Thanks again :) , I'll make the changes and resend .

Regards,
Srishti
>
> julia
>
>>
>> Regards,
>> Srishti
>>
>> >
>> > julia
>> >
>> >> e =
>> >> -container_of
>> >> +list_entry
>> >>  (
>> >>   )
>> >>
>> >> >> (
>> >> >> e =
>> >> >> -container_of
>> >> >> +list_entry
>> >> >>  (
>> >> >>   ...)
>> >> >> )
>> >> >
>> >> > Here you don't need the outer ( ).  This makes a disjunction with only
>> >> > one choice.  Since there is only one choice, you don't need the
>> >> > disjunction.
>> >>
>> >> Thanks a lot , for pointing out the errors .
>> >>
>> >> Regards,
>> >> Srishti
>> >> > julia
>> >> >
>> >> >> Signed-off-by: Srishti Sharma <srishtis...@gmail.com>
>> >> >> ---
>> >> >>  drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 12 ++--
>> >> >>  1 file changed, 6 insertions(+), 6 deletions(-)
>> >> >>
>> >> >> diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c 
>> 

Re: [Outreachy kernel] [PATCH] Staging: rtl8188eu: core: Use list_entry instead of container_of

2017-09-30 Thread Srishti Sharma
On Sat, Sep 30, 2017 at 11:51 AM, Julia Lawall  wrote:
>
>
> On Sat, 30 Sep 2017, Srishti Sharma wrote:
>
>> On Sat, Sep 30, 2017 at 11:36 AM, Julia Lawall  wrote:
>> >
>> >
>> > On Sat, 30 Sep 2017, Srishti Sharma wrote:
>> >
>> >> On Sat, Sep 30, 2017 at 10:35 AM, Julia Lawall  
>> >> wrote:
>> >> >
>> >> >
>> >> > On Sat, 30 Sep 2017, Srishti Sharma wrote:
>> >> >
>> >> >> For variables of the type struct list_head* use list_entry to access
>> >> >> the current list element instead of using container_of.
>> >> >> Done using the following semantic patch by coccinelle.
>> >> >>
>> >> >> @r@
>> >> >> identifier e;
>> >> >> struct list_head* l;
>> >> >> @@
>> >> >>
>> >> >> <... when != l == NULL
>> >> >> l;
>> >> >> ...>
>> >> > I don't see what is the goal of the above code.  The list_head variable 
>> >> > is
>> >> > not going to be in a statement by itself.  There is also no need to 
>> >> > check
>> >> > for l being NULL.  If it is NULL, the original code is incorrect too.
>> >>
>> >> Since only those container_of are to replaced with list_entry which
>> >> have a variable of type list_head*  , I wanted to check if it occurs
>> >> anywhere before
>> >> container_of ,
>> >
>> > Why?  If it is a list, then it seems appropriate to access it using
>> > list_head.
>> >
>> >> which it only does in it's declaration , because it
>> >> can't be in any
>> >> statement by itself . I think it will be better to write .
>> >>
>> >> @r@
>> >> identifier e;
>> >> struct list_head* l;
>> >> @@
>> >>
>> >> <...
>> >> container_of(l,...);
>> >> ...>
>> >
>> > This doesn't ensure that there is a preceding container_of, if that is
>> > what you are trying to do.  The problem is that <... P ...> finds 0 or
>> > more occurrences of pattern P, not 1 or more occurrences.  1 or more
>> > occurrences is <+... P ...+>.  But it would be simpler if you want an
>> > occurrence of container_of before the thing you are transforming to put
>> >
>> > container_of(l,...);
>> > ...
>> > e = ...
>> >
>> > But this doesn't make sense either, partly because the preceding
>> > container_of is just not needed, and also because a container_of would not
>> > be in a statement by itself.  In Coccinelle, when you put a ; after
>> > something is means that the thing is a complete statement, not just the
>> > end half of a statement.
>>
>> So , I guess we can simply write.
>>
>> e =
>> -container_of
>> +list_entry
>>  (l,...)
>
> Yes.  You don't even need the e =.  As long as there is a call to
> container_of on a list_head * value, you can change it.

Okay, Thanks again :) , I'll make the changes and resend .

Regards,
Srishti
>
> julia
>
>>
>> Regards,
>> Srishti
>>
>> >
>> > julia
>> >
>> >> e =
>> >> -container_of
>> >> +list_entry
>> >>  (
>> >>   )
>> >>
>> >> >> (
>> >> >> e =
>> >> >> -container_of
>> >> >> +list_entry
>> >> >>  (
>> >> >>   ...)
>> >> >> )
>> >> >
>> >> > Here you don't need the outer ( ).  This makes a disjunction with only
>> >> > one choice.  Since there is only one choice, you don't need the
>> >> > disjunction.
>> >>
>> >> Thanks a lot , for pointing out the errors .
>> >>
>> >> Regards,
>> >> Srishti
>> >> > julia
>> >> >
>> >> >> Signed-off-by: Srishti Sharma 
>> >> >> ---
>> >> >>  drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 12 ++--
>> >> >>  1 file changed, 6 insertions(+), 6 deletions(-)
>> >> >>
>> >> >> diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c 
>> >> >> b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
>> >> >> index 22cf362..f9df4ac 100644
&

Re: [Outreachy kernel] [PATCH] Staging: rtl8188eu: core: Use list_entry instead of container_of

2017-09-30 Thread Srishti Sharma
On Sat, Sep 30, 2017 at 11:36 AM, Julia Lawall <julia.law...@lip6.fr> wrote:
>
>
> On Sat, 30 Sep 2017, Srishti Sharma wrote:
>
>> On Sat, Sep 30, 2017 at 10:35 AM, Julia Lawall <julia.law...@lip6.fr> wrote:
>> >
>> >
>> > On Sat, 30 Sep 2017, Srishti Sharma wrote:
>> >
>> >> For variables of the type struct list_head* use list_entry to access
>> >> the current list element instead of using container_of.
>> >> Done using the following semantic patch by coccinelle.
>> >>
>> >> @r@
>> >> identifier e;
>> >> struct list_head* l;
>> >> @@
>> >>
>> >> <... when != l == NULL
>> >> l;
>> >> ...>
>> > I don't see what is the goal of the above code.  The list_head variable is
>> > not going to be in a statement by itself.  There is also no need to check
>> > for l being NULL.  If it is NULL, the original code is incorrect too.
>>
>> Since only those container_of are to replaced with list_entry which
>> have a variable of type list_head*  , I wanted to check if it occurs
>> anywhere before
>> container_of ,
>
> Why?  If it is a list, then it seems appropriate to access it using
> list_head.
>
>> which it only does in it's declaration , because it
>> can't be in any
>> statement by itself . I think it will be better to write .
>>
>> @r@
>> identifier e;
>> struct list_head* l;
>> @@
>>
>> <...
>> container_of(l,...);
>> ...>
>
> This doesn't ensure that there is a preceding container_of, if that is
> what you are trying to do.  The problem is that <... P ...> finds 0 or
> more occurrences of pattern P, not 1 or more occurrences.  1 or more
> occurrences is <+... P ...+>.  But it would be simpler if you want an
> occurrence of container_of before the thing you are transforming to put
>
> container_of(l,...);
> ...
> e = ...
>
> But this doesn't make sense either, partly because the preceding
> container_of is just not needed, and also because a container_of would not
> be in a statement by itself.  In Coccinelle, when you put a ; after
> something is means that the thing is a complete statement, not just the
> end half of a statement.

So , I guess we can simply write.

e =
-container_of
+list_entry
 (l,...)

Regards,
Srishti

>
> julia
>
>> e =
>> -container_of
>> +list_entry
>>  (
>>   )
>>
>> >> (
>> >> e =
>> >> -container_of
>> >> +list_entry
>> >>  (
>> >>   ...)
>> >> )
>> >
>> > Here you don't need the outer ( ).  This makes a disjunction with only
>> > one choice.  Since there is only one choice, you don't need the
>> > disjunction.
>>
>> Thanks a lot , for pointing out the errors .
>>
>> Regards,
>> Srishti
>> > julia
>> >
>> >> Signed-off-by: Srishti Sharma <srishtis...@gmail.com>
>> >> ---
>> >>  drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 12 ++--
>> >>  1 file changed, 6 insertions(+), 6 deletions(-)
>> >>
>> >> diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c 
>> >> b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
>> >> index 22cf362..f9df4ac 100644
>> >> --- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
>> >> +++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
>> >> @@ -152,8 +152,8 @@ u32   _rtw_free_sta_priv(struct   sta_priv 
>> >> *pstapriv)
>> >>   while (phead != plist) {
>> >>   int i;
>> >>
>> >> - psta = container_of(plist, struct sta_info,
>> >> - hash_list);
>> >> + psta = list_entry(plist, struct sta_info,
>> >> +   hash_list);
>> >>   plist = plist->next;
>> >>
>> >>   for (i = 0; i < 16; i++) {
>> >> @@ -323,7 +323,7 @@ u32   rtw_free_stainfo(struct adapter *padapter, 
>> >> struct sta_info *psta)
>> >>   plist = phead->next;
>> >>
>> >>   while (!list_empty(phead)) {
>> >> - prframe = container_of(plist, struct recv_frame, 
>> >> list);
>> >> +   

Re: [Outreachy kernel] [PATCH] Staging: rtl8188eu: core: Use list_entry instead of container_of

2017-09-30 Thread Srishti Sharma
On Sat, Sep 30, 2017 at 11:36 AM, Julia Lawall  wrote:
>
>
> On Sat, 30 Sep 2017, Srishti Sharma wrote:
>
>> On Sat, Sep 30, 2017 at 10:35 AM, Julia Lawall  wrote:
>> >
>> >
>> > On Sat, 30 Sep 2017, Srishti Sharma wrote:
>> >
>> >> For variables of the type struct list_head* use list_entry to access
>> >> the current list element instead of using container_of.
>> >> Done using the following semantic patch by coccinelle.
>> >>
>> >> @r@
>> >> identifier e;
>> >> struct list_head* l;
>> >> @@
>> >>
>> >> <... when != l == NULL
>> >> l;
>> >> ...>
>> > I don't see what is the goal of the above code.  The list_head variable is
>> > not going to be in a statement by itself.  There is also no need to check
>> > for l being NULL.  If it is NULL, the original code is incorrect too.
>>
>> Since only those container_of are to replaced with list_entry which
>> have a variable of type list_head*  , I wanted to check if it occurs
>> anywhere before
>> container_of ,
>
> Why?  If it is a list, then it seems appropriate to access it using
> list_head.
>
>> which it only does in it's declaration , because it
>> can't be in any
>> statement by itself . I think it will be better to write .
>>
>> @r@
>> identifier e;
>> struct list_head* l;
>> @@
>>
>> <...
>> container_of(l,...);
>> ...>
>
> This doesn't ensure that there is a preceding container_of, if that is
> what you are trying to do.  The problem is that <... P ...> finds 0 or
> more occurrences of pattern P, not 1 or more occurrences.  1 or more
> occurrences is <+... P ...+>.  But it would be simpler if you want an
> occurrence of container_of before the thing you are transforming to put
>
> container_of(l,...);
> ...
> e = ...
>
> But this doesn't make sense either, partly because the preceding
> container_of is just not needed, and also because a container_of would not
> be in a statement by itself.  In Coccinelle, when you put a ; after
> something is means that the thing is a complete statement, not just the
> end half of a statement.

So , I guess we can simply write.

e =
-container_of
+list_entry
 (l,...)

Regards,
Srishti

>
> julia
>
>> e =
>> -container_of
>> +list_entry
>>  (
>>   )
>>
>> >> (
>> >> e =
>> >> -container_of
>> >> +list_entry
>> >>  (
>> >>   ...)
>> >> )
>> >
>> > Here you don't need the outer ( ).  This makes a disjunction with only
>> > one choice.  Since there is only one choice, you don't need the
>> > disjunction.
>>
>> Thanks a lot , for pointing out the errors .
>>
>> Regards,
>> Srishti
>> > julia
>> >
>> >> Signed-off-by: Srishti Sharma 
>> >> ---
>> >>  drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 12 ++--
>> >>  1 file changed, 6 insertions(+), 6 deletions(-)
>> >>
>> >> diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c 
>> >> b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
>> >> index 22cf362..f9df4ac 100644
>> >> --- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
>> >> +++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
>> >> @@ -152,8 +152,8 @@ u32   _rtw_free_sta_priv(struct   sta_priv 
>> >> *pstapriv)
>> >>   while (phead != plist) {
>> >>   int i;
>> >>
>> >> - psta = container_of(plist, struct sta_info,
>> >> - hash_list);
>> >> + psta = list_entry(plist, struct sta_info,
>> >> +   hash_list);
>> >>   plist = plist->next;
>> >>
>> >>   for (i = 0; i < 16; i++) {
>> >> @@ -323,7 +323,7 @@ u32   rtw_free_stainfo(struct adapter *padapter, 
>> >> struct sta_info *psta)
>> >>   plist = phead->next;
>> >>
>> >>   while (!list_empty(phead)) {
>> >> - prframe = container_of(plist, struct recv_frame, 
>> >> list);
>> >> + prframe = list_entry(plist, struct recv_frame, 
>> >> l

Re: [Outreachy kernel] [PATCH] Staging: rtl8188eu: core: Use list_entry instead of container_of

2017-09-30 Thread Srishti Sharma
On Sat, Sep 30, 2017 at 10:35 AM, Julia Lawall <julia.law...@lip6.fr> wrote:
>
>
> On Sat, 30 Sep 2017, Srishti Sharma wrote:
>
>> For variables of the type struct list_head* use list_entry to access
>> the current list element instead of using container_of.
>> Done using the following semantic patch by coccinelle.
>>
>> @r@
>> identifier e;
>> struct list_head* l;
>> @@
>>
>> <... when != l == NULL
>> l;
>> ...>
> I don't see what is the goal of the above code.  The list_head variable is
> not going to be in a statement by itself.  There is also no need to check
> for l being NULL.  If it is NULL, the original code is incorrect too.

Since only those container_of are to replaced with list_entry which
have a variable of type list_head*  , I wanted to check if it occurs
anywhere before
container_of , which it only does in it's declaration , because it
can't be in any
statement by itself . I think it will be better to write .

@r@
identifier e;
struct list_head* l;
@@

<...
container_of(l,...);
...>

e =
-container_of
+list_entry
 (
  )

>> (
>> e =
>> -container_of
>> +list_entry
>>  (
>>   ...)
>> )
>
> Here you don't need the outer ( ).  This makes a disjunction with only
> one choice.  Since there is only one choice, you don't need the
> disjunction.

Thanks a lot , for pointing out the errors .

Regards,
Srishti
> julia
>
>> Signed-off-by: Srishti Sharma <srishtis...@gmail.com>
>> ---
>>  drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 12 ++--
>>  1 file changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c 
>> b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
>> index 22cf362..f9df4ac 100644
>> --- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
>> +++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
>> @@ -152,8 +152,8 @@ u32   _rtw_free_sta_priv(struct   sta_priv 
>> *pstapriv)
>>   while (phead != plist) {
>>   int i;
>>
>> - psta = container_of(plist, struct sta_info,
>> - hash_list);
>> + psta = list_entry(plist, struct sta_info,
>> +   hash_list);
>>   plist = plist->next;
>>
>>   for (i = 0; i < 16; i++) {
>> @@ -323,7 +323,7 @@ u32   rtw_free_stainfo(struct adapter *padapter, 
>> struct sta_info *psta)
>>   plist = phead->next;
>>
>>   while (!list_empty(phead)) {
>> - prframe = container_of(plist, struct recv_frame, list);
>> + prframe = list_entry(plist, struct recv_frame, list);
>>
>>   plist = plist->next;
>>
>> @@ -399,7 +399,7 @@ void rtw_free_all_stainfo(struct adapter *padapter)
>>   plist = phead->next;
>>
>>   while (phead != plist) {
>> - psta = container_of(plist, struct sta_info, hash_list);
>> + psta = list_entry(plist, struct sta_info, hash_list);
>>
>>   plist = plist->next;
>>
>> @@ -435,7 +435,7 @@ struct sta_info *rtw_get_stainfo(struct sta_priv 
>> *pstapriv, u8 *hwaddr)
>>   plist = phead->next;
>>
>>   while (phead != plist) {
>> - psta = container_of(plist, struct sta_info, hash_list);
>> + psta = list_entry(plist, struct sta_info, hash_list);
>>
>>   if ((!memcmp(psta->hwaddr, addr, ETH_ALEN)) == true) {
>>   /*  if found the matched address */
>> @@ -493,7 +493,7 @@ u8 rtw_access_ctrl(struct adapter *padapter, u8 
>> *mac_addr)
>>   phead = get_list_head(pacl_node_q);
>>   plist = phead->next;
>>   while (phead != plist) {
>> - paclnode = container_of(plist, struct rtw_wlan_acl_node, list);
>> + paclnode = list_entry(plist, struct rtw_wlan_acl_node, list);
>>   plist = plist->next;
>>
>>   if (!memcmp(paclnode->addr, mac_addr, ETH_ALEN)) {
>> --
>> 2.7.4
>>
>> --
>> 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 outreachy-kernel+unsubscr...@googlegroups.com.
>> To post to this group, send email to outreachy-ker...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/outreachy-kernel/1506734581-10932-1-git-send-email-srishtishar%40gmail.com.
>> For more options, visit https://groups.google.com/d/optout.
>>


Re: [Outreachy kernel] [PATCH] Staging: rtl8188eu: core: Use list_entry instead of container_of

2017-09-30 Thread Srishti Sharma
On Sat, Sep 30, 2017 at 10:35 AM, Julia Lawall  wrote:
>
>
> On Sat, 30 Sep 2017, Srishti Sharma wrote:
>
>> For variables of the type struct list_head* use list_entry to access
>> the current list element instead of using container_of.
>> Done using the following semantic patch by coccinelle.
>>
>> @r@
>> identifier e;
>> struct list_head* l;
>> @@
>>
>> <... when != l == NULL
>> l;
>> ...>
> I don't see what is the goal of the above code.  The list_head variable is
> not going to be in a statement by itself.  There is also no need to check
> for l being NULL.  If it is NULL, the original code is incorrect too.

Since only those container_of are to replaced with list_entry which
have a variable of type list_head*  , I wanted to check if it occurs
anywhere before
container_of , which it only does in it's declaration , because it
can't be in any
statement by itself . I think it will be better to write .

@r@
identifier e;
struct list_head* l;
@@

<...
container_of(l,...);
...>

e =
-container_of
+list_entry
 (
  )

>> (
>> e =
>> -container_of
>> +list_entry
>>  (
>>   ...)
>> )
>
> Here you don't need the outer ( ).  This makes a disjunction with only
> one choice.  Since there is only one choice, you don't need the
> disjunction.

Thanks a lot , for pointing out the errors .

Regards,
Srishti
> julia
>
>> Signed-off-by: Srishti Sharma 
>> ---
>>  drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 12 ++--
>>  1 file changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c 
>> b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
>> index 22cf362..f9df4ac 100644
>> --- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
>> +++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
>> @@ -152,8 +152,8 @@ u32   _rtw_free_sta_priv(struct   sta_priv 
>> *pstapriv)
>>   while (phead != plist) {
>>   int i;
>>
>> - psta = container_of(plist, struct sta_info,
>> - hash_list);
>> + psta = list_entry(plist, struct sta_info,
>> +   hash_list);
>>   plist = plist->next;
>>
>>   for (i = 0; i < 16; i++) {
>> @@ -323,7 +323,7 @@ u32   rtw_free_stainfo(struct adapter *padapter, 
>> struct sta_info *psta)
>>   plist = phead->next;
>>
>>   while (!list_empty(phead)) {
>> - prframe = container_of(plist, struct recv_frame, list);
>> + prframe = list_entry(plist, struct recv_frame, list);
>>
>>   plist = plist->next;
>>
>> @@ -399,7 +399,7 @@ void rtw_free_all_stainfo(struct adapter *padapter)
>>   plist = phead->next;
>>
>>   while (phead != plist) {
>> - psta = container_of(plist, struct sta_info, hash_list);
>> + psta = list_entry(plist, struct sta_info, hash_list);
>>
>>   plist = plist->next;
>>
>> @@ -435,7 +435,7 @@ struct sta_info *rtw_get_stainfo(struct sta_priv 
>> *pstapriv, u8 *hwaddr)
>>   plist = phead->next;
>>
>>   while (phead != plist) {
>> - psta = container_of(plist, struct sta_info, hash_list);
>> + psta = list_entry(plist, struct sta_info, hash_list);
>>
>>   if ((!memcmp(psta->hwaddr, addr, ETH_ALEN)) == true) {
>>   /*  if found the matched address */
>> @@ -493,7 +493,7 @@ u8 rtw_access_ctrl(struct adapter *padapter, u8 
>> *mac_addr)
>>   phead = get_list_head(pacl_node_q);
>>   plist = phead->next;
>>   while (phead != plist) {
>> - paclnode = container_of(plist, struct rtw_wlan_acl_node, list);
>> + paclnode = list_entry(plist, struct rtw_wlan_acl_node, list);
>>   plist = plist->next;
>>
>>   if (!memcmp(paclnode->addr, mac_addr, ETH_ALEN)) {
>> --
>> 2.7.4
>>
>> --
>> 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 outreachy-kernel+unsubscr...@googlegroups.com.
>> To post to this group, send email to outreachy-ker...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/outreachy-kernel/1506734581-10932-1-git-send-email-srishtishar%40gmail.com.
>> For more options, visit https://groups.google.com/d/optout.
>>


[PATCH] Staging: rtl8188eu: core: Use list_entry instead of container_of

2017-09-29 Thread Srishti Sharma
For variables of the type struct list_head* use list_entry to access
the current list element instead of using container_of.
Done using the following semantic patch by coccinelle.

@r@
identifier e;
struct list_head* l;
@@

<... when != l == NULL
l;
...>

(
e =
-container_of
+list_entry
 (
  ...)
)

Signed-off-by: Srishti Sharma <srishtis...@gmail.com>
---
 drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c 
b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
index 22cf362..f9df4ac 100644
--- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
+++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
@@ -152,8 +152,8 @@ u32 _rtw_free_sta_priv(struct   sta_priv *pstapriv)
while (phead != plist) {
int i;
 
-   psta = container_of(plist, struct sta_info,
-   hash_list);
+   psta = list_entry(plist, struct sta_info,
+ hash_list);
plist = plist->next;
 
for (i = 0; i < 16; i++) {
@@ -323,7 +323,7 @@ u32 rtw_free_stainfo(struct adapter *padapter, struct 
sta_info *psta)
plist = phead->next;
 
while (!list_empty(phead)) {
-   prframe = container_of(plist, struct recv_frame, list);
+   prframe = list_entry(plist, struct recv_frame, list);
 
plist = plist->next;
 
@@ -399,7 +399,7 @@ void rtw_free_all_stainfo(struct adapter *padapter)
plist = phead->next;
 
while (phead != plist) {
-   psta = container_of(plist, struct sta_info, hash_list);
+   psta = list_entry(plist, struct sta_info, hash_list);
 
plist = plist->next;
 
@@ -435,7 +435,7 @@ struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, 
u8 *hwaddr)
plist = phead->next;
 
while (phead != plist) {
-   psta = container_of(plist, struct sta_info, hash_list);
+   psta = list_entry(plist, struct sta_info, hash_list);
 
if ((!memcmp(psta->hwaddr, addr, ETH_ALEN)) == true) {
/*  if found the matched address */
@@ -493,7 +493,7 @@ u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr)
phead = get_list_head(pacl_node_q);
plist = phead->next;
while (phead != plist) {
-   paclnode = container_of(plist, struct rtw_wlan_acl_node, list);
+   paclnode = list_entry(plist, struct rtw_wlan_acl_node, list);
plist = plist->next;
 
if (!memcmp(paclnode->addr, mac_addr, ETH_ALEN)) {
-- 
2.7.4



[PATCH] Staging: rtl8188eu: core: Use list_entry instead of container_of

2017-09-29 Thread Srishti Sharma
For variables of the type struct list_head* use list_entry to access
the current list element instead of using container_of.
Done using the following semantic patch by coccinelle.

@r@
identifier e;
struct list_head* l;
@@

<... when != l == NULL
l;
...>

(
e =
-container_of
+list_entry
 (
  ...)
)

Signed-off-by: Srishti Sharma 
---
 drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c 
b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
index 22cf362..f9df4ac 100644
--- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
+++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
@@ -152,8 +152,8 @@ u32 _rtw_free_sta_priv(struct   sta_priv *pstapriv)
while (phead != plist) {
int i;
 
-   psta = container_of(plist, struct sta_info,
-   hash_list);
+   psta = list_entry(plist, struct sta_info,
+ hash_list);
plist = plist->next;
 
for (i = 0; i < 16; i++) {
@@ -323,7 +323,7 @@ u32 rtw_free_stainfo(struct adapter *padapter, struct 
sta_info *psta)
plist = phead->next;
 
while (!list_empty(phead)) {
-   prframe = container_of(plist, struct recv_frame, list);
+   prframe = list_entry(plist, struct recv_frame, list);
 
plist = plist->next;
 
@@ -399,7 +399,7 @@ void rtw_free_all_stainfo(struct adapter *padapter)
plist = phead->next;
 
while (phead != plist) {
-   psta = container_of(plist, struct sta_info, hash_list);
+   psta = list_entry(plist, struct sta_info, hash_list);
 
plist = plist->next;
 
@@ -435,7 +435,7 @@ struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, 
u8 *hwaddr)
plist = phead->next;
 
while (phead != plist) {
-   psta = container_of(plist, struct sta_info, hash_list);
+   psta = list_entry(plist, struct sta_info, hash_list);
 
if ((!memcmp(psta->hwaddr, addr, ETH_ALEN)) == true) {
/*  if found the matched address */
@@ -493,7 +493,7 @@ u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr)
phead = get_list_head(pacl_node_q);
plist = phead->next;
while (phead != plist) {
-   paclnode = container_of(plist, struct rtw_wlan_acl_node, list);
+   paclnode = list_entry(plist, struct rtw_wlan_acl_node, list);
plist = plist->next;
 
if (!memcmp(paclnode->addr, mac_addr, ETH_ALEN)) {
-- 
2.7.4



[PATCH] Staging: rtl8188eu: core: Use list_entry instead of container_of

2017-09-29 Thread Srishti Sharma
For variables that have type struct list_head* use list_entry to
access current list element instead of using container_of.
Done using the following semantic patch by coccinelle.

@r@
identifier e;
struct list_head* l;
@@

<... when != l == NULL
l;
...>

(
e=
-container_of
+list_entry
(
 ...)
)

Signed-off-by: Srishti Sharma <srishtis...@gmail.com>
---
 drivers/staging/rtl8188eu/core/rtw_recv.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c 
b/drivers/staging/rtl8188eu/core/rtw_recv.c
index 3fd5f41..af59c16 100644
--- a/drivers/staging/rtl8188eu/core/rtw_recv.c
+++ b/drivers/staging/rtl8188eu/core/rtw_recv.c
@@ -193,7 +193,7 @@ void rtw_free_recvframe_queue(struct __queue *pframequeue,  
struct __queue *pfre
plist = phead->next;
 
while (phead != plist) {
-   hdr = container_of(plist, struct recv_frame, list);
+   hdr = list_entry(plist, struct recv_frame, list);
 
plist = plist->next;
 
@@ -943,7 +943,7 @@ static int validate_recv_ctrl_frame(struct adapter 
*padapter,
xmitframe_plist = xmitframe_phead->next;
 
if (xmitframe_phead != xmitframe_plist) {
-   pxmitframe = container_of(xmitframe_plist, 
struct xmit_frame, list);
+   pxmitframe = list_entry(xmitframe_plist, struct 
xmit_frame, list);
 
xmitframe_plist = xmitframe_plist->next;
 
@@ -1347,7 +1347,7 @@ static struct recv_frame *recvframe_defrag(struct adapter 
*adapter,
 
phead = get_list_head(defrag_q);
plist = phead->next;
-   pfhdr = container_of(plist, struct recv_frame, list);
+   pfhdr = list_entry(plist, struct recv_frame, list);
prframe = pfhdr;
list_del_init(&(prframe->list));
 
@@ -1367,7 +1367,7 @@ static struct recv_frame *recvframe_defrag(struct adapter 
*adapter,
plist = plist->next;
 
while (phead != plist) {
-   pnfhdr = container_of(plist, struct recv_frame, list);
+   pnfhdr = list_entry(plist, struct recv_frame, list);
pnextrframe = pnfhdr;
 
/* check the fragment sequence  (2nd ~n fragment frame) */
@@ -1655,7 +1655,7 @@ static int enqueue_reorder_recvframe(struct 
recv_reorder_ctrl *preorder_ctrl,
plist = phead->next;
 
while (phead != plist) {
-   hdr = container_of(plist, struct recv_frame, list);
+   hdr = list_entry(plist, struct recv_frame, list);
pnextattrib = >attrib;
 
if (SN_LESS(pnextattrib->seq_num, pattrib->seq_num))
@@ -1690,7 +1690,7 @@ static int recv_indicatepkts_in_order(struct adapter 
*padapter, struct recv_reor
if (list_empty(phead))
return true;
 
-   prhdr = container_of(plist, struct recv_frame, list);
+   prhdr = list_entry(plist, struct recv_frame, list);
pattrib = >attrib;
preorder_ctrl->indicate_seq = pattrib->seq_num;
}
@@ -1698,7 +1698,7 @@ static int recv_indicatepkts_in_order(struct adapter 
*padapter, struct recv_reor
/*  Prepare indication list and indication. */
/*  Check if there is any packet need indicate. */
while (!list_empty(phead)) {
-   prhdr = container_of(plist, struct recv_frame, list);
+   prhdr = list_entry(plist, struct recv_frame, list);
prframe = prhdr;
pattrib = >attrib;
 
-- 
2.7.4



[PATCH] Staging: rtl8188eu: core: Use list_entry instead of container_of

2017-09-29 Thread Srishti Sharma
For variables that have type struct list_head* use list_entry to
access current list element instead of using container_of.
Done using the following semantic patch by coccinelle.

@r@
identifier e;
struct list_head* l;
@@

<... when != l == NULL
l;
...>

(
e=
-container_of
+list_entry
(
 ...)
)

Signed-off-by: Srishti Sharma 
---
 drivers/staging/rtl8188eu/core/rtw_recv.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c 
b/drivers/staging/rtl8188eu/core/rtw_recv.c
index 3fd5f41..af59c16 100644
--- a/drivers/staging/rtl8188eu/core/rtw_recv.c
+++ b/drivers/staging/rtl8188eu/core/rtw_recv.c
@@ -193,7 +193,7 @@ void rtw_free_recvframe_queue(struct __queue *pframequeue,  
struct __queue *pfre
plist = phead->next;
 
while (phead != plist) {
-   hdr = container_of(plist, struct recv_frame, list);
+   hdr = list_entry(plist, struct recv_frame, list);
 
plist = plist->next;
 
@@ -943,7 +943,7 @@ static int validate_recv_ctrl_frame(struct adapter 
*padapter,
xmitframe_plist = xmitframe_phead->next;
 
if (xmitframe_phead != xmitframe_plist) {
-   pxmitframe = container_of(xmitframe_plist, 
struct xmit_frame, list);
+   pxmitframe = list_entry(xmitframe_plist, struct 
xmit_frame, list);
 
xmitframe_plist = xmitframe_plist->next;
 
@@ -1347,7 +1347,7 @@ static struct recv_frame *recvframe_defrag(struct adapter 
*adapter,
 
phead = get_list_head(defrag_q);
plist = phead->next;
-   pfhdr = container_of(plist, struct recv_frame, list);
+   pfhdr = list_entry(plist, struct recv_frame, list);
prframe = pfhdr;
list_del_init(&(prframe->list));
 
@@ -1367,7 +1367,7 @@ static struct recv_frame *recvframe_defrag(struct adapter 
*adapter,
plist = plist->next;
 
while (phead != plist) {
-   pnfhdr = container_of(plist, struct recv_frame, list);
+   pnfhdr = list_entry(plist, struct recv_frame, list);
pnextrframe = pnfhdr;
 
/* check the fragment sequence  (2nd ~n fragment frame) */
@@ -1655,7 +1655,7 @@ static int enqueue_reorder_recvframe(struct 
recv_reorder_ctrl *preorder_ctrl,
plist = phead->next;
 
while (phead != plist) {
-   hdr = container_of(plist, struct recv_frame, list);
+   hdr = list_entry(plist, struct recv_frame, list);
pnextattrib = >attrib;
 
if (SN_LESS(pnextattrib->seq_num, pattrib->seq_num))
@@ -1690,7 +1690,7 @@ static int recv_indicatepkts_in_order(struct adapter 
*padapter, struct recv_reor
if (list_empty(phead))
return true;
 
-   prhdr = container_of(plist, struct recv_frame, list);
+   prhdr = list_entry(plist, struct recv_frame, list);
pattrib = >attrib;
preorder_ctrl->indicate_seq = pattrib->seq_num;
}
@@ -1698,7 +1698,7 @@ static int recv_indicatepkts_in_order(struct adapter 
*padapter, struct recv_reor
/*  Prepare indication list and indication. */
/*  Check if there is any packet need indicate. */
while (!list_empty(phead)) {
-   prhdr = container_of(plist, struct recv_frame, list);
+   prhdr = list_entry(plist, struct recv_frame, list);
prframe = prhdr;
pattrib = >attrib;
 
-- 
2.7.4



[PATCH] drm/virtio: Replace instances of reference/unreference with get/put

2017-09-29 Thread Srishti Sharma
Replace reference/unreference with get/put as it is consistent
with the kernel coding style. Done using the following semantic
patch by coccinelle.

@r@
expression e;
@@

-drm_gem_object_unreference_unlocked(e);
+drm_gem_object_put_unlocked(e);

Signed-off-by: Srishti Sharma <srishtis...@gmail.com>
---
 drivers/gpu/drm/virtio/virtgpu_display.c |  4 ++--
 drivers/gpu/drm/virtio/virtgpu_gem.c |  4 ++--
 drivers/gpu/drm/virtio/virtgpu_ioctl.c   | 12 ++--
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_display.c 
b/drivers/gpu/drm/virtio/virtgpu_display.c
index b6d5205..41b0930 100644
--- a/drivers/gpu/drm/virtio/virtgpu_display.c
+++ b/drivers/gpu/drm/virtio/virtgpu_display.c
@@ -53,7 +53,7 @@ static void virtio_gpu_user_framebuffer_destroy(struct 
drm_framebuffer *fb)
struct virtio_gpu_framebuffer *virtio_gpu_fb
= to_virtio_gpu_framebuffer(fb);
 
-   drm_gem_object_unreference_unlocked(virtio_gpu_fb->obj);
+   drm_gem_object_put_unlocked(virtio_gpu_fb->obj);
drm_framebuffer_cleanup(fb);
kfree(virtio_gpu_fb);
 }
@@ -327,7 +327,7 @@ virtio_gpu_user_framebuffer_create(struct drm_device *dev,
ret = virtio_gpu_framebuffer_init(dev, virtio_gpu_fb, mode_cmd, obj);
if (ret) {
kfree(virtio_gpu_fb);
-   drm_gem_object_unreference_unlocked(obj);
+   drm_gem_object_put_unlocked(obj);
return NULL;
}
 
diff --git a/drivers/gpu/drm/virtio/virtgpu_gem.c 
b/drivers/gpu/drm/virtio/virtgpu_gem.c
index 72ad7b1..92fb277 100644
--- a/drivers/gpu/drm/virtio/virtgpu_gem.c
+++ b/drivers/gpu/drm/virtio/virtgpu_gem.c
@@ -72,7 +72,7 @@ int virtio_gpu_gem_create(struct drm_file *file,
*obj_p = >gem_base;
 
/* drop reference from allocate - handle holds it now */
-   drm_gem_object_unreference_unlocked(>gem_base);
+   drm_gem_object_put_unlocked(>gem_base);
 
*handle_p = handle;
return 0;
@@ -130,7 +130,7 @@ int virtio_gpu_mode_dumb_mmap(struct drm_file *file_priv,
return -ENOENT;
obj = gem_to_virtio_gpu_obj(gobj);
*offset_p = virtio_gpu_object_mmap_offset(obj);
-   drm_gem_object_unreference_unlocked(gobj);
+   drm_gem_object_put_unlocked(gobj);
return 0;
 }
 
diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c 
b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
index b94bd54..0528edb 100644
--- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c
+++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
@@ -86,7 +86,7 @@ static void virtio_gpu_unref_list(struct list_head *head)
bo = buf->bo;
qobj = container_of(bo, struct virtio_gpu_object, tbo);
 
-   drm_gem_object_unreference_unlocked(>gem_base);
+   drm_gem_object_put_unlocked(>gem_base);
}
 }
 
@@ -304,7 +304,7 @@ static int virtio_gpu_resource_create_ioctl(struct 
drm_device *dev, void *data,
}
return ret;
}
-   drm_gem_object_unreference_unlocked(obj);
+   drm_gem_object_put_unlocked(obj);
 
rc->res_handle = res_id; /* similiar to a VM address */
rc->bo_handle = handle;
@@ -341,7 +341,7 @@ static int virtio_gpu_resource_info_ioctl(struct drm_device 
*dev, void *data,
 
ri->size = qobj->gem_base.size;
ri->res_handle = qobj->hw_res_handle;
-   drm_gem_object_unreference_unlocked(gobj);
+   drm_gem_object_put_unlocked(gobj);
return 0;
 }
 
@@ -389,7 +389,7 @@ static int virtio_gpu_transfer_from_host_ioctl(struct 
drm_device *dev,
 out_unres:
virtio_gpu_object_unreserve(qobj);
 out:
-   drm_gem_object_unreference_unlocked(gobj);
+   drm_gem_object_put_unlocked(gobj);
return ret;
 }
 
@@ -439,7 +439,7 @@ static int virtio_gpu_transfer_to_host_ioctl(struct 
drm_device *dev, void *data,
 out_unres:
virtio_gpu_object_unreserve(qobj);
 out:
-   drm_gem_object_unreference_unlocked(gobj);
+   drm_gem_object_put_unlocked(gobj);
return ret;
 }
 
@@ -462,7 +462,7 @@ static int virtio_gpu_wait_ioctl(struct drm_device *dev, 
void *data,
nowait = true;
ret = virtio_gpu_object_wait(qobj, nowait);
 
-   drm_gem_object_unreference_unlocked(gobj);
+   drm_gem_object_put_unlocked(gobj);
return ret;
 }
 
-- 
2.7.4



[PATCH] drm/virtio: Replace instances of reference/unreference with get/put

2017-09-29 Thread Srishti Sharma
Replace reference/unreference with get/put as it is consistent
with the kernel coding style. Done using the following semantic
patch by coccinelle.

@r@
expression e;
@@

-drm_gem_object_unreference_unlocked(e);
+drm_gem_object_put_unlocked(e);

Signed-off-by: Srishti Sharma 
---
 drivers/gpu/drm/virtio/virtgpu_display.c |  4 ++--
 drivers/gpu/drm/virtio/virtgpu_gem.c |  4 ++--
 drivers/gpu/drm/virtio/virtgpu_ioctl.c   | 12 ++--
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_display.c 
b/drivers/gpu/drm/virtio/virtgpu_display.c
index b6d5205..41b0930 100644
--- a/drivers/gpu/drm/virtio/virtgpu_display.c
+++ b/drivers/gpu/drm/virtio/virtgpu_display.c
@@ -53,7 +53,7 @@ static void virtio_gpu_user_framebuffer_destroy(struct 
drm_framebuffer *fb)
struct virtio_gpu_framebuffer *virtio_gpu_fb
= to_virtio_gpu_framebuffer(fb);
 
-   drm_gem_object_unreference_unlocked(virtio_gpu_fb->obj);
+   drm_gem_object_put_unlocked(virtio_gpu_fb->obj);
drm_framebuffer_cleanup(fb);
kfree(virtio_gpu_fb);
 }
@@ -327,7 +327,7 @@ virtio_gpu_user_framebuffer_create(struct drm_device *dev,
ret = virtio_gpu_framebuffer_init(dev, virtio_gpu_fb, mode_cmd, obj);
if (ret) {
kfree(virtio_gpu_fb);
-   drm_gem_object_unreference_unlocked(obj);
+   drm_gem_object_put_unlocked(obj);
return NULL;
}
 
diff --git a/drivers/gpu/drm/virtio/virtgpu_gem.c 
b/drivers/gpu/drm/virtio/virtgpu_gem.c
index 72ad7b1..92fb277 100644
--- a/drivers/gpu/drm/virtio/virtgpu_gem.c
+++ b/drivers/gpu/drm/virtio/virtgpu_gem.c
@@ -72,7 +72,7 @@ int virtio_gpu_gem_create(struct drm_file *file,
*obj_p = >gem_base;
 
/* drop reference from allocate - handle holds it now */
-   drm_gem_object_unreference_unlocked(>gem_base);
+   drm_gem_object_put_unlocked(>gem_base);
 
*handle_p = handle;
return 0;
@@ -130,7 +130,7 @@ int virtio_gpu_mode_dumb_mmap(struct drm_file *file_priv,
return -ENOENT;
obj = gem_to_virtio_gpu_obj(gobj);
*offset_p = virtio_gpu_object_mmap_offset(obj);
-   drm_gem_object_unreference_unlocked(gobj);
+   drm_gem_object_put_unlocked(gobj);
return 0;
 }
 
diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c 
b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
index b94bd54..0528edb 100644
--- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c
+++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
@@ -86,7 +86,7 @@ static void virtio_gpu_unref_list(struct list_head *head)
bo = buf->bo;
qobj = container_of(bo, struct virtio_gpu_object, tbo);
 
-   drm_gem_object_unreference_unlocked(>gem_base);
+   drm_gem_object_put_unlocked(>gem_base);
}
 }
 
@@ -304,7 +304,7 @@ static int virtio_gpu_resource_create_ioctl(struct 
drm_device *dev, void *data,
}
return ret;
}
-   drm_gem_object_unreference_unlocked(obj);
+   drm_gem_object_put_unlocked(obj);
 
rc->res_handle = res_id; /* similiar to a VM address */
rc->bo_handle = handle;
@@ -341,7 +341,7 @@ static int virtio_gpu_resource_info_ioctl(struct drm_device 
*dev, void *data,
 
ri->size = qobj->gem_base.size;
ri->res_handle = qobj->hw_res_handle;
-   drm_gem_object_unreference_unlocked(gobj);
+   drm_gem_object_put_unlocked(gobj);
return 0;
 }
 
@@ -389,7 +389,7 @@ static int virtio_gpu_transfer_from_host_ioctl(struct 
drm_device *dev,
 out_unres:
virtio_gpu_object_unreserve(qobj);
 out:
-   drm_gem_object_unreference_unlocked(gobj);
+   drm_gem_object_put_unlocked(gobj);
return ret;
 }
 
@@ -439,7 +439,7 @@ static int virtio_gpu_transfer_to_host_ioctl(struct 
drm_device *dev, void *data,
 out_unres:
virtio_gpu_object_unreserve(qobj);
 out:
-   drm_gem_object_unreference_unlocked(gobj);
+   drm_gem_object_put_unlocked(gobj);
return ret;
 }
 
@@ -462,7 +462,7 @@ static int virtio_gpu_wait_ioctl(struct drm_device *dev, 
void *data,
nowait = true;
ret = virtio_gpu_object_wait(qobj, nowait);
 
-   drm_gem_object_unreference_unlocked(gobj);
+   drm_gem_object_put_unlocked(gobj);
return ret;
 }
 
-- 
2.7.4



[PATCH] drm/arm: Replace instances of drm_dev_unref with drm_dev_put.

2017-09-29 Thread Srishti Sharma
Replace drm_dev_unref with drm_dev_put as it is more consistent
with kernel coding style. Done using the following semantic
patch by coccinelle.

@r@
expression e;
@@

-drm_dev_unref();
+drm_dev_put();

Signed-off-by: Srishti Sharma <srishtis...@gmail.com>
---
 drivers/gpu/drm/arm/hdlcd_drv.c  | 4 ++--
 drivers/gpu/drm/arm/malidp_drv.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
index f9bda7b..1a96462 100644
--- a/drivers/gpu/drm/arm/hdlcd_drv.c
+++ b/drivers/gpu/drm/arm/hdlcd_drv.c
@@ -353,7 +353,7 @@ static int hdlcd_drm_bind(struct device *dev)
 err_free:
drm_mode_config_cleanup(drm);
dev_set_drvdata(dev, NULL);
-   drm_dev_unref(drm);
+   drm_dev_put(drm);
 
return ret;
 }
@@ -378,7 +378,7 @@ static void hdlcd_drm_unbind(struct device *dev)
pm_runtime_disable(drm->dev);
of_reserved_mem_device_release(drm->dev);
drm_mode_config_cleanup(drm);
-   drm_dev_unref(drm);
+   drm_dev_put(drm);
drm->dev_private = NULL;
dev_set_drvdata(dev, NULL);
 }
diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
index 7ae94a1..1b92f41 100644
--- a/drivers/gpu/drm/arm/malidp_drv.c
+++ b/drivers/gpu/drm/arm/malidp_drv.c
@@ -665,7 +665,7 @@ static int malidp_bind(struct device *dev)
malidp_runtime_pm_suspend(dev);
drm->dev_private = NULL;
dev_set_drvdata(dev, NULL);
-   drm_dev_unref(drm);
+   drm_dev_put(drm);
 alloc_fail:
of_reserved_mem_device_release(dev);
 
@@ -698,7 +698,7 @@ static void malidp_unbind(struct device *dev)
malidp_runtime_pm_suspend(dev);
drm->dev_private = NULL;
dev_set_drvdata(dev, NULL);
-   drm_dev_unref(drm);
+   drm_dev_put(drm);
of_reserved_mem_device_release(dev);
 }
 
-- 
2.7.4



[PATCH] drm/arm: Replace instances of drm_dev_unref with drm_dev_put.

2017-09-29 Thread Srishti Sharma
Replace drm_dev_unref with drm_dev_put as it is more consistent
with kernel coding style. Done using the following semantic
patch by coccinelle.

@r@
expression e;
@@

-drm_dev_unref();
+drm_dev_put();

Signed-off-by: Srishti Sharma 
---
 drivers/gpu/drm/arm/hdlcd_drv.c  | 4 ++--
 drivers/gpu/drm/arm/malidp_drv.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
index f9bda7b..1a96462 100644
--- a/drivers/gpu/drm/arm/hdlcd_drv.c
+++ b/drivers/gpu/drm/arm/hdlcd_drv.c
@@ -353,7 +353,7 @@ static int hdlcd_drm_bind(struct device *dev)
 err_free:
drm_mode_config_cleanup(drm);
dev_set_drvdata(dev, NULL);
-   drm_dev_unref(drm);
+   drm_dev_put(drm);
 
return ret;
 }
@@ -378,7 +378,7 @@ static void hdlcd_drm_unbind(struct device *dev)
pm_runtime_disable(drm->dev);
of_reserved_mem_device_release(drm->dev);
drm_mode_config_cleanup(drm);
-   drm_dev_unref(drm);
+   drm_dev_put(drm);
drm->dev_private = NULL;
dev_set_drvdata(dev, NULL);
 }
diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
index 7ae94a1..1b92f41 100644
--- a/drivers/gpu/drm/arm/malidp_drv.c
+++ b/drivers/gpu/drm/arm/malidp_drv.c
@@ -665,7 +665,7 @@ static int malidp_bind(struct device *dev)
malidp_runtime_pm_suspend(dev);
drm->dev_private = NULL;
dev_set_drvdata(dev, NULL);
-   drm_dev_unref(drm);
+   drm_dev_put(drm);
 alloc_fail:
of_reserved_mem_device_release(dev);
 
@@ -698,7 +698,7 @@ static void malidp_unbind(struct device *dev)
malidp_runtime_pm_suspend(dev);
drm->dev_private = NULL;
dev_set_drvdata(dev, NULL);
-   drm_dev_unref(drm);
+   drm_dev_put(drm);
of_reserved_mem_device_release(dev);
 }
 
-- 
2.7.4



[PATCH v2 2/2] Staging: dgnc: Remove unused fields in struct channel_t

2017-09-16 Thread Srishti Sharma
Eliminate the fields that are not used and the comments
associated with them.

Signed-off-by: Srishti Sharma <srishtis...@gmail.com>
---
Changes in v2:
 - Use the word field instead of variable.

 drivers/staging/dgnc/dgnc_driver.h | 6 --
 1 file changed, 6 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.h 
b/drivers/staging/dgnc/dgnc_driver.h
index 5d2566e..082d659 100644
--- a/drivers/staging/dgnc/dgnc_driver.h
+++ b/drivers/staging/dgnc/dgnc_driver.h
@@ -312,8 +312,6 @@ struct un_t {
  * @ch_err_overrun: Count of overruns on channel.
  * @ch_xon_sends: Count of xons transmitted.
  * @ch_xoff_sends: Count of xoffs transmitted.
- * @proc_entry_pointer: Proc// entry.
- * @dgnc_channel_table: Proc// entry.
  */
 struct channel_t {
struct dgnc_board *ch_bd;
@@ -382,10 +380,6 @@ struct channel_t {
 
ulong   ch_xon_sends;
ulong   ch_xoff_sends;
-
-   struct proc_dir_entry *proc_entry_pointer;
-   struct dgnc_proc_entry *dgnc_channel_table;
-
 };
 
 extern uintdgnc_major; /* Our driver/mgmt major */
-- 
2.7.4



[PATCH v2 2/2] Staging: dgnc: Remove unused fields in struct channel_t

2017-09-16 Thread Srishti Sharma
Eliminate the fields that are not used and the comments
associated with them.

Signed-off-by: Srishti Sharma 
---
Changes in v2:
 - Use the word field instead of variable.

 drivers/staging/dgnc/dgnc_driver.h | 6 --
 1 file changed, 6 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.h 
b/drivers/staging/dgnc/dgnc_driver.h
index 5d2566e..082d659 100644
--- a/drivers/staging/dgnc/dgnc_driver.h
+++ b/drivers/staging/dgnc/dgnc_driver.h
@@ -312,8 +312,6 @@ struct un_t {
  * @ch_err_overrun: Count of overruns on channel.
  * @ch_xon_sends: Count of xons transmitted.
  * @ch_xoff_sends: Count of xoffs transmitted.
- * @proc_entry_pointer: Proc// entry.
- * @dgnc_channel_table: Proc// entry.
  */
 struct channel_t {
struct dgnc_board *ch_bd;
@@ -382,10 +380,6 @@ struct channel_t {
 
ulong   ch_xon_sends;
ulong   ch_xoff_sends;
-
-   struct proc_dir_entry *proc_entry_pointer;
-   struct dgnc_proc_entry *dgnc_channel_table;
-
 };
 
 extern uintdgnc_major; /* Our driver/mgmt major */
-- 
2.7.4



[PATCH v2 1/2] Staging: dgnc: Remove unused fields in struct dgnc_board

2017-09-16 Thread Srishti Sharma
Remove unused fields and comments associated with them in
the structure definition.

Signed-off-by: Srishti Sharma <srishtis...@gmail.com>
---
Changes in v2:
 - Use the word field instead of variable.

 drivers/staging/dgnc/dgnc_driver.h | 9 -
 1 file changed, 9 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.h 
b/drivers/staging/dgnc/dgnc_driver.h
index 764d6fe..5d2566e 100644
--- a/drivers/staging/dgnc/dgnc_driver.h
+++ b/drivers/staging/dgnc/dgnc_driver.h
@@ -104,7 +104,6 @@ struct board_ops {
  * struct dgnc_board - Per board information.
  * @boardnum: Board number (0 - 32).
  *
- * @type: Type of board.
  * @name: Product name.
  * @pdev: Pointer to the pci_dev structure.
  * @bd_flags: Board flags.
@@ -140,13 +139,9 @@ struct board_ops {
  * @dpastatus: Board status as defined by DPA.
  * @bd_dividend: Board/UART's specific dividend.
  * @bd_ops: Pointer to board operations structure.
- * @proc_entry_pointer: Proc/ entry
- * @dgnc_board_table: Proc/ entry
  */
 struct dgnc_board {
int boardnum;
-
-   int type;
char*name;
struct pci_dev  *pdev;
unsigned long   bd_flags;
@@ -200,10 +195,6 @@ struct dgnc_board {
uintbd_dividend;
 
struct board_ops *bd_ops;
-
-   struct proc_dir_entry *proc_entry_pointer;
-   struct dgnc_proc_entry *dgnc_board_table;
-
 };
 
 /* Unit flag definitions for un_flags. */
-- 
2.7.4



[PATCH v2 1/2] Staging: dgnc: Remove unused fields in struct dgnc_board

2017-09-16 Thread Srishti Sharma
Remove unused fields and comments associated with them in
the structure definition.

Signed-off-by: Srishti Sharma 
---
Changes in v2:
 - Use the word field instead of variable.

 drivers/staging/dgnc/dgnc_driver.h | 9 -
 1 file changed, 9 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.h 
b/drivers/staging/dgnc/dgnc_driver.h
index 764d6fe..5d2566e 100644
--- a/drivers/staging/dgnc/dgnc_driver.h
+++ b/drivers/staging/dgnc/dgnc_driver.h
@@ -104,7 +104,6 @@ struct board_ops {
  * struct dgnc_board - Per board information.
  * @boardnum: Board number (0 - 32).
  *
- * @type: Type of board.
  * @name: Product name.
  * @pdev: Pointer to the pci_dev structure.
  * @bd_flags: Board flags.
@@ -140,13 +139,9 @@ struct board_ops {
  * @dpastatus: Board status as defined by DPA.
  * @bd_dividend: Board/UART's specific dividend.
  * @bd_ops: Pointer to board operations structure.
- * @proc_entry_pointer: Proc/ entry
- * @dgnc_board_table: Proc/ entry
  */
 struct dgnc_board {
int boardnum;
-
-   int type;
char*name;
struct pci_dev  *pdev;
unsigned long   bd_flags;
@@ -200,10 +195,6 @@ struct dgnc_board {
uintbd_dividend;
 
struct board_ops *bd_ops;
-
-   struct proc_dir_entry *proc_entry_pointer;
-   struct dgnc_proc_entry *dgnc_board_table;
-
 };
 
 /* Unit flag definitions for un_flags. */
-- 
2.7.4



[PATCH v2 0/2] Remove unused fields in structure definition

2017-09-16 Thread Srishti Sharma
Remove fields that are not used, from structure definitions , and 
eliminate the comments associated with them.

Srishti Sharma (2):
  Staging: dgnc: Remove unused variables in structure definition
  Staging: dgnc: Remove unused variable in structure

 drivers/staging/dgnc/dgnc_driver.h | 15 ---
 1 file changed, 15 deletions(-)

-- 
2.7.4



[PATCH v2 0/2] Remove unused fields in structure definition

2017-09-16 Thread Srishti Sharma
Remove fields that are not used, from structure definitions , and 
eliminate the comments associated with them.

Srishti Sharma (2):
  Staging: dgnc: Remove unused variables in structure definition
  Staging: dgnc: Remove unused variable in structure

 drivers/staging/dgnc/dgnc_driver.h | 15 ---
 1 file changed, 15 deletions(-)

-- 
2.7.4



[PATCH 0/2] Remove unused variables in structure definition

2017-09-16 Thread Srishti Sharma
This patch series attempts to remove unused variables in structure
variables and the comments associated with them.

Srishti Sharma (2):
  Staging: dgnc: Remove unused variables in structure definition
  Staging: dgnc: Remove unused variable in structure

 drivers/staging/dgnc/dgnc_driver.h | 15 ---
 1 file changed, 15 deletions(-)

-- 
2.7.4



[PATCH 0/2] Remove unused variables in structure definition

2017-09-16 Thread Srishti Sharma
This patch series attempts to remove unused variables in structure
variables and the comments associated with them.

Srishti Sharma (2):
  Staging: dgnc: Remove unused variables in structure definition
  Staging: dgnc: Remove unused variable in structure

 drivers/staging/dgnc/dgnc_driver.h | 15 ---
 1 file changed, 15 deletions(-)

-- 
2.7.4



[PATCH 2/2] Staging: dgnc: Remove unused variable in struct channel_t

2017-09-16 Thread Srishti Sharma
Eliminate the variables that are not used and the comments
associated with them.

Signed-off-by: Srishti Sharma <srishtis...@gmail.com>
---
 drivers/staging/dgnc/dgnc_driver.h | 6 --
 1 file changed, 6 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.h 
b/drivers/staging/dgnc/dgnc_driver.h
index 5d2566e..082d659 100644
--- a/drivers/staging/dgnc/dgnc_driver.h
+++ b/drivers/staging/dgnc/dgnc_driver.h
@@ -312,8 +312,6 @@ struct un_t {
  * @ch_err_overrun: Count of overruns on channel.
  * @ch_xon_sends: Count of xons transmitted.
  * @ch_xoff_sends: Count of xoffs transmitted.
- * @proc_entry_pointer: Proc// entry.
- * @dgnc_channel_table: Proc// entry.
  */
 struct channel_t {
struct dgnc_board *ch_bd;
@@ -382,10 +380,6 @@ struct channel_t {
 
ulong   ch_xon_sends;
ulong   ch_xoff_sends;
-
-   struct proc_dir_entry *proc_entry_pointer;
-   struct dgnc_proc_entry *dgnc_channel_table;
-
 };
 
 extern uintdgnc_major; /* Our driver/mgmt major */
-- 
2.7.4



[PATCH 2/2] Staging: dgnc: Remove unused variable in struct channel_t

2017-09-16 Thread Srishti Sharma
Eliminate the variables that are not used and the comments
associated with them.

Signed-off-by: Srishti Sharma 
---
 drivers/staging/dgnc/dgnc_driver.h | 6 --
 1 file changed, 6 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.h 
b/drivers/staging/dgnc/dgnc_driver.h
index 5d2566e..082d659 100644
--- a/drivers/staging/dgnc/dgnc_driver.h
+++ b/drivers/staging/dgnc/dgnc_driver.h
@@ -312,8 +312,6 @@ struct un_t {
  * @ch_err_overrun: Count of overruns on channel.
  * @ch_xon_sends: Count of xons transmitted.
  * @ch_xoff_sends: Count of xoffs transmitted.
- * @proc_entry_pointer: Proc// entry.
- * @dgnc_channel_table: Proc// entry.
  */
 struct channel_t {
struct dgnc_board *ch_bd;
@@ -382,10 +380,6 @@ struct channel_t {
 
ulong   ch_xon_sends;
ulong   ch_xoff_sends;
-
-   struct proc_dir_entry *proc_entry_pointer;
-   struct dgnc_proc_entry *dgnc_channel_table;
-
 };
 
 extern uintdgnc_major; /* Our driver/mgmt major */
-- 
2.7.4



[PATCH 1/2] Staging: dgnc: Remove unused variables in struct dgnc_board

2017-09-16 Thread Srishti Sharma
Remove unused variables and comments associated with them in
the structure definition.

Signed-off-by: Srishti Sharma <srishtis...@gmail.com>
---
 drivers/staging/dgnc/dgnc_driver.h | 9 -
 1 file changed, 9 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.h 
b/drivers/staging/dgnc/dgnc_driver.h
index 764d6fe..5d2566e 100644
--- a/drivers/staging/dgnc/dgnc_driver.h
+++ b/drivers/staging/dgnc/dgnc_driver.h
@@ -104,7 +104,6 @@ struct board_ops {
  * struct dgnc_board - Per board information.
  * @boardnum: Board number (0 - 32).
  *
- * @type: Type of board.
  * @name: Product name.
  * @pdev: Pointer to the pci_dev structure.
  * @bd_flags: Board flags.
@@ -140,13 +139,9 @@ struct board_ops {
  * @dpastatus: Board status as defined by DPA.
  * @bd_dividend: Board/UART's specific dividend.
  * @bd_ops: Pointer to board operations structure.
- * @proc_entry_pointer: Proc/ entry
- * @dgnc_board_table: Proc/ entry
  */
 struct dgnc_board {
int boardnum;
-
-   int type;
char*name;
struct pci_dev  *pdev;
unsigned long   bd_flags;
@@ -200,10 +195,6 @@ struct dgnc_board {
uintbd_dividend;
 
struct board_ops *bd_ops;
-
-   struct proc_dir_entry *proc_entry_pointer;
-   struct dgnc_proc_entry *dgnc_board_table;
-
 };
 
 /* Unit flag definitions for un_flags. */
-- 
2.7.4



[PATCH 1/2] Staging: dgnc: Remove unused variables in struct dgnc_board

2017-09-16 Thread Srishti Sharma
Remove unused variables and comments associated with them in
the structure definition.

Signed-off-by: Srishti Sharma 
---
 drivers/staging/dgnc/dgnc_driver.h | 9 -
 1 file changed, 9 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.h 
b/drivers/staging/dgnc/dgnc_driver.h
index 764d6fe..5d2566e 100644
--- a/drivers/staging/dgnc/dgnc_driver.h
+++ b/drivers/staging/dgnc/dgnc_driver.h
@@ -104,7 +104,6 @@ struct board_ops {
  * struct dgnc_board - Per board information.
  * @boardnum: Board number (0 - 32).
  *
- * @type: Type of board.
  * @name: Product name.
  * @pdev: Pointer to the pci_dev structure.
  * @bd_flags: Board flags.
@@ -140,13 +139,9 @@ struct board_ops {
  * @dpastatus: Board status as defined by DPA.
  * @bd_dividend: Board/UART's specific dividend.
  * @bd_ops: Pointer to board operations structure.
- * @proc_entry_pointer: Proc/ entry
- * @dgnc_board_table: Proc/ entry
  */
 struct dgnc_board {
int boardnum;
-
-   int type;
char*name;
struct pci_dev  *pdev;
unsigned long   bd_flags;
@@ -200,10 +195,6 @@ struct dgnc_board {
uintbd_dividend;
 
struct board_ops *bd_ops;
-
-   struct proc_dir_entry *proc_entry_pointer;
-   struct dgnc_proc_entry *dgnc_board_table;
-
 };
 
 /* Unit flag definitions for un_flags. */
-- 
2.7.4



Re: [Outreachy kernel] [PATCH] Staging: dgnc: Remove unused variables from structure definition

2017-09-16 Thread Srishti Sharma
On Sat, Sep 16, 2017 at 5:45 PM, Julia Lawall <julia.law...@lip6.fr> wrote:
>
>
> On Sat, 16 Sep 2017, Srishti Sharma wrote:
>
>> On Sat, Sep 16, 2017 at 5:20 PM, Julia Lawall <julia.law...@lip6.fr> wrote:
>> >
>> >
>> > On Sat, 16 Sep 2017, Srishti Sharma wrote:
>> >
>> >> Some variables in the structure were unused and hence them and
>> >> the comments associated with them can be removed.
>> >
>> > How did you find these?  The last two can easily be checked with grep, but
>> > that is ont the case for type.
>>
>> I removed them and then compiled the code to see if it still compiles.
>
> This is not 100% reliable because of the possibility of uses inside
> ifdefs.  So you need to double check that you have found every occurrence
> of the structure type for the type field.  The others seem not dangerous.

Okay, I'll do that . Thanks

Srishti
>
> julia
>
>> I was using grep earlier to see if the fields in the structure are
>> ever accessed by the variables of that structure type, as the TODO of
>> the driver says that there is a lot of unneeded code.
>> >
>> > Actually there are two structures in the file with useless
>> > proc_entry_pointer fields.  The other one has a useless
>> > dgnc_channel_table.  It could be reasonable to make a series to do both
>> > structures.
>>
>> Okay, I'll send them as a series. Thanks
>>
>> Regards,
>> Srishti
>>
>> > julia
>> >
>> >>
>> >> Signed-off-by: Srishti Sharma <srishtis...@gmail.com>
>> >> ---
>> >>  drivers/staging/dgnc/dgnc_driver.h | 10 --
>> >>  1 file changed, 10 deletions(-)
>> >>
>> >> diff --git a/drivers/staging/dgnc/dgnc_driver.h 
>> >> b/drivers/staging/dgnc/dgnc_driver.h
>> >> index 764d6fe..2b625cc 100644
>> >> --- a/drivers/staging/dgnc/dgnc_driver.h
>> >> +++ b/drivers/staging/dgnc/dgnc_driver.h
>> >> @@ -103,8 +103,6 @@ struct board_ops {
>> >>  /**
>> >>   * struct dgnc_board - Per board information.
>> >>   * @boardnum: Board number (0 - 32).
>> >> - *
>> >> - * @type: Type of board.
>> >>   * @name: Product name.
>> >>   * @pdev: Pointer to the pci_dev structure.
>> >>   * @bd_flags: Board flags.
>> >> @@ -140,13 +138,9 @@ struct board_ops {
>> >>   * @dpastatus: Board status as defined by DPA.
>> >>   * @bd_dividend: Board/UART's specific dividend.
>> >>   * @bd_ops: Pointer to board operations structure.
>> >> - * @proc_entry_pointer: Proc/ entry
>> >> - * @dgnc_board_table: Proc/ entry
>> >>   */
>> >>  struct dgnc_board {
>> >>   int boardnum;
>> >> -
>> >> - int type;
>> >>   char*name;
>> >>   struct pci_dev  *pdev;
>> >>   unsigned long   bd_flags;
>> >> @@ -200,10 +194,6 @@ struct dgnc_board {
>> >>   uintbd_dividend;
>> >>
>> >>   struct board_ops *bd_ops;
>> >> -
>> >> - struct proc_dir_entry *proc_entry_pointer;
>> >> - struct dgnc_proc_entry *dgnc_board_table;
>> >> -
>> >>  };
>> >>
>> >>  /* Unit flag definitions for un_flags. */
>> >> --
>> >> 2.7.4
>> >>
>> >> --
>> >> 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 outreachy-kernel+unsubscr...@googlegroups.com.
>> >> To post to this group, send email to outreachy-ker...@googlegroups.com.
>> >> To view this discussion on the web visit 
>> >> https://groups.google.com/d/msgid/outreachy-kernel/1505562186-11813-1-git-send-email-srishtishar%40gmail.com.
>> >> For more options, visit https://groups.google.com/d/optout.
>> >>
>>


Re: [Outreachy kernel] [PATCH] Staging: dgnc: Remove unused variables from structure definition

2017-09-16 Thread Srishti Sharma
On Sat, Sep 16, 2017 at 5:45 PM, Julia Lawall  wrote:
>
>
> On Sat, 16 Sep 2017, Srishti Sharma wrote:
>
>> On Sat, Sep 16, 2017 at 5:20 PM, Julia Lawall  wrote:
>> >
>> >
>> > On Sat, 16 Sep 2017, Srishti Sharma wrote:
>> >
>> >> Some variables in the structure were unused and hence them and
>> >> the comments associated with them can be removed.
>> >
>> > How did you find these?  The last two can easily be checked with grep, but
>> > that is ont the case for type.
>>
>> I removed them and then compiled the code to see if it still compiles.
>
> This is not 100% reliable because of the possibility of uses inside
> ifdefs.  So you need to double check that you have found every occurrence
> of the structure type for the type field.  The others seem not dangerous.

Okay, I'll do that . Thanks

Srishti
>
> julia
>
>> I was using grep earlier to see if the fields in the structure are
>> ever accessed by the variables of that structure type, as the TODO of
>> the driver says that there is a lot of unneeded code.
>> >
>> > Actually there are two structures in the file with useless
>> > proc_entry_pointer fields.  The other one has a useless
>> > dgnc_channel_table.  It could be reasonable to make a series to do both
>> > structures.
>>
>> Okay, I'll send them as a series. Thanks
>>
>> Regards,
>> Srishti
>>
>> > julia
>> >
>> >>
>> >> Signed-off-by: Srishti Sharma 
>> >> ---
>> >>  drivers/staging/dgnc/dgnc_driver.h | 10 --
>> >>  1 file changed, 10 deletions(-)
>> >>
>> >> diff --git a/drivers/staging/dgnc/dgnc_driver.h 
>> >> b/drivers/staging/dgnc/dgnc_driver.h
>> >> index 764d6fe..2b625cc 100644
>> >> --- a/drivers/staging/dgnc/dgnc_driver.h
>> >> +++ b/drivers/staging/dgnc/dgnc_driver.h
>> >> @@ -103,8 +103,6 @@ struct board_ops {
>> >>  /**
>> >>   * struct dgnc_board - Per board information.
>> >>   * @boardnum: Board number (0 - 32).
>> >> - *
>> >> - * @type: Type of board.
>> >>   * @name: Product name.
>> >>   * @pdev: Pointer to the pci_dev structure.
>> >>   * @bd_flags: Board flags.
>> >> @@ -140,13 +138,9 @@ struct board_ops {
>> >>   * @dpastatus: Board status as defined by DPA.
>> >>   * @bd_dividend: Board/UART's specific dividend.
>> >>   * @bd_ops: Pointer to board operations structure.
>> >> - * @proc_entry_pointer: Proc/ entry
>> >> - * @dgnc_board_table: Proc/ entry
>> >>   */
>> >>  struct dgnc_board {
>> >>   int boardnum;
>> >> -
>> >> - int type;
>> >>   char*name;
>> >>   struct pci_dev  *pdev;
>> >>   unsigned long   bd_flags;
>> >> @@ -200,10 +194,6 @@ struct dgnc_board {
>> >>   uintbd_dividend;
>> >>
>> >>   struct board_ops *bd_ops;
>> >> -
>> >> - struct proc_dir_entry *proc_entry_pointer;
>> >> - struct dgnc_proc_entry *dgnc_board_table;
>> >> -
>> >>  };
>> >>
>> >>  /* Unit flag definitions for un_flags. */
>> >> --
>> >> 2.7.4
>> >>
>> >> --
>> >> 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 outreachy-kernel+unsubscr...@googlegroups.com.
>> >> To post to this group, send email to outreachy-ker...@googlegroups.com.
>> >> To view this discussion on the web visit 
>> >> https://groups.google.com/d/msgid/outreachy-kernel/1505562186-11813-1-git-send-email-srishtishar%40gmail.com.
>> >> For more options, visit https://groups.google.com/d/optout.
>> >>
>>


  1   2   3   >