diff mbox

[v3,06/15] driver_nl80211: use one CB for driver event RX

Message ID 20111119123951.182358879@sipsolutions.net
State Accepted
Commit 1afc986d844ff197f2230f77750efd69a4589340
Headers show

Commit Message

Johannes Berg Nov. 19, 2011, 12:39 p.m. UTC
From: Johannes Berg <johannes.berg@intel.com>

There's no need to clone the CB all the time
and then assign it, just use a constant one.

Signed-hostap: Johannes Berg <johannes.berg@intel.com>
---
 src/drivers/driver_nl80211.c |   22 ++++++++++++++--------
 1 files changed, 14 insertions(+), 8 deletions(-)

Comments

Jouni Malinen Dec. 3, 2011, 6 p.m. UTC | #1
On Sat, Nov 19, 2011 at 01:39:16PM +0100, Johannes Berg wrote:
> There's no need to clone the CB all the time
> and then assign it, just use a constant one.

Thanks, applied.
diff mbox

Patch

diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 1b5dabf..ca33f3a 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -213,6 +213,7 @@  struct wpa_driver_nl80211_data {
 	int scan_complete_events;
 
 	struct nl80211_handles nl_event;
+	struct nl_cb *nl_cb;
 
 	u8 auth_bssid[ETH_ALEN];
 	u8 bssid[ETH_ALEN];
@@ -1848,18 +1849,11 @@  static int process_event(struct nl_msg *msg, void *arg)
 static void wpa_driver_nl80211_event_receive(int sock, void *eloop_ctx,
 					     void *handle)
 {
-	struct nl_cb *cb;
 	struct wpa_driver_nl80211_data *drv = eloop_ctx;
 
 	wpa_printf(MSG_DEBUG, "nl80211: Event message available");
 
-	cb = nl_cb_clone(drv->global->nl_cb);
-	if (!cb)
-		return;
-	nl_cb_set(cb, NL_CB_SEQ_CHECK, NL_CB_CUSTOM, no_seq_check, NULL);
-	nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, process_event, drv);
-	nl_recvmsgs(handle, cb);
-	nl_cb_put(cb);
+	nl_recvmsgs(handle, drv->nl_cb);
 }
 
 
@@ -2227,6 +2221,17 @@  static int wpa_driver_nl80211_init_nl(struct wpa_driver_nl80211_data *drv)
 		/* Continue without regulatory events */
 	}
 
+	drv->nl_cb = nl_cb_alloc(NL_CB_DEFAULT);
+	if (!drv->nl_cb) {
+		wpa_printf(MSG_ERROR, "nl80211: failed to alloc cb struct\n");
+		goto err4;
+	}
+
+	nl_cb_set(drv->nl_cb, NL_CB_SEQ_CHECK, NL_CB_CUSTOM,
+		  no_seq_check, NULL);
+	nl_cb_set(drv->nl_cb, NL_CB_VALID, NL_CB_CUSTOM,
+		  process_event, drv);
+
 	eloop_register_read_sock(nl_socket_get_fd(drv->nl_event.handle),
 				 wpa_driver_nl80211_event_receive, drv,
 				 drv->nl_event.handle);
@@ -2703,6 +2708,7 @@  static void wpa_driver_nl80211_deinit(void *priv)
 
 	eloop_unregister_read_sock(nl_socket_get_fd(drv->nl_event.handle));
 	nl_destroy_handles(&drv->nl_event);
+	nl_cb_put(drv->nl_cb);
 
 	os_free(drv->filter_ssids);