staging: r8188eu: remove intf_start and intf_stop
cover staging: r8188eu: remove intf_start and intf_stop
Remove the two pointers to media-specific start and stop functions. The r8188eu driver supports only usb.
Update some of the functions in the start and stop paths to return standard error codes instead of _SUCCESS and _FAIL.
Martin Kaiser (6):
staging: r8188eu: pass a struct recv_buf to rtw_read_port
staging: r8188eu: use standard error codes in rtw_read_port
staging: r8188eu: use standard error codes in rtl8188eu_inirp_init
staging: r8188eu: remove intf_start pointer
staging: r8188eu: handle rtl8188eu_inirp_init errors
staging: r8188eu: remove intf_stop pointer
drivers/staging/r8188eu/hal/usb_halinit.c | 16 ++++++-------- drivers/staging/r8188eu/hal/usb_ops_linux.c | 20 ++++++++--------- drivers/staging/r8188eu/include/drv_types.h | 2 -- drivers/staging/r8188eu/include/hal_intf.h | 2 +- drivers/staging/r8188eu/include/rtw_io.h | 2 +- drivers/staging/r8188eu/os_dep/os_intfs.c | 12 +++++------ drivers/staging/r8188eu/os_dep/usb_intf.c | 24 +++------------------ 7 files changed, 26 insertions(+), 52 deletions(-)
Signature · 1 line
2.30.2
PATCH 1/6 staging: r8188eu: pass a struct recv_buf to rtw_read_port
The rtw_read_port function needs a struct recv_buf for preparing the usb transfer.
Replace its u8 *rmem parameter with a struct recv_buf pointer to avoid casts in the caller and in rtw_read_port.
--- drivers/staging/r8188eu/hal/usb_halinit.c | 2 +- drivers/staging/r8188eu/hal/usb_ops_linux.c | 9 ++++----- drivers/staging/r8188eu/include/rtw_io.h | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-)
drivers/staging/r8188eu/hal/usb_halinit.c +1 -1
@@ -860,7 +860,7 @@ unsigned int rtl8188eu_inirp_init(struct adapter *Adapter)/* issue Rx irp to receive data */ precvbuf = (struct recv_buf *)precvpriv->precv_buf;for (i =0 ; i <NR_RECVBUFF ; i++) { -if (!rtw_read_port (Adapter, (unsigned char *)precvbuf)) { +if (!rtw_read_port (Adapter, precvbuf)) { status = _FAIL; goto exit; }
drivers/staging/r8188eu/hal/usb_ops_linux.c +4 -5
@@ -364,7 +364,7 @@ static void usb_read_port_complete(struct urb *purb)if (purb->status ==0 ) {/* SUCCESS */ if ((purb->actual_length >MAX_RECVBUF_SZ ) || (purb->actual_length <RXDESC_SIZE )) { precvbuf->reuse = true; -rtw_read_port (adapt, (unsigned char *)precvbuf); +rtw_read_port (adapt, precvbuf); }else {rtw_reset_continual_urb_error (adapter_to_dvobj (adapt));
@@ -376,7 +376,7 @@ static void usb_read_port_complete(struct urb *purb) precvbuf->pskb =NULL ; precvbuf->reuse = false; -rtw_read_port (adapt, (unsigned char *)precvbuf); +rtw_read_port (adapt, precvbuf); } }else {skb_put (precvbuf->pskb, purb->actual_length);
@@ -396,7 +396,7 @@ static void usb_read_port_complete(struct urb *purb)case -EPROTO :case -EOVERFLOW : precvbuf->reuse = true; -rtw_read_port (adapt, (unsigned char *)precvbuf); +rtw_read_port (adapt, precvbuf);break ;case -EINPROGRESS :break ;
@@ -406,10 +406,9 @@ static void usb_read_port_complete(struct urb *purb) } } -u32 rtw_read_port (struct adapter *adapter,u8 *rmem) +u32 rtw_read_port (struct adapter *adapter,struct recv_buf *precvbuf) {struct urb *purb =NULL ; -struct recv_buf *precvbuf = (struct recv_buf *)rmem;struct dvobj_priv *pdvobj =adapter_to_dvobj (adapter);struct recv_priv *precvpriv = &adapter->recvpriv;struct usb_device *pusbd = pdvobj->pusbdev;
drivers/staging/r8188eu/include/rtw_io.h +1 -1
@@ -19,7 +19,7 @@int __must_check rtw_read8 (struct adapter *adapter,u32 addr,u8 *data);int __must_check rtw_read16 (struct adapter *adapter,u32 addr,u16 *data);int __must_check rtw_read32 (struct adapter *adapter,u32 addr,u32 *data); -u32 rtw_read_port (struct adapter *adapter,u8 *pmem); +u32 rtw_read_port (struct adapter *adapter,struct recv_buf *precvbuf);void rtw_read_port_cancel (struct adapter *adapter);int rtw_write8 (struct adapter *adapter,u32 addr,u8 val);
Signature · 1 line
2.30.2
PATCH 2/6 staging: r8188eu: use standard error codes in rtw_read_port
In reply to Martin KaiserReplace the driver-specific _SUCCESS and _FAIL error codes in rtw_read_port. Return 0 for success or a negative error code as we do elsewhere in the kernel.
--- drivers/staging/r8188eu/hal/usb_ops_linux.c | 13 ++++++------- drivers/staging/r8188eu/include/rtw_io.h | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-)
drivers/staging/r8188eu/hal/usb_ops_linux.c +6 -7
@@ -406,7 +406,7 @@ static void usb_read_port_complete(struct urb *purb) } } -u32 rtw_read_port (struct adapter *adapter,struct recv_buf *precvbuf) +int rtw_read_port (struct adapter *adapter,struct recv_buf *precvbuf) {struct urb *purb =NULL ;struct dvobj_priv *pdvobj =adapter_to_dvobj (adapter);
@@ -416,13 +416,12 @@ u32 rtw_read_port(struct adapter *adapter, struct recv_buf *precvbuf)unsigned int pipe;size_t tmpaddr =0 ;size_t alignment =0 ; -u32 ret = _SUCCESS;if (adapter->bDriverStopped || adapter->bSurpriseRemoved) -return _FAIL; +return -EPERM ;if (!precvbuf) -return _FAIL; +return -ENOMEM ;if (!precvbuf->reuse || !precvbuf->pskb) { precvbuf->pskb =skb_dequeue (&precvpriv->free_recv_skb_queue);
@@ -434,7 +433,7 @@ u32 rtw_read_port(struct adapter *adapter, struct recv_buf *precvbuf)if (!precvbuf->reuse || !precvbuf->pskb) { precvbuf->pskb =netdev_alloc_skb (adapter->pnetdev,MAX_RECVBUF_SZ +RECVBUFF_ALIGN_SZ );if (!precvbuf->pskb) -return _FAIL; +return -ENOMEM ; tmpaddr = (size_t )precvbuf->pskb->data; alignment = tmpaddr & (RECVBUFF_ALIGN_SZ -1 );
@@ -458,9 +457,9 @@ u32 rtw_read_port(struct adapter *adapter, struct recv_buf *precvbuf) err =usb_submit_urb (purb,GFP_ATOMIC );if ((err) && (err != (-EPERM ))) - ret = _FAIL; +return err; -return ret; +return 0 ; }void rtl8188eu_xmit_tasklet (unsigned long priv)
drivers/staging/r8188eu/include/rtw_io.h +1 -1
@@ -19,7 +19,7 @@int __must_check rtw_read8 (struct adapter *adapter,u32 addr,u8 *data);int __must_check rtw_read16 (struct adapter *adapter,u32 addr,u16 *data);int __must_check rtw_read32 (struct adapter *adapter,u32 addr,u32 *data); -u32 rtw_read_port (struct adapter *adapter,struct recv_buf *precvbuf); +int rtw_read_port (struct adapter *adapter,struct recv_buf *precvbuf);void rtw_read_port_cancel (struct adapter *adapter);int rtw_write8 (struct adapter *adapter,u32 addr,u8 val);
Signature · 1 line
2.30.2
PATCH 3/6 staging: r8188eu: use standard error codes in rtl8188eu_inirp_init
In reply to Martin KaiserReplace the driver-specific _SUCCESS and _FAIL error codes in rtl8188eu_inirp_init. Return 0 for success or a negative error code as we do elsewhere in the kernel.
--- drivers/staging/r8188eu/hal/usb_halinit.c | 16 ++++++---------- drivers/staging/r8188eu/include/hal_intf.h | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-)
drivers/staging/r8188eu/hal/usb_halinit.c +6 -10
@@ -848,29 +848,25 @@ u32 rtl8188eu_hal_deinit(struct adapter *Adapter)return _SUCCESS; } -unsigned int rtl8188eu_inirp_init (struct adapter *Adapter) +int rtl8188eu_inirp_init (struct adapter *Adapter) {u8 i;struct recv_buf *precvbuf; -uint status;struct recv_priv *precvpriv = &Adapter->recvpriv; - - status = _SUCCESS; +int ret;/* issue Rx irp to receive data */ precvbuf = (struct recv_buf *)precvpriv->precv_buf;for (i =0 ; i <NR_RECVBUFF ; i++) { -if (!rtw_read_port (Adapter, precvbuf)) { - status = _FAIL; - goto exit; - } + ret =rtw_read_port (Adapter, precvbuf); +if (ret) +return ret; precvbuf++; precvpriv->free_recv_buf_queue_cnt--; } -exit: -return status; +return 0 ; }/* */
drivers/staging/r8188eu/include/hal_intf.h +1 -1
@@ -26,7 +26,7 @@ void UpdateHalRAMask8188EUsb(struct adapter *adapt, u32 mac_id, u8 rssi_level);int rtl8188e_IOL_exec_cmds_sync (struct adapter *adapter,struct xmit_frame *xmit_frame,u32 max_wating_ms,u32 bndy_cnt); -unsigned int rtl8188eu_inirp_init (struct adapter *Adapter); +int rtl8188eu_inirp_init (struct adapter *Adapter);uint rtw_hal_init (struct adapter *padapter);uint rtw_hal_deinit (struct adapter *padapter);
Signature · 1 line
2.30.2
PATCH 4/6 staging: r8188eu: remove intf_start pointer
In reply to Martin KaiserRemove the intf_start pointer that points to a media-specific start function (pci, usb, sdio, ...). The r8188eu driver supports only usb.
We could call usb_intf_start directly instead of going through the function pointer. usb_intf_start is just a call to rtl8188eu_inirp_init so we can directly replace the intf_start pointer with rtl8188eu_inirp_init.
--- drivers/staging/r8188eu/include/drv_types.h | 1 - drivers/staging/r8188eu/os_dep/os_intfs.c | 6 ++---- drivers/staging/r8188eu/os_dep/usb_intf.c | 6 ------ 3 files changed, 2 insertions(+), 11 deletions(-)
drivers/staging/r8188eu/include/drv_types.h +0 -1
@@ -171,7 +171,6 @@ struct adapter {s8 signal_strength;void *cmdThread; -void (*intf_start)(struct adapter *adapter);void (*intf_stop)(struct adapter *adapter);struct net_device *pnetdev;
drivers/staging/r8188eu/os_dep/os_intfs.c +2 -4
@@ -631,8 +631,7 @@ static int _netdev_open(struct net_device *pnetdev)pr_info ("can't init mlme_ext_priv\n" ); goto netdev_open_error; } -if (padapter->intf_start) - padapter->intf_start (padapter); +rtl8188eu_inirp_init (padapter);rtw_led_control (padapter,LED_CTL_NO_LINK );
@@ -684,8 +683,7 @@ static int ips_netdrv_open(struct adapter *padapter)if (status == _FAIL) goto netdev_open_error; -if (padapter->intf_start) - padapter->intf_start (padapter); +rtl8188eu_inirp_init (padapter);rtw_set_pwr_state_check_timer (&padapter->pwrctrlpriv);_set_timer (&padapter->mlmepriv.dynamic_chk_timer,5000 );
drivers/staging/r8188eu/os_dep/usb_intf.c +0 -6
@@ -152,11 +152,6 @@ static void usb_dvobj_deinit(struct usb_interface *usb_intf) } -static void usb_intf_start (struct adapter *padapter) -{ -rtl8188eu_inirp_init (padapter); -} -static void usb_intf_stop (struct adapter *padapter) {/* cancel in irp */
@@ -313,7 +308,6 @@ static int rtw_usb_if1_init(struct dvobj_priv *dvobj, struct usb_interface *pusbSET_NETDEV_DEV (pnetdev,dvobj_to_dev (dvobj)); padapter =rtw_netdev_priv (pnetdev); - padapter->intf_start = &usb_intf_start; padapter->intf_stop = &usb_intf_stop;/* step read_chip_version */
Signature · 1 line
2.30.2
PATCH 5/6 staging: r8188eu: handle rtl8188eu_inirp_init errors
In reply to Martin KaiserThe rtl8188eu_inirp_init returns 0 for success or a negative error code. Handle this return value in the two places where rtl8188eu_inirp_init is called.
--- drivers/staging/r8188eu/os_dep/os_intfs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/staging/r8188eu/os_dep/os_intfs.c +4 -2
@@ -631,7 +631,8 @@ static int _netdev_open(struct net_device *pnetdev)pr_info ("can't init mlme_ext_priv\n" ); goto netdev_open_error; } -rtl8188eu_inirp_init (padapter); +if (rtl8188eu_inirp_init (padapter)) + goto netdev_open_error;rtw_led_control (padapter,LED_CTL_NO_LINK );
@@ -683,7 +684,8 @@ static int ips_netdrv_open(struct adapter *padapter)if (status == _FAIL) goto netdev_open_error; -rtl8188eu_inirp_init (padapter); +if (rtl8188eu_inirp_init (padapter)) + goto netdev_open_error;rtw_set_pwr_state_check_timer (&padapter->pwrctrlpriv);_set_timer (&padapter->mlmepriv.dynamic_chk_timer,5000 );
Signature · 1 line
2.30.2
PATCH 6/6 staging: r8188eu: remove intf_stop pointer
In reply to Martin KaiserRemove the intf_stop pointer that points to a media-specific stop function. The r8188eu driver supports only usb.
For usb drivers, intf_stop points to usb_intf_stop, which is only two lines long. We can remove intf_stop and usb_intf_stop and call the two cancel functions directly.
--- drivers/staging/r8188eu/include/drv_types.h | 1 - drivers/staging/r8188eu/os_dep/os_intfs.c | 4 ++-- drivers/staging/r8188eu/os_dep/usb_intf.c | 18 +++--------------- 3 files changed, 5 insertions(+), 18 deletions(-)
drivers/staging/r8188eu/include/drv_types.h +0 -1
@@ -171,7 +171,6 @@ struct adapter {s8 signal_strength;void *cmdThread; -void (*intf_stop)(struct adapter *adapter);struct net_device *pnetdev;/* used by rtw_rereg_nd_name related function */
drivers/staging/r8188eu/os_dep/os_intfs.c +2 -2
@@ -761,8 +761,8 @@ void rtw_ips_dev_unload(struct adapter *padapter) {rtw_fifo_cleanup (padapter); -if (padapter->intf_stop) - padapter->intf_stop (padapter); +rtw_read_port_cancel (padapter); +rtw_write_port_cancel (padapter);/* s5. */ if (!padapter->bSurpriseRemoved)
drivers/staging/r8188eu/os_dep/usb_intf.c +3 -15
@@ -152,17 +152,6 @@ static void usb_dvobj_deinit(struct usb_interface *usb_intf) } -static void usb_intf_stop (struct adapter *padapter) -{ -/* cancel in irp */ -rtw_read_port_cancel (padapter); - -/* cancel out irp */ -rtw_write_port_cancel (padapter); - -/* todo:cancel other irps */ -} -static void rtw_dev_unload (struct adapter *padapter) {if (padapter->bup) {
@@ -170,8 +159,9 @@ static void rtw_dev_unload(struct adapter *padapter)if (padapter->xmitpriv.ack_tx)rtw_ack_tx_done (&padapter->xmitpriv,RTW_SCTX_DONE_DRV_STOP );/* s3. */ -if (padapter->intf_stop) - padapter->intf_stop (padapter); +rtw_read_port_cancel (padapter); +rtw_write_port_cancel (padapter); +/* s4. */ rtw_stop_drv_threads (padapter);
@@ -308,8 +298,6 @@ static int rtw_usb_if1_init(struct dvobj_priv *dvobj, struct usb_interface *pusbSET_NETDEV_DEV (pnetdev,dvobj_to_dev (dvobj)); padapter =rtw_netdev_priv (pnetdev); - padapter->intf_stop = &usb_intf_stop; -/* step read_chip_version */ rtl8188e_read_chip_version (padapter);
Signature · 1 line
2.30.2
Quoted 14 lines · Martin Kaiser
Remove the two pointers to media-specific start and stop functions. The r8188eu driver supports only usb.
Update some of the functions in the start and stop paths to return standard error codes instead of
_SUCCESSand_FAIL.Martin Kaiser (6):
staging: r8188eu: pass a structrecv_buftortw_read_port
staging: r8188eu: use standard error codes inrtw_read_port
staging: r8188eu: use standard error codes inrtl8188eu_inirp_init
staging: r8188eu: removeintf_startpointer
staging: r8188eu: handlertl8188eu_inirp_initerrors
staging: r8188eu: removeintf_stoppointer
Quoted 9 lines
drivers/staging/r8188eu/hal/usb_halinit.c | 16 ++++++-------- drivers/staging/r8188eu/hal/usb_ops_linux.c | 20 ++++++++--------- drivers/staging/r8188eu/include/drv_types.h | 2 -- drivers/staging/r8188eu/include/hal_intf.h | 2 +- drivers/staging/r8188eu/include/rtw_io.h | 2 +- drivers/staging/r8188eu/os_dep/os_intfs.c | 12 +++++------ drivers/staging/r8188eu/os_dep/usb_intf.c | 24 +++------------------ 7 files changed, 26 insertions(+), 52 deletions(-)