diff options
author | Johannes Berg <johannes@sipsolutions.net> | 2007-04-26 23:45:47 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2007-04-26 23:45:47 -0400 |
commit | dd8ceabcd10d47f6f28ecfaf2eac7beffca11b3c (patch) | |
tree | 59c9c85e2e1919f614a350e17ce47d597e61b1f1 /net | |
parent | 4b1e255384570138c2a823904796d46f628e8350 (diff) |
[WEXT]: Cleanup early ioctl call path.
This patch makes the code in wireless_process_ioctl somewhat more
readable.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/wireless/wext.c | 73 |
1 files changed, 26 insertions, 47 deletions
diff --git a/net/wireless/wext.c b/net/wireless/wext.c index dabc6453518a..adcb08344d5b 100644 --- a/net/wireless/wext.c +++ b/net/wireless/wext.c | |||
@@ -1035,53 +1035,31 @@ static int wireless_process_ioctl(struct ifreq *ifr, unsigned int cmd) | |||
1035 | /* A bunch of special cases, then the generic case... | 1035 | /* A bunch of special cases, then the generic case... |
1036 | * Note that 'cmd' is already filtered in dev_ioctl() with | 1036 | * Note that 'cmd' is already filtered in dev_ioctl() with |
1037 | * (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST) */ | 1037 | * (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST) */ |
1038 | switch (cmd) { | 1038 | if (cmd == SIOCGIWSTATS) |
1039 | case SIOCGIWSTATS: | 1039 | return ioctl_standard_call(dev, ifr, cmd, |
1040 | /* Get Wireless Stats */ | ||
1041 | return ioctl_standard_call(dev, | ||
1042 | ifr, | ||
1043 | cmd, | ||
1044 | &iw_handler_get_iwstats); | 1040 | &iw_handler_get_iwstats); |
1045 | 1041 | ||
1046 | case SIOCGIWPRIV: | 1042 | if (cmd == SIOCGIWPRIV && dev->wireless_handlers) |
1047 | /* Check if we have some wireless handlers defined */ | 1043 | return ioctl_standard_call(dev, ifr, cmd, |
1048 | if (dev->wireless_handlers != NULL) { | 1044 | &iw_handler_get_private); |
1049 | /* We export to user space the definition of | 1045 | |
1050 | * the private handler ourselves */ | 1046 | /* Basic check */ |
1051 | return ioctl_standard_call(dev, | 1047 | if (!netif_device_present(dev)) |
1052 | ifr, | 1048 | return -ENODEV; |
1053 | cmd, | 1049 | |
1054 | &iw_handler_get_private); | 1050 | /* New driver API : try to find the handler */ |
1055 | } | 1051 | handler = get_handler(dev, cmd); |
1056 | // ## Fall-through for old API ## | 1052 | if (handler) { |
1057 | default: | 1053 | /* Standard and private are not the same */ |
1058 | /* Generic IOCTL */ | 1054 | if (cmd < SIOCIWFIRSTPRIV) |
1059 | /* Basic check */ | 1055 | return ioctl_standard_call(dev, ifr, cmd, handler); |
1060 | if (!netif_device_present(dev)) | 1056 | else |
1061 | return -ENODEV; | 1057 | return ioctl_private_call(dev, ifr, cmd, handler); |
1062 | /* New driver API : try to find the handler */ | ||
1063 | handler = get_handler(dev, cmd); | ||
1064 | if (handler != NULL) { | ||
1065 | /* Standard and private are not the same */ | ||
1066 | if (cmd < SIOCIWFIRSTPRIV) | ||
1067 | return ioctl_standard_call(dev, | ||
1068 | ifr, | ||
1069 | cmd, | ||
1070 | handler); | ||
1071 | else | ||
1072 | return ioctl_private_call(dev, | ||
1073 | ifr, | ||
1074 | cmd, | ||
1075 | handler); | ||
1076 | } | ||
1077 | /* Old driver API : call driver ioctl handler */ | ||
1078 | if (dev->do_ioctl) { | ||
1079 | return dev->do_ioctl(dev, ifr, cmd); | ||
1080 | } | ||
1081 | return -EOPNOTSUPP; | ||
1082 | } | 1058 | } |
1083 | /* Not reached */ | 1059 | /* Old driver API : call driver ioctl handler */ |
1084 | return -EINVAL; | 1060 | if (dev->do_ioctl) |
1061 | return dev->do_ioctl(dev, ifr, cmd); | ||
1062 | return -EOPNOTSUPP; | ||
1085 | } | 1063 | } |
1086 | 1064 | ||
1087 | /* entry point from dev ioctl */ | 1065 | /* entry point from dev ioctl */ |
@@ -1093,9 +1071,10 @@ int wext_handle_ioctl(struct ifreq *ifr, unsigned int cmd, | |||
1093 | /* If command is `set a parameter', or | 1071 | /* If command is `set a parameter', or |
1094 | * `get the encoding parameters', check if | 1072 | * `get the encoding parameters', check if |
1095 | * the user has the right to do it */ | 1073 | * the user has the right to do it */ |
1096 | if (IW_IS_SET(cmd) || cmd == SIOCGIWENCODE || cmd == SIOCGIWENCODEEXT) | 1074 | if ((IW_IS_SET(cmd) || cmd == SIOCGIWENCODE || cmd == SIOCGIWENCODEEXT) |
1097 | if (!capable(CAP_NET_ADMIN)) | 1075 | && !capable(CAP_NET_ADMIN)) |
1098 | return -EPERM; | 1076 | return -EPERM; |
1077 | |||
1099 | dev_load(ifr->ifr_name); | 1078 | dev_load(ifr->ifr_name); |
1100 | rtnl_lock(); | 1079 | rtnl_lock(); |
1101 | ret = wireless_process_ioctl(ifr, cmd); | 1080 | ret = wireless_process_ioctl(ifr, cmd); |