Skip to contentSkip to conversation

clean up error handling

PATCH In review Omer El Idrissi 2 participants 4 messages Mar 26 Staging

lore
Share & tools
lore
#0 lore raw

v4 cover clean up error handling

This series lets sdio_init() propagate standard kernel error codes instead of returning _SUCCESS/_FAIL. There are two callers for this function. rtw_resume_process_normal() already returns negative values but the caller doesn't check for errors so changing this doesn't affect anything. sdio_dvobj_init() returns NULL on
error so leave that as-is.

---
v4:
- Squash commits 2, 3, and 4 into one commit

v3:
- Add one commit that lets sdio_dvobj_init() use more readable error handling
- Add v3 and v2 tags

v2:
- Add one commit that lets rtw_resume_process_normal cleanly check errors and return errno instead of using vendor-defined check

v1:
- Use direct returns in sdio_dvobj_init()
- Cleanup return in sdio_init()

Omer El Idrissi (2):
staging: rtl8723bs: use direct returns in sdio_dvobj_init()
staging: rtl8723bs: cleanup return in sdio_init()

 drivers/staging/rtl8723bs/os_dep/os_intfs.c  |  8 +++----
 drivers/staging/rtl8723bs/os_dep/sdio_intf.c | 25 ++++++++------------
 2 files changed, 14 insertions(+), 19 deletions(-)
Signature · 1 line
2.51.0
#1 lore raw

PATCH v4 1/2 staging: rtl8723bs: use direct returns in sdio_dvobj_init()

Make sdio_dvobj_init() use direct returns

---
 drivers/staging/rtl8723bs/os_dep/sdio_intf.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)
drivers/staging/rtl8723bs/os_dep/sdio_intf.c +6 -11
index d664e254912c..358eac0837cf 100644
@@ -155,13 +155,12 @@ static void sdio_deinit(struct dvobj_priv *dvobj)
 }
 static struct dvobj_priv *sdio_dvobj_init(struct sdio_func *func)
 {
-	int status = _FAIL;
 	struct dvobj_priv *dvobj = NULL;
 	struct sdio_data *psdio;
 
 	dvobj = devobj_init();
 	if (!dvobj)
-		goto exit;
+		return NULL;
 
 	sdio_set_drvdata(func, dvobj);
 
@@ -172,18 +171,14 @@ static struct dvobj_priv *sdio_dvobj_init(struct sdio_func *func)
 		goto free_dvobj;
 
 	rtw_reset_continual_io_error(dvobj);
-	status = _SUCCESS;
 
-free_dvobj:
-	if (status != _SUCCESS && dvobj) {
-		sdio_set_drvdata(func, NULL);
+	return dvobj;
 
-		devobj_deinit(dvobj);
+free_dvobj:
+	sdio_set_drvdata(func, NULL);
+	devobj_deinit(dvobj);
 
-		dvobj = NULL;
-	}
-exit:
-	return dvobj;
+	return NULL;
 }
 
 static void sdio_dvobj_deinit(struct sdio_func *func)
Signature · 1 line
2.51.0
#2 lore raw

PATCH v4 2/2 staging: rtl8723bs: cleanup return in sdio_init()

In reply to Omer El Idrissi

Make sdio_init() return errno from sdio_enable_func or sdio_set_block_size instead of _SUCCESS/_FAIL vendor-defined macros. Let rtw_resume_process_normal return errno returned by sdio_init instead of -1. sdio_dvobj_init returns NULL on error so leave that as is. Let sdio_dvobj_init use a slightly more readable and conventional error check for sdio_init().

---
 drivers/staging/rtl8723bs/os_dep/os_intfs.c  | 8 ++++----
 drivers/staging/rtl8723bs/os_dep/sdio_intf.c | 8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)
drivers/staging/rtl8723bs/os_dep/os_intfs.c +4 -4
index 7ba689f2dfc8..e943dcea1a21 100644
@@ -1135,10 +1135,10 @@ static int rtw_resume_process_normal(struct adapter *padapter)
 	pwrpriv = adapter_to_pwrctl(padapter);
 	pmlmepriv = &padapter->mlmepriv;
 	/*  interface init */
-	/* if (sdio_init(adapter_to_dvobj(padapter)) != _SUCCESS) */
-	if ((padapter->intf_init) && (padapter->intf_init(adapter_to_dvobj(padapter)) != _SUCCESS)) {
-		ret = -1;
-		goto exit;
+	if (padapter->intf_init) {
+		ret = padapter->intf_init(adapter_to_dvobj(padapter));
+		if (ret)
+			goto exit;
 	}
 	rtw_hal_disable_interrupt(padapter);
 	/* if (sdio_alloc_irq(adapter_to_dvobj(padapter)) != _SUCCESS) */
drivers/staging/rtl8723bs/os_dep/sdio_intf.c +4 -4
index 358eac0837cf..d0feb28b7043 100644
@@ -131,9 +131,7 @@ static u32 sdio_init(struct dvobj_priv *dvobj)
 release:
 	sdio_release_host(func);
 
-	if (err)
-		return _FAIL;
-	return _SUCCESS;
+	return err;
 }
 
 static void sdio_deinit(struct dvobj_priv *dvobj)
@@ -157,6 +155,7 @@ static struct dvobj_priv *sdio_dvobj_init(struct sdio_func *func)
 {
 	struct dvobj_priv *dvobj = NULL;
 	struct sdio_data *psdio;
+	int ret;
 
 	dvobj = devobj_init();
 	if (!dvobj)
@@ -167,7 +166,8 @@ static struct dvobj_priv *sdio_dvobj_init(struct sdio_func *func)
 	psdio = &dvobj->intf_data;
 	psdio->func = func;
 
-	if (sdio_init(dvobj) != _SUCCESS)
+	ret = sdio_init(dvobj);
+	if (ret)
 		goto free_dvobj;
 
 	rtw_reset_continual_io_error(dvobj);
Signature · 1 line
2.51.0
Reviewed-by on the v4 series
#3 lore raw
In reply to Omer El Idrissi
Quoted 9 lines · Omer El Idrissi

This series lets sdio_init() propagate standard kernel error codes instead of returning _SUCCESS/_FAIL. There are two callers for this function. rtw_resume_process_normal() already returns negative values but the caller doesn't check for errors so changing this doesn't affect anything. sdio_dvobj_init() returns NULL on
error so leave that as-is.

---

Great! Thanks.

regards,
dan carpenter