Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dd8ceabc authored by Johannes Berg's avatar Johannes Berg Committed by David S. Miller
Browse files

[WEXT]: Cleanup early ioctl call path.



This patch makes the code in wireless_process_ioctl somewhat more
readable.

Signed-off-by: default avatarJohannes Berg <johannes@sipsolutions.net>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4b1e2553
Loading
Loading
Loading
Loading
+26 −47
Original line number Original line Diff line number Diff line
@@ -1035,54 +1035,32 @@ static int wireless_process_ioctl(struct ifreq *ifr, unsigned int cmd)
	/* A bunch of special cases, then the generic case...
	/* A bunch of special cases, then the generic case...
	 * Note that 'cmd' is already filtered in dev_ioctl() with
	 * Note that 'cmd' is already filtered in dev_ioctl() with
	 * (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST) */
	 * (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST) */
	switch (cmd) {
	if (cmd == SIOCGIWSTATS)
	case SIOCGIWSTATS:
		return ioctl_standard_call(dev, ifr, cmd,
		/* Get Wireless Stats */
		return ioctl_standard_call(dev,
					   ifr,
					   cmd,
					   &iw_handler_get_iwstats);
					   &iw_handler_get_iwstats);


	case SIOCGIWPRIV:
	if (cmd == SIOCGIWPRIV && dev->wireless_handlers)
		/* Check if we have some wireless handlers defined */
		return ioctl_standard_call(dev, ifr, cmd,
		if (dev->wireless_handlers != NULL) {
			/* We export to user space the definition of
			 * the private handler ourselves */
			return ioctl_standard_call(dev,
						   ifr,
						   cmd,
					   &iw_handler_get_private);
					   &iw_handler_get_private);
		}

		// ## Fall-through for old API ##
	default:
		/* Generic IOCTL */
	/* Basic check */
	/* Basic check */
	if (!netif_device_present(dev))
	if (!netif_device_present(dev))
		return -ENODEV;
		return -ENODEV;

	/* New driver API : try to find the handler */
	/* New driver API : try to find the handler */
	handler = get_handler(dev, cmd);
	handler = get_handler(dev, cmd);
		if (handler != NULL) {
	if (handler) {
		/* Standard and private are not the same */
		/* Standard and private are not the same */
		if (cmd < SIOCIWFIRSTPRIV)
		if (cmd < SIOCIWFIRSTPRIV)
				return ioctl_standard_call(dev,
			return ioctl_standard_call(dev, ifr, cmd, handler);
							   ifr,
							   cmd,
							   handler);
		else
		else
				return ioctl_private_call(dev,
			return ioctl_private_call(dev, ifr, cmd, handler);
							  ifr,
							  cmd,
							  handler);
	}
	}
	/* Old driver API : call driver ioctl handler */
	/* Old driver API : call driver ioctl handler */
		if (dev->do_ioctl) {
	if (dev->do_ioctl)
		return dev->do_ioctl(dev, ifr, cmd);
		return dev->do_ioctl(dev, ifr, cmd);
		}
	return -EOPNOTSUPP;
	return -EOPNOTSUPP;
}
}
	/* Not reached */
	return -EINVAL;
}


/* entry point from dev ioctl */
/* entry point from dev ioctl */
int wext_handle_ioctl(struct ifreq *ifr, unsigned int cmd,
int wext_handle_ioctl(struct ifreq *ifr, unsigned int cmd,
@@ -1093,9 +1071,10 @@ int wext_handle_ioctl(struct ifreq *ifr, unsigned int cmd,
	/* If command is `set a parameter', or
	/* If command is `set a parameter', or
	 * `get the encoding parameters', check if
	 * `get the encoding parameters', check if
	 * the user has the right to do it */
	 * the user has the right to do it */
	if (IW_IS_SET(cmd) || cmd == SIOCGIWENCODE || cmd == SIOCGIWENCODEEXT)
	if ((IW_IS_SET(cmd) || cmd == SIOCGIWENCODE || cmd == SIOCGIWENCODEEXT)
		if (!capable(CAP_NET_ADMIN))
	    && !capable(CAP_NET_ADMIN))
		return -EPERM;
		return -EPERM;

	dev_load(ifr->ifr_name);
	dev_load(ifr->ifr_name);
	rtnl_lock();
	rtnl_lock();
	ret = wireless_process_ioctl(ifr, cmd);
	ret = wireless_process_ioctl(ifr, cmd);