staging: r8188eu: cleanups in rtw_android_set_block()
1) We can tighten up the code a little by returning directly and it makes the code more future proof and easier to read. 2) "free" is a better name than "exit". 3) sizeof(priv_cmd) is shorter and more clear than sizeof(struct android_wifi_priv_cmd). Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
d0915b2255
commit
85e1c554f4
1 changed files with 7 additions and 12 deletions
|
@ -148,20 +148,15 @@ static int rtw_android_set_block(struct net_device *net, char *command,
|
||||||
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)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
char *command = NULL;
|
char *command;
|
||||||
int cmd_num;
|
int cmd_num;
|
||||||
int bytes_written = 0;
|
int bytes_written = 0;
|
||||||
struct android_wifi_priv_cmd priv_cmd;
|
struct android_wifi_priv_cmd priv_cmd;
|
||||||
|
|
||||||
if (!ifr->ifr_data) {
|
if (!ifr->ifr_data)
|
||||||
ret = -EINVAL;
|
return -EINVAL;
|
||||||
goto exit;
|
if (copy_from_user(&priv_cmd, ifr->ifr_data, sizeof(priv_cmd)))
|
||||||
}
|
return -EFAULT;
|
||||||
if (copy_from_user(&priv_cmd, ifr->ifr_data,
|
|
||||||
sizeof(struct android_wifi_priv_cmd))) {
|
|
||||||
ret = -EFAULT;
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
if (priv_cmd.total_len < 1)
|
if (priv_cmd.total_len < 1)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
command = memdup_user(priv_cmd.buf, priv_cmd.total_len);
|
command = memdup_user(priv_cmd.buf, priv_cmd.total_len);
|
||||||
|
@ -181,7 +176,7 @@ int rtw_android_priv_cmd(struct net_device *net, struct ifreq *ifr, int cmd)
|
||||||
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 free;
|
||||||
}
|
}
|
||||||
switch (cmd_num) {
|
switch (cmd_num) {
|
||||||
case ANDROID_WIFI_CMD_STOP:
|
case ANDROID_WIFI_CMD_STOP:
|
||||||
|
@ -269,7 +264,7 @@ response:
|
||||||
} else {
|
} else {
|
||||||
ret = bytes_written;
|
ret = bytes_written;
|
||||||
}
|
}
|
||||||
exit:
|
free:
|
||||||
kfree(command);
|
kfree(command);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue