From 45c64aa030f5b2674f4ab25e336d22a7029863b1 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:55:31 +0200 Subject: [PATCH] staging: rtl8723au: Pass a struct rtw_adapter * to the USB functions This lowers the dependency on struct intf_hdl so we can start getting rid of if. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_io.c | 30 ++++++------ drivers/staging/rtl8723au/hal/usb_halinit.c | 8 +-- drivers/staging/rtl8723au/hal/usb_ops_linux.c | 49 +++++++++++-------- drivers/staging/rtl8723au/include/rtw_io.h | 28 +++++------ .../staging/rtl8723au/include/usb_ops_linux.h | 12 ++--- .../staging/rtl8723au/os_dep/usb_ops_linux.c | 15 +++--- 6 files changed, 73 insertions(+), 69 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_io.c b/drivers/staging/rtl8723au/core/rtw_io.c index 442a86b69e04..0f424f946dbb 100644 --- a/drivers/staging/rtl8723au/core/rtw_io.c +++ b/drivers/staging/rtl8723au/core/rtw_io.c @@ -46,7 +46,7 @@ u8 _rtw_read823a(struct rtw_adapter *adapter, u32 addr) u8 r_val; struct intf_hdl *pintfhdl = &adapter->intf; - r_val = pintfhdl->io_ops._read8(pintfhdl, addr); + r_val = pintfhdl->io_ops._read8(adapter, addr); return r_val; } @@ -56,7 +56,7 @@ u16 _rtw_read1623a(struct rtw_adapter *adapter, u32 addr) u16 r_val; struct intf_hdl *pintfhdl = &adapter->intf; - r_val = pintfhdl->io_ops._read16(pintfhdl, addr); + r_val = pintfhdl->io_ops._read16(adapter, addr); return le16_to_cpu(r_val); } @@ -66,7 +66,7 @@ u32 _rtw_read3223a(struct rtw_adapter *adapter, u32 addr) u32 r_val; struct intf_hdl *pintfhdl = &adapter->intf; - r_val = pintfhdl->io_ops._read32(pintfhdl, addr); + r_val = pintfhdl->io_ops._read32(adapter, addr); return le32_to_cpu(r_val); } @@ -76,7 +76,7 @@ int _rtw_write823a(struct rtw_adapter *adapter, u32 addr, u8 val) struct intf_hdl *pintfhdl = &adapter->intf; int ret; - ret = pintfhdl->io_ops._write8(pintfhdl, addr, val); + ret = pintfhdl->io_ops._write8(adapter, addr, val); return RTW_STATUS_CODE23a(ret); } @@ -87,7 +87,7 @@ int _rtw_write1623a(struct rtw_adapter *adapter, u32 addr, u16 val) int ret; val = cpu_to_le16(val); - ret = pintfhdl->io_ops._write16(pintfhdl, addr, val); + ret = pintfhdl->io_ops._write16(adapter, addr, val); return RTW_STATUS_CODE23a(ret); } @@ -98,7 +98,7 @@ int _rtw_write3223a(struct rtw_adapter *adapter, u32 addr, u32 val) int ret; val = cpu_to_le32(val); - ret = pintfhdl->io_ops._write32(pintfhdl, addr, val); + ret = pintfhdl->io_ops._write32(adapter, addr, val); return RTW_STATUS_CODE23a(ret); } @@ -108,7 +108,7 @@ int _rtw_writeN23a(struct rtw_adapter *adapter, u32 addr , u32 length , u8 *pdat struct intf_hdl *pintfhdl = &adapter->intf; int ret; - ret = pintfhdl->io_ops._writeN(pintfhdl, addr, length, pdata); + ret = pintfhdl->io_ops._writeN(adapter, addr, length, pdata); return RTW_STATUS_CODE23a(ret); } @@ -125,14 +125,14 @@ void _rtw_read_mem23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *pmem) return; } - pintfhdl->io_ops._read_mem(pintfhdl, addr, cnt, pmem); + pintfhdl->io_ops._read_mem(adapter, addr, cnt, pmem); } void _rtw_write_mem23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *pmem) { struct intf_hdl *pintfhdl = &adapter->intf; - pintfhdl->io_ops._write_mem(pintfhdl, addr, cnt, pmem); + pintfhdl->io_ops._write_mem(adapter, addr, cnt, pmem); } void _rtw_read_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, @@ -149,18 +149,18 @@ void _rtw_read_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, return; } - pintfhdl->io_ops._read_port(pintfhdl, addr, cnt, rbuf); + pintfhdl->io_ops._read_port(adapter, addr, cnt, rbuf); } void _rtw_read_port23a_cancel(struct rtw_adapter *adapter) { - void (*_read_port_cancel)(struct intf_hdl *pintfhdl); + void (*_read_port_cancel)(struct rtw_adapter *adapter); struct intf_hdl *pintfhdl = &adapter->intf; _read_port_cancel = pintfhdl->io_ops._read_port_cancel; if (_read_port_cancel) - _read_port_cancel(pintfhdl); + _read_port_cancel(adapter); } u32 _rtw_write_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, @@ -169,18 +169,18 @@ u32 _rtw_write_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, struct intf_hdl *pintfhdl = &adapter->intf; u32 ret = _SUCCESS; - ret = pintfhdl->io_ops._write_port(pintfhdl, addr, cnt, xbuf); + ret = pintfhdl->io_ops._write_port(adapter, addr, cnt, xbuf); return ret; } void _rtw_write_port23a_cancel(struct rtw_adapter *adapter) { - void (*_write_port_cancel)(struct intf_hdl *pintfhdl); + void (*_write_port_cancel)(struct rtw_adapter *adapter); struct intf_hdl *pintfhdl = &adapter->intf; _write_port_cancel = pintfhdl->io_ops._write_port_cancel; if (_write_port_cancel) - _write_port_cancel(pintfhdl); + _write_port_cancel(adapter); } diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index f5b1b10bed58..1dd2a08a0963 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -1229,9 +1229,9 @@ static unsigned int rtl8723au_inirp_init(struct rtw_adapter *Adapter) uint status; struct intf_hdl *pintfhdl = &Adapter->intf; struct recv_priv *precvpriv = &Adapter->recvpriv; - u32 (*_read_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, + u32 (*_read_port)(struct rtw_adapter *padapter, u32 addr, u32 cnt, struct recv_buf *rbuf); - u32 (*_read_interrupt)(struct intf_hdl *pintfhdl, u32 addr); + u32 (*_read_interrupt)(struct rtw_adapter *padapter, u32 addr); struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); _read_port = pintfhdl->io_ops._read_port; @@ -1245,7 +1245,7 @@ static unsigned int rtl8723au_inirp_init(struct rtw_adapter *Adapter) /* issue Rx irp to receive data */ precvbuf = (struct recv_buf *)precvpriv->precv_buf; for (i = 0; i < NR_RECVBUFF; i++) { - if (_read_port(pintfhdl, precvpriv->ff_hwaddr, 0, precvbuf) == + if (_read_port(Adapter, precvpriv->ff_hwaddr, 0, precvbuf) == false) { RT_TRACE(_module_hci_hal_init_c_, _drv_err_, ("usb_rx_init: usb_read_port error\n")); @@ -1256,7 +1256,7 @@ static unsigned int rtl8723au_inirp_init(struct rtw_adapter *Adapter) precvpriv->free_recv_buf_queue_cnt--; } _read_interrupt = pintfhdl->io_ops._read_interrupt; - if (_read_interrupt(pintfhdl, RECV_INT_IN_ADDR) == false) { + if (_read_interrupt(Adapter, RECV_INT_IN_ADDR) == false) { RT_TRACE(_module_hci_hal_init_c_, _drv_err_, ("usb_rx_init: usb_read_interrupt error\n")); status = _FAIL; diff --git a/drivers/staging/rtl8723au/hal/usb_ops_linux.c b/drivers/staging/rtl8723au/hal/usb_ops_linux.c index 4b23e8a6e194..29e67a8e85cb 100644 --- a/drivers/staging/rtl8723au/hal/usb_ops_linux.c +++ b/drivers/staging/rtl8723au/hal/usb_ops_linux.c @@ -22,9 +22,10 @@ #include #include -static int usbctrl_vendorreq(struct intf_hdl *pintfhdl, u8 request, u16 value, u16 index, void *pdata, u16 len, u8 requesttype) +static int usbctrl_vendorreq(struct rtw_adapter *padapter, u8 request, + u16 value, u16 index, void *pdata, u16 len, + u8 requesttype) { - struct rtw_adapter *padapter = pintfhdl->padapter ; struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(padapter); struct usb_device *udev = pdvobjpriv->pusbdev; @@ -124,7 +125,7 @@ exit: return status; } -static u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr) +static u8 usb_read8(struct rtw_adapter *padapter, u32 addr) { u8 request; u8 requesttype; @@ -140,12 +141,13 @@ static u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr) wvalue = (u16)(addr&0x0000ffff); len = 1; - usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); + usbctrl_vendorreq(padapter, request, wvalue, index, &data, + len, requesttype); return data; } -static u16 usb_read16(struct intf_hdl *pintfhdl, u32 addr) +static u16 usb_read16(struct rtw_adapter *padapter, u32 addr) { u8 request; u8 requesttype; @@ -161,12 +163,13 @@ static u16 usb_read16(struct intf_hdl *pintfhdl, u32 addr) wvalue = (u16)(addr&0x0000ffff); len = 2; - usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); + usbctrl_vendorreq(padapter, request, wvalue, index, &data, + len, requesttype); return data; } -static u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr) +static u32 usb_read32(struct rtw_adapter *padapter, u32 addr) { u8 request; u8 requesttype; @@ -182,12 +185,13 @@ static u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr) wvalue = (u16)(addr&0x0000ffff); len = 4; - usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); + usbctrl_vendorreq(padapter, request, wvalue, index, &data, + len, requesttype); return data; } -static int usb_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val) +static int usb_write8(struct rtw_adapter *padapter, u32 addr, u8 val) { u8 request; u8 requesttype; @@ -206,12 +210,13 @@ static int usb_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val) data = val; - ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); + ret = usbctrl_vendorreq(padapter, request, wvalue, index, &data, + len, requesttype); return ret; } -static int usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val) +static int usb_write16(struct rtw_adapter *padapter, u32 addr, u16 val) { u8 request; u8 requesttype; @@ -230,11 +235,12 @@ static int usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val) data = val; - ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); + ret = usbctrl_vendorreq(padapter, request, wvalue, index, &data, + len, requesttype); return ret; } -static int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val) +static int usb_write32(struct rtw_adapter *padapter, u32 addr, u32 val) { u8 request; u8 requesttype; @@ -252,12 +258,14 @@ static int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val) len = 4; data = val; - ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); + ret = usbctrl_vendorreq(padapter, request, wvalue, index, &data, + len, requesttype); return ret; } -static int usb_writeN(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata) +static int usb_writeN(struct rtw_adapter *padapter, + u32 addr, u32 length, u8 *pdata) { u8 request; u8 requesttype; @@ -273,9 +281,10 @@ static int usb_writeN(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata wvalue = (u16)(addr&0x0000ffff); len = length; - memcpy(buf, pdata, len); + memcpy(buf, pdata, len); - ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, buf, len, requesttype); + ret = usbctrl_vendorreq(padapter, request, wvalue, index, buf, + len, requesttype); return ret; } @@ -423,12 +432,11 @@ urb_submit: } } -static u32 usb_read_interrupt(struct intf_hdl *pintfhdl, u32 addr) +static u32 usb_read_interrupt(struct rtw_adapter *adapter, u32 addr) { int err; unsigned int pipe; u32 ret = _SUCCESS; - struct rtw_adapter *adapter = pintfhdl->padapter; struct dvobj_priv *pdvobj = adapter_to_dvobj(adapter); struct recv_priv *precvpriv = &adapter->recvpriv; struct usb_device *pusbd = pdvobj->pusbdev; @@ -720,7 +728,7 @@ static void usb_read_port_complete(struct urb *purb, struct pt_regs *regs) } } -static u32 usb_read_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, +static u32 usb_read_port(struct rtw_adapter *adapter, u32 addr, u32 cnt, struct recv_buf *precvbuf) { int err; @@ -729,7 +737,6 @@ static u32 usb_read_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, unsigned long alignment = 0; u32 ret = _SUCCESS; struct urb *purb = NULL; - struct rtw_adapter *adapter = pintfhdl->padapter; struct dvobj_priv *pdvobj = adapter_to_dvobj(adapter); struct recv_priv *precvpriv = &adapter->recvpriv; struct usb_device *pusbd = pdvobj->pusbdev; diff --git a/drivers/staging/rtl8723au/include/rtw_io.h b/drivers/staging/rtl8723au/include/rtw_io.h index 2abc24d429cd..7b710d748516 100644 --- a/drivers/staging/rtl8723au/include/rtw_io.h +++ b/drivers/staging/rtl8723au/include/rtw_io.h @@ -101,25 +101,25 @@ struct intf_hdl; struct _io_ops { - u8 (*_read8)(struct intf_hdl *pintfhdl, u32 addr); - u16 (*_read16)(struct intf_hdl *pintfhdl, u32 addr); - u32 (*_read32)(struct intf_hdl *pintfhdl, u32 addr); + u8 (*_read8)(struct rtw_adapter *adapter, u32 addr); + u16 (*_read16)(struct rtw_adapter *adapter, u32 addr); + u32 (*_read32)(struct rtw_adapter *adapter, u32 addr); - int (*_write8)(struct intf_hdl *pintfhdl, u32 addr, u8 val); - int (*_write16)(struct intf_hdl *pintfhdl, u32 addr, u16 val); - int (*_write32)(struct intf_hdl *pintfhdl, u32 addr, u32 val); - int (*_writeN)(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata); + int (*_write8)(struct rtw_adapter *adapter, u32 addr, u8 val); + int (*_write16)(struct rtw_adapter *adapter, u32 addr, u16 val); + int (*_write32)(struct rtw_adapter *adapter, u32 addr, u32 val); + int (*_writeN)(struct rtw_adapter *adapter, u32 addr, u32 length, u8 *pdata); - void (*_read_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem); - void (*_write_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem); + void (*_read_mem)(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *pmem); + void (*_write_mem)(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *pmem); - u32 (*_read_interrupt)(struct intf_hdl *pintfhdl, u32 addr); + u32 (*_read_interrupt)(struct rtw_adapter *adapter, u32 addr); - u32 (*_read_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, struct recv_buf *rbuf); - u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, struct xmit_buf *pmem); + u32 (*_read_port)(struct rtw_adapter *adapter, u32 addr, u32 cnt, struct recv_buf *rbuf); + u32 (*_write_port)(struct rtw_adapter *adapter, u32 addr, u32 cnt, struct xmit_buf *pmem); - void (*_read_port_cancel)(struct intf_hdl *pintfhdl); - void (*_write_port_cancel)(struct intf_hdl *pintfhdl); + void (*_read_port_cancel)(struct rtw_adapter *adapter); + void (*_write_port_cancel)(struct rtw_adapter *adapter); }; struct io_req { diff --git a/drivers/staging/rtl8723au/include/usb_ops_linux.h b/drivers/staging/rtl8723au/include/usb_ops_linux.h index 8f5c59eace5a..0eb33e01c78c 100644 --- a/drivers/staging/rtl8723au/include/usb_ops_linux.h +++ b/drivers/staging/rtl8723au/include/usb_ops_linux.h @@ -34,13 +34,13 @@ unsigned int ffaddr2pipehdl23a(struct dvobj_priv *pdvobj, u32 addr); -void usb_read_mem23a(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem); -void usb_write_mem23a(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem); +void usb_read_mem23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *rmem); +void usb_write_mem23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *wmem); -void usb_read_port_cancel23a(struct intf_hdl *pintfhdl); +void usb_read_port_cancel23a(struct rtw_adapter *adapter); -u32 usb_write_port23a(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, - struct xmit_buf *wmem); -void usb_write_port23a_cancel(struct intf_hdl *pintfhdl); +u32 usb_write_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, + struct xmit_buf *wmem); +void usb_write_port23a_cancel(struct rtw_adapter *adapter); #endif diff --git a/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c b/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c index c49160e477d8..b88f72f0f06b 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c +++ b/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c @@ -41,18 +41,17 @@ struct zero_bulkout_context { void *padapter; }; -void usb_read_mem23a(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem) +void usb_read_mem23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *rmem) { } -void usb_write_mem23a(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem) +void usb_write_mem23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *wmem) { } -void usb_read_port_cancel23a(struct intf_hdl *pintfhdl) +void usb_read_port_cancel23a(struct rtw_adapter *padapter) { struct recv_buf *precvbuf; - struct rtw_adapter *padapter = pintfhdl->padapter; int i; precvbuf = (struct recv_buf *)padapter->recvpriv.precv_buf; @@ -161,11 +160,10 @@ check_completion: tasklet_hi_schedule(&pxmitpriv->xmit_tasklet); } -u32 usb_write_port23a(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, - struct xmit_buf *pxmitbuf) +u32 usb_write_port23a(struct rtw_adapter *padapter, u32 addr, u32 cnt, + struct xmit_buf *pxmitbuf) { struct urb *purb = NULL; - struct rtw_adapter *padapter = (struct rtw_adapter *)pintfhdl->padapter; struct dvobj_priv *pdvobj = adapter_to_dvobj(padapter); struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct xmit_frame *pxmitframe = (struct xmit_frame *)pxmitbuf->priv_data; @@ -255,9 +253,8 @@ exit: return ret; } -void usb_write_port23a_cancel(struct intf_hdl *pintfhdl) +void usb_write_port23a_cancel(struct rtw_adapter *padapter) { - struct rtw_adapter *padapter = pintfhdl->padapter; struct xmit_buf *pxmitbuf; struct list_head *plist; int j; -- 2.30.2