All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Staging: rtl8192e: Use list_first_entry instead of list_entry
@ 2016-03-06 15:36 Bhumika Goyal
  2016-03-07  0:06 ` [Outreachy kernel] " Julia Lawall
  0 siblings, 1 reply; 2+ messages in thread
From: Bhumika Goyal @ 2016-03-06 15:36 UTC (permalink / raw)
  To: outreachy-kernel; +Cc: Bhumika Goyal

This patch replaces list_entry with list_first_entry as it makes the
code more clear.
Done using coccinelle:

@@
expression e;
@@
(
- list_entry(e->next,
+ list_first_entry(e,
  ...)
|
- list_entry(e->prev,
+ list_last_entry(e,
  ...)
)

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
---
 drivers/staging/rtl8192e/rtl819x_TSProc.c | 2 +-
 drivers/staging/rtl8192e/rtllib_rx.c      | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl819x_TSProc.c b/drivers/staging/rtl8192e/rtl819x_TSProc.c
index 2c8a526..22ee936 100644
--- a/drivers/staging/rtl8192e/rtl819x_TSProc.c
+++ b/drivers/staging/rtl8192e/rtl819x_TSProc.c
@@ -371,7 +371,7 @@ bool GetTs(struct rtllib_device *ieee, struct ts_common_info **ppTS,
 				((TxRxSelect == TX_DIR) ? DIR_UP : DIR_DOWN);
 
 	if (!list_empty(pUnusedList)) {
-		(*ppTS) = list_entry(pUnusedList->next,
+		(*ppTS) = list_first_entry(pUnusedList,
 			  struct ts_common_info, List);
 		list_del_init(&(*ppTS)->List);
 		if (TxRxSelect == TX_DIR) {
diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c
index af64bd3..5893005 100644
--- a/drivers/staging/rtl8192e/rtllib_rx.c
+++ b/drivers/staging/rtl8192e/rtllib_rx.c
@@ -461,11 +461,11 @@ static bool AddReorderEntry(struct rx_ts_record *pTS,
 
 	while (pList->next != &pTS->RxPendingPktList) {
 		if (SN_LESS(pReorderEntry->SeqNum, ((struct rx_reorder_entry *)
-		    list_entry(pList->next, struct rx_reorder_entry,
+		    list_first_entry(pList, struct rx_reorder_entry,
 		    List))->SeqNum))
 			pList = pList->next;
 		else if (SN_EQUAL(pReorderEntry->SeqNum,
-			((struct rx_reorder_entry *)list_entry(pList->next,
+			((struct rx_reorder_entry *)list_first_entry(pList,
 			struct rx_reorder_entry, List))->SeqNum))
 				return false;
 		else
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Outreachy kernel] [PATCH] Staging: rtl8192e: Use list_first_entry instead of list_entry
  2016-03-06 15:36 [PATCH] Staging: rtl8192e: Use list_first_entry instead of list_entry Bhumika Goyal
@ 2016-03-07  0:06 ` Julia Lawall
  0 siblings, 0 replies; 2+ messages in thread
From: Julia Lawall @ 2016-03-07  0:06 UTC (permalink / raw)
  To: Bhumika Goyal; +Cc: outreachy-kernel



On Sun, 6 Mar 2016, Bhumika Goyal wrote:

> This patch replaces list_entry with list_first_entry as it makes the
> code more clear.
> Done using coccinelle:
>
> @@
> expression e;
> @@
> (
> - list_entry(e->next,
> + list_first_entry(e,
>   ...)
> |
> - list_entry(e->prev,
> + list_last_entry(e,
>   ...)
> )
>
> Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
> ---
>  drivers/staging/rtl8192e/rtl819x_TSProc.c | 2 +-
>  drivers/staging/rtl8192e/rtllib_rx.c      | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/staging/rtl8192e/rtl819x_TSProc.c b/drivers/staging/rtl8192e/rtl819x_TSProc.c
> index 2c8a526..22ee936 100644
> --- a/drivers/staging/rtl8192e/rtl819x_TSProc.c
> +++ b/drivers/staging/rtl8192e/rtl819x_TSProc.c
> @@ -371,7 +371,7 @@ bool GetTs(struct rtllib_device *ieee, struct ts_common_info **ppTS,
>  				((TxRxSelect == TX_DIR) ? DIR_UP : DIR_DOWN);
>
>  	if (!list_empty(pUnusedList)) {
> -		(*ppTS) = list_entry(pUnusedList->next,
> +		(*ppTS) = list_first_entry(pUnusedList,
>  			  struct ts_common_info, List);
>  		list_del_init(&(*ppTS)->List);
>  		if (TxRxSelect == TX_DIR) {
> diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c
> index af64bd3..5893005 100644
> --- a/drivers/staging/rtl8192e/rtllib_rx.c
> +++ b/drivers/staging/rtl8192e/rtllib_rx.c
> @@ -461,11 +461,11 @@ static bool AddReorderEntry(struct rx_ts_record *pTS,
>
>  	while (pList->next != &pTS->RxPendingPktList) {

Is this a list_for_each in disguise?

julia

>  		if (SN_LESS(pReorderEntry->SeqNum, ((struct rx_reorder_entry *)
> -		    list_entry(pList->next, struct rx_reorder_entry,
> +		    list_first_entry(pList, struct rx_reorder_entry,
>  		    List))->SeqNum))
>  			pList = pList->next;
>  		else if (SN_EQUAL(pReorderEntry->SeqNum,
> -			((struct rx_reorder_entry *)list_entry(pList->next,
> +			((struct rx_reorder_entry *)list_first_entry(pList,
>  			struct rx_reorder_entry, List))->SeqNum))
>  				return false;
>  		else
> --
> 1.9.1
>
> --
> You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1457278585-16295-1-git-send-email-bhumirks%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-03-07  0:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-06 15:36 [PATCH] Staging: rtl8192e: Use list_first_entry instead of list_entry Bhumika Goyal
2016-03-07  0:06 ` [Outreachy kernel] " Julia Lawall

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.