2015-11-18 06:08:19

by Glen Lee

[permalink] [raw]
Subject: [PATCH 00/16] tidy up sdio/spi module and remove wilc_dev

This patch series removes global variable wilc_dev and tidy up sdio/spi
modules. I sync with arnd's latest patch series because this work depends
on his patches.

Glen Lee (16):
staging: wilc1000: remove sdio speed control codes
staging: wilc1000: remove spi speed control codes
staging: wilc1000: remove paltform define PLAT_WMS8304
staging: wilc1000: pass struct wilc to the functions which use
hif_func
staging: wilc1000: pass wilc to all function pointers of wilc_hif_func
staging: wilc1000: wilc_sdio_cmd52: pass struct wilc
staging: wilc1000: wilc_sdio_cmd53: pass struct wilc
staging: wilc1000: wilc_spi_write: pass struct wilc
staging: wilc1000: wilc_spi_read: pass struct wilc
staging: wilc1000: wilc_spi_write_read: pass struct wilc
staging: wilc1000: add struct wilc to host_if_drv
staging: wilc1000: wilc_send_config_pkt: pass struct wilc
staging: wilc1000: wilc_wlan_cfg_set: pass struct wilc
staging: wilc1000: wilc_wlan_cfg_get: pass struct wilc
staging: wilc1000: wilc_dbg: remove wilc
staging: wilc1000: use wilc instead of wilc_dev and remove wilc_dev

drivers/staging/wilc1000/coreconfigurator.c | 7 +-
drivers/staging/wilc1000/coreconfigurator.h | 3 +-
drivers/staging/wilc1000/host_interface.c | 133 +++++++-------
drivers/staging/wilc1000/host_interface.h | 2 +
drivers/staging/wilc1000/linux_wlan.c | 123 ++++++-------
drivers/staging/wilc1000/linux_wlan_sdio.c | 60 +------
drivers/staging/wilc1000/linux_wlan_sdio.h | 7 +-
drivers/staging/wilc1000/linux_wlan_spi.c | 215 +----------------------
drivers/staging/wilc1000/linux_wlan_spi.h | 9 +-
drivers/staging/wilc1000/wilc_sdio.c | 150 ++++++++--------
drivers/staging/wilc1000/wilc_spi.c | 142 +++++++--------
drivers/staging/wilc1000/wilc_wfi_netdevice.h | 3 +-
drivers/staging/wilc1000/wilc_wlan.c | 244 +++++++++++++-------------
drivers/staging/wilc1000/wilc_wlan.h | 37 ++--
drivers/staging/wilc1000/wilc_wlan_if.h | 3 +-
15 files changed, 447 insertions(+), 691 deletions(-)

--
1.9.1



2015-11-18 06:09:33

by Glen Lee

[permalink] [raw]
Subject: [PATCH 12/16] staging: wilc1000: wilc_send_config_pkt: pass struct wilc

This patch passes struct wilc to wilc_send_config_pkt. The function
wilc_wlan_cfg_set and wilc_wlan_cfg_get function will get wilc to replace
wilc_dev with it.

Signed-off-by: Glen Lee <[email protected]>
---
drivers/staging/wilc1000/coreconfigurator.c | 3 +-
drivers/staging/wilc1000/coreconfigurator.h | 3 +-
drivers/staging/wilc1000/host_interface.c | 127 +++++++++++++++-------------
3 files changed, 74 insertions(+), 59 deletions(-)

diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c
index 47fa82f..dc290d1 100644
--- a/drivers/staging/wilc1000/coreconfigurator.c
+++ b/drivers/staging/wilc1000/coreconfigurator.c
@@ -588,7 +588,8 @@ s32 wilc_dealloc_assoc_resp_info(tstrConnectRespInfo *pstrConnectRespInfo)
* @date 1 Mar 2012
* @version 1.0
*/
-s32 wilc_send_config_pkt(u8 mode, struct wid *wids, u32 count, u32 drv)
+s32 wilc_send_config_pkt(struct wilc *wilc, u8 mode, struct wid *wids,
+ u32 count, u32 drv)
{
s32 counter = 0, ret = 0;

diff --git a/drivers/staging/wilc1000/coreconfigurator.h b/drivers/staging/wilc1000/coreconfigurator.h
index 912d5c2..3f2a7d3 100644
--- a/drivers/staging/wilc1000/coreconfigurator.h
+++ b/drivers/staging/wilc1000/coreconfigurator.h
@@ -127,7 +127,8 @@ typedef struct {
size_t ie_len;
} tstrDisconnectNotifInfo;

-s32 wilc_send_config_pkt(u8 mode, struct wid *wids, u32 count, u32 drv);
+s32 wilc_send_config_pkt(struct wilc *wilc, u8 mode, struct wid *wids,
+ u32 count, u32 drv);
s32 wilc_parse_network_info(u8 *pu8MsgBuffer, tstrNetworkInfo **ppstrNetworkInfo);
s32 wilc_dealloc_network_info(tstrNetworkInfo *pstrNetworkInfo);

diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c
index 3609949..43b77b7 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -329,7 +329,7 @@ static s32 handle_set_channel(struct host_if_drv *hif_drv,

PRINT_D(HOSTINF_DBG, "Setting channel\n");

- result = wilc_send_config_pkt(SET_CFG, &wid, 1,
+ result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, &wid, 1,
get_id_from_handler(hif_drv));

if (result) {
@@ -351,7 +351,8 @@ static s32 handle_set_wfi_drv_handler(struct host_if_drv *hif_drv,
wid.val = (s8 *)&hif_drv_handler->handler;
wid.size = sizeof(u32);

- result = wilc_send_config_pkt(SET_CFG, &wid, 1, hif_drv_handler->handler);
+ result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, &wid, 1,
+ hif_drv_handler->handler);

if (!hif_drv)
up(&hif_sema_driver);
@@ -375,7 +376,7 @@ static s32 handle_set_operation_mode(struct host_if_drv *hif_drv,
wid.val = (s8 *)&hif_op_mode->mode;
wid.size = sizeof(u32);

- result = wilc_send_config_pkt(SET_CFG, &wid, 1,
+ result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, &wid, 1,
get_id_from_handler(hif_drv));

if ((hif_op_mode->mode) == IDLE_MODE)
@@ -410,7 +411,7 @@ static s32 handle_set_ip_address(struct host_if_drv *hif_drv, u8 *ip_addr, u8 id
wid.val = (u8 *)ip_addr;
wid.size = IP_ALEN;

- result = wilc_send_config_pkt(SET_CFG, &wid, 1,
+ result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, &wid, 1,
get_id_from_handler(hif_drv));

host_int_get_ipaddress(hif_drv, firmware_ip_addr, idx);
@@ -435,7 +436,7 @@ static s32 handle_get_ip_address(struct host_if_drv *hif_drv, u8 idx)
wid.val = kmalloc(IP_ALEN, GFP_KERNEL);
wid.size = IP_ALEN;

- result = wilc_send_config_pkt(GET_CFG, &wid, 1,
+ result = wilc_send_config_pkt(hif_drv->wilc, GET_CFG, &wid, 1,
get_id_from_handler(hif_drv));

PRINT_INFO(HOSTINF_DBG, "%pI4\n", wid.val);
@@ -478,7 +479,7 @@ static s32 handle_set_mac_address(struct host_if_drv *hif_drv,
wid.size = ETH_ALEN;
PRINT_D(GENERIC_DBG, "mac addr = :%pM\n", wid.val);

- result = wilc_send_config_pkt(SET_CFG, &wid, 1,
+ result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, &wid, 1,
get_id_from_handler(hif_drv));
if (result) {
PRINT_ER("Failed to set mac address\n");
@@ -500,7 +501,7 @@ static s32 handle_get_mac_address(struct host_if_drv *hif_drv,
wid.val = get_mac_addr->mac_addr;
wid.size = ETH_ALEN;

- result = wilc_send_config_pkt(GET_CFG, &wid, 1,
+ result = wilc_send_config_pkt(hif_drv->wilc, GET_CFG, &wid, 1,
get_id_from_handler(hif_drv));

if (result) {
@@ -795,8 +796,8 @@ static s32 handle_cfg_param(struct host_if_drv *hif_drv,
wid_cnt++;
}

- result = wilc_send_config_pkt(SET_CFG, wid_list, wid_cnt,
- get_id_from_handler(hif_drv));
+ result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, wid_list,
+ wid_cnt, get_id_from_handler(hif_drv));

if (result)
PRINT_ER("Error in setting CFG params\n");
@@ -918,8 +919,9 @@ static s32 Handle_Scan(struct host_if_drv *hif_drv,
else if (hif_drv->hif_state == HOST_IF_IDLE)
scan_while_connected = false;

- result = wilc_send_config_pkt(SET_CFG, strWIDList, u32WidsCount,
- get_id_from_handler(hif_drv));
+ result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, strWIDList,
+ u32WidsCount,
+ get_id_from_handler(hif_drv));

if (result)
PRINT_ER("Failed to send scan paramters config packet\n");
@@ -962,7 +964,7 @@ static s32 Handle_ScanDone(struct host_if_drv *hif_drv,
wid.val = (s8 *)&u8abort_running_scan;
wid.size = sizeof(char);

- result = wilc_send_config_pkt(SET_CFG, &wid, 1,
+ result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, &wid, 1,
get_id_from_handler(hif_drv));

if (result) {
@@ -1216,8 +1218,9 @@ static s32 Handle_Connect(struct host_if_drv *hif_drv,
PRINT_D(GENERIC_DBG, "save bssid = %pM\n", wilc_connected_SSID);
}

- result = wilc_send_config_pkt(SET_CFG, strWIDList, u32WidsCount,
- get_id_from_handler(hif_drv));
+ result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, strWIDList,
+ u32WidsCount,
+ get_id_from_handler(hif_drv));
if (result) {
PRINT_ER("failed to send config packet\n");
result = -EFAULT;
@@ -1313,8 +1316,9 @@ static s32 Handle_FlushConnect(struct host_if_drv *hif_drv)

u32WidsCount++;

- result = wilc_send_config_pkt(SET_CFG, strWIDList, u32WidsCount,
- get_id_from_handler(join_req_drv));
+ result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, strWIDList,
+ u32WidsCount,
+ get_id_from_handler(join_req_drv));
if (result) {
PRINT_ER("failed to send config packet\n");
result = -EINVAL;
@@ -1374,7 +1378,7 @@ static s32 Handle_ConnectTimeout(struct host_if_drv *hif_drv)

PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");

- result = wilc_send_config_pkt(SET_CFG, &wid, 1,
+ result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, &wid, 1,
get_id_from_handler(hif_drv));
if (result)
PRINT_ER("Failed to send dissconect config packet\n");
@@ -1757,8 +1761,9 @@ static int Handle_Key(struct host_if_drv *hif_drv,
strWIDList[3].size = pstrHostIFkeyAttr->attr.wep.key_len;
strWIDList[3].val = (s8 *)pu8keybuf;

- result = wilc_send_config_pkt(SET_CFG, strWIDList, 4,
- get_id_from_handler(hif_drv));
+ result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG,
+ strWIDList, 4,
+ get_id_from_handler(hif_drv));
kfree(pu8keybuf);
}

@@ -1780,8 +1785,9 @@ static int Handle_Key(struct host_if_drv *hif_drv,
wid.val = (s8 *)pu8keybuf;
wid.size = pstrHostIFkeyAttr->attr.wep.key_len + 2;

- result = wilc_send_config_pkt(SET_CFG, &wid, 1,
- get_id_from_handler(hif_drv));
+ result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG,
+ &wid, 1,
+ get_id_from_handler(hif_drv));
kfree(pu8keybuf);
} else if (pstrHostIFkeyAttr->action & REMOVEKEY) {
PRINT_D(HOSTINF_DBG, "Removing key\n");
@@ -1792,8 +1798,9 @@ static int Handle_Key(struct host_if_drv *hif_drv,
wid.val = s8idxarray;
wid.size = 1;

- result = wilc_send_config_pkt(SET_CFG, &wid, 1,
- get_id_from_handler(hif_drv));
+ result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG,
+ &wid, 1,
+ get_id_from_handler(hif_drv));
} else {
wid.id = (u16)WID_KEY_ID;
wid.type = WID_CHAR;
@@ -1802,8 +1809,9 @@ static int Handle_Key(struct host_if_drv *hif_drv,

PRINT_D(HOSTINF_DBG, "Setting default key index\n");

- result = wilc_send_config_pkt(SET_CFG, &wid, 1,
- get_id_from_handler(hif_drv));
+ result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG,
+ &wid, 1,
+ get_id_from_handler(hif_drv));
}
up(&hif_drv->sem_test_key_block);
break;
@@ -1835,8 +1843,9 @@ static int Handle_Key(struct host_if_drv *hif_drv,
strWIDList[1].val = (s8 *)pu8keybuf;
strWIDList[1].size = RX_MIC_KEY_MSG_LEN;

- result = wilc_send_config_pkt(SET_CFG, strWIDList, 2,
- get_id_from_handler(hif_drv));
+ result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG,
+ strWIDList, 2,
+ get_id_from_handler(hif_drv));

kfree(pu8keybuf);
up(&hif_drv->sem_test_key_block);
@@ -1868,8 +1877,9 @@ static int Handle_Key(struct host_if_drv *hif_drv,
wid.val = (s8 *)pu8keybuf;
wid.size = RX_MIC_KEY_MSG_LEN;

- result = wilc_send_config_pkt(SET_CFG, &wid, 1,
- get_id_from_handler(hif_drv));
+ result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG,
+ &wid, 1,
+ get_id_from_handler(hif_drv));

kfree(pu8keybuf);
up(&hif_drv->sem_test_key_block);
@@ -1907,8 +1917,9 @@ _WPARxGtk_end_case_:
strWIDList[1].val = (s8 *)pu8keybuf;
strWIDList[1].size = PTK_KEY_MSG_LEN + 1;

- result = wilc_send_config_pkt(SET_CFG, strWIDList, 2,
- get_id_from_handler(hif_drv));
+ result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG,
+ strWIDList, 2,
+ get_id_from_handler(hif_drv));
kfree(pu8keybuf);
up(&hif_drv->sem_test_key_block);
}
@@ -1930,8 +1941,9 @@ _WPARxGtk_end_case_:
wid.val = (s8 *)pu8keybuf;
wid.size = PTK_KEY_MSG_LEN;

- result = wilc_send_config_pkt(SET_CFG, &wid, 1,
- get_id_from_handler(hif_drv));
+ result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG,
+ &wid, 1,
+ get_id_from_handler(hif_drv));
kfree(pu8keybuf);
up(&hif_drv->sem_test_key_block);
}
@@ -1965,7 +1977,7 @@ _WPAPtk_end_case_:
wid.val = (s8 *)pu8keybuf;
wid.size = (pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1;

- result = wilc_send_config_pkt(SET_CFG, &wid, 1,
+ result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, &wid, 1,
get_id_from_handler(hif_drv));

kfree(pu8keybuf);
@@ -1997,7 +2009,7 @@ static void Handle_Disconnect(struct host_if_drv *hif_drv)

eth_zero_addr(wilc_connected_SSID);

- result = wilc_send_config_pkt(SET_CFG, &wid, 1,
+ result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, &wid, 1,
get_id_from_handler(hif_drv));

if (result) {
@@ -2084,7 +2096,7 @@ static s32 Handle_GetChnl(struct host_if_drv *hif_drv)

PRINT_D(HOSTINF_DBG, "Getting channel value\n");

- result = wilc_send_config_pkt(GET_CFG, &wid, 1,
+ result = wilc_send_config_pkt(hif_drv->wilc, GET_CFG, &wid, 1,
get_id_from_handler(hif_drv));

if (result) {
@@ -2109,7 +2121,7 @@ static void Handle_GetRssi(struct host_if_drv *hif_drv)

PRINT_D(HOSTINF_DBG, "Getting RSSI value\n");

- result = wilc_send_config_pkt(GET_CFG, &wid, 1,
+ result = wilc_send_config_pkt(hif_drv->wilc, GET_CFG, &wid, 1,
get_id_from_handler(hif_drv));
if (result) {
PRINT_ER("Failed to get RSSI value\n");
@@ -2133,7 +2145,7 @@ static void Handle_GetLinkspeed(struct host_if_drv *hif_drv)

PRINT_D(HOSTINF_DBG, "Getting LINKSPEED value\n");

- result = wilc_send_config_pkt(GET_CFG, &wid, 1,
+ result = wilc_send_config_pkt(hif_drv->wilc, GET_CFG, &wid, 1,
get_id_from_handler(hif_drv));
if (result) {
PRINT_ER("Failed to get LINKSPEED value\n");
@@ -2178,8 +2190,9 @@ static s32 Handle_GetStatistics(struct host_if_drv *hif_drv, struct rf_info *pst
strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->tx_fail_cnt;
u32WidsCount++;

- result = wilc_send_config_pkt(GET_CFG, strWIDList, u32WidsCount,
- get_id_from_handler(hif_drv));
+ result = wilc_send_config_pkt(hif_drv->wilc, GET_CFG, strWIDList,
+ u32WidsCount,
+ get_id_from_handler(hif_drv));

if (result)
PRINT_ER("Failed to send scan paramters config packet\n");
@@ -2205,7 +2218,7 @@ static s32 Handle_Get_InActiveTime(struct host_if_drv *hif_drv,

PRINT_D(CFG80211_DBG, "SETING STA inactive time\n");

- result = wilc_send_config_pkt(SET_CFG, &wid, 1,
+ result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, &wid, 1,
get_id_from_handler(hif_drv));

if (result) {
@@ -2218,7 +2231,7 @@ static s32 Handle_Get_InActiveTime(struct host_if_drv *hif_drv,
wid.val = (s8 *)&inactive_time;
wid.size = sizeof(u32);

- result = wilc_send_config_pkt(GET_CFG, &wid, 1,
+ result = wilc_send_config_pkt(hif_drv->wilc, GET_CFG, &wid, 1,
get_id_from_handler(hif_drv));

if (result) {
@@ -2277,7 +2290,7 @@ static void Handle_AddBeacon(struct host_if_drv *hif_drv,
memcpy(pu8CurrByte, pstrSetBeaconParam->tail, pstrSetBeaconParam->tail_len);
pu8CurrByte += pstrSetBeaconParam->tail_len;

- result = wilc_send_config_pkt(SET_CFG, &wid, 1,
+ result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, &wid, 1,
get_id_from_handler(hif_drv));
if (result)
PRINT_ER("Failed to send add beacon config packet\n");
@@ -2306,7 +2319,7 @@ static void Handle_DelBeacon(struct host_if_drv *hif_drv)

PRINT_D(HOSTINF_DBG, "Deleting BEACON\n");

- result = wilc_send_config_pkt(SET_CFG, &wid, 1,
+ result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, &wid, 1,
get_id_from_handler(hif_drv));
if (result)
PRINT_ER("Failed to send delete beacon config packet\n");
@@ -2379,7 +2392,7 @@ static void Handle_AddStation(struct host_if_drv *hif_drv,
pu8CurrByte = wid.val;
pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);

- result = wilc_send_config_pkt(SET_CFG, &wid, 1,
+ result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, &wid, 1,
get_id_from_handler(hif_drv));
if (result != 0)
PRINT_ER("Failed to send add station config packet\n");
@@ -2421,7 +2434,7 @@ static void Handle_DelAllSta(struct host_if_drv *hif_drv,
pu8CurrByte += ETH_ALEN;
}

- result = wilc_send_config_pkt(SET_CFG, &wid, 1,
+ result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, &wid, 1,
get_id_from_handler(hif_drv));
if (result)
PRINT_ER("Failed to send add station config packet\n");
@@ -2453,7 +2466,7 @@ static void Handle_DelStation(struct host_if_drv *hif_drv,

memcpy(pu8CurrByte, pstrDelStaParam->mac_addr, ETH_ALEN);

- result = wilc_send_config_pkt(SET_CFG, &wid, 1,
+ result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, &wid, 1,
get_id_from_handler(hif_drv));
if (result)
PRINT_ER("Failed to send add station config packet\n");
@@ -2481,7 +2494,7 @@ static void Handle_EditStation(struct host_if_drv *hif_drv,
pu8CurrByte = wid.val;
pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);

- result = wilc_send_config_pkt(SET_CFG, &wid, 1,
+ result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, &wid, 1,
get_id_from_handler(hif_drv));
if (result)
PRINT_ER("Failed to send edit station config packet\n");
@@ -2542,7 +2555,7 @@ static int Handle_RemainOnChan(struct host_if_drv *hif_drv,
wid.val[0] = u8remain_on_chan_flag;
wid.val[1] = (s8)pstrHostIfRemainOnChan->ch;

- result = wilc_send_config_pkt(SET_CFG, &wid, 1,
+ result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, &wid, 1,
get_id_from_handler(hif_drv));
if (result != 0)
PRINT_ER("Failed to set remain on channel\n");
@@ -2590,7 +2603,7 @@ static int Handle_RegisterFrame(struct host_if_drv *hif_drv,

wid.size = sizeof(u16) + 2;

- result = wilc_send_config_pkt(SET_CFG, &wid, 1,
+ result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, &wid, 1,
get_id_from_handler(hif_drv));
if (result) {
PRINT_ER("Failed to frame register config packet\n");
@@ -2622,7 +2635,7 @@ static u32 Handle_ListenStateExpired(struct host_if_drv *hif_drv,
wid.val[0] = u8remain_on_chan_flag;
wid.val[1] = FALSE_FRMWR_CHANNEL;

- result = wilc_send_config_pkt(SET_CFG, &wid, 1,
+ result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, &wid, 1,
get_id_from_handler(hif_drv));
if (result != 0) {
PRINT_ER("Failed to set remain on channel\n");
@@ -2680,7 +2693,7 @@ static void Handle_PowerManagement(struct host_if_drv *hif_drv,

PRINT_D(HOSTINF_DBG, "Handling Power Management\n");

- result = wilc_send_config_pkt(SET_CFG, &wid, 1,
+ result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, &wid, 1,
get_id_from_handler(hif_drv));
if (result)
PRINT_ER("Failed to send power management config packet\n");
@@ -2717,7 +2730,7 @@ static void Handle_SetMulticastFilter(struct host_if_drv *hif_drv,
memcpy(pu8CurrByte, wilc_multicast_mac_addr_list,
((strHostIfSetMulti->cnt) * ETH_ALEN));

- result = wilc_send_config_pkt(SET_CFG, &wid, 1,
+ result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, &wid, 1,
get_id_from_handler(hif_drv));
if (result)
PRINT_ER("Failed to send setup multicast config packet\n");
@@ -2763,7 +2776,7 @@ static s32 Handle_AddBASession(struct host_if_drv *hif_drv,
*ptr++ = 8;
*ptr++ = 0;

- result = wilc_send_config_pkt(SET_CFG, &wid, 1,
+ result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, &wid, 1,
get_id_from_handler(hif_drv));
if (result)
PRINT_D(HOSTINF_DBG, "Couldn't open BA Session\n");
@@ -2782,7 +2795,7 @@ static s32 Handle_AddBASession(struct host_if_drv *hif_drv,
*ptr++ = (strHostIfBASessionInfo->buf_size & 0xFF);
*ptr++ = ((strHostIfBASessionInfo->time_out >> 16) & 0xFF);
*ptr++ = 3;
- result = wilc_send_config_pkt(SET_CFG, &wid, 1,
+ result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, &wid, 1,
get_id_from_handler(hif_drv));

kfree(wid.val);
@@ -2817,7 +2830,7 @@ static s32 Handle_DelAllRxBASessions(struct host_if_drv *hif_drv,
*ptr++ = 0;
*ptr++ = 32;

- result = wilc_send_config_pkt(SET_CFG, &wid, 1,
+ result = wilc_send_config_pkt(hif_drv->wilc, SET_CFG, &wid, 1,
get_id_from_handler(hif_drv));
if (result)
PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
@@ -3556,7 +3569,7 @@ static s32 host_int_get_assoc_res_info(struct host_if_drv *hif_drv,
wid.val = pu8AssocRespInfo;
wid.size = u32MaxAssocRespInfoLen;

- result = wilc_send_config_pkt(GET_CFG, &wid, 1,
+ result = wilc_send_config_pkt(hif_drv->wilc, GET_CFG, &wid, 1,
get_id_from_handler(hif_drv));
if (result) {
*pu32RcvdAssocRespInfoLen = 0;
--
1.9.1


2015-11-18 06:09:27

by Glen Lee

[permalink] [raw]
Subject: [PATCH 11/16] staging: wilc1000: add struct wilc to host_if_drv

This patch adds struct wilc to host_if_dev and assign wilc to use driver's
primary structure in host_if_dev.

Signed-off-by: Glen Lee <[email protected]>
---
drivers/staging/wilc1000/host_interface.c | 1 +
drivers/staging/wilc1000/host_interface.h | 2 ++
2 files changed, 3 insertions(+)

diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c
index 2531d20..3609949 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -3848,6 +3848,7 @@ s32 wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler)
result = -ENOMEM;
goto _fail_;
}
+ hif_drv->wilc = wilc;
*hif_drv_handler = hif_drv;
err = add_handler_in_list(hif_drv);
if (err) {
diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h
index efeb9e2..004467c6 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -259,7 +259,9 @@ enum p2p_listen_state {
P2P_GRP_FORMATION
};

+struct wilc;
struct host_if_drv {
+ struct wilc *wilc;
struct user_scan_req usr_scan_req;
struct user_conn_req usr_conn_req;
struct remain_ch remain_on_ch;
--
1.9.1


2015-11-18 06:08:31

by Glen Lee

[permalink] [raw]
Subject: [PATCH 02/16] staging: wilc1000: remove spi speed control codes

This patch removes spi speed control codes. We are not using define SPEED to
specify speed of spi, it is not proper way of doing this. It will be
provided by the device tree.

The following functions and variable are removed.
MIN_SPEED, MAX_SPEED, SPEED
wilc_spi_set_max_speed
wilc_spi_max_bus_speed
wilc_spi_default_bus_speed
hif_set_max_bus_speed
hif_set_default_bus_speed

Signed-off-by: Glen Lee <[email protected]>
---
drivers/staging/wilc1000/linux_wlan_spi.c | 42 -------------------------------
drivers/staging/wilc1000/linux_wlan_spi.h | 2 --
drivers/staging/wilc1000/wilc_spi.c | 11 --------
drivers/staging/wilc1000/wilc_wlan.h | 2 --
4 files changed, 57 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan_spi.c b/drivers/staging/wilc1000/linux_wlan_spi.c
index 1d8922d..5e3bff0 100644
--- a/drivers/staging/wilc1000/linux_wlan_spi.c
+++ b/drivers/staging/wilc1000/linux_wlan_spi.c
@@ -17,33 +17,6 @@

#define USE_SPI_DMA 0 /* johnny add */

-#ifdef WILC_ASIC_A0
- #if defined(PLAT_PANDA_ES_OMAP4460)
- #define MIN_SPEED 12000000
- #define MAX_SPEED 24000000
- #elif defined(PLAT_WMS8304)
- #define MIN_SPEED 12000000
- #define MAX_SPEED 24000000 /* 4000000 */
- #elif defined(CUSTOMER_PLATFORM)
-/*
- TODO : define Clock speed under 48M.
- *
- * ex)
- * #define MIN_SPEED 24000000
- * #define MAX_SPEED 48000000
- */
- #else
- #define MIN_SPEED 24000000
- #define MAX_SPEED 48000000
- #endif
-#else /* WILC_ASIC_A0 */
-/* Limit clk to 6MHz on FPGA. */
- #define MIN_SPEED 6000000
- #define MAX_SPEED 6000000
-#endif /* WILC_ASIC_A0 */
-
-static u32 SPEED = MIN_SPEED;
-
static const struct wilc1000_ops wilc1000_spi_ops;

static int wilc_bus_probe(struct spi_device *spi)
@@ -119,7 +92,6 @@ int wilc_spi_write(u8 *b, u32 len)
struct spi_transfer tr = {
.tx_buf = b + (i * TXRX_PHASE_SIZE),
.len = TXRX_PHASE_SIZE,
- .speed_hz = SPEED,
.bits_per_word = 8,
.delay_usecs = 0,
};
@@ -145,7 +117,6 @@ int wilc_spi_write(u8 *b, u32 len)
struct spi_transfer tr = {
.tx_buf = b + (blk * TXRX_PHASE_SIZE),
.len = remainder,
- .speed_hz = SPEED,
.bits_per_word = 8,
.delay_usecs = 0,
};
@@ -187,7 +158,6 @@ int wilc_spi_write(u8 *b, u32 len)
struct spi_transfer tr = {
.tx_buf = b,
.len = len,
- .speed_hz = SPEED,
.delay_usecs = 0,
};
char *r_buffer = kzalloc(len, GFP_KERNEL);
@@ -249,7 +219,6 @@ int wilc_spi_read(u8 *rb, u32 rlen)
struct spi_transfer tr = {
.rx_buf = rb + (i * TXRX_PHASE_SIZE),
.len = TXRX_PHASE_SIZE,
- .speed_hz = SPEED,
.bits_per_word = 8,
.delay_usecs = 0,
};
@@ -273,7 +242,6 @@ int wilc_spi_read(u8 *rb, u32 rlen)
struct spi_transfer tr = {
.rx_buf = rb + (blk * TXRX_PHASE_SIZE),
.len = remainder,
- .speed_hz = SPEED,
.bits_per_word = 8,
.delay_usecs = 0,
};
@@ -313,7 +281,6 @@ int wilc_spi_read(u8 *rb, u32 rlen)
struct spi_transfer tr = {
.rx_buf = rb,
.len = rlen,
- .speed_hz = SPEED,
.delay_usecs = 0,

};
@@ -359,7 +326,6 @@ int wilc_spi_write_read(u8 *wb, u8 *rb, u32 rlen)
.rx_buf = rb,
.tx_buf = wb,
.len = rlen,
- .speed_hz = SPEED,
.bits_per_word = 8,
.delay_usecs = 0,

@@ -384,11 +350,3 @@ int wilc_spi_write_read(u8 *wb, u8 *rb, u32 rlen)

return ret;
}
-
-int wilc_spi_set_max_speed(void)
-{
- SPEED = MAX_SPEED;
-
- PRINT_INFO(BUS_DBG, "@@@@@@@@@@@@ change SPI speed to %d @@@@@@@@@\n", SPEED);
- return 1;
-}
diff --git a/drivers/staging/wilc1000/linux_wlan_spi.h b/drivers/staging/wilc1000/linux_wlan_spi.h
index f434f79..baa98cc 100644
--- a/drivers/staging/wilc1000/linux_wlan_spi.h
+++ b/drivers/staging/wilc1000/linux_wlan_spi.h
@@ -7,6 +7,4 @@ int wilc_spi_init(void);
int wilc_spi_write(u8 *b, u32 len);
int wilc_spi_read(u8 *rb, u32 rlen);
int wilc_spi_write_read(u8 *wb, u8 *rb, u32 rlen);
-int wilc_spi_set_max_speed(void);
-
#endif
diff --git a/drivers/staging/wilc1000/wilc_spi.c b/drivers/staging/wilc1000/wilc_spi.c
index 803d0f4..bd150a5 100644
--- a/drivers/staging/wilc1000/wilc_spi.c
+++ b/drivers/staging/wilc1000/wilc_spi.c
@@ -791,15 +791,6 @@ static int _wilc_spi_init(struct wilc *wilc, wilc_debug_func func)
return 1;
}

-static void wilc_spi_max_bus_speed(void)
-{
- wilc_spi_set_max_speed();
-}
-
-static void wilc_spi_default_bus_speed(void)
-{
-}
-
static int wilc_spi_read_size(u32 *size)
{
int ret;
@@ -1034,6 +1025,4 @@ const struct wilc_hif_func wilc_hif_spi = {
.hif_block_tx_ext = _wilc_spi_write,
.hif_block_rx_ext = _wilc_spi_read,
.hif_sync_ext = wilc_spi_sync_ext,
- .hif_set_max_bus_speed = wilc_spi_max_bus_speed,
- .hif_set_default_bus_speed = wilc_spi_default_bus_speed,
};
diff --git a/drivers/staging/wilc1000/wilc_wlan.h b/drivers/staging/wilc1000/wilc_wlan.h
index 20bca44..ee13771e 100644
--- a/drivers/staging/wilc1000/wilc_wlan.h
+++ b/drivers/staging/wilc1000/wilc_wlan.h
@@ -251,8 +251,6 @@ struct wilc_hif_func {
int (*hif_block_tx_ext)(u32, u8 *, u32);
int (*hif_block_rx_ext)(u32, u8 *, u32);
int (*hif_sync_ext)(int);
- void (*hif_set_max_bus_speed)(void);
- void (*hif_set_default_bus_speed)(void);
int (*enable_interrupt)(struct wilc *nic);
void (*disable_interrupt)(struct wilc *nic);
};
--
1.9.1


2015-11-18 06:08:57

by Glen Lee

[permalink] [raw]
Subject: [PATCH 06/16] staging: wilc1000: wilc_sdio_cmd52: pass struct wilc

This patch adds new function parameter struct wilc and use it instead of
wilc_dev. Pass wilc to the function as well.

Signed-off-by: Glen Lee <[email protected]>
---
drivers/staging/wilc1000/linux_wlan_sdio.c | 4 +--
drivers/staging/wilc1000/linux_wlan_sdio.h | 2 +-
drivers/staging/wilc1000/wilc_sdio.c | 42 +++++++++++++++---------------
3 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan_sdio.c b/drivers/staging/wilc1000/linux_wlan_sdio.c
index 761cb3d..6a38876 100644
--- a/drivers/staging/wilc1000/linux_wlan_sdio.c
+++ b/drivers/staging/wilc1000/linux_wlan_sdio.c
@@ -29,9 +29,9 @@ static void wilc_sdio_interrupt(struct sdio_func *func)
sdio_claim_host(func);
}

-int wilc_sdio_cmd52(sdio_cmd52_t *cmd)
+int wilc_sdio_cmd52(struct wilc *wilc, sdio_cmd52_t *cmd)
{
- struct sdio_func *func = container_of(wilc_dev->dev, struct sdio_func, dev);
+ struct sdio_func *func = container_of(wilc->dev, struct sdio_func, dev);
int ret;
u8 data;

diff --git a/drivers/staging/wilc1000/linux_wlan_sdio.h b/drivers/staging/wilc1000/linux_wlan_sdio.h
index dbe911a..d966bb9 100644
--- a/drivers/staging/wilc1000/linux_wlan_sdio.h
+++ b/drivers/staging/wilc1000/linux_wlan_sdio.h
@@ -1,7 +1,7 @@
#include <linux/mmc/sdio_func.h>

int wilc_sdio_init(void);
-int wilc_sdio_cmd52(sdio_cmd52_t *cmd);
+int wilc_sdio_cmd52(struct wilc *wilc, sdio_cmd52_t *cmd);
int wilc_sdio_cmd53(sdio_cmd53_t *cmd);

int wilc_sdio_enable_interrupt(struct wilc *);
diff --git a/drivers/staging/wilc1000/wilc_sdio.c b/drivers/staging/wilc1000/wilc_sdio.c
index a920e76..4d0ee69 100644
--- a/drivers/staging/wilc1000/wilc_sdio.c
+++ b/drivers/staging/wilc1000/wilc_sdio.c
@@ -47,21 +47,21 @@ static int sdio_set_func0_csa_address(struct wilc *wilc, u32 adr)
cmd.raw = 0;
cmd.address = 0x10c;
cmd.data = (u8)adr;
- if (!wilc_sdio_cmd52(&cmd)) {
+ if (!wilc_sdio_cmd52(wilc, &cmd)) {
g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd52, set 0x10c data...\n");
goto _fail_;
}

cmd.address = 0x10d;
cmd.data = (u8)(adr >> 8);
- if (!wilc_sdio_cmd52(&cmd)) {
+ if (!wilc_sdio_cmd52(wilc, &cmd)) {
g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd52, set 0x10d data...\n");
goto _fail_;
}

cmd.address = 0x10e;
cmd.data = (u8)(adr >> 16);
- if (!wilc_sdio_cmd52(&cmd)) {
+ if (!wilc_sdio_cmd52(wilc, &cmd)) {
g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd52, set 0x10e data...\n");
goto _fail_;
}
@@ -80,14 +80,14 @@ static int sdio_set_func0_block_size(struct wilc *wilc, u32 block_size)
cmd.raw = 0;
cmd.address = 0x10;
cmd.data = (u8)block_size;
- if (!wilc_sdio_cmd52(&cmd)) {
+ if (!wilc_sdio_cmd52(wilc, &cmd)) {
g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd52, set 0x10 data...\n");
goto _fail_;
}

cmd.address = 0x11;
cmd.data = (u8)(block_size >> 8);
- if (!wilc_sdio_cmd52(&cmd)) {
+ if (!wilc_sdio_cmd52(wilc, &cmd)) {
g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd52, set 0x11 data...\n");
goto _fail_;
}
@@ -112,13 +112,13 @@ static int sdio_set_func1_block_size(struct wilc *wilc, u32 block_size)
cmd.raw = 0;
cmd.address = 0x110;
cmd.data = (u8)block_size;
- if (!wilc_sdio_cmd52(&cmd)) {
+ if (!wilc_sdio_cmd52(wilc, &cmd)) {
g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd52, set 0x110 data...\n");
goto _fail_;
}
cmd.address = 0x111;
cmd.data = (u8)(block_size >> 8);
- if (!wilc_sdio_cmd52(&cmd)) {
+ if (!wilc_sdio_cmd52(wilc, &cmd)) {
g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd52, set 0x111 data...\n");
goto _fail_;
}
@@ -139,7 +139,7 @@ static int sdio_clear_int(struct wilc *wilc)
cmd.raw = 0;
cmd.address = 0x4;
cmd.data = 0;
- wilc_sdio_cmd52(&cmd);
+ wilc_sdio_cmd52(wilc, &cmd);

return cmd.data;
} else {
@@ -175,7 +175,7 @@ static int sdio_write_reg(struct wilc *wilc, u32 addr, u32 data)
cmd.raw = 0;
cmd.address = addr;
cmd.data = data;
- if (!wilc_sdio_cmd52(&cmd)) {
+ if (!wilc_sdio_cmd52(wilc, &cmd)) {
g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd 52, read reg (%08x) ...\n", addr);
goto _fail_;
}
@@ -303,7 +303,7 @@ static int sdio_read_reg(struct wilc *wilc, u32 addr, u32 *data)
cmd.function = 0;
cmd.raw = 0;
cmd.address = addr;
- if (!wilc_sdio_cmd52(&cmd)) {
+ if (!wilc_sdio_cmd52(wilc, &cmd)) {
g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd 52, read reg (%08x) ...\n", addr);
goto _fail_;
}
@@ -516,7 +516,7 @@ static int sdio_init(struct wilc *wilc, wilc_debug_func func)
cmd.raw = 1;
cmd.address = 0x100;
cmd.data = 0x80;
- if (!wilc_sdio_cmd52(&cmd)) {
+ if (!wilc_sdio_cmd52(wilc, &cmd)) {
g_sdio.dPrint(N_ERR, "[wilc sdio]: Fail cmd 52, enable csa...\n");
goto _fail_;
}
@@ -538,7 +538,7 @@ static int sdio_init(struct wilc *wilc, wilc_debug_func func)
cmd.raw = 1;
cmd.address = 0x2;
cmd.data = 0x2;
- if (!wilc_sdio_cmd52(&cmd)) {
+ if (!wilc_sdio_cmd52(wilc, &cmd)) {
g_sdio.dPrint(N_ERR, "[wilc sdio] Fail cmd 52, set IOE register...\n");
goto _fail_;
}
@@ -553,7 +553,7 @@ static int sdio_init(struct wilc *wilc, wilc_debug_func func)
loop = 3;
do {
cmd.data = 0;
- if (!wilc_sdio_cmd52(&cmd)) {
+ if (!wilc_sdio_cmd52(wilc, &cmd)) {
g_sdio.dPrint(N_ERR, "[wilc sdio]: Fail cmd 52, get IOR register...\n");
goto _fail_;
}
@@ -582,7 +582,7 @@ static int sdio_init(struct wilc *wilc, wilc_debug_func func)
cmd.raw = 1;
cmd.address = 0x4;
cmd.data = 0x3;
- if (!wilc_sdio_cmd52(&cmd)) {
+ if (!wilc_sdio_cmd52(wilc, &cmd)) {
g_sdio.dPrint(N_ERR, "[wilc sdio]: Fail cmd 52, set IEN register...\n");
goto _fail_;
}
@@ -622,7 +622,7 @@ static int sdio_read_size(struct wilc *wilc, u32 *size)
cmd.raw = 0;
cmd.address = 0xf2;
cmd.data = 0;
- wilc_sdio_cmd52(&cmd);
+ wilc_sdio_cmd52(wilc, &cmd);
tmp = cmd.data;

/* cmd.read_write = 0; */
@@ -630,7 +630,7 @@ static int sdio_read_size(struct wilc *wilc, u32 *size)
/* cmd.raw = 0; */
cmd.address = 0xf3;
cmd.data = 0;
- wilc_sdio_cmd52(&cmd);
+ wilc_sdio_cmd52(wilc, &cmd);
tmp |= (cmd.data << 8);

*size = tmp;
@@ -654,7 +654,7 @@ static int sdio_read_int(struct wilc *wilc, u32 *int_status)
cmd.function = 1;
cmd.address = 0x04;
cmd.data = 0;
- wilc_sdio_cmd52(&cmd);
+ wilc_sdio_cmd52(wilc, &cmd);

if (cmd.data & BIT(0))
tmp |= INT_0;
@@ -682,7 +682,7 @@ static int sdio_read_int(struct wilc *wilc, u32 *int_status)
cmd.raw = 0;
cmd.address = 0xf7;
cmd.data = 0;
- wilc_sdio_cmd52(&cmd);
+ wilc_sdio_cmd52(wilc, &cmd);
irq_flags = cmd.data & 0x1f;
tmp |= ((irq_flags >> 0) << IRG_FLAGS_OFFSET);
}
@@ -725,7 +725,7 @@ static int sdio_clear_int_ext(struct wilc *wilc, u32 val)
cmd.address = 0xf8;
cmd.data = reg;

- ret = wilc_sdio_cmd52(&cmd);
+ ret = wilc_sdio_cmd52(wilc, &cmd);
if (!ret) {
g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd52, set 0xf8 data (%d) ...\n", __LINE__);
goto _fail_;
@@ -753,7 +753,7 @@ static int sdio_clear_int_ext(struct wilc *wilc, u32 val)
cmd.address = 0xf8;
cmd.data = BIT(i);

- ret = wilc_sdio_cmd52(&cmd);
+ ret = wilc_sdio_cmd52(wilc, &cmd);
if (!ret) {
g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd52, set 0xf8 data (%d) ...\n", __LINE__);
goto _fail_;
@@ -796,7 +796,7 @@ static int sdio_clear_int_ext(struct wilc *wilc, u32 val)
cmd.raw = 0;
cmd.address = 0xf6;
cmd.data = vmm_ctl;
- ret = wilc_sdio_cmd52(&cmd);
+ ret = wilc_sdio_cmd52(wilc, &cmd);
if (!ret) {
g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd52, set 0xf6 data (%d) ...\n", __LINE__);
goto _fail_;
--
1.9.1


2015-11-18 06:09:51

by Glen Lee

[permalink] [raw]
Subject: [PATCH 15/16] staging: wilc1000: wilc_dbg: remove wilc

This patch remove parameter struct wilc since it is not used and also wilc_dev
will be removed.

Signed-off-by: Glen Lee <[email protected]>
---
drivers/staging/wilc1000/linux_wlan.c | 2 +-
drivers/staging/wilc1000/wilc_wfi_netdevice.h | 2 +-
drivers/staging/wilc1000/wilc_wlan.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c
index 1457e75..cd471ab 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -245,7 +245,7 @@ static void deinit_irq(struct net_device *dev)
}
}

-void wilc_dbg(struct wilc *wilc, u8 *buff)
+void wilc_dbg(u8 *buff)
{
PRINT_D(INIT_DBG, "%d\n", *buff);
}
diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
index 6ec6d6a..4c8de8b 100644
--- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h
+++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
@@ -210,7 +210,7 @@ extern struct net_device *WILC_WFI_devs[];
void wilc_frmw_to_linux(struct wilc *wilc, u8 *buff, u32 size, u32 pkt_offset);
void wilc_mac_indicate(struct wilc *wilc, int flag);
void wilc_rx_complete(struct wilc *wilc);
-void wilc_dbg(struct wilc *, u8 *buff);
+void wilc_dbg(u8 *buff);

int wilc_lock_timeout(struct wilc *wilc, void *, u32 timeout);
void wilc_netdev_cleanup(struct wilc *wilc);
diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c
index a271851..a73e99f 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -51,7 +51,7 @@ static void wilc_debug(u32 flag, char *fmt, ...)
vsprintf(buf, fmt, args);
va_end(args);

- wilc_dbg(wilc_dev, buf);
+ wilc_dbg(buf);
}
}

--
1.9.1


2015-11-18 06:09:09

by Glen Lee

[permalink] [raw]
Subject: [PATCH 08/16] staging: wilc1000: wilc_spi_write: pass struct wilc

This patch add new function parameter struct wilc and use it instead of
wilc_dev, and pass wilc to the function as well.

Signed-off-by: Glen Lee <[email protected]>
---
drivers/staging/wilc1000/linux_wlan_spi.c | 4 ++--
drivers/staging/wilc1000/linux_wlan_spi.h | 3 ++-
drivers/staging/wilc1000/wilc_spi.c | 6 +++---
3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan_spi.c b/drivers/staging/wilc1000/linux_wlan_spi.c
index bfd3cc3..7be750b 100644
--- a/drivers/staging/wilc1000/linux_wlan_spi.c
+++ b/drivers/staging/wilc1000/linux_wlan_spi.c
@@ -66,9 +66,9 @@ int wilc_spi_init(void)
return 1;
}

-int wilc_spi_write(u8 *b, u32 len)
+int wilc_spi_write(struct wilc *wilc, u8 *b, u32 len)
{
- struct spi_device *spi = to_spi_device(wilc_dev->dev);
+ struct spi_device *spi = to_spi_device(wilc->dev);
int ret;
struct spi_message msg;

diff --git a/drivers/staging/wilc1000/linux_wlan_spi.h b/drivers/staging/wilc1000/linux_wlan_spi.h
index baa98cc..41d47dc 100644
--- a/drivers/staging/wilc1000/linux_wlan_spi.h
+++ b/drivers/staging/wilc1000/linux_wlan_spi.h
@@ -2,9 +2,10 @@
#define LINUX_WLAN_SPI_H

#include <linux/spi/spi.h>
+#include "wilc_wfi_netdevice.h"

int wilc_spi_init(void);
-int wilc_spi_write(u8 *b, u32 len);
+int wilc_spi_write(struct wilc *wilc, u8 *b, u32 len);
int wilc_spi_read(u8 *rb, u32 rlen);
int wilc_spi_write_read(u8 *wb, u8 *rb, u32 rlen);
#endif
diff --git a/drivers/staging/wilc1000/wilc_spi.c b/drivers/staging/wilc1000/wilc_spi.c
index 7a96004..0d89a282 100644
--- a/drivers/staging/wilc1000/wilc_spi.c
+++ b/drivers/staging/wilc1000/wilc_spi.c
@@ -482,7 +482,7 @@ static int spi_data_write(struct wilc *wilc, u8 *b, u32 sz)
order = 0x2;
}
cmd |= order;
- if (!wilc_spi_write(&cmd, 1)) {
+ if (!wilc_spi_write(wilc, &cmd, 1)) {
PRINT_ER("[wilc spi]: Failed data block cmd write, bus error...\n");
result = N_FAIL;
break;
@@ -491,7 +491,7 @@ static int spi_data_write(struct wilc *wilc, u8 *b, u32 sz)
/**
* Write data
**/
- if (!wilc_spi_write(&b[ix], nbytes)) {
+ if (!wilc_spi_write(wilc, &b[ix], nbytes)) {
PRINT_ER("[wilc spi]: Failed data block write, bus error...\n");
result = N_FAIL;
break;
@@ -501,7 +501,7 @@ static int spi_data_write(struct wilc *wilc, u8 *b, u32 sz)
* Write Crc
**/
if (!g_spi.crc_off) {
- if (!wilc_spi_write(crc, 2)) {
+ if (!wilc_spi_write(wilc, crc, 2)) {
PRINT_ER("[wilc spi]: Failed data block crc write, bus error...\n");
result = N_FAIL;
break;
--
1.9.1


2015-11-18 06:08:51

by Glen Lee

[permalink] [raw]
Subject: [PATCH 05/16] staging: wilc1000: pass wilc to all function pointers of wilc_hif_func

This patch adds new function parameter struct wilc to all function pointers
of struct wilc_hif_func, and all functions of wilc_sdio.c and wilc_spi.c
need to be changed as it's function pointer is changed.
Pass wilc in all the functions call as well.

The wilc will be passed to functions in linux_wlan_sdio.c and linux_wlan_spi.c
to replace with global variable wilc_dev in the next patch.

Signed-off-by: Glen Lee <[email protected]>
---
drivers/staging/wilc1000/wilc_sdio.c | 84 +++++++++---------
drivers/staging/wilc1000/wilc_spi.c | 113 +++++++++++++-----------
drivers/staging/wilc1000/wilc_wlan.c | 167 +++++++++++++++++++----------------
drivers/staging/wilc1000/wilc_wlan.h | 26 +++---
4 files changed, 208 insertions(+), 182 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_sdio.c b/drivers/staging/wilc1000/wilc_sdio.c
index 398c7f5..a920e76 100644
--- a/drivers/staging/wilc1000/wilc_sdio.c
+++ b/drivers/staging/wilc1000/wilc_sdio.c
@@ -26,8 +26,8 @@ typedef struct {

static wilc_sdio_t g_sdio;

-static int sdio_write_reg(u32 addr, u32 data);
-static int sdio_read_reg(u32 addr, u32 *data);
+static int sdio_write_reg(struct wilc *wilc, u32 addr, u32 data);
+static int sdio_read_reg(struct wilc *wilc, u32 addr, u32 *data);

/********************************************
*
@@ -35,7 +35,7 @@ static int sdio_read_reg(u32 addr, u32 *data);
*
********************************************/

-static int sdio_set_func0_csa_address(u32 adr)
+static int sdio_set_func0_csa_address(struct wilc *wilc, u32 adr)
{
sdio_cmd52_t cmd;

@@ -71,7 +71,7 @@ _fail_:
return 0;
}

-static int sdio_set_func0_block_size(u32 block_size)
+static int sdio_set_func0_block_size(struct wilc *wilc, u32 block_size)
{
sdio_cmd52_t cmd;

@@ -103,7 +103,7 @@ _fail_:
*
********************************************/

-static int sdio_set_func1_block_size(u32 block_size)
+static int sdio_set_func1_block_size(struct wilc *wilc, u32 block_size)
{
sdio_cmd52_t cmd;

@@ -128,7 +128,7 @@ _fail_:
return 0;
}

-static int sdio_clear_int(void)
+static int sdio_clear_int(struct wilc *wilc)
{
if (!g_sdio.irq_gpio) {
/* u32 sts; */
@@ -145,12 +145,12 @@ static int sdio_clear_int(void)
} else {
u32 reg;

- if (!sdio_read_reg(WILC_HOST_RX_CTRL_0, &reg)) {
+ if (!sdio_read_reg(wilc, WILC_HOST_RX_CTRL_0, &reg)) {
g_sdio.dPrint(N_ERR, "[wilc spi]: Failed read reg (%08x)...\n", WILC_HOST_RX_CTRL_0);
return 0;
}
reg &= ~0x1;
- sdio_write_reg(WILC_HOST_RX_CTRL_0, reg);
+ sdio_write_reg(wilc, WILC_HOST_RX_CTRL_0, reg);
return 1;
}

@@ -161,7 +161,7 @@ static int sdio_clear_int(void)
* Sdio interfaces
*
********************************************/
-static int sdio_write_reg(u32 addr, u32 data)
+static int sdio_write_reg(struct wilc *wilc, u32 addr, u32 data)
{
#ifdef BIG_ENDIAN
data = BYTE_SWAP(data);
@@ -185,7 +185,7 @@ static int sdio_write_reg(u32 addr, u32 data)
/**
* set the AHB address
**/
- if (!sdio_set_func0_csa_address(addr))
+ if (!sdio_set_func0_csa_address(wilc, addr))
goto _fail_;

cmd.read_write = 1;
@@ -210,7 +210,7 @@ _fail_:
return 0;
}

-static int sdio_write(u32 addr, u8 *buf, u32 size)
+static int sdio_write(struct wilc *wilc, u32 addr, u8 *buf, u32 size)
{
u32 block_size = g_sdio.block_size;
sdio_cmd53_t cmd;
@@ -257,7 +257,7 @@ static int sdio_write(u32 addr, u8 *buf, u32 size)
cmd.buffer = buf;
cmd.block_size = block_size;
if (addr > 0) {
- if (!sdio_set_func0_csa_address(addr))
+ if (!sdio_set_func0_csa_address(wilc, addr))
goto _fail_;
}
if (!wilc_sdio_cmd53(&cmd)) {
@@ -278,7 +278,7 @@ static int sdio_write(u32 addr, u8 *buf, u32 size)
cmd.block_size = block_size; /* johnny : prevent it from setting unexpected value */

if (addr > 0) {
- if (!sdio_set_func0_csa_address(addr))
+ if (!sdio_set_func0_csa_address(wilc, addr))
goto _fail_;
}
if (!wilc_sdio_cmd53(&cmd)) {
@@ -294,7 +294,7 @@ _fail_:
return 0;
}

-static int sdio_read_reg(u32 addr, u32 *data)
+static int sdio_read_reg(struct wilc *wilc, u32 addr, u32 *data)
{
if ((addr >= 0xf0) && (addr <= 0xff)) {
sdio_cmd52_t cmd;
@@ -311,7 +311,7 @@ static int sdio_read_reg(u32 addr, u32 *data)
} else {
sdio_cmd53_t cmd;

- if (!sdio_set_func0_csa_address(addr))
+ if (!sdio_set_func0_csa_address(wilc, addr))
goto _fail_;

cmd.read_write = 0;
@@ -341,7 +341,7 @@ _fail_:
return 0;
}

-static int sdio_read(u32 addr, u8 *buf, u32 size)
+static int sdio_read(struct wilc *wilc, u32 addr, u8 *buf, u32 size)
{
u32 block_size = g_sdio.block_size;
sdio_cmd53_t cmd;
@@ -388,7 +388,7 @@ static int sdio_read(u32 addr, u8 *buf, u32 size)
cmd.buffer = buf;
cmd.block_size = block_size;
if (addr > 0) {
- if (!sdio_set_func0_csa_address(addr))
+ if (!sdio_set_func0_csa_address(wilc, addr))
goto _fail_;
}
if (!wilc_sdio_cmd53(&cmd)) {
@@ -409,7 +409,7 @@ static int sdio_read(u32 addr, u8 *buf, u32 size)
cmd.block_size = block_size; /* johnny : prevent it from setting unexpected value */

if (addr > 0) {
- if (!sdio_set_func0_csa_address(addr))
+ if (!sdio_set_func0_csa_address(wilc, addr))
goto _fail_;
}
if (!wilc_sdio_cmd53(&cmd)) {
@@ -431,25 +431,25 @@ _fail_:
*
********************************************/

-static int sdio_deinit(void *pv)
+static int sdio_deinit(struct wilc *wilc)
{
return 1;
}

-static int sdio_sync(void)
+static int sdio_sync(struct wilc *wilc)
{
u32 reg;

/**
* Disable power sequencer
**/
- if (!sdio_read_reg(WILC_MISC, &reg)) {
+ if (!sdio_read_reg(wilc, WILC_MISC, &reg)) {
g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed read misc reg...\n");
return 0;
}

reg &= ~BIT(8);
- if (!sdio_write_reg(WILC_MISC, reg)) {
+ if (!sdio_write_reg(wilc, WILC_MISC, reg)) {
g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed write misc reg...\n");
return 0;
}
@@ -461,13 +461,13 @@ static int sdio_sync(void)
/**
* interrupt pin mux select
**/
- ret = sdio_read_reg(WILC_PIN_MUX_0, &reg);
+ ret = sdio_read_reg(wilc, WILC_PIN_MUX_0, &reg);
if (!ret) {
g_sdio.dPrint(N_ERR, "[wilc spi]: Failed read reg (%08x)...\n", WILC_PIN_MUX_0);
return 0;
}
reg |= BIT(8);
- ret = sdio_write_reg(WILC_PIN_MUX_0, reg);
+ ret = sdio_write_reg(wilc, WILC_PIN_MUX_0, reg);
if (!ret) {
g_sdio.dPrint(N_ERR, "[wilc spi]: Failed write reg (%08x)...\n", WILC_PIN_MUX_0);
return 0;
@@ -476,13 +476,13 @@ static int sdio_sync(void)
/**
* interrupt enable
**/
- ret = sdio_read_reg(WILC_INTR_ENABLE, &reg);
+ ret = sdio_read_reg(wilc, WILC_INTR_ENABLE, &reg);
if (!ret) {
g_sdio.dPrint(N_ERR, "[wilc spi]: Failed read reg (%08x)...\n", WILC_INTR_ENABLE);
return 0;
}
reg |= BIT(16);
- ret = sdio_write_reg(WILC_INTR_ENABLE, reg);
+ ret = sdio_write_reg(wilc, WILC_INTR_ENABLE, reg);
if (!ret) {
g_sdio.dPrint(N_ERR, "[wilc spi]: Failed write reg (%08x)...\n", WILC_INTR_ENABLE);
return 0;
@@ -524,7 +524,7 @@ static int sdio_init(struct wilc *wilc, wilc_debug_func func)
/**
* function 0 block size
**/
- if (!sdio_set_func0_block_size(WILC_SDIO_BLOCK_SIZE)) {
+ if (!sdio_set_func0_block_size(wilc, WILC_SDIO_BLOCK_SIZE)) {
g_sdio.dPrint(N_ERR, "[wilc sdio]: Fail cmd 52, set func 0 block size...\n");
goto _fail_;
}
@@ -569,7 +569,7 @@ static int sdio_init(struct wilc *wilc, wilc_debug_func func)
/**
* func 1 is ready, set func 1 block size
**/
- if (!sdio_set_func1_block_size(WILC_SDIO_BLOCK_SIZE)) {
+ if (!sdio_set_func1_block_size(wilc, WILC_SDIO_BLOCK_SIZE)) {
g_sdio.dPrint(N_ERR, "[wilc sdio]: Fail set func 1 block size...\n");
goto _fail_;
}
@@ -590,7 +590,7 @@ static int sdio_init(struct wilc *wilc, wilc_debug_func func)
/**
* make sure can read back chip id correctly
**/
- if (!sdio_read_reg(0x1000, &chipid)) {
+ if (!sdio_read_reg(wilc, 0x1000, &chipid)) {
g_sdio.dPrint(N_ERR, "[wilc sdio]: Fail cmd read chip id...\n");
goto _fail_;
}
@@ -608,7 +608,7 @@ _fail_:
return 0;
}

-static int sdio_read_size(u32 *size)
+static int sdio_read_size(struct wilc *wilc, u32 *size)
{

u32 tmp;
@@ -637,13 +637,13 @@ static int sdio_read_size(u32 *size)
return 1;
}

-static int sdio_read_int(u32 *int_status)
+static int sdio_read_int(struct wilc *wilc, u32 *int_status)
{

u32 tmp;
sdio_cmd52_t cmd;

- sdio_read_size(&tmp);
+ sdio_read_size(wilc, &tmp);

/**
* Read IRQ flags
@@ -692,7 +692,7 @@ static int sdio_read_int(u32 *int_status)
return 1;
}

-static int sdio_clear_int_ext(u32 val)
+static int sdio_clear_int_ext(struct wilc *wilc, u32 val)
{
int ret;

@@ -810,7 +810,7 @@ _fail_:
return 0;
}

-static int sdio_sync_ext(int nint /* how mant interrupts to enable. */)
+static int sdio_sync_ext(struct wilc *wilc, int nint)
{
u32 reg;

@@ -828,13 +828,13 @@ static int sdio_sync_ext(int nint /* how mant interrupts to enable. */)
/**
* Disable power sequencer
**/
- if (!sdio_read_reg(WILC_MISC, &reg)) {
+ if (!sdio_read_reg(wilc, WILC_MISC, &reg)) {
g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed read misc reg...\n");
return 0;
}

reg &= ~BIT(8);
- if (!sdio_write_reg(WILC_MISC, reg)) {
+ if (!sdio_write_reg(wilc, WILC_MISC, reg)) {
g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed write misc reg...\n");
return 0;
}
@@ -846,13 +846,13 @@ static int sdio_sync_ext(int nint /* how mant interrupts to enable. */)
/**
* interrupt pin mux select
**/
- ret = sdio_read_reg(WILC_PIN_MUX_0, &reg);
+ ret = sdio_read_reg(wilc, WILC_PIN_MUX_0, &reg);
if (!ret) {
g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed read reg (%08x)...\n", WILC_PIN_MUX_0);
return 0;
}
reg |= BIT(8);
- ret = sdio_write_reg(WILC_PIN_MUX_0, reg);
+ ret = sdio_write_reg(wilc, WILC_PIN_MUX_0, reg);
if (!ret) {
g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed write reg (%08x)...\n", WILC_PIN_MUX_0);
return 0;
@@ -861,7 +861,7 @@ static int sdio_sync_ext(int nint /* how mant interrupts to enable. */)
/**
* interrupt enable
**/
- ret = sdio_read_reg(WILC_INTR_ENABLE, &reg);
+ ret = sdio_read_reg(wilc, WILC_INTR_ENABLE, &reg);
if (!ret) {
g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed read reg (%08x)...\n", WILC_INTR_ENABLE);
return 0;
@@ -869,13 +869,13 @@ static int sdio_sync_ext(int nint /* how mant interrupts to enable. */)

for (i = 0; (i < 5) && (nint > 0); i++, nint--)
reg |= BIT((27 + i));
- ret = sdio_write_reg(WILC_INTR_ENABLE, reg);
+ ret = sdio_write_reg(wilc, WILC_INTR_ENABLE, reg);
if (!ret) {
g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed write reg (%08x)...\n", WILC_INTR_ENABLE);
return 0;
}
if (nint) {
- ret = sdio_read_reg(WILC_INTR2_ENABLE, &reg);
+ ret = sdio_read_reg(wilc, WILC_INTR2_ENABLE, &reg);
if (!ret) {
g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed read reg (%08x)...\n", WILC_INTR2_ENABLE);
return 0;
@@ -884,7 +884,7 @@ static int sdio_sync_ext(int nint /* how mant interrupts to enable. */)
for (i = 0; (i < 3) && (nint > 0); i++, nint--)
reg |= BIT(i);

- ret = sdio_read_reg(WILC_INTR2_ENABLE, &reg);
+ ret = sdio_read_reg(wilc, WILC_INTR2_ENABLE, &reg);
if (!ret) {
g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed write reg (%08x)...\n", WILC_INTR2_ENABLE);
return 0;
diff --git a/drivers/staging/wilc1000/wilc_spi.c b/drivers/staging/wilc1000/wilc_spi.c
index bd150a5..7a96004 100644
--- a/drivers/staging/wilc1000/wilc_spi.c
+++ b/drivers/staging/wilc1000/wilc_spi.c
@@ -22,8 +22,8 @@ typedef struct {

static wilc_spi_t g_spi;

-static int _wilc_spi_read(u32, u8 *, u32);
-static int _wilc_spi_write(u32, u8 *, u32);
+static int _wilc_spi_read(struct wilc *wilc, u32, u8 *, u32);
+static int _wilc_spi_write(struct wilc *wilc, u32, u8 *, u32);

/********************************************
*
@@ -108,7 +108,8 @@ static u8 crc7(u8 crc, const u8 *buffer, u32 len)
#define DATA_PKT_SZ_8K (8 * 1024)
#define DATA_PKT_SZ DATA_PKT_SZ_8K

-static int spi_cmd_complete(u8 cmd, u32 adr, u8 *b, u32 sz, u8 clockless)
+static int spi_cmd_complete(struct wilc *wilc, u8 cmd, u32 adr, u8 *b, u32 sz,
+ u8 clockless)
{
u8 wb[32], rb[32];
u8 wix, rix;
@@ -447,7 +448,7 @@ _error_:
return result;
}

-static int spi_data_write(u8 *b, u32 sz)
+static int spi_data_write(struct wilc *wilc, u8 *b, u32 sz)
{
int ix, nbytes;
int result = 1;
@@ -524,14 +525,15 @@ static int spi_data_write(u8 *b, u32 sz)
*
********************************************/

-static int spi_internal_write(u32 adr, u32 dat)
+static int spi_internal_write(struct wilc *wilc, u32 adr, u32 dat)
{
int result;

#ifdef BIG_ENDIAN
dat = BYTE_SWAP(dat);
#endif
- result = spi_cmd_complete(CMD_INTERNAL_WRITE, adr, (u8 *)&dat, 4, 0);
+ result = spi_cmd_complete(wilc, CMD_INTERNAL_WRITE, adr, (u8 *)&dat, 4,
+ 0);
if (result != N_OK) {
PRINT_ER("[wilc spi]: Failed internal write cmd...\n");
}
@@ -539,11 +541,12 @@ static int spi_internal_write(u32 adr, u32 dat)
return result;
}

-static int spi_internal_read(u32 adr, u32 *data)
+static int spi_internal_read(struct wilc *wilc, u32 adr, u32 *data)
{
int result;

- result = spi_cmd_complete(CMD_INTERNAL_READ, adr, (u8 *)data, 4, 0);
+ result = spi_cmd_complete(wilc, CMD_INTERNAL_READ, adr, (u8 *)data, 4,
+ 0);
if (result != N_OK) {
PRINT_ER("[wilc spi]: Failed internal read cmd...\n");
return 0;
@@ -562,7 +565,7 @@ static int spi_internal_read(u32 adr, u32 *data)
*
********************************************/

-static int wilc_spi_write_reg(u32 addr, u32 data)
+static int wilc_spi_write_reg(struct wilc *wilc, u32 addr, u32 data)
{
int result = N_OK;
u8 cmd = CMD_SINGLE_WRITE;
@@ -577,7 +580,7 @@ static int wilc_spi_write_reg(u32 addr, u32 data)
clockless = 1;
}

- result = spi_cmd_complete(cmd, addr, (u8 *)&data, 4, clockless);
+ result = spi_cmd_complete(wilc, cmd, addr, (u8 *)&data, 4, clockless);
if (result != N_OK) {
PRINT_ER("[wilc spi]: Failed cmd, write reg (%08x)...\n", addr);
}
@@ -585,7 +588,7 @@ static int wilc_spi_write_reg(u32 addr, u32 data)
return result;
}

-static int _wilc_spi_write(u32 addr, u8 *buf, u32 size)
+static int _wilc_spi_write(struct wilc *wilc, u32 addr, u8 *buf, u32 size)
{
int result;
u8 cmd = CMD_DMA_EXT_WRITE;
@@ -596,7 +599,7 @@ static int _wilc_spi_write(u32 addr, u8 *buf, u32 size)
if (size <= 4)
return 0;

- result = spi_cmd_complete(cmd, addr, NULL, size, 0);
+ result = spi_cmd_complete(wilc, cmd, addr, NULL, size, 0);
if (result != N_OK) {
PRINT_ER("[wilc spi]: Failed cmd, write block (%08x)...\n", addr);
return 0;
@@ -605,7 +608,7 @@ static int _wilc_spi_write(u32 addr, u8 *buf, u32 size)
/**
* Data
**/
- result = spi_data_write(buf, size);
+ result = spi_data_write(wilc, buf, size);
if (result != N_OK) {
PRINT_ER("[wilc spi]: Failed block data write...\n");
}
@@ -613,7 +616,7 @@ static int _wilc_spi_write(u32 addr, u8 *buf, u32 size)
return 1;
}

-static int wilc_spi_read_reg(u32 addr, u32 *data)
+static int wilc_spi_read_reg(struct wilc *wilc, u32 addr, u32 *data)
{
int result = N_OK;
u8 cmd = CMD_SINGLE_READ;
@@ -626,7 +629,7 @@ static int wilc_spi_read_reg(u32 addr, u32 *data)
clockless = 1;
}

- result = spi_cmd_complete(cmd, addr, (u8 *)data, 4, clockless);
+ result = spi_cmd_complete(wilc, cmd, addr, (u8 *)data, 4, clockless);
if (result != N_OK) {
PRINT_ER("[wilc spi]: Failed cmd, read reg (%08x)...\n", addr);
return 0;
@@ -639,7 +642,7 @@ static int wilc_spi_read_reg(u32 addr, u32 *data)
return 1;
}

-static int _wilc_spi_read(u32 addr, u8 *buf, u32 size)
+static int _wilc_spi_read(struct wilc *wilc, u32 addr, u8 *buf, u32 size)
{
u8 cmd = CMD_DMA_EXT_READ;
int result;
@@ -647,7 +650,7 @@ static int _wilc_spi_read(u32 addr, u8 *buf, u32 size)
if (size <= 4)
return 0;

- result = spi_cmd_complete(cmd, addr, buf, size, 0);
+ result = spi_cmd_complete(wilc, cmd, addr, buf, size, 0);
if (result != N_OK) {
PRINT_ER("[wilc spi]: Failed cmd, read block (%08x)...\n", addr);
return 0;
@@ -662,20 +665,20 @@ static int _wilc_spi_read(u32 addr, u8 *buf, u32 size)
*
********************************************/

-static int wilc_spi_clear_int(void)
+static int wilc_spi_clear_int(struct wilc *wilc)
{
u32 reg;

- if (!wilc_spi_read_reg(WILC_HOST_RX_CTRL_0, &reg)) {
+ if (!wilc_spi_read_reg(wilc, WILC_HOST_RX_CTRL_0, &reg)) {
PRINT_ER("[wilc spi]: Failed read reg (%08x)...\n", WILC_HOST_RX_CTRL_0);
return 0;
}
reg &= ~0x1;
- wilc_spi_write_reg(WILC_HOST_RX_CTRL_0, reg);
+ wilc_spi_write_reg(wilc, WILC_HOST_RX_CTRL_0, reg);
return 1;
}

-static int _wilc_spi_deinit(void *pv)
+static int _wilc_spi_deinit(struct wilc *wilc)
{
/**
* TODO:
@@ -683,7 +686,7 @@ static int _wilc_spi_deinit(void *pv)
return 1;
}

-static int wilc_spi_sync(void)
+static int wilc_spi_sync(struct wilc *wilc)
{
u32 reg;
int ret;
@@ -691,13 +694,13 @@ static int wilc_spi_sync(void)
/**
* interrupt pin mux select
**/
- ret = wilc_spi_read_reg(WILC_PIN_MUX_0, &reg);
+ ret = wilc_spi_read_reg(wilc, WILC_PIN_MUX_0, &reg);
if (!ret) {
PRINT_ER("[wilc spi]: Failed read reg (%08x)...\n", WILC_PIN_MUX_0);
return 0;
}
reg |= BIT(8);
- ret = wilc_spi_write_reg(WILC_PIN_MUX_0, reg);
+ ret = wilc_spi_write_reg(wilc, WILC_PIN_MUX_0, reg);
if (!ret) {
PRINT_ER("[wilc spi]: Failed write reg (%08x)...\n", WILC_PIN_MUX_0);
return 0;
@@ -706,13 +709,13 @@ static int wilc_spi_sync(void)
/**
* interrupt enable
**/
- ret = wilc_spi_read_reg(WILC_INTR_ENABLE, &reg);
+ ret = wilc_spi_read_reg(wilc, WILC_INTR_ENABLE, &reg);
if (!ret) {
PRINT_ER("[wilc spi]: Failed read reg (%08x)...\n", WILC_INTR_ENABLE);
return 0;
}
reg |= BIT(16);
- ret = wilc_spi_write_reg(WILC_INTR_ENABLE, reg);
+ ret = wilc_spi_write_reg(wilc, WILC_INTR_ENABLE, reg);
if (!ret) {
PRINT_ER("[wilc spi]: Failed write reg (%08x)...\n", WILC_INTR_ENABLE);
return 0;
@@ -730,7 +733,7 @@ static int _wilc_spi_init(struct wilc *wilc, wilc_debug_func func)

if (isinit) {

- if (!wilc_spi_read_reg(0x1000, &chipid)) {
+ if (!wilc_spi_read_reg(wilc, 0x1000, &chipid)) {
PRINT_ER("[wilc spi]: Fail cmd read chip id...\n");
return 0;
}
@@ -752,12 +755,12 @@ static int _wilc_spi_init(struct wilc *wilc, wilc_debug_func func)

/* TODO: We can remove the CRC trials if there is a definite way to reset */
/* the SPI to it's initial value. */
- if (!spi_internal_read(WILC_SPI_PROTOCOL_OFFSET, &reg)) {
+ if (!spi_internal_read(wilc, WILC_SPI_PROTOCOL_OFFSET, &reg)) {
/* Read failed. Try with CRC off. This might happen when module
* is removed but chip isn't reset*/
g_spi.crc_off = 1;
PRINT_ER("[wilc spi]: Failed internal read protocol with CRC on, retyring with CRC off...\n");
- if (!spi_internal_read(WILC_SPI_PROTOCOL_OFFSET, &reg)) {
+ if (!spi_internal_read(wilc, WILC_SPI_PROTOCOL_OFFSET, &reg)) {
/* Reaad failed with both CRC on and off, something went bad */
PRINT_ER("[wilc spi]: Failed internal read protocol...\n");
return 0;
@@ -767,7 +770,7 @@ static int _wilc_spi_init(struct wilc *wilc, wilc_debug_func func)
reg &= ~0xc; /* disable crc checking */
reg &= ~0x70;
reg |= (0x5 << 4);
- if (!spi_internal_write(WILC_SPI_PROTOCOL_OFFSET, reg)) {
+ if (!spi_internal_write(wilc, WILC_SPI_PROTOCOL_OFFSET, reg)) {
PRINT_ER("[wilc spi %d]: Failed internal write protocol reg...\n", __LINE__);
return 0;
}
@@ -778,7 +781,7 @@ static int _wilc_spi_init(struct wilc *wilc, wilc_debug_func func)
/**
* make sure can read back chip id correctly
**/
- if (!wilc_spi_read_reg(0x1000, &chipid)) {
+ if (!wilc_spi_read_reg(wilc, 0x1000, &chipid)) {
PRINT_ER("[wilc spi]: Fail cmd read chip id...\n");
return 0;
}
@@ -791,18 +794,20 @@ static int _wilc_spi_init(struct wilc *wilc, wilc_debug_func func)
return 1;
}

-static int wilc_spi_read_size(u32 *size)
+static int wilc_spi_read_size(struct wilc *wilc, u32 *size)
{
int ret;

if (g_spi.has_thrpt_enh) {
- ret = spi_internal_read(0xe840 - WILC_SPI_REG_BASE, size);
+ ret = spi_internal_read(wilc, 0xe840 - WILC_SPI_REG_BASE,
+ size);
*size = *size & IRQ_DMA_WD_CNT_MASK;
} else {
u32 tmp;
u32 byte_cnt;

- ret = wilc_spi_read_reg(WILC_VMM_TO_HOST_SIZE, &byte_cnt);
+ ret = wilc_spi_read_reg(wilc, WILC_VMM_TO_HOST_SIZE,
+ &byte_cnt);
if (!ret) {
PRINT_ER("[wilc spi]: Failed read WILC_VMM_TO_HOST_SIZE ...\n");
goto _fail_;
@@ -819,17 +824,19 @@ _fail_:



-static int wilc_spi_read_int(u32 *int_status)
+static int wilc_spi_read_int(struct wilc *wilc, u32 *int_status)
{
int ret;

if (g_spi.has_thrpt_enh) {
- ret = spi_internal_read(0xe840 - WILC_SPI_REG_BASE, int_status);
+ ret = spi_internal_read(wilc, 0xe840 - WILC_SPI_REG_BASE,
+ int_status);
} else {
u32 tmp;
u32 byte_cnt;

- ret = wilc_spi_read_reg(WILC_VMM_TO_HOST_SIZE, &byte_cnt);
+ ret = wilc_spi_read_reg(wilc, WILC_VMM_TO_HOST_SIZE,
+ &byte_cnt);
if (!ret) {
PRINT_ER("[wilc spi]: Failed read WILC_VMM_TO_HOST_SIZE ...\n");
goto _fail_;
@@ -845,11 +852,12 @@ static int wilc_spi_read_int(u32 *int_status)

happended = 0;

- wilc_spi_read_reg(0x1a90, &irq_flags);
+ wilc_spi_read_reg(wilc, 0x1a90, &irq_flags);
tmp |= ((irq_flags >> 27) << IRG_FLAGS_OFFSET);

if (g_spi.nint > 5) {
- wilc_spi_read_reg(0x1a94, &irq_flags);
+ wilc_spi_read_reg(wilc, 0x1a94,
+ &irq_flags);
tmp |= (((irq_flags >> 0) & 0x7) << (IRG_FLAGS_OFFSET + 5));
}

@@ -875,12 +883,13 @@ _fail_:
return ret;
}

-static int wilc_spi_clear_int_ext(u32 val)
+static int wilc_spi_clear_int_ext(struct wilc *wilc, u32 val)
{
int ret;

if (g_spi.has_thrpt_enh) {
- ret = spi_internal_write(0xe844 - WILC_SPI_REG_BASE, val);
+ ret = spi_internal_write(wilc, 0xe844 - WILC_SPI_REG_BASE,
+ val);
} else {
u32 flags;

@@ -892,7 +901,7 @@ static int wilc_spi_clear_int_ext(u32 val)
for (i = 0; i < g_spi.nint; i++) {
/* No matter what you write 1 or 0, it will clear interrupt. */
if (flags & 1)
- ret = wilc_spi_write_reg(0x10c8 + i * 4, 1);
+ ret = wilc_spi_write_reg(wilc, 0x10c8 + i * 4, 1);
if (!ret)
break;
flags >>= 1;
@@ -919,7 +928,8 @@ static int wilc_spi_clear_int_ext(u32 val)
if ((val & SEL_VMM_TBL1) == SEL_VMM_TBL1)
tbl_ctl |= BIT(1);

- ret = wilc_spi_write_reg(WILC_VMM_TBL_CTL, tbl_ctl);
+ ret = wilc_spi_write_reg(wilc, WILC_VMM_TBL_CTL,
+ tbl_ctl);
if (!ret) {
PRINT_ER("[wilc spi]: fail write reg vmm_tbl_ctl...\n");
goto _fail_;
@@ -929,7 +939,8 @@ static int wilc_spi_clear_int_ext(u32 val)
/**
* enable vmm transfer.
**/
- ret = wilc_spi_write_reg(WILC_VMM_CORE_CTL, 1);
+ ret = wilc_spi_write_reg(wilc,
+ WILC_VMM_CORE_CTL, 1);
if (!ret) {
PRINT_ER("[wilc spi]: fail write reg vmm_core_ctl...\n");
goto _fail_;
@@ -941,7 +952,7 @@ _fail_:
return ret;
}

-static int wilc_spi_sync_ext(int nint /* how mant interrupts to enable. */)
+static int wilc_spi_sync_ext(struct wilc *wilc, int nint)
{
u32 reg;
int ret, i;
@@ -956,13 +967,13 @@ static int wilc_spi_sync_ext(int nint /* how mant interrupts to enable. */)
/**
* interrupt pin mux select
**/
- ret = wilc_spi_read_reg(WILC_PIN_MUX_0, &reg);
+ ret = wilc_spi_read_reg(wilc, WILC_PIN_MUX_0, &reg);
if (!ret) {
PRINT_ER("[wilc spi]: Failed read reg (%08x)...\n", WILC_PIN_MUX_0);
return 0;
}
reg |= BIT(8);
- ret = wilc_spi_write_reg(WILC_PIN_MUX_0, reg);
+ ret = wilc_spi_write_reg(wilc, WILC_PIN_MUX_0, reg);
if (!ret) {
PRINT_ER("[wilc spi]: Failed write reg (%08x)...\n", WILC_PIN_MUX_0);
return 0;
@@ -971,7 +982,7 @@ static int wilc_spi_sync_ext(int nint /* how mant interrupts to enable. */)
/**
* interrupt enable
**/
- ret = wilc_spi_read_reg(WILC_INTR_ENABLE, &reg);
+ ret = wilc_spi_read_reg(wilc, WILC_INTR_ENABLE, &reg);
if (!ret) {
PRINT_ER("[wilc spi]: Failed read reg (%08x)...\n", WILC_INTR_ENABLE);
return 0;
@@ -980,13 +991,13 @@ static int wilc_spi_sync_ext(int nint /* how mant interrupts to enable. */)
for (i = 0; (i < 5) && (nint > 0); i++, nint--) {
reg |= (BIT((27 + i)));
}
- ret = wilc_spi_write_reg(WILC_INTR_ENABLE, reg);
+ ret = wilc_spi_write_reg(wilc, WILC_INTR_ENABLE, reg);
if (!ret) {
PRINT_ER("[wilc spi]: Failed write reg (%08x)...\n", WILC_INTR_ENABLE);
return 0;
}
if (nint) {
- ret = wilc_spi_read_reg(WILC_INTR2_ENABLE, &reg);
+ ret = wilc_spi_read_reg(wilc, WILC_INTR2_ENABLE, &reg);
if (!ret) {
PRINT_ER("[wilc spi]: Failed read reg (%08x)...\n", WILC_INTR2_ENABLE);
return 0;
@@ -996,7 +1007,7 @@ static int wilc_spi_sync_ext(int nint /* how mant interrupts to enable. */)
reg |= BIT(i);
}

- ret = wilc_spi_read_reg(WILC_INTR2_ENABLE, &reg);
+ ret = wilc_spi_read_reg(wilc, WILC_INTR2_ENABLE, &reg);
if (!ret) {
PRINT_ER("[wilc spi]: Failed write reg (%08x)...\n", WILC_INTR2_ENABLE);
return 0;
diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c
index e30a34d..9ac6ad7 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -566,9 +566,9 @@ static inline void chip_allow_sleep(struct wilc *wilc)
{
u32 reg = 0;

- g_wlan.hif_func.hif_read_reg(0xf0, &reg);
+ g_wlan.hif_func.hif_read_reg(wilc, 0xf0, &reg);

- g_wlan.hif_func.hif_write_reg(0xf0, reg & ~BIT(0));
+ g_wlan.hif_func.hif_write_reg(wilc, 0xf0, reg & ~BIT(0));
}

static inline void chip_wakeup(struct wilc *wilc)
@@ -578,9 +578,9 @@ static inline void chip_wakeup(struct wilc *wilc)

if ((g_wlan.io_type & 0x1) == HIF_SPI) {
do {
- g_wlan.hif_func.hif_read_reg(1, &reg);
- g_wlan.hif_func.hif_write_reg(1, reg | BIT(1));
- g_wlan.hif_func.hif_write_reg(1, reg & ~BIT(1));
+ g_wlan.hif_func.hif_read_reg(wilc, 1, &reg);
+ g_wlan.hif_func.hif_write_reg(wilc, 1, reg | BIT(1));
+ g_wlan.hif_func.hif_write_reg(wilc, 1, reg & ~BIT(1));

do {
usleep_range(2 * 1000, 2 * 1000);
@@ -591,41 +591,44 @@ static inline void chip_wakeup(struct wilc *wilc)

} while (wilc_get_chipid(wilc, true) == 0);
} else if ((g_wlan.io_type & 0x1) == HIF_SDIO) {
- g_wlan.hif_func.hif_read_reg(0xf0, &reg);
+ g_wlan.hif_func.hif_read_reg(wilc, 0xf0, &reg);
do {
- g_wlan.hif_func.hif_write_reg(0xf0, reg | BIT(0));
- g_wlan.hif_func.hif_read_reg(0xf1, &clk_status_reg);
+ g_wlan.hif_func.hif_write_reg(wilc, 0xf0,
+ reg | BIT(0));
+ g_wlan.hif_func.hif_read_reg(wilc, 0xf1,
+ &clk_status_reg);

while (((clk_status_reg & 0x1) == 0) && (((++trials) % 3) == 0)) {
usleep_range(2 * 1000, 2 * 1000);

- g_wlan.hif_func.hif_read_reg(0xf1, &clk_status_reg);
+ g_wlan.hif_func.hif_read_reg(wilc, 0xf1,
+ &clk_status_reg);

if ((clk_status_reg & 0x1) == 0)
wilc_debug(N_ERR, "clocks still OFF. Wake up failed\n");
}
if ((clk_status_reg & 0x1) == 0) {
- g_wlan.hif_func.hif_write_reg(0xf0, reg &
- (~BIT(0)));
+ g_wlan.hif_func.hif_write_reg(wilc, 0xf0,
+ reg & (~BIT(0)));
}
} while ((clk_status_reg & 0x1) == 0);
}

if (chip_ps_state == CHIP_SLEEPING_MANUAL) {
- g_wlan.hif_func.hif_read_reg(0x1C0C, &reg);
+ g_wlan.hif_func.hif_read_reg(wilc, 0x1C0C, &reg);
reg &= ~BIT(0);
- g_wlan.hif_func.hif_write_reg(0x1C0C, reg);
+ g_wlan.hif_func.hif_write_reg(wilc, 0x1C0C, reg);

if (wilc_get_chipid(wilc, false) >= 0x1002b0) {
u32 val32;

- g_wlan.hif_func.hif_read_reg(0x1e1c, &val32);
+ g_wlan.hif_func.hif_read_reg(wilc, 0x1e1c, &val32);
val32 |= BIT(6);
- g_wlan.hif_func.hif_write_reg(0x1e1c, val32);
+ g_wlan.hif_func.hif_write_reg(wilc, 0x1e1c, val32);

- g_wlan.hif_func.hif_read_reg(0x1e9c, &val32);
+ g_wlan.hif_func.hif_read_reg(wilc, 0x1e9c, &val32);
val32 |= BIT(6);
- g_wlan.hif_func.hif_write_reg(0x1e9c, val32);
+ g_wlan.hif_func.hif_write_reg(wilc, 0x1e9c, val32);
}
}
chip_ps_state = CHIP_WAKEDUP;
@@ -637,15 +640,18 @@ static inline void chip_wakeup(struct wilc *wilc)

do {
if ((g_wlan.io_type & 0x1) == HIF_SPI) {
- g_wlan.hif_func.hif_read_reg(1, &reg);
- g_wlan.hif_func.hif_write_reg(1, reg & ~BIT(1));
- g_wlan.hif_func.hif_write_reg(1, reg | BIT(1));
- g_wlan.hif_func.hif_write_reg(1, reg & ~BIT(1));
+ g_wlan.hif_func.hif_read_reg(wilc, 1, &reg);
+ g_wlan.hif_func.hif_write_reg(wilc, 1, reg & ~BIT(1));
+ g_wlan.hif_func.hif_write_reg(wilc, 1, reg | BIT(1));
+ g_wlan.hif_func.hif_write_reg(wilc, 1, reg & ~BIT(1));
} else if ((g_wlan.io_type & 0x1) == HIF_SDIO) {
- g_wlan.hif_func.hif_read_reg(0xf0, &reg);
- g_wlan.hif_func.hif_write_reg(0xf0, reg & ~BIT(0));
- g_wlan.hif_func.hif_write_reg(0xf0, reg | BIT(0));
- g_wlan.hif_func.hif_write_reg(0xf0, reg & ~BIT(0));
+ g_wlan.hif_func.hif_read_reg(wilc, 0xf0, &reg);
+ g_wlan.hif_func.hif_write_reg(wilc, 0xf0,
+ reg & ~BIT(0));
+ g_wlan.hif_func.hif_write_reg(wilc, 0xf0,
+ reg | BIT(0));
+ g_wlan.hif_func.hif_write_reg(wilc, 0xf0,
+ reg & ~BIT(0));
}

do {
@@ -659,20 +665,20 @@ static inline void chip_wakeup(struct wilc *wilc)
} while (wilc_get_chipid(wilc, true) == 0);

if (chip_ps_state == CHIP_SLEEPING_MANUAL) {
- g_wlan.hif_func.hif_read_reg(0x1C0C, &reg);
+ g_wlan.hif_func.hif_read_reg(wilc, 0x1C0C, &reg);
reg &= ~BIT(0);
- g_wlan.hif_func.hif_write_reg(0x1C0C, reg);
+ g_wlan.hif_func.hif_write_reg(wilc, 0x1C0C, reg);

if (wilc_get_chipid(wilc, false) >= 0x1002b0) {
u32 val32;

- g_wlan.hif_func.hif_read_reg(0x1e1c, &val32);
+ g_wlan.hif_func.hif_read_reg(wilc, 0x1e1c, &val32);
val32 |= BIT(6);
- g_wlan.hif_func.hif_write_reg(0x1e1c, val32);
+ g_wlan.hif_func.hif_write_reg(wilc, 0x1e1c, val32);

- g_wlan.hif_func.hif_read_reg(0x1e9c, &val32);
+ g_wlan.hif_func.hif_read_reg(wilc, 0x1e9c, &val32);
val32 |= BIT(6);
- g_wlan.hif_func.hif_write_reg(0x1e9c, val32);
+ g_wlan.hif_func.hif_write_reg(wilc, 0x1e9c, val32);
}
}
chip_ps_state = CHIP_WAKEDUP;
@@ -687,7 +693,7 @@ void wilc_chip_sleep_manually(struct wilc *wilc)
#ifdef WILC_OPTIMIZE_SLEEP_INT
chip_allow_sleep(wilc);
#endif
- g_wlan.hif_func.hif_write_reg(0x10a8, 1);
+ g_wlan.hif_func.hif_write_reg(wilc, 0x10a8, 1);

chip_ps_state = CHIP_SLEEPING_MANUAL;
release_bus(wilc, RELEASE_ONLY);
@@ -778,7 +784,8 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count)
acquire_bus(wilc, ACQUIRE_AND_WAKEUP);
counter = 0;
do {
- ret = p->hif_func.hif_read_reg(WILC_HOST_TX_CTRL, &reg);
+ ret = p->hif_func.hif_read_reg(wilc, WILC_HOST_TX_CTRL,
+ &reg);
if (!ret) {
wilc_debug(N_ERR, "[wilc txq]: fail can't read reg vmm_tbl_entry..\n");
break;
@@ -792,7 +799,7 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count)
if (counter > 200) {
counter = 0;
PRINT_D(TX_DBG, "Looping in tx ctrl , forcce quit\n");
- ret = p->hif_func.hif_write_reg(WILC_HOST_TX_CTRL, 0);
+ ret = p->hif_func.hif_write_reg(wilc, WILC_HOST_TX_CTRL, 0);
break;
}
PRINT_WRN(GENERIC_DBG, "[wilc txq]: warn, vmm table not clear yet, wait...\n");
@@ -807,20 +814,21 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count)

timeout = 200;
do {
- ret = p->hif_func.hif_block_tx(WILC_VMM_TBL_RX_SHADOW_BASE, (u8 *)vmm_table, ((i + 1) * 4));
+ ret = p->hif_func.hif_block_tx(wilc, WILC_VMM_TBL_RX_SHADOW_BASE, (u8 *)vmm_table, ((i + 1) * 4));
if (!ret) {
wilc_debug(N_ERR, "ERR block TX of VMM table.\n");
break;
}

- ret = p->hif_func.hif_write_reg(WILC_HOST_VMM_CTL, 0x2);
+ ret = p->hif_func.hif_write_reg(wilc, WILC_HOST_VMM_CTL,
+ 0x2);
if (!ret) {
wilc_debug(N_ERR, "[wilc txq]: fail can't write reg host_vmm_ctl..\n");
break;
}

do {
- ret = p->hif_func.hif_read_reg(WILC_HOST_VMM_CTL, &reg);
+ ret = p->hif_func.hif_read_reg(wilc, WILC_HOST_VMM_CTL, &reg);
if (!ret) {
wilc_debug(N_ERR, "[wilc txq]: fail can't read reg host_vmm_ctl..\n");
break;
@@ -836,7 +844,7 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count)
}
} while (--timeout);
if (timeout <= 0) {
- ret = p->hif_func.hif_write_reg(WILC_HOST_VMM_CTL, 0x0);
+ ret = p->hif_func.hif_write_reg(wilc, WILC_HOST_VMM_CTL, 0x0);
break;
}

@@ -846,13 +854,13 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count)
if (entries == 0) {
PRINT_WRN(GENERIC_DBG, "[wilc txq]: no more buffer in the chip (reg: %08x), retry later [[ %d, %x ]]\n", reg, i, vmm_table[i - 1]);

- ret = p->hif_func.hif_read_reg(WILC_HOST_TX_CTRL, &reg);
+ ret = p->hif_func.hif_read_reg(wilc, WILC_HOST_TX_CTRL, &reg);
if (!ret) {
wilc_debug(N_ERR, "[wilc txq]: fail can't read reg WILC_HOST_TX_CTRL..\n");
break;
}
reg &= ~BIT(0);
- ret = p->hif_func.hif_write_reg(WILC_HOST_TX_CTRL, reg);
+ ret = p->hif_func.hif_write_reg(wilc, WILC_HOST_TX_CTRL, reg);
if (!ret) {
wilc_debug(N_ERR, "[wilc txq]: fail can't write reg WILC_HOST_TX_CTRL..\n");
break;
@@ -928,13 +936,13 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count)

acquire_bus(wilc, ACQUIRE_AND_WAKEUP);

- ret = p->hif_func.hif_clear_int_ext(ENABLE_TX_VMM);
+ ret = p->hif_func.hif_clear_int_ext(wilc, ENABLE_TX_VMM);
if (!ret) {
wilc_debug(N_ERR, "[wilc txq]: fail can't start tx VMM ...\n");
goto _end_;
}

- ret = p->hif_func.hif_block_tx_ext(0, txb, offset);
+ ret = p->hif_func.hif_block_tx_ext(wilc, 0, txb, offset);
if (!ret) {
wilc_debug(N_ERR, "[wilc txq]: fail can't block tx ext...\n");
goto _end_;
@@ -1058,14 +1066,14 @@ static void wilc_wlan_handle_rxq(struct wilc *wilc)

static void wilc_unknown_isr_ext(struct wilc *wilc)
{
- g_wlan.hif_func.hif_clear_int_ext(0);
+ g_wlan.hif_func.hif_clear_int_ext(wilc, 0);
}

static void wilc_pllupdate_isr_ext(struct wilc *wilc, u32 int_stats)
{
int trials = 10;

- g_wlan.hif_func.hif_clear_int_ext(PLL_INT_CLR);
+ g_wlan.hif_func.hif_clear_int_ext(wilc, PLL_INT_CLR);

if (g_wlan.io_type == HIF_SDIO)
mdelay(WILC_PLL_TO_SDIO);
@@ -1080,7 +1088,7 @@ static void wilc_pllupdate_isr_ext(struct wilc *wilc, u32 int_stats)

static void wilc_sleeptimer_isr_ext(struct wilc *wilc, u32 int_stats1)
{
- g_wlan.hif_func.hif_clear_int_ext(SLEEP_INT_CLR);
+ g_wlan.hif_func.hif_clear_int_ext(wilc, SLEEP_INT_CLR);
#ifndef WILC_OPTIMIZE_SLEEP_INT
chip_ps_state = CHIP_SLEEPING_AUTO;
#endif
@@ -1104,7 +1112,7 @@ static void wilc_wlan_handle_isr_ext(struct wilc *wilc, u32 int_status)
u32 time = 0;

wilc_debug(N_ERR, "RX Size equal zero ... Trying to read it again for %d time\n", time++);
- p->hif_func.hif_read_size(&size);
+ p->hif_func.hif_read_size(wilc, &size);
size = ((size & 0x7fff) << 2);
retries++;
}
@@ -1128,8 +1136,9 @@ static void wilc_wlan_handle_isr_ext(struct wilc *wilc, u32 int_status)
goto _end_;
}
#endif
- p->hif_func.hif_clear_int_ext(DATA_INT_CLR | ENABLE_RX_VMM);
- ret = p->hif_func.hif_block_rx_ext(0, buffer, size);
+ p->hif_func.hif_clear_int_ext(wilc,
+ DATA_INT_CLR | ENABLE_RX_VMM);
+ ret = p->hif_func.hif_block_rx_ext(wilc, 0, buffer, size);

if (!ret) {
wilc_debug(N_ERR, "[wilc isr]: fail block rx...\n");
@@ -1162,7 +1171,7 @@ void wilc_handle_isr(struct wilc *wilc)
u32 int_status;

acquire_bus(wilc, ACQUIRE_AND_WAKEUP);
- g_wlan.hif_func.hif_read_int(&int_status);
+ g_wlan.hif_func.hif_read_int(wilc, &int_status);

if (int_status & PLL_INT_EXT)
wilc_pllupdate_isr_ext(wilc, int_status);
@@ -1219,7 +1228,8 @@ int wilc_wlan_firmware_download(struct wilc *wilc, const u8 *buffer, u32 buffer_
size2 = blksz;

memcpy(dma_buffer, &buffer[offset], size2);
- ret = p->hif_func.hif_block_tx(addr, dma_buffer, size2);
+ ret = p->hif_func.hif_block_tx(wilc, addr, dma_buffer,
+ size2);
if (!ret)
break;

@@ -1260,7 +1270,7 @@ int wilc_wlan_start(struct wilc *wilc)
reg = 1;
}
acquire_bus(wilc, ACQUIRE_ONLY);
- ret = p->hif_func.hif_write_reg(WILC_VMM_CORE_CFG, reg);
+ ret = p->hif_func.hif_write_reg(wilc, WILC_VMM_CORE_CFG, reg);
if (!ret) {
wilc_debug(N_ERR, "[wilc start]: fail write reg vmm_core_cfg...\n");
release_bus(wilc, RELEASE_ONLY);
@@ -1294,7 +1304,7 @@ int wilc_wlan_start(struct wilc *wilc)
reg |= WILC_HAVE_DISABLE_WILC_UART;
#endif

- ret = p->hif_func.hif_write_reg(WILC_GP_REG_1, reg);
+ ret = p->hif_func.hif_write_reg(wilc, WILC_GP_REG_1, reg);
if (!ret) {
wilc_debug(N_ERR, "[wilc start]: fail write WILC_GP_REG_1 ...\n");
release_bus(wilc, RELEASE_ONLY);
@@ -1302,9 +1312,9 @@ int wilc_wlan_start(struct wilc *wilc)
return ret;
}

- p->hif_func.hif_sync_ext(NUM_INT_EXT);
+ p->hif_func.hif_sync_ext(wilc, NUM_INT_EXT);

- ret = p->hif_func.hif_read_reg(0x1000, &chipid);
+ ret = p->hif_func.hif_read_reg(wilc, 0x1000, &chipid);
if (!ret) {
wilc_debug(N_ERR, "[wilc start]: fail read reg 0x1000 ...\n");
release_bus(wilc, RELEASE_ONLY);
@@ -1312,16 +1322,16 @@ int wilc_wlan_start(struct wilc *wilc)
return ret;
}

- p->hif_func.hif_read_reg(WILC_GLB_RESET_0, &reg);
+ p->hif_func.hif_read_reg(wilc, WILC_GLB_RESET_0, &reg);
if ((reg & BIT(10)) == BIT(10)) {
reg &= ~BIT(10);
- p->hif_func.hif_write_reg(WILC_GLB_RESET_0, reg);
- p->hif_func.hif_read_reg(WILC_GLB_RESET_0, &reg);
+ p->hif_func.hif_write_reg(wilc, WILC_GLB_RESET_0, reg);
+ p->hif_func.hif_read_reg(wilc, WILC_GLB_RESET_0, &reg);
}

reg |= BIT(10);
- ret = p->hif_func.hif_write_reg(WILC_GLB_RESET_0, reg);
- p->hif_func.hif_read_reg(WILC_GLB_RESET_0, &reg);
+ ret = p->hif_func.hif_write_reg(wilc, WILC_GLB_RESET_0, reg);
+ p->hif_func.hif_read_reg(wilc, WILC_GLB_RESET_0, &reg);
release_bus(wilc, RELEASE_ONLY);

return (ret < 0) ? ret : 0;
@@ -1333,7 +1343,7 @@ void wilc_wlan_global_reset(struct wilc *wilc)
wilc_wlan_dev_t *p = &g_wlan;

acquire_bus(wilc, ACQUIRE_AND_WAKEUP);
- p->hif_func.hif_write_reg(WILC_GLB_RESET_0, 0x0);
+ p->hif_func.hif_write_reg(wilc, WILC_GLB_RESET_0, 0x0);
release_bus(wilc, RELEASE_ONLY);
}
int wilc_wlan_stop(struct wilc *wilc)
@@ -1344,7 +1354,7 @@ int wilc_wlan_stop(struct wilc *wilc)
u8 timeout = 10;
acquire_bus(wilc, ACQUIRE_AND_WAKEUP);

- ret = p->hif_func.hif_read_reg(WILC_GLB_RESET_0, &reg);
+ ret = p->hif_func.hif_read_reg(wilc, WILC_GLB_RESET_0, &reg);
if (!ret) {
PRINT_ER("Error while reading reg\n");
release_bus(wilc, RELEASE_ALLOW_SLEEP);
@@ -1352,7 +1362,7 @@ int wilc_wlan_stop(struct wilc *wilc)
}

reg &= ~BIT(10);
- ret = p->hif_func.hif_write_reg(WILC_GLB_RESET_0, reg);
+ ret = p->hif_func.hif_write_reg(wilc, WILC_GLB_RESET_0, reg);
if (!ret) {
PRINT_ER("Error while writing reg\n");
release_bus(wilc, RELEASE_ALLOW_SLEEP);
@@ -1360,7 +1370,7 @@ int wilc_wlan_stop(struct wilc *wilc)
}

do {
- ret = p->hif_func.hif_read_reg(WILC_GLB_RESET_0, &reg);
+ ret = p->hif_func.hif_read_reg(wilc, WILC_GLB_RESET_0, &reg);
if (!ret) {
PRINT_ER("Error while reading reg\n");
release_bus(wilc, RELEASE_ALLOW_SLEEP);
@@ -1373,12 +1383,14 @@ int wilc_wlan_stop(struct wilc *wilc)
PRINT_D(GENERIC_DBG, "Bit 10 not reset : Retry %d\n",
timeout);
reg &= ~BIT(10);
- ret = p->hif_func.hif_write_reg(WILC_GLB_RESET_0, reg);
+ ret = p->hif_func.hif_write_reg(wilc, WILC_GLB_RESET_0,
+ reg);
timeout--;
} else {
PRINT_D(GENERIC_DBG, "Bit 10 reset after : Retry %d\n",
timeout);
- ret = p->hif_func.hif_read_reg(WILC_GLB_RESET_0, &reg);
+ ret = p->hif_func.hif_read_reg(wilc, WILC_GLB_RESET_0,
+ &reg);
if (!ret) {
PRINT_ER("Error while reading reg\n");
release_bus(wilc, RELEASE_ALLOW_SLEEP);
@@ -1393,10 +1405,10 @@ int wilc_wlan_stop(struct wilc *wilc)
reg = (BIT(0) | BIT(1) | BIT(2) | BIT(3) | BIT(8) | BIT(9) | BIT(26) |
BIT(29) | BIT(30) | BIT(31));

- p->hif_func.hif_write_reg(WILC_GLB_RESET_0, reg);
+ p->hif_func.hif_write_reg(wilc, WILC_GLB_RESET_0, reg);
reg = (u32)~BIT(10);

- ret = p->hif_func.hif_write_reg(WILC_GLB_RESET_0, reg);
+ ret = p->hif_func.hif_write_reg(wilc, WILC_GLB_RESET_0, reg);

release_bus(wilc, RELEASE_ALLOW_SLEEP);

@@ -1444,13 +1456,14 @@ void wilc_wlan_cleanup(struct net_device *dev)

acquire_bus(wilc, ACQUIRE_AND_WAKEUP);

- ret = p->hif_func.hif_read_reg(WILC_GP_REG_0, &reg);
+ ret = p->hif_func.hif_read_reg(wilc, WILC_GP_REG_0, &reg);
if (!ret) {
PRINT_ER("Error while reading reg\n");
release_bus(wilc, RELEASE_ALLOW_SLEEP);
}
PRINT_ER("Writing ABORT reg\n");
- ret = p->hif_func.hif_write_reg(WILC_GP_REG_0, (reg | ABORT_INT));
+ ret = p->hif_func.hif_write_reg(wilc, WILC_GP_REG_0,
+ (reg | ABORT_INT));
if (!ret) {
PRINT_ER("Error while writing reg\n");
release_bus(wilc, RELEASE_ALLOW_SLEEP);
@@ -1590,18 +1603,18 @@ static u32 init_chip(struct net_device *dev)
chipid = wilc_get_chipid(wilc, true);

if ((chipid & 0xfff) != 0xa0) {
- ret = g_wlan.hif_func.hif_read_reg(0x1118, &reg);
+ ret = g_wlan.hif_func.hif_read_reg(wilc, 0x1118, &reg);
if (!ret) {
wilc_debug(N_ERR, "[wilc start]: fail read reg 0x1118 ...\n");
return ret;
}
reg |= BIT(0);
- ret = g_wlan.hif_func.hif_write_reg(0x1118, reg);
+ ret = g_wlan.hif_func.hif_write_reg(wilc, 0x1118, reg);
if (!ret) {
wilc_debug(N_ERR, "[wilc start]: fail write reg 0x1118 ...\n");
return ret;
}
- ret = g_wlan.hif_func.hif_write_reg(0xc0000, 0x71);
+ ret = g_wlan.hif_func.hif_write_reg(wilc, 0xc0000, 0x71);
if (!ret) {
wilc_debug(N_ERR, "[wilc start]: fail write reg 0xc0000 ...\n");
return ret;
@@ -1620,8 +1633,8 @@ u32 wilc_get_chipid(struct wilc *wilc, u8 update)
u32 rfrevid;

if (chipid == 0 || update != 0) {
- g_wlan.hif_func.hif_read_reg(0x1000, &tempchipid);
- g_wlan.hif_func.hif_read_reg(0x13f4, &rfrevid);
+ g_wlan.hif_func.hif_read_reg(wilc, 0x1000, &tempchipid);
+ g_wlan.hif_func.hif_read_reg(wilc, 0x13f4, &rfrevid);
if (!ISWILC1000(tempchipid)) {
chipid = 0;
goto _fail_;
@@ -1723,7 +1736,8 @@ u16 wilc_set_machw_change_vir_if(struct net_device *dev, bool value)
wilc = nic->wilc;

mutex_lock(&wilc->hif_cs);
- ret = (&g_wlan)->hif_func.hif_read_reg(WILC_CHANGING_VIR_IF, &reg);
+ ret = (&g_wlan)->hif_func.hif_read_reg(wilc, WILC_CHANGING_VIR_IF,
+ &reg);
if (!ret)
PRINT_ER("Error while Reading reg WILC_CHANGING_VIR_IF\n");

@@ -1732,7 +1746,8 @@ u16 wilc_set_machw_change_vir_if(struct net_device *dev, bool value)
else
reg &= ~BIT(31);

- ret = (&g_wlan)->hif_func.hif_write_reg(WILC_CHANGING_VIR_IF, reg);
+ ret = (&g_wlan)->hif_func.hif_write_reg(wilc, WILC_CHANGING_VIR_IF,
+ reg);

if (!ret)
PRINT_ER("Error while writing reg WILC_CHANGING_VIR_IF\n");
diff --git a/drivers/staging/wilc1000/wilc_wlan.h b/drivers/staging/wilc1000/wilc_wlan.h
index 334abafe..c3f13aa 100644
--- a/drivers/staging/wilc1000/wilc_wlan.h
+++ b/drivers/staging/wilc1000/wilc_wlan.h
@@ -238,19 +238,19 @@ struct rxq_entry_t {
struct wilc;
struct wilc_hif_func {
int (*hif_init)(struct wilc *, wilc_debug_func);
- int (*hif_deinit)(void *);
- int (*hif_read_reg)(u32, u32 *);
- int (*hif_write_reg)(u32, u32);
- int (*hif_block_rx)(u32, u8 *, u32);
- int (*hif_block_tx)(u32, u8 *, u32);
- int (*hif_sync)(void);
- int (*hif_clear_int)(void);
- int (*hif_read_int)(u32 *);
- int (*hif_clear_int_ext)(u32);
- int (*hif_read_size)(u32 *);
- int (*hif_block_tx_ext)(u32, u8 *, u32);
- int (*hif_block_rx_ext)(u32, u8 *, u32);
- int (*hif_sync_ext)(int);
+ int (*hif_deinit)(struct wilc *);
+ int (*hif_read_reg)(struct wilc *, u32, u32 *);
+ int (*hif_write_reg)(struct wilc *, u32, u32);
+ int (*hif_block_rx)(struct wilc *, u32, u8 *, u32);
+ int (*hif_block_tx)(struct wilc *, u32, u8 *, u32);
+ int (*hif_sync)(struct wilc *);
+ int (*hif_clear_int)(struct wilc *);
+ int (*hif_read_int)(struct wilc *, u32 *);
+ int (*hif_clear_int_ext)(struct wilc *, u32);
+ int (*hif_read_size)(struct wilc *, u32 *);
+ int (*hif_block_tx_ext)(struct wilc *, u32, u8 *, u32);
+ int (*hif_block_rx_ext)(struct wilc *, u32, u8 *, u32);
+ int (*hif_sync_ext)(struct wilc *, int);
int (*enable_interrupt)(struct wilc *nic);
void (*disable_interrupt)(struct wilc *nic);
};
--
1.9.1


2015-11-18 06:09:45

by Glen Lee

[permalink] [raw]
Subject: [PATCH 14/16] staging: wilc1000: wilc_wlan_cfg_get: pass struct wilc

This patch passes the struct wilc to the function and use it instead of
global variable wilc_dev.

Signed-off-by: Glen Lee <[email protected]>
---
drivers/staging/wilc1000/coreconfigurator.c | 2 +-
drivers/staging/wilc1000/linux_wlan.c | 2 +-
drivers/staging/wilc1000/wilc_wlan.c | 4 ++--
drivers/staging/wilc1000/wilc_wlan.h | 3 ++-
4 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c
index 6278aec..0cd2acc 100644
--- a/drivers/staging/wilc1000/coreconfigurator.c
+++ b/drivers/staging/wilc1000/coreconfigurator.c
@@ -597,7 +597,7 @@ s32 wilc_send_config_pkt(struct wilc *wilc, u8 mode, struct wid *wids,
for (counter = 0; counter < count; counter++) {
PRINT_INFO(CORECONFIG_DBG, "Sending CFG packet [%d][%d]\n", !counter,
(counter == count - 1));
- if (!wilc_wlan_cfg_get(!counter,
+ if (!wilc_wlan_cfg_get(wilc, !counter,
wids[counter].id,
(counter == count - 1),
drv)) {
diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c
index 792cc0b..1457e75 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -939,7 +939,7 @@ int wilc1000_wlan_init(struct net_device *dev, perInterface_wlan_t *p_nic)
goto _fail_irq_enable_;
}

- if (wilc_wlan_cfg_get(1, WID_FIRMWARE_VERSION, 1, 0)) {
+ if (wilc_wlan_cfg_get(wl, 1, WID_FIRMWARE_VERSION, 1, 0)) {
int size;
char Firmware_ver[20];

diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c
index 03c707b..a271851 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -1540,10 +1540,10 @@ int wilc_wlan_cfg_set(struct wilc *wilc, int start, u32 wid, u8 *buffer,
return ret_size;
}

-int wilc_wlan_cfg_get(int start, u32 wid, int commit, u32 drv_handler)
+int wilc_wlan_cfg_get(struct wilc *wilc, int start, u32 wid, int commit,
+ u32 drv_handler)
{
wilc_wlan_dev_t *p = &g_wlan;
- struct wilc *wilc = wilc_dev;
u32 offset;
int ret_size;

diff --git a/drivers/staging/wilc1000/wilc_wlan.h b/drivers/staging/wilc1000/wilc_wlan.h
index e1a8c73..2ac63a3 100644
--- a/drivers/staging/wilc1000/wilc_wlan.h
+++ b/drivers/staging/wilc1000/wilc_wlan.h
@@ -291,7 +291,8 @@ void wilc_handle_isr(struct wilc *wilc);
void wilc_wlan_cleanup(struct net_device *dev);
int wilc_wlan_cfg_set(struct wilc *wilc, int start, u32 wid, u8 *buffer,
u32 buffer_size, int commit, u32 drv_handler);
-int wilc_wlan_cfg_get(int start, u32 wid, int commit, u32 drv_handler);
+int wilc_wlan_cfg_get(struct wilc *wilc, int start, u32 wid, int commit,
+ u32 drv_handler);
int wilc_wlan_cfg_get_val(u32 wid, u8 *buffer, u32 buffer_size);
int wilc_wlan_txq_add_mgmt_pkt(struct net_device *dev, void *priv, u8 *buffer,
u32 buffer_size, wilc_tx_complete_func_t func);
--
1.9.1


2015-11-18 06:08:37

by Glen Lee

[permalink] [raw]
Subject: [PATCH 03/16] staging: wilc1000: remove paltform define PLAT_WMS8304

This patch removes PLAT_WMS8304 and it's related codes as well. We will not
use this way of supporting other platform. This will be supported if necessary
by device tree later.

Signed-off-by: Glen Lee <[email protected]>
---
drivers/staging/wilc1000/linux_wlan_spi.c | 161 ------------------------------
1 file changed, 161 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan_spi.c b/drivers/staging/wilc1000/linux_wlan_spi.c
index 5e3bff0..bfd3cc3 100644
--- a/drivers/staging/wilc1000/linux_wlan_spi.c
+++ b/drivers/staging/wilc1000/linux_wlan_spi.c
@@ -66,88 +66,6 @@ int wilc_spi_init(void)
return 1;
}

-#if defined(PLAT_WMS8304)
-#define TXRX_PHASE_SIZE (4096)
-#endif
-
-#if defined(TXRX_PHASE_SIZE)
-
-int wilc_spi_write(u8 *b, u32 len)
-{
- struct spi_device *spi = to_spi_device(wilc_dev->dev);
- int ret;
-
- if (len > 0 && b != NULL) {
- int i = 0;
- int blk = len / TXRX_PHASE_SIZE;
- int remainder = len % TXRX_PHASE_SIZE;
-
- char *r_buffer = kzalloc(TXRX_PHASE_SIZE, GFP_KERNEL);
- if (!r_buffer)
- return -ENOMEM;
-
- if (blk) {
- while (i < blk) {
- struct spi_message msg;
- struct spi_transfer tr = {
- .tx_buf = b + (i * TXRX_PHASE_SIZE),
- .len = TXRX_PHASE_SIZE,
- .bits_per_word = 8,
- .delay_usecs = 0,
- };
-
- tr.rx_buf = r_buffer;
-
- memset(&msg, 0, sizeof(msg));
- spi_message_init(&msg);
- msg.spi = spi;
- msg.is_dma_mapped = USE_SPI_DMA;
-
- spi_message_add_tail(&tr, &msg);
- ret = spi_sync(spi, &msg);
- if (ret < 0) {
- PRINT_ER("SPI transaction failed\n");
- }
- i++;
-
- }
- }
- if (remainder) {
- struct spi_message msg;
- struct spi_transfer tr = {
- .tx_buf = b + (blk * TXRX_PHASE_SIZE),
- .len = remainder,
- .bits_per_word = 8,
- .delay_usecs = 0,
- };
- tr.rx_buf = r_buffer;
-
- memset(&msg, 0, sizeof(msg));
- spi_message_init(&msg);
- msg.spi = spi;
- msg.is_dma_mapped = USE_SPI_DMA; /* rachel */
-
- spi_message_add_tail(&tr, &msg);
- ret = spi_sync(spi, &msg);
- if (ret < 0) {
- PRINT_ER("SPI transaction failed\n");
- }
- }
- kfree(r_buffer);
- } else {
- PRINT_ER("can't write data with the following length: %d\n", len);
- PRINT_ER("FAILED due to NULL buffer or ZERO length check the following length: %d\n", len);
- ret = -1;
- }
-
- /* change return value to match WILC interface */
- (ret < 0) ? (ret = 0) : (ret = 1);
-
- return ret;
-
-}
-
-#else
int wilc_spi_write(u8 *b, u32 len)
{
struct spi_device *spi = to_spi_device(wilc_dev->dev);
@@ -194,83 +112,6 @@ int wilc_spi_write(u8 *b, u32 len)
return ret;
}

-#endif
-
-#if defined(TXRX_PHASE_SIZE)
-
-int wilc_spi_read(u8 *rb, u32 rlen)
-{
- struct spi_device *spi = to_spi_device(wilc_dev->dev);
- int ret;
-
- if (rlen > 0) {
- int i = 0;
-
- int blk = rlen / TXRX_PHASE_SIZE;
- int remainder = rlen % TXRX_PHASE_SIZE;
-
- char *t_buffer = kzalloc(TXRX_PHASE_SIZE, GFP_KERNEL);
- if (!t_buffer)
- return -ENOMEM;
-
- if (blk) {
- while (i < blk) {
- struct spi_message msg;
- struct spi_transfer tr = {
- .rx_buf = rb + (i * TXRX_PHASE_SIZE),
- .len = TXRX_PHASE_SIZE,
- .bits_per_word = 8,
- .delay_usecs = 0,
- };
- tr.tx_buf = t_buffer;
-
- memset(&msg, 0, sizeof(msg));
- spi_message_init(&msg);
- msg.spi = spi;
- msg.is_dma_mapped = USE_SPI_DMA;
-
- spi_message_add_tail(&tr, &msg);
- ret = spi_sync(spi, &msg);
- if (ret < 0) {
- PRINT_ER("SPI transaction failed\n");
- }
- i++;
- }
- }
- if (remainder) {
- struct spi_message msg;
- struct spi_transfer tr = {
- .rx_buf = rb + (blk * TXRX_PHASE_SIZE),
- .len = remainder,
- .bits_per_word = 8,
- .delay_usecs = 0,
- };
- tr.tx_buf = t_buffer;
-
- memset(&msg, 0, sizeof(msg));
- spi_message_init(&msg);
- msg.spi = spi;
- msg.is_dma_mapped = USE_SPI_DMA; /* rachel */
-
- spi_message_add_tail(&tr, &msg);
- ret = spi_sync(spi, &msg);
- if (ret < 0) {
- PRINT_ER("SPI transaction failed\n");
- }
- }
-
- kfree(t_buffer);
- } else {
- PRINT_ER("can't read data with the following length: %u\n", rlen);
- ret = -1;
- }
- /* change return value to match WILC interface */
- (ret < 0) ? (ret = 0) : (ret = 1);
-
- return ret;
-}
-
-#else
int wilc_spi_read(u8 *rb, u32 rlen)
{
struct spi_device *spi = to_spi_device(wilc_dev->dev);
@@ -313,8 +154,6 @@ int wilc_spi_read(u8 *rb, u32 rlen)
return ret;
}

-#endif
-
int wilc_spi_write_read(u8 *wb, u8 *rb, u32 rlen)
{
struct spi_device *spi = to_spi_device(wilc_dev->dev);
--
1.9.1


2015-11-18 06:09:39

by Glen Lee

[permalink] [raw]
Subject: [PATCH 13/16] staging: wilc1000: wilc_wlan_cfg_set: pass struct wilc

This patch pass struct wilc to the function and use it instead of global
variable wilc_dev.

Signed-off-by: Glen Lee <[email protected]>
---
drivers/staging/wilc1000/coreconfigurator.c | 2 +-
drivers/staging/wilc1000/linux_wlan.c | 101 ++++++++++++++++------------
drivers/staging/wilc1000/wilc_wlan.c | 5 +-
drivers/staging/wilc1000/wilc_wlan.h | 4 +-
4 files changed, 63 insertions(+), 49 deletions(-)

diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c
index dc290d1..6278aec 100644
--- a/drivers/staging/wilc1000/coreconfigurator.c
+++ b/drivers/staging/wilc1000/coreconfigurator.c
@@ -616,7 +616,7 @@ s32 wilc_send_config_pkt(struct wilc *wilc, u8 mode, struct wid *wids,
} else if (mode == SET_CFG) {
for (counter = 0; counter < count; counter++) {
PRINT_D(CORECONFIG_DBG, "Sending config SET PACKET WID:%x\n", wids[counter].id);
- if (!wilc_wlan_cfg_set(!counter,
+ if (!wilc_wlan_cfg_set(wilc, !counter,
wids[counter].id,
wids[counter].val,
wids[counter].size,
diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c
index 43458e6..792cc0b 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -537,179 +537,194 @@ static int linux_wlan_init_test_config(struct net_device *dev,

*(int *)c_val = 1;

- if (!wilc_wlan_cfg_set(1, WID_SET_DRV_HANDLER, c_val, 4, 0, 0))
+ if (!wilc_wlan_cfg_set(wilc, 1, WID_SET_DRV_HANDLER, c_val, 4, 0, 0))
goto _fail_;

c_val[0] = 0;
- if (!wilc_wlan_cfg_set(0, WID_PC_TEST_MODE, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(wilc, 0, WID_PC_TEST_MODE, c_val, 1, 0, 0))
goto _fail_;

c_val[0] = INFRASTRUCTURE;
- if (!wilc_wlan_cfg_set(0, WID_BSS_TYPE, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(wilc, 0, WID_BSS_TYPE, c_val, 1, 0, 0))
goto _fail_;

c_val[0] = RATE_AUTO;
- if (!wilc_wlan_cfg_set(0, WID_CURRENT_TX_RATE, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(wilc, 0, WID_CURRENT_TX_RATE, c_val, 1, 0, 0))
goto _fail_;

c_val[0] = G_MIXED_11B_2_MODE;
- if (!wilc_wlan_cfg_set(0, WID_11G_OPERATING_MODE, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(wilc, 0, WID_11G_OPERATING_MODE, c_val, 1, 0,
+ 0))
goto _fail_;

c_val[0] = 1;
- if (!wilc_wlan_cfg_set(0, WID_CURRENT_CHANNEL, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(wilc, 0, WID_CURRENT_CHANNEL, c_val, 1, 0, 0))
goto _fail_;

c_val[0] = G_SHORT_PREAMBLE;
- if (!wilc_wlan_cfg_set(0, WID_PREAMBLE, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(wilc, 0, WID_PREAMBLE, c_val, 1, 0, 0))
goto _fail_;

c_val[0] = AUTO_PROT;
- if (!wilc_wlan_cfg_set(0, WID_11N_PROT_MECH, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(wilc, 0, WID_11N_PROT_MECH, c_val, 1, 0, 0))
goto _fail_;

c_val[0] = ACTIVE_SCAN;
- if (!wilc_wlan_cfg_set(0, WID_SCAN_TYPE, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(wilc, 0, WID_SCAN_TYPE, c_val, 1, 0, 0))
goto _fail_;

c_val[0] = SITE_SURVEY_OFF;
- if (!wilc_wlan_cfg_set(0, WID_SITE_SURVEY, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(wilc, 0, WID_SITE_SURVEY, c_val, 1, 0, 0))
goto _fail_;

*((int *)c_val) = 0xffff;
- if (!wilc_wlan_cfg_set(0, WID_RTS_THRESHOLD, c_val, 2, 0, 0))
+ if (!wilc_wlan_cfg_set(wilc, 0, WID_RTS_THRESHOLD, c_val, 2, 0, 0))
goto _fail_;

*((int *)c_val) = 2346;
- if (!wilc_wlan_cfg_set(0, WID_FRAG_THRESHOLD, c_val, 2, 0, 0))
+ if (!wilc_wlan_cfg_set(wilc, 0, WID_FRAG_THRESHOLD, c_val, 2, 0, 0))
goto _fail_;

c_val[0] = 0;
- if (!wilc_wlan_cfg_set(0, WID_BCAST_SSID, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(wilc, 0, WID_BCAST_SSID, c_val, 1, 0, 0))
goto _fail_;

c_val[0] = 1;
- if (!wilc_wlan_cfg_set(0, WID_QOS_ENABLE, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(wilc, 0, WID_QOS_ENABLE, c_val, 1, 0, 0))
goto _fail_;

c_val[0] = NO_POWERSAVE;
- if (!wilc_wlan_cfg_set(0, WID_POWER_MANAGEMENT, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(wilc, 0, WID_POWER_MANAGEMENT, c_val, 1, 0, 0))
goto _fail_;

c_val[0] = NO_SECURITY; /* NO_ENCRYPT, 0x79 */
- if (!wilc_wlan_cfg_set(0, WID_11I_MODE, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(wilc, 0, WID_11I_MODE, c_val, 1, 0, 0))
goto _fail_;

c_val[0] = OPEN_SYSTEM;
- if (!wilc_wlan_cfg_set(0, WID_AUTH_TYPE, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(wilc, 0, WID_AUTH_TYPE, c_val, 1, 0, 0))
goto _fail_;

strcpy(c_val, "123456790abcdef1234567890");
- if (!wilc_wlan_cfg_set(0, WID_WEP_KEY_VALUE, c_val, (strlen(c_val) + 1), 0, 0))
+ if (!wilc_wlan_cfg_set(wilc, 0, WID_WEP_KEY_VALUE, c_val,
+ (strlen(c_val) + 1), 0, 0))
goto _fail_;

strcpy(c_val, "12345678");
- if (!wilc_wlan_cfg_set(0, WID_11I_PSK, c_val, (strlen(c_val)), 0, 0))
+ if (!wilc_wlan_cfg_set(wilc, 0, WID_11I_PSK, c_val, (strlen(c_val)), 0,
+ 0))
goto _fail_;

strcpy(c_val, "password");
- if (!wilc_wlan_cfg_set(0, WID_1X_KEY, c_val, (strlen(c_val) + 1), 0, 0))
+ if (!wilc_wlan_cfg_set(wilc, 0, WID_1X_KEY, c_val, (strlen(c_val) + 1),
+ 0, 0))
goto _fail_;

c_val[0] = 192;
c_val[1] = 168;
c_val[2] = 1;
c_val[3] = 112;
- if (!wilc_wlan_cfg_set(0, WID_1X_SERV_ADDR, c_val, 4, 0, 0))
+ if (!wilc_wlan_cfg_set(wilc, 0, WID_1X_SERV_ADDR, c_val, 4, 0, 0))
goto _fail_;

c_val[0] = 3;
- if (!wilc_wlan_cfg_set(0, WID_LISTEN_INTERVAL, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(wilc, 0, WID_LISTEN_INTERVAL, c_val, 1, 0, 0))
goto _fail_;

c_val[0] = 3;
- if (!wilc_wlan_cfg_set(0, WID_DTIM_PERIOD, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(wilc, 0, WID_DTIM_PERIOD, c_val, 1, 0, 0))
goto _fail_;

c_val[0] = NORMAL_ACK;
- if (!wilc_wlan_cfg_set(0, WID_ACK_POLICY, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(wilc, 0, WID_ACK_POLICY, c_val, 1, 0, 0))
goto _fail_;

c_val[0] = 0;
- if (!wilc_wlan_cfg_set(0, WID_USER_CONTROL_ON_TX_POWER, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(wilc, 0, WID_USER_CONTROL_ON_TX_POWER, c_val, 1,
+ 0, 0))
goto _fail_;

c_val[0] = 48;
- if (!wilc_wlan_cfg_set(0, WID_TX_POWER_LEVEL_11A, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(wilc, 0, WID_TX_POWER_LEVEL_11A, c_val, 1, 0,
+ 0))
goto _fail_;

c_val[0] = 28;
- if (!wilc_wlan_cfg_set(0, WID_TX_POWER_LEVEL_11B, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(wilc, 0, WID_TX_POWER_LEVEL_11B, c_val, 1, 0,
+ 0))
goto _fail_;

*((int *)c_val) = 100;
- if (!wilc_wlan_cfg_set(0, WID_BEACON_INTERVAL, c_val, 2, 0, 0))
+ if (!wilc_wlan_cfg_set(wilc, 0, WID_BEACON_INTERVAL, c_val, 2, 0, 0))
goto _fail_;

c_val[0] = REKEY_DISABLE;
- if (!wilc_wlan_cfg_set(0, WID_REKEY_POLICY, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(wilc, 0, WID_REKEY_POLICY, c_val, 1, 0, 0))
goto _fail_;

*((int *)c_val) = 84600;
- if (!wilc_wlan_cfg_set(0, WID_REKEY_PERIOD, c_val, 4, 0, 0))
+ if (!wilc_wlan_cfg_set(wilc, 0, WID_REKEY_PERIOD, c_val, 4, 0, 0))
goto _fail_;

*((int *)c_val) = 500;
- if (!wilc_wlan_cfg_set(0, WID_REKEY_PACKET_COUNT, c_val, 4, 0, 0))
+ if (!wilc_wlan_cfg_set(wilc, 0, WID_REKEY_PACKET_COUNT, c_val, 4, 0,
+ 0))
goto _fail_;

c_val[0] = 1;
- if (!wilc_wlan_cfg_set(0, WID_SHORT_SLOT_ALLOWED, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(wilc, 0, WID_SHORT_SLOT_ALLOWED, c_val, 1, 0,
+ 0))
goto _fail_;

c_val[0] = G_SELF_CTS_PROT;
- if (!wilc_wlan_cfg_set(0, WID_11N_ERP_PROT_TYPE, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(wilc, 0, WID_11N_ERP_PROT_TYPE, c_val, 1, 0, 0))
goto _fail_;

c_val[0] = 1;
- if (!wilc_wlan_cfg_set(0, WID_11N_ENABLE, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(wilc, 0, WID_11N_ENABLE, c_val, 1, 0, 0))
goto _fail_;

c_val[0] = HT_MIXED_MODE;
- if (!wilc_wlan_cfg_set(0, WID_11N_OPERATING_MODE, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(wilc, 0, WID_11N_OPERATING_MODE, c_val, 1, 0,
+ 0))
goto _fail_;

c_val[0] = 1;
- if (!wilc_wlan_cfg_set(0, WID_11N_TXOP_PROT_DISABLE, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(wilc, 0, WID_11N_TXOP_PROT_DISABLE, c_val, 1, 0,
+ 0))
goto _fail_;

memcpy(c_val, mac_add, 6);

- if (!wilc_wlan_cfg_set(0, WID_MAC_ADDR, c_val, 6, 0, 0))
+ if (!wilc_wlan_cfg_set(wilc, 0, WID_MAC_ADDR, c_val, 6, 0, 0))
goto _fail_;

c_val[0] = DETECT_PROTECT_REPORT;
- if (!wilc_wlan_cfg_set(0, WID_11N_OBSS_NONHT_DETECTION, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(wilc, 0, WID_11N_OBSS_NONHT_DETECTION, c_val, 1,
+ 0, 0))
goto _fail_;

c_val[0] = RTS_CTS_NONHT_PROT;
- if (!wilc_wlan_cfg_set(0, WID_11N_HT_PROT_TYPE, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(wilc, 0, WID_11N_HT_PROT_TYPE, c_val, 1, 0, 0))
goto _fail_;

c_val[0] = 0;
- if (!wilc_wlan_cfg_set(0, WID_11N_RIFS_PROT_ENABLE, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(wilc, 0, WID_11N_RIFS_PROT_ENABLE, c_val, 1, 0,
+ 0))
goto _fail_;

c_val[0] = MIMO_MODE;
- if (!wilc_wlan_cfg_set(0, WID_11N_SMPS_MODE, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(wilc, 0, WID_11N_SMPS_MODE, c_val, 1, 0, 0))
goto _fail_;

c_val[0] = 7;
- if (!wilc_wlan_cfg_set(0, WID_11N_CURRENT_TX_MCS, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(wilc, 0, WID_11N_CURRENT_TX_MCS, c_val, 1, 0,
+ 0))
goto _fail_;

c_val[0] = 1;
- if (!wilc_wlan_cfg_set(0, WID_11N_IMMEDIATE_BA_ENABLED, c_val, 1, 1, 1))
+ if (!wilc_wlan_cfg_set(wilc, 0, WID_11N_IMMEDIATE_BA_ENABLED, c_val, 1,
+ 1, 1))
goto _fail_;

return 0;
diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c
index 9ac6ad7..03c707b 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -1499,11 +1499,10 @@ static int wilc_wlan_cfg_commit(struct wilc *wilc, int type, u32 drv_handler)
return 0;
}

-int wilc_wlan_cfg_set(int start, u32 wid, u8 *buffer, u32 buffer_size,
- int commit, u32 drv_handler)
+int wilc_wlan_cfg_set(struct wilc *wilc, int start, u32 wid, u8 *buffer,
+ u32 buffer_size, int commit, u32 drv_handler)
{
wilc_wlan_dev_t *p = &g_wlan;
- struct wilc *wilc = wilc_dev;
u32 offset;
int ret_size;

diff --git a/drivers/staging/wilc1000/wilc_wlan.h b/drivers/staging/wilc1000/wilc_wlan.h
index c3f13aa..e1a8c73 100644
--- a/drivers/staging/wilc1000/wilc_wlan.h
+++ b/drivers/staging/wilc1000/wilc_wlan.h
@@ -289,8 +289,8 @@ int wilc_wlan_txq_add_net_pkt(struct net_device *dev, void *priv, u8 *buffer,
int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count);
void wilc_handle_isr(struct wilc *wilc);
void wilc_wlan_cleanup(struct net_device *dev);
-int wilc_wlan_cfg_set(int start, u32 wid, u8 *buffer, u32 buffer_size,
- int commit, u32 drv_handler);
+int wilc_wlan_cfg_set(struct wilc *wilc, int start, u32 wid, u8 *buffer,
+ u32 buffer_size, int commit, u32 drv_handler);
int wilc_wlan_cfg_get(int start, u32 wid, int commit, u32 drv_handler);
int wilc_wlan_cfg_get_val(u32 wid, u8 *buffer, u32 buffer_size);
int wilc_wlan_txq_add_mgmt_pkt(struct net_device *dev, void *priv, u8 *buffer,
--
1.9.1


2015-11-18 06:08:25

by Glen Lee

[permalink] [raw]
Subject: [PATCH 01/16] staging: wilc1000: remove sdio speed control codes

This patch removes spi speed control related functions and variable. We cannot
get exact clock what we need in this way and it can causes some problem in host
side by setting the clock, so remove the codes.
Speed control codes in spi also will removed in next patch, so it's ok to
remove functions in linux_wlan.c and wilc_wlan.c which also not used anymore.

The Following functions and varialbe are removed.
MAX_SPEED, sdio_default_speed
wilc_bus_set_default_speed
wilc_bus_set_max_speed
linux_sdio_set_speed
linux_sdio_get_speed
wilc_sdio_set_max_speed
wilc_sdio_set_default_speed

Signed-off-by: Glen Lee <[email protected]>
---
drivers/staging/wilc1000/linux_wlan.c | 8 -----
drivers/staging/wilc1000/linux_wlan_sdio.c | 52 ------------------------------
drivers/staging/wilc1000/linux_wlan_sdio.h | 3 --
drivers/staging/wilc1000/wilc_sdio.c | 12 -------
drivers/staging/wilc1000/wilc_wlan.c | 10 ------
5 files changed, 85 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c
index 89b5aca..ab17110 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -733,12 +733,6 @@ void wilc1000_wlan_deinit(struct net_device *dev)
if (wl->initialized) {
netdev_info(dev, "Deinitializing wilc1000...\n");

-#if defined(PLAT_ALLWINNER_A20) || defined(PLAT_ALLWINNER_A23) || defined(PLAT_ALLWINNER_A31)
- PRINT_D(INIT_DBG, "skip wilc_bus_set_default_speed\n");
-#else
- wilc_bus_set_default_speed();
-#endif
-
PRINT_D(INIT_DBG, "Disabling IRQ\n");
if (!wl->dev_irq_num &&
wl->ops->disable_interrupt) {
@@ -929,8 +923,6 @@ int wilc1000_wlan_init(struct net_device *dev, perInterface_wlan_t *p_nic)
goto _fail_irq_enable_;
}

- wilc_bus_set_max_speed();
-
if (wilc_wlan_cfg_get(1, WID_FIRMWARE_VERSION, 1, 0)) {
int size;
char Firmware_ver[20];
diff --git a/drivers/staging/wilc1000/linux_wlan_sdio.c b/drivers/staging/wilc1000/linux_wlan_sdio.c
index 1f366b5..761cb3d 100644
--- a/drivers/staging/wilc1000/linux_wlan_sdio.c
+++ b/drivers/staging/wilc1000/linux_wlan_sdio.c
@@ -11,19 +11,7 @@

#define SDIO_MODALIAS "wilc1000_sdio"

-#if defined(CUSTOMER_PLATFORM)
-/* TODO : User have to stable bus clock as user's environment. */
- #ifdef MAX_BUS_SPEED
- #define MAX_SPEED MAX_BUS_SPEED
- #else
- #define MAX_SPEED 50000000
- #endif
-#else
- #define MAX_SPEED (6 * 1000000) /* Max 50M */
-#endif
-
static struct sdio_func *wilc_sdio_func;
-static unsigned int sdio_default_speed;

#define SDIO_VENDOR_ID_WILC 0x0296
#define SDIO_DEVICE_ID_WILC 0x5347
@@ -177,49 +165,9 @@ void wilc_sdio_disable_interrupt(struct wilc *dev)
PRINT_D(INIT_DBG, "wilc_sdio_disable_interrupt OUT\n");
}

-static int linux_sdio_set_speed(int speed)
-{
- struct mmc_ios ios;
- struct sdio_func *func = container_of(wilc_dev->dev, struct sdio_func, dev);
-
- sdio_claim_host(func);
-
- memcpy((void *)&ios, (void *)&func->card->host->ios, sizeof(struct mmc_ios));
- func->card->host->ios.clock = speed;
- ios.clock = speed;
- func->card->host->ops->set_ios(func->card->host, &ios);
- sdio_release_host(func);
- PRINT_INFO(INIT_DBG, "@@@@@@@@@@@@ change SDIO speed to %d @@@@@@@@@\n", speed);
-
- return 1;
-}
-
-static int linux_sdio_get_speed(void)
-{
- struct sdio_func *func = container_of(wilc_dev->dev, struct sdio_func, dev);
- return func->card->host->ios.clock;
-}
-
int wilc_sdio_init(void)
{
-
- /**
- * TODO :
- **/
-
-
- sdio_default_speed = linux_sdio_get_speed();
return 1;
}

-int wilc_sdio_set_max_speed(void)
-{
- return linux_sdio_set_speed(MAX_SPEED);
-}
-
-int wilc_sdio_set_default_speed(void)
-{
- return linux_sdio_set_speed(sdio_default_speed);
-}
-
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/wilc1000/linux_wlan_sdio.h b/drivers/staging/wilc1000/linux_wlan_sdio.h
index d7b213a..dbe911a 100644
--- a/drivers/staging/wilc1000/linux_wlan_sdio.h
+++ b/drivers/staging/wilc1000/linux_wlan_sdio.h
@@ -6,6 +6,3 @@ int wilc_sdio_cmd53(sdio_cmd53_t *cmd);

int wilc_sdio_enable_interrupt(struct wilc *);
void wilc_sdio_disable_interrupt(struct wilc *);
-int wilc_sdio_set_max_speed(void);
-int wilc_sdio_set_default_speed(void);
-
diff --git a/drivers/staging/wilc1000/wilc_sdio.c b/drivers/staging/wilc1000/wilc_sdio.c
index 2418d52..398c7f5 100644
--- a/drivers/staging/wilc1000/wilc_sdio.c
+++ b/drivers/staging/wilc1000/wilc_sdio.c
@@ -608,16 +608,6 @@ _fail_:
return 0;
}

-static void sdio_set_max_speed(void)
-{
- wilc_sdio_set_max_speed();
-}
-
-static void sdio_set_default_speed(void)
-{
- wilc_sdio_set_default_speed();
-}
-
static int sdio_read_size(u32 *size)
{

@@ -925,8 +915,6 @@ const struct wilc_hif_func wilc_hif_sdio = {
.hif_block_tx_ext = sdio_write,
.hif_block_rx_ext = sdio_read,
.hif_sync_ext = sdio_sync_ext,
- .hif_set_max_bus_speed = sdio_set_max_speed,
- .hif_set_default_bus_speed = sdio_set_default_speed,
.enable_interrupt = wilc_sdio_enable_interrupt,
.disable_interrupt = wilc_sdio_disable_interrupt,
};
diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c
index df8503f..114ea95 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -1575,16 +1575,6 @@ int wilc_wlan_cfg_get_val(u32 wid, u8 *buffer, u32 buffer_size)
return ret;
}

-void wilc_bus_set_max_speed(void)
-{
- g_wlan.hif_func.hif_set_max_bus_speed();
-}
-
-void wilc_bus_set_default_speed(void)
-{
- g_wlan.hif_func.hif_set_default_bus_speed();
-}
-
static u32 init_chip(struct net_device *dev)
{
u32 chipid;
--
1.9.1


2015-11-18 06:09:15

by Glen Lee

[permalink] [raw]
Subject: [PATCH 09/16] staging: wilc1000: wilc_spi_read: pass struct wilc

This patch adds new function parameter struct wilc and use it instead of
global variable wilc_dev, and pass wilc to the functions as well.

Signed-off-by: Glen Lee <[email protected]>
---
drivers/staging/wilc1000/linux_wlan_spi.c | 4 ++--
drivers/staging/wilc1000/linux_wlan_spi.h | 2 +-
drivers/staging/wilc1000/wilc_spi.c | 10 +++++-----
3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan_spi.c b/drivers/staging/wilc1000/linux_wlan_spi.c
index 7be750b..5066191 100644
--- a/drivers/staging/wilc1000/linux_wlan_spi.c
+++ b/drivers/staging/wilc1000/linux_wlan_spi.c
@@ -112,9 +112,9 @@ int wilc_spi_write(struct wilc *wilc, u8 *b, u32 len)
return ret;
}

-int wilc_spi_read(u8 *rb, u32 rlen)
+int wilc_spi_read(struct wilc *wilc, u8 *rb, u32 rlen)
{
- struct spi_device *spi = to_spi_device(wilc_dev->dev);
+ struct spi_device *spi = to_spi_device(wilc->dev);
int ret;

if (rlen > 0) {
diff --git a/drivers/staging/wilc1000/linux_wlan_spi.h b/drivers/staging/wilc1000/linux_wlan_spi.h
index 41d47dc..16f0b9f 100644
--- a/drivers/staging/wilc1000/linux_wlan_spi.h
+++ b/drivers/staging/wilc1000/linux_wlan_spi.h
@@ -6,6 +6,6 @@

int wilc_spi_init(void);
int wilc_spi_write(struct wilc *wilc, u8 *b, u32 len);
-int wilc_spi_read(u8 *rb, u32 rlen);
+int wilc_spi_read(struct wilc *wilc, u8 *rb, u32 rlen);
int wilc_spi_write_read(u8 *wb, u8 *rb, u32 rlen);
#endif
diff --git a/drivers/staging/wilc1000/wilc_spi.c b/drivers/staging/wilc1000/wilc_spi.c
index 0d89a282..f5db2fc 100644
--- a/drivers/staging/wilc1000/wilc_spi.c
+++ b/drivers/staging/wilc1000/wilc_spi.c
@@ -365,7 +365,7 @@ static int spi_cmd_complete(struct wilc *wilc, u8 cmd, u32 adr, u8 *b, u32 sz,
/**
* Read bytes
**/
- if (!wilc_spi_read(&b[ix], nbytes)) {
+ if (!wilc_spi_read(wilc, &b[ix], nbytes)) {
PRINT_ER("[wilc spi]: Failed data block read, bus error...\n");
result = N_FAIL;
goto _error_;
@@ -375,7 +375,7 @@ static int spi_cmd_complete(struct wilc *wilc, u8 cmd, u32 adr, u8 *b, u32 sz,
* Read Crc
**/
if (!g_spi.crc_off) {
- if (!wilc_spi_read(crc, 2)) {
+ if (!wilc_spi_read(wilc, crc, 2)) {
PRINT_ER("[wilc spi]: Failed data block crc read, bus error...\n");
result = N_FAIL;
goto _error_;
@@ -406,7 +406,7 @@ static int spi_cmd_complete(struct wilc *wilc, u8 cmd, u32 adr, u8 *b, u32 sz,
**/
retry = 10;
do {
- if (!wilc_spi_read(&rsp, 1)) {
+ if (!wilc_spi_read(wilc, &rsp, 1)) {
PRINT_ER("[wilc spi]: Failed data response read, bus error...\n");
result = N_FAIL;
break;
@@ -422,7 +422,7 @@ static int spi_cmd_complete(struct wilc *wilc, u8 cmd, u32 adr, u8 *b, u32 sz,
/**
* Read bytes
**/
- if (!wilc_spi_read(&b[ix], nbytes)) {
+ if (!wilc_spi_read(wilc, &b[ix], nbytes)) {
PRINT_ER("[wilc spi]: Failed data block read, bus error...\n");
result = N_FAIL;
break;
@@ -432,7 +432,7 @@ static int spi_cmd_complete(struct wilc *wilc, u8 cmd, u32 adr, u8 *b, u32 sz,
* Read Crc
**/
if (!g_spi.crc_off) {
- if (!wilc_spi_read(crc, 2)) {
+ if (!wilc_spi_read(wilc, crc, 2)) {
PRINT_ER("[wilc spi]: Failed data block crc read, bus error...\n");
result = N_FAIL;
break;
--
1.9.1


2015-11-18 06:09:21

by Glen Lee

[permalink] [raw]
Subject: [PATCH 10/16] staging: wilc1000: wilc_spi_write_read: pass struct wilc

This patch adds new function parameter struct wilc and use it instead of
global variable wilc_dev, and pass wilc to the function as well.

Signed-off-by: Glen Lee <[email protected]>
---
drivers/staging/wilc1000/linux_wlan_spi.c | 4 ++--
drivers/staging/wilc1000/linux_wlan_spi.h | 2 +-
drivers/staging/wilc1000/wilc_spi.c | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan_spi.c b/drivers/staging/wilc1000/linux_wlan_spi.c
index 5066191..f3ffc9e 100644
--- a/drivers/staging/wilc1000/linux_wlan_spi.c
+++ b/drivers/staging/wilc1000/linux_wlan_spi.c
@@ -154,9 +154,9 @@ int wilc_spi_read(struct wilc *wilc, u8 *rb, u32 rlen)
return ret;
}

-int wilc_spi_write_read(u8 *wb, u8 *rb, u32 rlen)
+int wilc_spi_write_read(struct wilc *wilc, u8 *wb, u8 *rb, u32 rlen)
{
- struct spi_device *spi = to_spi_device(wilc_dev->dev);
+ struct spi_device *spi = to_spi_device(wilc->dev);
int ret;

if (rlen > 0) {
diff --git a/drivers/staging/wilc1000/linux_wlan_spi.h b/drivers/staging/wilc1000/linux_wlan_spi.h
index 16f0b9f..00733ab 100644
--- a/drivers/staging/wilc1000/linux_wlan_spi.h
+++ b/drivers/staging/wilc1000/linux_wlan_spi.h
@@ -7,5 +7,5 @@
int wilc_spi_init(void);
int wilc_spi_write(struct wilc *wilc, u8 *b, u32 len);
int wilc_spi_read(struct wilc *wilc, u8 *rb, u32 rlen);
-int wilc_spi_write_read(u8 *wb, u8 *rb, u32 rlen);
+int wilc_spi_write_read(struct wilc *wilc, u8 *wb, u8 *rb, u32 rlen);
#endif
diff --git a/drivers/staging/wilc1000/wilc_spi.c b/drivers/staging/wilc1000/wilc_spi.c
index f5db2fc..b6a6ce2 100644
--- a/drivers/staging/wilc1000/wilc_spi.c
+++ b/drivers/staging/wilc1000/wilc_spi.c
@@ -250,7 +250,7 @@ static int spi_cmd_complete(struct wilc *wilc, u8 cmd, u32 adr, u8 *b, u32 sz,
}
rix = len;

- if (!wilc_spi_write_read(wb, rb, len2)) {
+ if (!wilc_spi_write_read(wilc, wb, rb, len2)) {
PRINT_ER("[wilc spi]: Failed cmd write, bus error...\n");
result = N_FAIL;
return result;
--
1.9.1


2015-11-18 06:09:03

by Glen Lee

[permalink] [raw]
Subject: [PATCH 07/16] staging: wilc1000: wilc_sdio_cmd53: pass struct wilc

This patch adds new function parameter struct wilc and use it instead of
global variable wilc_dev and pass wilc to the function as well.

Signed-off-by: Glen Lee <[email protected]>
---
drivers/staging/wilc1000/linux_wlan_sdio.c | 4 ++--
drivers/staging/wilc1000/linux_wlan_sdio.h | 2 +-
drivers/staging/wilc1000/wilc_sdio.c | 12 ++++++------
3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan_sdio.c b/drivers/staging/wilc1000/linux_wlan_sdio.c
index 6a38876..92633aa 100644
--- a/drivers/staging/wilc1000/linux_wlan_sdio.c
+++ b/drivers/staging/wilc1000/linux_wlan_sdio.c
@@ -61,9 +61,9 @@ int wilc_sdio_cmd52(struct wilc *wilc, sdio_cmd52_t *cmd)
}


-int wilc_sdio_cmd53(sdio_cmd53_t *cmd)
+int wilc_sdio_cmd53(struct wilc *wilc, sdio_cmd53_t *cmd)
{
- struct sdio_func *func = container_of(wilc_dev->dev, struct sdio_func, dev);
+ struct sdio_func *func = container_of(wilc->dev, struct sdio_func, dev);
int size, ret;

sdio_claim_host(func);
diff --git a/drivers/staging/wilc1000/linux_wlan_sdio.h b/drivers/staging/wilc1000/linux_wlan_sdio.h
index d966bb9..8d276c6 100644
--- a/drivers/staging/wilc1000/linux_wlan_sdio.h
+++ b/drivers/staging/wilc1000/linux_wlan_sdio.h
@@ -2,7 +2,7 @@

int wilc_sdio_init(void);
int wilc_sdio_cmd52(struct wilc *wilc, sdio_cmd52_t *cmd);
-int wilc_sdio_cmd53(sdio_cmd53_t *cmd);
+int wilc_sdio_cmd53(struct wilc *wilc, sdio_cmd53_t *cmd);

int wilc_sdio_enable_interrupt(struct wilc *);
void wilc_sdio_disable_interrupt(struct wilc *);
diff --git a/drivers/staging/wilc1000/wilc_sdio.c b/drivers/staging/wilc1000/wilc_sdio.c
index 4d0ee69..a68a7a4 100644
--- a/drivers/staging/wilc1000/wilc_sdio.c
+++ b/drivers/staging/wilc1000/wilc_sdio.c
@@ -197,7 +197,7 @@ static int sdio_write_reg(struct wilc *wilc, u32 addr, u32 data)
cmd.buffer = (u8 *)&data;
cmd.block_size = g_sdio.block_size; /* johnny : prevent it from setting unexpected value */

- if (!wilc_sdio_cmd53(&cmd)) {
+ if (!wilc_sdio_cmd53(wilc, &cmd)) {
g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd53, write reg (%08x)...\n", addr);
goto _fail_;
}
@@ -260,7 +260,7 @@ static int sdio_write(struct wilc *wilc, u32 addr, u8 *buf, u32 size)
if (!sdio_set_func0_csa_address(wilc, addr))
goto _fail_;
}
- if (!wilc_sdio_cmd53(&cmd)) {
+ if (!wilc_sdio_cmd53(wilc, &cmd)) {
g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd53 [%x], block send...\n", addr);
goto _fail_;
}
@@ -281,7 +281,7 @@ static int sdio_write(struct wilc *wilc, u32 addr, u8 *buf, u32 size)
if (!sdio_set_func0_csa_address(wilc, addr))
goto _fail_;
}
- if (!wilc_sdio_cmd53(&cmd)) {
+ if (!wilc_sdio_cmd53(wilc, &cmd)) {
g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd53 [%x], bytes send...\n", addr);
goto _fail_;
}
@@ -324,7 +324,7 @@ static int sdio_read_reg(struct wilc *wilc, u32 addr, u32 *data)

cmd.block_size = g_sdio.block_size; /* johnny : prevent it from setting unexpected value */

- if (!wilc_sdio_cmd53(&cmd)) {
+ if (!wilc_sdio_cmd53(wilc, &cmd)) {
g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd53, read reg (%08x)...\n", addr);
goto _fail_;
}
@@ -391,7 +391,7 @@ static int sdio_read(struct wilc *wilc, u32 addr, u8 *buf, u32 size)
if (!sdio_set_func0_csa_address(wilc, addr))
goto _fail_;
}
- if (!wilc_sdio_cmd53(&cmd)) {
+ if (!wilc_sdio_cmd53(wilc, &cmd)) {
g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd53 [%x], block read...\n", addr);
goto _fail_;
}
@@ -412,7 +412,7 @@ static int sdio_read(struct wilc *wilc, u32 addr, u8 *buf, u32 size)
if (!sdio_set_func0_csa_address(wilc, addr))
goto _fail_;
}
- if (!wilc_sdio_cmd53(&cmd)) {
+ if (!wilc_sdio_cmd53(wilc, &cmd)) {
g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd53 [%x], bytes read...\n", addr);
goto _fail_;
}
--
1.9.1


2015-11-18 06:09:57

by Glen Lee

[permalink] [raw]
Subject: [PATCH 16/16] staging: wilc1000: use wilc instead of wilc_dev and remove wilc_dev

This patch changes wilc_dev with wilc in the function call
wilc_wlan_get_num_conn_ifcs, and remove wilc_dev and it's related codes.

Signed-off-by: Glen Lee <[email protected]>
---
drivers/staging/wilc1000/host_interface.c | 2 +-
drivers/staging/wilc1000/linux_wlan.c | 5 +----
drivers/staging/wilc1000/wilc_wfi_netdevice.h | 1 -
3 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c
index 43b77b7..e366366 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -2919,7 +2919,7 @@ static int hostIFthread(void *pvArg)
del_timer(&hif_drv->scan_timer);
PRINT_D(HOSTINF_DBG, "scan completed successfully\n");

- if (!wilc_wlan_get_num_conn_ifcs(wilc_dev))
+ if (!wilc_wlan_get_num_conn_ifcs(wilc))
wilc_chip_sleep_manually(wilc);

Handle_ScanDone(msg.drv, SCAN_EVENT_DONE);
diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c
index cd471ab..73954f4 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -43,8 +43,6 @@ static int mac_init_fn(struct net_device *ndev);
static struct net_device_stats *mac_stats(struct net_device *dev);
static int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd);
static void wilc_set_multicast_list(struct net_device *dev);
-struct wilc *wilc_dev;
-EXPORT_SYMBOL_GPL(wilc_dev);

bool wilc_enable_ps = true;

@@ -1432,7 +1430,7 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type,

sema_init(&close_exit_sync, 0);

- wl = kzalloc(sizeof(*wilc_dev), GFP_KERNEL);
+ wl = kzalloc(sizeof(*wl), GFP_KERNEL);
if (!wl)
return -ENOMEM;

@@ -1495,7 +1493,6 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type,
nic->iftype = STATION_MODE;
nic->mac_opened = 0;
}
- wilc_dev = *wilc = wl;

return 0;
}
diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
index 4c8de8b..212d607 100644
--- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h
+++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
@@ -205,7 +205,6 @@ struct WILC_WFI_mon_priv {

int wilc1000_wlan_init(struct net_device *dev, perInterface_wlan_t *p_nic);

-extern struct wilc *wilc_dev;
extern struct net_device *WILC_WFI_devs[];
void wilc_frmw_to_linux(struct wilc *wilc, u8 *buff, u32 size, u32 pkt_offset);
void wilc_mac_indicate(struct wilc *wilc, int flag);
--
1.9.1


2015-11-18 06:08:44

by Glen Lee

[permalink] [raw]
Subject: [PATCH 04/16] staging: wilc1000: pass struct wilc to the functions which use hif_func

This patch passes struct wilc to the functions which use hif_func inside.
The function pointers of wilc_hif_func will pass wilc also in the later
patch. Pass wilc to the functions if necessary.

Flollowings are modified functions.
chip_wakeup
wilc_chip_sleep_manually
chip_allow_sleep
wilc_get_chipid
wilc_unknown_isr_ext
wilc_pllupdate_isr_ext
wilc_sleeptimer_isr_ext

Signed-off-by: Glen Lee <[email protected]>
---
drivers/staging/wilc1000/host_interface.c | 3 +-
drivers/staging/wilc1000/linux_wlan.c | 5 +--
drivers/staging/wilc1000/wilc_wlan.c | 56 +++++++++++++++----------------
drivers/staging/wilc1000/wilc_wlan.h | 2 +-
drivers/staging/wilc1000/wilc_wlan_if.h | 3 +-
5 files changed, 36 insertions(+), 33 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c
index 640cb6b..2531d20 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -2834,6 +2834,7 @@ static int hostIFthread(void *pvArg)
u32 u32Ret;
struct host_if_msg msg;
struct host_if_drv *hif_drv;
+ struct wilc *wilc = (struct wilc*)pvArg;

memset(&msg, 0, sizeof(struct host_if_msg));

@@ -2906,7 +2907,7 @@ static int hostIFthread(void *pvArg)
PRINT_D(HOSTINF_DBG, "scan completed successfully\n");

if (!wilc_wlan_get_num_conn_ifcs(wilc_dev))
- wilc_chip_sleep_manually();
+ wilc_chip_sleep_manually(wilc);

Handle_ScanDone(msg.drv, SCAN_EVENT_DONE);

diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c
index ab17110..43458e6 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -514,7 +514,8 @@ static int wilc1000_firmware_download(struct net_device *dev)
return 0;
}

-static int linux_wlan_init_test_config(struct net_device *dev, struct wilc *p_nic)
+static int linux_wlan_init_test_config(struct net_device *dev,
+ struct wilc *wilc)
{
unsigned char c_val[64];
unsigned char mac_add[] = {0x00, 0x80, 0xC2, 0x5E, 0xa2, 0xff};
@@ -532,7 +533,7 @@ static int linux_wlan_init_test_config(struct net_device *dev, struct wilc *p_ni
PRINT_D(INIT_DBG, "MAC address is : %02x-%02x-%02x-%02x-%02x-%02x\n",
mac_add[0], mac_add[1], mac_add[2],
mac_add[3], mac_add[4], mac_add[5]);
- wilc_get_chipid(0);
+ wilc_get_chipid(wilc, 0);

*(int *)c_val = 1;

diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c
index 114ea95..e30a34d 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -35,9 +35,9 @@ typedef struct {
static wilc_wlan_dev_t g_wlan;

#ifdef WILC_OPTIMIZE_SLEEP_INT
-static inline void chip_allow_sleep(void);
+static inline void chip_allow_sleep(struct wilc *wilc);
#endif
-static inline void chip_wakeup(void);
+static inline void chip_wakeup(struct wilc *wilc);
static u32 dbgflag = N_INIT | N_ERR | N_INTR | N_TXQ | N_RXQ;

/* FIXME: replace with dev_debug() */
@@ -65,7 +65,7 @@ static inline void acquire_bus(struct wilc *wilc, BUS_ACQUIRE_T acquire)
#endif
{
if (acquire == ACQUIRE_AND_WAKEUP)
- chip_wakeup();
+ chip_wakeup(wilc);
}
}

@@ -73,7 +73,7 @@ static inline void release_bus(struct wilc *wilc, BUS_RELEASE_T release)
{
#ifdef WILC_OPTIMIZE_SLEEP_INT
if (release == RELEASE_ALLOW_SLEEP)
- chip_allow_sleep();
+ chip_allow_sleep(wilc);
#endif
mutex_unlock(&wilc->hif_cs);
}
@@ -562,7 +562,7 @@ static struct rxq_entry_t *wilc_wlan_rxq_remove(struct wilc *wilc)

#ifdef WILC_OPTIMIZE_SLEEP_INT

-static inline void chip_allow_sleep(void)
+static inline void chip_allow_sleep(struct wilc *wilc)
{
u32 reg = 0;

@@ -571,7 +571,7 @@ static inline void chip_allow_sleep(void)
g_wlan.hif_func.hif_write_reg(0xf0, reg & ~BIT(0));
}

-static inline void chip_wakeup(void)
+static inline void chip_wakeup(struct wilc *wilc)
{
u32 reg, clk_status_reg, trials = 0;
u32 sleep_time;
@@ -584,12 +584,12 @@ static inline void chip_wakeup(void)

do {
usleep_range(2 * 1000, 2 * 1000);
- if ((wilc_get_chipid(true) == 0))
+ if ((wilc_get_chipid(wilc, true) == 0))
wilc_debug(N_ERR, "Couldn't read chip id. Wake up failed\n");

- } while ((wilc_get_chipid(true) == 0) && ((++trials % 3) == 0));
+ } while ((wilc_get_chipid(wilc, true) == 0) && ((++trials % 3) == 0));

- } while (wilc_get_chipid(true) == 0);
+ } while (wilc_get_chipid(wilc, true) == 0);
} else if ((g_wlan.io_type & 0x1) == HIF_SDIO) {
g_wlan.hif_func.hif_read_reg(0xf0, &reg);
do {
@@ -616,7 +616,7 @@ static inline void chip_wakeup(void)
reg &= ~BIT(0);
g_wlan.hif_func.hif_write_reg(0x1C0C, reg);

- if (wilc_get_chipid(false) >= 0x1002b0) {
+ if (wilc_get_chipid(wilc, false) >= 0x1002b0) {
u32 val32;

g_wlan.hif_func.hif_read_reg(0x1e1c, &val32);
@@ -631,7 +631,7 @@ static inline void chip_wakeup(void)
chip_ps_state = CHIP_WAKEDUP;
}
#else
-static inline void chip_wakeup(void)
+static inline void chip_wakeup(struct wilc *wilc)
{
u32 reg, trials = 0;

@@ -651,19 +651,19 @@ static inline void chip_wakeup(void)
do {
mdelay(3);

- if ((wilc_get_chipid(true) == 0))
+ if ((wilc_get_chipid(wilc, true) == 0))
wilc_debug(N_ERR, "Couldn't read chip id. Wake up failed\n");

- } while ((wilc_get_chipid(true) == 0) && ((++trials % 3) == 0));
+ } while ((wilc_get_chipid(wilc, true) == 0) && ((++trials % 3) == 0));

- } while (wilc_get_chipid(true) == 0);
+ } while (wilc_get_chipid(wilc, true) == 0);

if (chip_ps_state == CHIP_SLEEPING_MANUAL) {
g_wlan.hif_func.hif_read_reg(0x1C0C, &reg);
reg &= ~BIT(0);
g_wlan.hif_func.hif_write_reg(0x1C0C, reg);

- if (wilc_get_chipid(false) >= 0x1002b0) {
+ if (wilc_get_chipid(wilc, false) >= 0x1002b0) {
u32 val32;

g_wlan.hif_func.hif_read_reg(0x1e1c, &val32);
@@ -678,19 +678,19 @@ static inline void chip_wakeup(void)
chip_ps_state = CHIP_WAKEDUP;
}
#endif
-void wilc_chip_sleep_manually(void)
+void wilc_chip_sleep_manually(struct wilc *wilc)
{
if (chip_ps_state != CHIP_WAKEDUP)
return;
- acquire_bus(wilc_dev, ACQUIRE_ONLY);
+ acquire_bus(wilc, ACQUIRE_ONLY);

#ifdef WILC_OPTIMIZE_SLEEP_INT
- chip_allow_sleep();
+ chip_allow_sleep(wilc);
#endif
g_wlan.hif_func.hif_write_reg(0x10a8, 1);

chip_ps_state = CHIP_SLEEPING_MANUAL;
- release_bus(wilc_dev, RELEASE_ONLY);
+ release_bus(wilc, RELEASE_ONLY);
}

int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count)
@@ -1056,12 +1056,12 @@ static void wilc_wlan_handle_rxq(struct wilc *wilc)
PRINT_D(RX_DBG, "THREAD: Exiting RX thread\n");
}

-static void wilc_unknown_isr_ext(void)
+static void wilc_unknown_isr_ext(struct wilc *wilc)
{
g_wlan.hif_func.hif_clear_int_ext(0);
}

-static void wilc_pllupdate_isr_ext(u32 int_stats)
+static void wilc_pllupdate_isr_ext(struct wilc *wilc, u32 int_stats)
{
int trials = 10;

@@ -1072,13 +1072,13 @@ static void wilc_pllupdate_isr_ext(u32 int_stats)
else
mdelay(WILC_PLL_TO_SPI);

- while (!(ISWILC1000(wilc_get_chipid(true)) && --trials)) {
+ while (!(ISWILC1000(wilc_get_chipid(wilc, true)) && --trials)) {
PRINT_D(TX_DBG, "PLL update retrying\n");
mdelay(1);
}
}

-static void wilc_sleeptimer_isr_ext(u32 int_stats1)
+static void wilc_sleeptimer_isr_ext(struct wilc *wilc, u32 int_stats1)
{
g_wlan.hif_func.hif_clear_int_ext(SLEEP_INT_CLR);
#ifndef WILC_OPTIMIZE_SLEEP_INT
@@ -1165,7 +1165,7 @@ void wilc_handle_isr(struct wilc *wilc)
g_wlan.hif_func.hif_read_int(&int_status);

if (int_status & PLL_INT_EXT)
- wilc_pllupdate_isr_ext(int_status);
+ wilc_pllupdate_isr_ext(wilc, int_status);

if (int_status & DATA_INT_EXT) {
wilc_wlan_handle_isr_ext(wilc, int_status);
@@ -1174,10 +1174,10 @@ void wilc_handle_isr(struct wilc *wilc)
#endif
}
if (int_status & SLEEP_INT_EXT)
- wilc_sleeptimer_isr_ext(int_status);
+ wilc_sleeptimer_isr_ext(wilc, int_status);

if (!(int_status & (ALL_INT_EXT))) {
- wilc_unknown_isr_ext();
+ wilc_unknown_isr_ext(wilc);
}
release_bus(wilc, RELEASE_ALLOW_SLEEP);
}
@@ -1587,7 +1587,7 @@ static u32 init_chip(struct net_device *dev)

acquire_bus(wilc, ACQUIRE_ONLY);

- chipid = wilc_get_chipid(true);
+ chipid = wilc_get_chipid(wilc, true);

if ((chipid & 0xfff) != 0xa0) {
ret = g_wlan.hif_func.hif_read_reg(0x1118, &reg);
@@ -1613,7 +1613,7 @@ static u32 init_chip(struct net_device *dev)
return ret;
}

-u32 wilc_get_chipid(u8 update)
+u32 wilc_get_chipid(struct wilc *wilc, u8 update)
{
static u32 chipid;
u32 tempchipid = 0;
diff --git a/drivers/staging/wilc1000/wilc_wlan.h b/drivers/staging/wilc1000/wilc_wlan.h
index ee13771e..334abafe 100644
--- a/drivers/staging/wilc1000/wilc_wlan.h
+++ b/drivers/staging/wilc1000/wilc_wlan.h
@@ -295,7 +295,7 @@ int wilc_wlan_cfg_get(int start, u32 wid, int commit, u32 drv_handler);
int wilc_wlan_cfg_get_val(u32 wid, u8 *buffer, u32 buffer_size);
int wilc_wlan_txq_add_mgmt_pkt(struct net_device *dev, void *priv, u8 *buffer,
u32 buffer_size, wilc_tx_complete_func_t func);
-void wilc_chip_sleep_manually(void);
+void wilc_chip_sleep_manually(struct wilc *wilc);

void wilc_enable_tcp_ack_filter(bool value);
int wilc_wlan_get_num_conn_ifcs(struct wilc *);
diff --git a/drivers/staging/wilc1000/wilc_wlan_if.h b/drivers/staging/wilc1000/wilc_wlan_if.h
index 2f465f4..618903c 100644
--- a/drivers/staging/wilc1000/wilc_wlan_if.h
+++ b/drivers/staging/wilc1000/wilc_wlan_if.h
@@ -909,9 +909,10 @@ typedef enum {
WID_MAX = 0xFFFF
} WID_T;

+struct wilc;
int wilc_wlan_init(struct net_device *dev);
void wilc_bus_set_max_speed(void);
void wilc_bus_set_default_speed(void);
-u32 wilc_get_chipid(u8 update);
+u32 wilc_get_chipid(struct wilc *wilc, u8 update);

#endif
--
1.9.1