rtl8188eu: Fix checkpatch errors in os_dep/rtw_android.c

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
This commit is contained in:
Larry Finger 2013-08-10 22:41:06 -05:00
parent 13e0c8cab0
commit b5d91ff7e0

View file

@ -79,29 +79,32 @@ static int g_wifi_on = true;
int rtw_android_cmdstr_to_num(char *cmdstr) int rtw_android_cmdstr_to_num(char *cmdstr)
{ {
int cmd_num; int cmd_num;
for (cmd_num=0 ; cmd_num<ANDROID_WIFI_CMD_MAX; cmd_num++) for (cmd_num = 0; cmd_num < ANDROID_WIFI_CMD_MAX; cmd_num++)
if (0 == strnicmp(cmdstr , android_wifi_cmd_str[cmd_num], strlen(android_wifi_cmd_str[cmd_num])) ) if (0 == strnicmp(cmdstr , android_wifi_cmd_str[cmd_num],
strlen(android_wifi_cmd_str[cmd_num])))
break; break;
return cmd_num; return cmd_num;
} }
static int rtw_android_get_rssi(struct net_device *net, char *command, int total_len) static int rtw_android_get_rssi(struct net_device *net, char *command,
int total_len)
{ {
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(net); struct adapter *padapter = (struct adapter *)rtw_netdev_priv(net);
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
struct wlan_network *pcur_network = &pmlmepriv->cur_network; struct wlan_network *pcur_network = &pmlmepriv->cur_network;
int bytes_written = 0; int bytes_written = 0;
if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { if (check_fwstate(pmlmepriv, _FW_LINKED)) {
bytes_written += snprintf(&command[bytes_written], total_len, "%s rssi %d", bytes_written += snprintf(&command[bytes_written], total_len,
pcur_network->network.Ssid.Ssid, padapter->recvpriv.rssi); "%s rssi %d",
pcur_network->network.Ssid.Ssid,
padapter->recvpriv.rssi);
} }
return bytes_written; return bytes_written;
} }
static int rtw_android_get_link_speed(struct net_device *net, char *command, int total_len) static int rtw_android_get_link_speed(struct net_device *net, char *command,
int total_len)
{ {
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(net); struct adapter *padapter = (struct adapter *)rtw_netdev_priv(net);
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
@ -110,44 +113,47 @@ static int rtw_android_get_link_speed(struct net_device *net, char *command, int
u16 link_speed = 0; u16 link_speed = 0;
link_speed = rtw_get_cur_max_rate(padapter)/10; link_speed = rtw_get_cur_max_rate(padapter)/10;
bytes_written = snprintf(command, total_len, "LinkSpeed %d", link_speed); bytes_written = snprintf(command, total_len, "LinkSpeed %d",
link_speed);
return bytes_written; return bytes_written;
} }
static int rtw_android_get_macaddr(struct net_device *net, char *command, int total_len) static int rtw_android_get_macaddr(struct net_device *net, char *command,
int total_len)
{ {
struct adapter *adapter = (struct adapter *)rtw_netdev_priv(net); struct adapter *adapter = (struct adapter *)rtw_netdev_priv(net);
int bytes_written = 0; int bytes_written = 0;
bytes_written = snprintf(command, total_len, "Macaddr = %pM", net->dev_addr); bytes_written = snprintf(command, total_len, "Macaddr = %pM",
net->dev_addr);
return bytes_written; return bytes_written;
} }
static int rtw_android_set_country(struct net_device *net, char *command, int total_len) static int android_set_cntry(struct net_device *net, char *command,
int total_len)
{ {
struct adapter *adapter = (struct adapter *)rtw_netdev_priv(net); struct adapter *adapter = (struct adapter *)rtw_netdev_priv(net);
char *country_code = command + strlen(android_wifi_cmd_str[ANDROID_WIFI_CMD_COUNTRY]) + 1; char *country_code = command + strlen(android_wifi_cmd_str[ANDROID_WIFI_CMD_COUNTRY]) + 1;
int ret; int ret;
ret = rtw_set_country(adapter, country_code); ret = rtw_set_country(adapter, country_code);
return (ret == _SUCCESS) ? 0 : -1;
return (ret==_SUCCESS)?0:-1;
} }
static int rtw_android_get_p2p_dev_addr(struct net_device *net, char *command, int total_len) static int android_get_p2p_addr(struct net_device *net, char *command,
int total_len)
{ {
int ret; int ret;
int bytes_written = 0; int bytes_written = 0;
//We use the same address as our HW MAC address /* We use the same address as our HW MAC address */
_rtw_memcpy(command, net->dev_addr, ETH_ALEN); _rtw_memcpy(command, net->dev_addr, ETH_ALEN);
bytes_written = ETH_ALEN; bytes_written = ETH_ALEN;
return bytes_written; return bytes_written;
} }
static int rtw_android_set_block(struct net_device *net, char *command, int total_len) static int rtw_android_set_block(struct net_device *net, char *command,
int total_len)
{ {
int ret; int ret;
struct adapter *adapter = (struct adapter *)rtw_netdev_priv(net); struct adapter *adapter = (struct adapter *)rtw_netdev_priv(net);
@ -156,20 +162,18 @@ static int rtw_android_set_block(struct net_device *net, char *command, int tota
return 0; return 0;
} }
static int get_int_from_command( char* pcmd ) static int get_int_from_command(char *pcmd)
{ {
int i = 0; int i;
for ( i = 0; i < strlen( pcmd ); i++ ) for (i = 0; i < strlen(pcmd); i++) {
{ if (pcmd[i] == '=') {
if ( pcmd[ i ] == '=' ) /* Skip the '=' and space characters. */
{
// Skip the '=' and space characters.
i += 2; i += 2;
break; break;
} }
} }
return ( rtw_atoi( pcmd + i ) ); return rtw_atoi(pcmd + i);
} }
int rtw_android_priv_cmd(struct net_device *net, struct ifreq *ifr, int cmd) int rtw_android_priv_cmd(struct net_device *net, struct ifreq *ifr, int cmd)
@ -181,54 +185,46 @@ int rtw_android_priv_cmd(struct net_device *net, struct ifreq *ifr, int cmd)
struct android_wifi_priv_cmd priv_cmd; struct android_wifi_priv_cmd priv_cmd;
rtw_lock_suspend(); rtw_lock_suspend();
if (!ifr->ifr_data) { if (!ifr->ifr_data) {
ret = -EINVAL; ret = -EINVAL;
goto exit; goto exit;
} }
if (copy_from_user(&priv_cmd, ifr->ifr_data, sizeof(struct android_wifi_priv_cmd))) { if (copy_from_user(&priv_cmd, ifr->ifr_data,
sizeof(struct android_wifi_priv_cmd))) {
ret = -EFAULT; ret = -EFAULT;
goto exit; goto exit;
} }
command = kmalloc(priv_cmd.total_len, GFP_KERNEL); command = kmalloc(priv_cmd.total_len, GFP_KERNEL);
if (!command) if (!command) {
{
DBG_88E("%s: failed to allocate memory\n", __func__); DBG_88E("%s: failed to allocate memory\n", __func__);
ret = -ENOMEM; ret = -ENOMEM;
goto exit; goto exit;
} }
if (!access_ok(VERIFY_READ, priv_cmd.buf, priv_cmd.total_len)) {
if (!access_ok(VERIFY_READ, priv_cmd.buf, priv_cmd.total_len)){
DBG_88E("%s: failed to access memory\n", __func__); DBG_88E("%s: failed to access memory\n", __func__);
ret = -EFAULT; ret = -EFAULT;
goto exit; goto exit;
} }
if (copy_from_user(command, (char __user *)priv_cmd.buf, priv_cmd.total_len)) { if (copy_from_user(command, (char __user *)priv_cmd.buf,
priv_cmd.total_len)) {
ret = -EFAULT; ret = -EFAULT;
goto exit; goto exit;
} }
DBG_88E("%s: Android private cmd \"%s\" on %s\n",
DBG_88E("%s: Android private cmd \"%s\" on %s\n" __func__, command, ifr->ifr_name);
, __func__, command, ifr->ifr_name);
cmd_num = rtw_android_cmdstr_to_num(command); cmd_num = rtw_android_cmdstr_to_num(command);
switch (cmd_num) { switch (cmd_num) {
case ANDROID_WIFI_CMD_START: case ANDROID_WIFI_CMD_START:
//bytes_written = wl_android_wifi_on(net);
goto response; goto response;
case ANDROID_WIFI_CMD_SETFWPATH: case ANDROID_WIFI_CMD_SETFWPATH:
goto response; goto response;
} }
if (!g_wifi_on) { if (!g_wifi_on) {
DBG_88E("%s: Ignore private cmd \"%s\" - iface %s is down\n" DBG_88E("%s: Ignore private cmd \"%s\" - iface %s is down\n",
,__func__, command, ifr->ifr_name); __func__, command, ifr->ifr_name);
ret = 0; ret = 0;
goto exit; goto exit;
} }
switch (cmd_num) { switch (cmd_num) {
case ANDROID_WIFI_CMD_STOP: case ANDROID_WIFI_CMD_STOP:
break; break;
@ -237,16 +233,20 @@ int rtw_android_priv_cmd(struct net_device *net, struct ifreq *ifr, int cmd)
case ANDROID_WIFI_CMD_SCAN_PASSIVE: case ANDROID_WIFI_CMD_SCAN_PASSIVE:
break; break;
case ANDROID_WIFI_CMD_RSSI: case ANDROID_WIFI_CMD_RSSI:
bytes_written = rtw_android_get_rssi(net, command, priv_cmd.total_len); bytes_written = rtw_android_get_rssi(net, command,
priv_cmd.total_len);
break; break;
case ANDROID_WIFI_CMD_LINKSPEED: case ANDROID_WIFI_CMD_LINKSPEED:
bytes_written = rtw_android_get_link_speed(net, command, priv_cmd.total_len); bytes_written = rtw_android_get_link_speed(net, command,
priv_cmd.total_len);
break; break;
case ANDROID_WIFI_CMD_MACADDR: case ANDROID_WIFI_CMD_MACADDR:
bytes_written = rtw_android_get_macaddr(net, command, priv_cmd.total_len); bytes_written = rtw_android_get_macaddr(net, command,
priv_cmd.total_len);
break; break;
case ANDROID_WIFI_CMD_BLOCK: case ANDROID_WIFI_CMD_BLOCK:
bytes_written = rtw_android_set_block(net, command, priv_cmd.total_len); bytes_written = rtw_android_set_block(net, command,
priv_cmd.total_len);
break; break;
case ANDROID_WIFI_CMD_RXFILTER_START: case ANDROID_WIFI_CMD_RXFILTER_START:
break; break;
@ -271,10 +271,12 @@ int rtw_android_priv_cmd(struct net_device *net, struct ifreq *ifr, int cmd)
case ANDROID_WIFI_CMD_GETBAND: case ANDROID_WIFI_CMD_GETBAND:
break; break;
case ANDROID_WIFI_CMD_COUNTRY: case ANDROID_WIFI_CMD_COUNTRY:
bytes_written = rtw_android_set_country(net, command, priv_cmd.total_len); bytes_written = android_set_cntry(net, command,
priv_cmd.total_len);
break; break;
case ANDROID_WIFI_CMD_P2P_DEV_ADDR: case ANDROID_WIFI_CMD_P2P_DEV_ADDR:
bytes_written = rtw_android_get_p2p_dev_addr(net, command, priv_cmd.total_len); bytes_written = android_get_p2p_addr(net, command,
priv_cmd.total_len);
break; break;
case ANDROID_WIFI_CMD_P2P_SET_NOA: case ANDROID_WIFI_CMD_P2P_SET_NOA:
break; break;
@ -293,14 +295,17 @@ response:
if ((bytes_written == 0) && (priv_cmd.total_len > 0)) if ((bytes_written == 0) && (priv_cmd.total_len > 0))
command[0] = '\0'; command[0] = '\0';
if (bytes_written >= priv_cmd.total_len) { if (bytes_written >= priv_cmd.total_len) {
DBG_88E("%s: bytes_written = %d\n", __func__, bytes_written); DBG_88E("%s: bytes_written = %d\n", __func__,
bytes_written);
bytes_written = priv_cmd.total_len; bytes_written = priv_cmd.total_len;
} else { } else {
bytes_written++; bytes_written++;
} }
priv_cmd.used_len = bytes_written; priv_cmd.used_len = bytes_written;
if (copy_to_user((char __user *)priv_cmd.buf, command, bytes_written)) { if (copy_to_user((char __user *)priv_cmd.buf, command,
DBG_88E("%s: failed to copy data to user buffer\n", __func__); bytes_written)) {
DBG_88E("%s: failed to copy data to user buffer\n",
__func__);
ret = -EFAULT; ret = -EFAULT;
} }
} else { } else {
@ -308,7 +313,6 @@ response:
} }
exit: exit:
rtw_unlock_suspend(); rtw_unlock_suspend();
if (command) kfree(command);
kfree(command);
return ret; return ret;
} }