Skip to contentSkip to conversation

staging: r8188eu: os_dep: simplifiy the rtw_resume function

PATCH Superseded Saurav Girepunje 2 participants 4 messages Sep 4, 2021 – Sep 9, 2021 Staging

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 staging: r8188eu: os_dep: simplifiy the rtw_resume function

Remove unused variable ret and pwrpriv.
Remove the condition with no effect (if == else) in usb_intf.c file.
Remove rtw_resume_process() and move whole thing to rtw_resume().

---

ChangeLog V2:
- Remove rtw_resume_process() and move whole thing to rtw_resume().

---
 drivers/staging/r8188eu/include/usb_osintf.h |  2 --
 drivers/staging/r8188eu/os_dep/usb_intf.c    | 12 ------------
 2 files changed, 14 deletions(-)
drivers/staging/r8188eu/include/usb_osintf.h +0 -2
index d1a1f739309c..34229b1cb081 100644
@@ -24,6 +24,4 @@ void *scdb_findEntry(struct adapter *priv, unsigned char *macAddr,
 void nat25_db_expire(struct adapter *priv);
 int nat25_db_handle(struct adapter *priv, struct sk_buff *skb, int method);
 
-int rtw_resume_process(struct adapter *padapter);
-
 #endif
drivers/staging/r8188eu/os_dep/usb_intf.c +0 -12
index bb85ab77fd26..77b03e7631b7 100644
@@ -493,18 +493,6 @@ static int rtw_resume(struct usb_interface *pusb_intf)
 {
 	struct dvobj_priv *dvobj = usb_get_intfdata(pusb_intf);
 	struct adapter *padapter = dvobj->if1;
-	struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
-	int ret = 0;
-
-	if (pwrpriv->bInternalAutoSuspend)
-		ret = rtw_resume_process(padapter);
-	else
-		ret = rtw_resume_process(padapter);
-	return ret;
-}
-
-int rtw_resume_process(struct adapter *padapter)
-{
 	struct net_device *pnetdev;
 	struct pwrctrl_priv *pwrpriv = NULL;
 	int ret = -1;

--
2.32.0

maintainer
#1 lore raw
Quoted 39 lines · Saurav Girepunje

Remove unused variable ret and pwrpriv.
Remove the condition with no effect (if == else) in usb_intf.c file.
Remove rtw_resume_process() and move whole thing to rtw_resume().

---

ChangeLog V2:
- Remove rtw_resume_process() and move whole thing to rtw_resume().

---
 drivers/staging/r8188eu/include/usb_osintf.h |  2 --
 drivers/staging/r8188eu/os_dep/usb_intf.c    | 12 ------------
 2 files changed, 14 deletions(-)
drivers/staging/r8188eu/include/usb_osintf.h +0 -2
index d1a1f739309c..34229b1cb081 100644
@@ -24,6 +24,4 @@ void *scdb_findEntry(struct adapter *priv, unsigned char *macAddr,
 void nat25_db_expire(struct adapter *priv);
 int nat25_db_handle(struct adapter *priv, struct sk_buff *skb, int method);
 
-int rtw_resume_process(struct adapter *padapter);
-
 #endif
drivers/staging/r8188eu/os_dep/usb_intf.c +0 -5
index bb85ab77fd26..77b03e7631b7 100644
@@ -493,18 +493,6 @@ static int rtw_resume(struct usb_interface *pusb_intf)
 {
 	struct dvobj_priv *dvobj = usb_get_intfdata(pusb_intf);
 	struct adapter *padapter = dvobj->if1;
-	struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
-	int ret = 0;
-
-	if (pwrpriv->bInternalAutoSuspend)
-		ret = rtw_resume_process(padapter);

drivers/staging/r8188eu/os_dep/usb_intf.c static int rtw_resume(struct usb_interface *pusb_intf) · line 498

Quoted 10 lines
drivers/staging/r8188eu/os_dep/usb_intf.c +0 -7
-	else
-		ret = rtw_resume_process(padapter);
-	return ret;
-}
-
-int rtw_resume_process(struct adapter *padapter)
-{
 	struct net_device *pnetdev;
 	struct pwrctrl_priv *pwrpriv = NULL;
 	int ret = -1;

You can also remove the test for padapter being NULL in this function, as you just proved it could never be null otherwise the above function you removed would have crashed, right? You should do that all at once so we remember why that test was removed.

thanks,

greg k-h

#2 lore raw
Quoted 56 lines · Greg KH
Quoted 39 lines · Saurav Girepunje

Remove unused variable ret and pwrpriv.
Remove the condition with no effect (if == else) in usb_intf.c file.
Remove rtw_resume_process() and move whole thing to rtw_resume().

---

ChangeLog V2:
- Remove rtw_resume_process() and move whole thing to rtw_resume().

---
  drivers/staging/r8188eu/include/usb_osintf.h |  2 --
  drivers/staging/r8188eu/os_dep/usb_intf.c    | 12 ------------
  2 files changed, 14 deletions(-)
drivers/staging/r8188eu/include/usb_osintf.h +0 -2
index d1a1f739309c..34229b1cb081 100644
@@ -24,6 +24,4 @@ void *scdb_findEntry(struct adapter *priv, unsigned char *macAddr,
  void nat25_db_expire(struct adapter *priv);
  int nat25_db_handle(struct adapter *priv, struct sk_buff *skb, int method);
 
-int rtw_resume_process(struct adapter *padapter);
-
  #endif
drivers/staging/r8188eu/os_dep/usb_intf.c +0 -5
index bb85ab77fd26..77b03e7631b7 100644
@@ -493,18 +493,6 @@ static int rtw_resume(struct usb_interface *pusb_intf)
  {
  	struct dvobj_priv *dvobj = usb_get_intfdata(pusb_intf);
  	struct adapter *padapter = dvobj->if1;
-	struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
-	int ret = 0;
-
-	if (pwrpriv->bInternalAutoSuspend)
-		ret = rtw_resume_process(padapter);

drivers/staging/r8188eu/os_dep/usb_intf.c static int rtw_resume(struct usb_interface *pusb_intf) · line 498

Quoted 10 lines
drivers/staging/r8188eu/os_dep/usb_intf.c +0 -7
-	else
-		ret = rtw_resume_process(padapter);
-	return ret;
-}
-
-int rtw_resume_process(struct adapter *padapter)
-{
  	struct net_device *pnetdev;
  	struct pwrctrl_priv *pwrpriv = NULL;
  	int ret = -1;

You can also remove the test for padapter being NULL in this function, as you just proved it could never be null otherwise the above function you removed would have crashed, right? You should do that all at once so we remember why that test was removed.

Quoted 4 lines

thanks,

greg k-h

Yes, padapter was deference without checking it could be NULL on rtw_resume.

I think having NULL check would be safe. However if padapter is NULL then on goto exit "if (pwrpriv)" condition will never true as pwrpriv is initialized with NULL. There should be one more goto exit just to return.!

let me know you thought greg,

Regards,
Saurav Girepunje

maintainer
#3 lore raw
Quoted 59 lines · Saurav Girepunje
Quoted 56 lines · Greg KH
Quoted 39 lines · Saurav Girepunje

Remove unused variable ret and pwrpriv.
Remove the condition with no effect (if == else) in usb_intf.c file.
Remove rtw_resume_process() and move whole thing to rtw_resume().

---

ChangeLog V2:
- Remove rtw_resume_process() and move whole thing to rtw_resume().

---
  drivers/staging/r8188eu/include/usb_osintf.h |  2 --
  drivers/staging/r8188eu/os_dep/usb_intf.c    | 12 ------------
  2 files changed, 14 deletions(-)
drivers/staging/r8188eu/include/usb_osintf.h +0 -2
index d1a1f739309c..34229b1cb081 100644
@@ -24,6 +24,4 @@ void *scdb_findEntry(struct adapter *priv, unsigned char *macAddr,
  void nat25_db_expire(struct adapter *priv);
  int nat25_db_handle(struct adapter *priv, struct sk_buff *skb, int method);
 
-int rtw_resume_process(struct adapter *padapter);
-
  #endif
drivers/staging/r8188eu/os_dep/usb_intf.c +0 -5
index bb85ab77fd26..77b03e7631b7 100644
@@ -493,18 +493,6 @@ static int rtw_resume(struct usb_interface *pusb_intf)
  {
  	struct dvobj_priv *dvobj = usb_get_intfdata(pusb_intf);
  	struct adapter *padapter = dvobj->if1;
-	struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
-	int ret = 0;
-
-	if (pwrpriv->bInternalAutoSuspend)
-		ret = rtw_resume_process(padapter);

drivers/staging/r8188eu/os_dep/usb_intf.c static int rtw_resume(struct usb_interface *pusb_intf) · line 498

Quoted 10 lines
drivers/staging/r8188eu/os_dep/usb_intf.c +0 -7
-	else
-		ret = rtw_resume_process(padapter);
-	return ret;
-}
-
-int rtw_resume_process(struct adapter *padapter)
-{
  	struct net_device *pnetdev;
  	struct pwrctrl_priv *pwrpriv = NULL;
  	int ret = -1;

You can also remove the test for padapter being NULL in this function, as you just proved it could never be null otherwise the above function you removed would have crashed, right? You should do that all at once so we remember why that test was removed.

Quoted 6 lines
Quoted 4 lines

thanks,

greg k-h

Yes, padapter was deference without checking it could be NULL on rtw_resume.

How can it ever be NULL there?

Quoted 5 lines

I think having NULL check would be safe. However if padapter is NULL then on goto exit "if (pwrpriv)" condition will never true as pwrpriv is initialized with NULL. There should be one more goto exit just to return.!

let me know you thought greg,

Don't check for things that can never happen.

thanks,

greg k-h