Patchwork [11/20] driver: nl80211: introduce i802_set_iface_flags()

login
register
mail settings
Submitter Arend van Spriel
Date May 16, 2013, 1:28 p.m.
Message ID <1368710915-32176-12-git-send-email-arend@broadcom.com>
Download mbox | patch
Permalink /patch/244304/
State Changes Requested
Headers show

Comments

Arend van Spriel - May 16, 2013, 1:28 p.m.
The driver uses linux_set_iface_flags() in several places. Introduce
and use i802_set_iface_flags() which also works for P2P Device
interface.

Signed-hostap: Arend van Spriel <arend@broadcom.com>
---
 src/drivers/driver_nl80211.c |   31 +++++++++++++++++++++++--------
 1 file changed, 23 insertions(+), 8 deletions(-)

Patch

diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 9d8d630..afdb098 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -3759,6 +3759,24 @@  nla_put_failure:
 	return ret;
 }
 
+
+static int i802_set_iface_flags(struct i802_bss *bss, int up)
+{
+	enum nl80211_iftype nlmode;
+
+	nlmode = nl80211_get_ifmode(bss);
+	if (nlmode != NL80211_IFTYPE_P2P_DEVICE) {
+		int sock;
+
+		sock = bss->drv->global->ioctl_sock;
+		return linux_set_iface_flags(sock, bss->ifname, up);
+	}
+
+	/* P2P Device has start/stop which is equivalent */
+	return nl80211_set_p2pdev(bss, up);
+}
+
+
 static int
 wpa_driver_nl80211_finish_drv_init(struct wpa_driver_nl80211_data *drv)
 {
@@ -3921,7 +3939,7 @@  static void wpa_driver_nl80211_deinit(struct i802_bss *bss)
 
 	eloop_cancel_timeout(wpa_driver_nl80211_scan_timeout, drv, drv->ctx);
 
-	(void) linux_set_iface_flags(drv->global->ioctl_sock, bss->ifname, 0);
+	(void)i802_set_iface_flags(bss, 0);
 	wpa_driver_nl80211_set_mode(bss, NL80211_IFTYPE_STATION);
 	nl80211_mgmt_unsubscribe(bss, "deinit");
 
@@ -7749,8 +7767,7 @@  static int wpa_driver_nl80211_set_mode(struct i802_bss *bss,
 	wpa_printf(MSG_DEBUG, "nl80211: Try mode change after setting "
 		   "interface down");
 	for (i = 0; i < 10; i++) {
-		res = linux_set_iface_flags(drv->global->ioctl_sock,
-					    bss->ifname, 0);
+		res = i802_set_iface_flags(bss, 0);
 		if (res == -EACCES || res == -ENODEV)
 			break;
 		if (res == 0) {
@@ -7759,8 +7776,7 @@  static int wpa_driver_nl80211_set_mode(struct i802_bss *bss,
 			ret = nl80211_set_mode(drv, drv->ifindex, nlmode);
 			if (ret == -EACCES)
 				break;
-			res = linux_set_iface_flags(drv->global->ioctl_sock,
-						    bss->ifname, 1);
+			res = i802_set_iface_flags(bss, 1);
 			if (res && !ret)
 				ret = -1;
 			else if (ret != -EBUSY)
@@ -9191,11 +9207,10 @@  static int wpa_driver_nl80211_deinit_p2p_cli(void *priv)
 static void wpa_driver_nl80211_resume(void *priv)
 {
 	struct i802_bss *bss = priv;
-	struct wpa_driver_nl80211_data *drv = bss->drv;
-	if (linux_set_iface_flags(drv->global->ioctl_sock, bss->ifname, 1)) {
+
+	if (i802_set_iface_flags(bss, 1))
 		wpa_printf(MSG_DEBUG, "nl80211: Failed to set interface up on "
 			   "resume event");
-	}
 }