Re: [PATCH] staging: rtl8723bs: os_dep: Move common code to func
Hi, On 25-07-19 20:31, Hariprasad Kelam wrote: Inthis file all functions has below common functionality 1.Check flag padapter->bSurpriseRemoved 2.Get sdio_func structure from intf_hdl. This patch introduces two new APIs rtw_isadapter_removed,rtw_sdio_get_func which helps to do above common functionality. Signed-off-by: Hariprasad Kelam Looks good to me: Reviewed-by: Hans de Goede Regards, Hans --- drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c | 149 ++ 1 file changed, 41 insertions(+), 108 deletions(-) diff --git a/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c b/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c index 50b8934..126429e 100644 --- a/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c @@ -26,26 +26,38 @@ inline void rtw_sdio_set_irq_thd(struct dvobj_priv *dvobj, void *thd_hdl) sdio_data->sys_sdio_irq_thd = thd_hdl; } -u8 sd_f0_read8(struct intf_hdl *pintfhdl, u32 addr, s32 *err) +static s32 rtw_isadapter_removed(struct intf_hdl *pintfhdl) { struct adapter *padapter; + + padapter = pintfhdl->padapter; + return padapter->bSurpriseRemoved; +} + +static struct sdio_func *rtw_sdio_get_func(struct intf_hdl *pintfhdl) +{ struct dvobj_priv *psdiodev; struct sdio_data *psdio; + psdiodev = pintfhdl->pintf_dev; + psdio = >intf_data; + + return psdio->func; +} + +u8 sd_f0_read8(struct intf_hdl *pintfhdl, u32 addr, s32 *err) +{ u8 v = 0; struct sdio_func *func; bool claim_needed; - padapter = pintfhdl->padapter; - psdiodev = pintfhdl->pintf_dev; - psdio = >intf_data; - if (padapter->bSurpriseRemoved) { + if (rtw_isadapter_removed(pintfhdl)) { /* DBG_871X(" %s (padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n", __func__); */ return v; } - func = psdio->func; + func = rtw_sdio_get_func(pintfhdl); claim_needed = rtw_sdio_claim_host_needed(func); if (claim_needed) @@ -65,23 +77,15 @@ u8 sd_f0_read8(struct intf_hdl *pintfhdl, u32 addr, s32 *err) */ s32 _sd_cmd52_read(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pdata) { - struct adapter *padapter; - struct dvobj_priv *psdiodev; - struct sdio_data *psdio; - int err = 0, i; struct sdio_func *func; - padapter = pintfhdl->padapter; - psdiodev = pintfhdl->pintf_dev; - psdio = >intf_data; - - if (padapter->bSurpriseRemoved) { + if (rtw_isadapter_removed(pintfhdl)) { /* DBG_871X(" %s (padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n", __func__); */ return err; } - func = psdio->func; + func = rtw_sdio_get_func(pintfhdl); for (i = 0; i < cnt; i++) { pdata[i] = sdio_readb(func, addr+i, ); @@ -100,24 +104,16 @@ s32 _sd_cmd52_read(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pdata) */ s32 sd_cmd52_read(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pdata) { - struct adapter *padapter; - struct dvobj_priv *psdiodev; - struct sdio_data *psdio; - int err = 0; struct sdio_func *func; bool claim_needed; - padapter = pintfhdl->padapter; - psdiodev = pintfhdl->pintf_dev; - psdio = >intf_data; - - if (padapter->bSurpriseRemoved) { + if (rtw_isadapter_removed(pintfhdl)) { /* DBG_871X(" %s (padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n", __func__); */ return err; } - func = psdio->func; + func = rtw_sdio_get_func(pintfhdl); claim_needed = rtw_sdio_claim_host_needed(func); if (claim_needed) @@ -135,23 +131,15 @@ s32 sd_cmd52_read(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pdata) */ s32 _sd_cmd52_write(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pdata) { - struct adapter *padapter; - struct dvobj_priv *psdiodev; - struct sdio_data *psdio; - int err = 0, i; struct sdio_func *func; - padapter = pintfhdl->padapter; - psdiodev = pintfhdl->pintf_dev; - psdio = >intf_data; - - if (padapter->bSurpriseRemoved) { + if (rtw_isadapter_removed(pintfhdl)) { /* DBG_871X(" %s (padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n", __func__); */ return err; } - func = psdio->func; + func = rtw_sdio_get_func(pintfhdl); for (i = 0; i < cnt; i++) { sdio_writeb(func, pdata[i], addr+i, ); @@ -170,24 +158,16 @@ s32 _sd_cmd52_write(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pdata) */ s32 sd_cmd52_write(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pdata) { - struct adapter *padapter; - struct dvobj_priv *psdiodev; - struct sdio_data *psdio; - int
[PATCH] staging: rtl8723bs: os_dep: Move common code to func
Inthis file all functions has below common functionality 1.Check flag padapter->bSurpriseRemoved 2.Get sdio_func structure from intf_hdl. This patch introduces two new APIs rtw_isadapter_removed,rtw_sdio_get_func which helps to do above common functionality. Signed-off-by: Hariprasad Kelam --- drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c | 149 ++ 1 file changed, 41 insertions(+), 108 deletions(-) diff --git a/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c b/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c index 50b8934..126429e 100644 --- a/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c @@ -26,26 +26,38 @@ inline void rtw_sdio_set_irq_thd(struct dvobj_priv *dvobj, void *thd_hdl) sdio_data->sys_sdio_irq_thd = thd_hdl; } -u8 sd_f0_read8(struct intf_hdl *pintfhdl, u32 addr, s32 *err) +static s32 rtw_isadapter_removed(struct intf_hdl *pintfhdl) { struct adapter *padapter; + + padapter = pintfhdl->padapter; + return padapter->bSurpriseRemoved; +} + +static struct sdio_func *rtw_sdio_get_func(struct intf_hdl *pintfhdl) +{ struct dvobj_priv *psdiodev; struct sdio_data *psdio; + psdiodev = pintfhdl->pintf_dev; + psdio = >intf_data; + + return psdio->func; +} + +u8 sd_f0_read8(struct intf_hdl *pintfhdl, u32 addr, s32 *err) +{ u8 v = 0; struct sdio_func *func; bool claim_needed; - padapter = pintfhdl->padapter; - psdiodev = pintfhdl->pintf_dev; - psdio = >intf_data; - if (padapter->bSurpriseRemoved) { + if (rtw_isadapter_removed(pintfhdl)) { /* DBG_871X(" %s (padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n", __func__); */ return v; } - func = psdio->func; + func = rtw_sdio_get_func(pintfhdl); claim_needed = rtw_sdio_claim_host_needed(func); if (claim_needed) @@ -65,23 +77,15 @@ u8 sd_f0_read8(struct intf_hdl *pintfhdl, u32 addr, s32 *err) */ s32 _sd_cmd52_read(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pdata) { - struct adapter *padapter; - struct dvobj_priv *psdiodev; - struct sdio_data *psdio; - int err = 0, i; struct sdio_func *func; - padapter = pintfhdl->padapter; - psdiodev = pintfhdl->pintf_dev; - psdio = >intf_data; - - if (padapter->bSurpriseRemoved) { + if (rtw_isadapter_removed(pintfhdl)) { /* DBG_871X(" %s (padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n", __func__); */ return err; } - func = psdio->func; + func = rtw_sdio_get_func(pintfhdl); for (i = 0; i < cnt; i++) { pdata[i] = sdio_readb(func, addr+i, ); @@ -100,24 +104,16 @@ s32 _sd_cmd52_read(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pdata) */ s32 sd_cmd52_read(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pdata) { - struct adapter *padapter; - struct dvobj_priv *psdiodev; - struct sdio_data *psdio; - int err = 0; struct sdio_func *func; bool claim_needed; - padapter = pintfhdl->padapter; - psdiodev = pintfhdl->pintf_dev; - psdio = >intf_data; - - if (padapter->bSurpriseRemoved) { + if (rtw_isadapter_removed(pintfhdl)) { /* DBG_871X(" %s (padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n", __func__); */ return err; } - func = psdio->func; + func = rtw_sdio_get_func(pintfhdl); claim_needed = rtw_sdio_claim_host_needed(func); if (claim_needed) @@ -135,23 +131,15 @@ s32 sd_cmd52_read(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pdata) */ s32 _sd_cmd52_write(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pdata) { - struct adapter *padapter; - struct dvobj_priv *psdiodev; - struct sdio_data *psdio; - int err = 0, i; struct sdio_func *func; - padapter = pintfhdl->padapter; - psdiodev = pintfhdl->pintf_dev; - psdio = >intf_data; - - if (padapter->bSurpriseRemoved) { + if (rtw_isadapter_removed(pintfhdl)) { /* DBG_871X(" %s (padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n", __func__); */ return err; } - func = psdio->func; + func = rtw_sdio_get_func(pintfhdl); for (i = 0; i < cnt; i++) { sdio_writeb(func, pdata[i], addr+i, ); @@ -170,24 +158,16 @@ s32 _sd_cmd52_write(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pdata) */ s32 sd_cmd52_write(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pdata) { - struct adapter *padapter; - struct dvobj_priv *psdiodev; - struct sdio_data *psdio; - int err = 0; struct sdio_func *func; bool claim_needed; - padapter