Skip to contentSkip to conversation

Staging: gdm72xx: Use list_first_entry_or_null

PATCH New Bhumika Goyal 1 participant 1 message Mar 6, 2016 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: gdm72xx: Use list_first_entry_or_null

This patch replaces list_empty and list_entry with list_first_entry_or_null as this makes the code more clear. Done using coccinelle:

@@
expression e1,e2;
statement S;
@@
- if(!list_empty(...)){
e2=
- list_entry(e1.next,
+ list_first_entry_or_null(&e1,
...);
+ if(e2){
...
}

---
 drivers/staging/gdm72xx/gdm_sdio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/gdm72xx/gdm_sdio.c +2 -2
index 9449418..b593691 100644
@@ -551,8 +551,8 @@ end_io:
 
 	spin_lock_irqsave(&rx->lock, flags);
 
-	if (!list_empty(&rx->req_list)) {
-		r = list_entry(rx->req_list.next, struct sdio_rx, list);
+	r = list_first_entry_or_null(&rx->req_list, struct sdio_rx, list);
+	if (r) {
 		spin_unlock_irqrestore(&rx->lock, flags);
 		if (r->callback)
 			r->callback(r->cb_data, rx->rx_buf, len);
Signature · 1 line
1.9.1