From patchwork Sat Nov 19 12:39:16 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 126574 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from maxx.maxx.shmoo.com (maxx.shmoo.com [205.134.188.171]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "maxx.shmoo.com", Issuer "CA Cert Signing Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id C765BB7232 for ; Sat, 19 Nov 2011 23:43:04 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 57E8D9D200; Sat, 19 Nov 2011 07:43:02 -0500 (EST) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id V2gjS+arE2CR; Sat, 19 Nov 2011 07:43:02 -0500 (EST) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id C72FE9D201; Sat, 19 Nov 2011 07:41:40 -0500 (EST) X-Original-To: mailman-post+hostap@maxx.shmoo.com Delivered-To: mailman-post+hostap@maxx.shmoo.com Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 52F339D1DB for ; Sat, 19 Nov 2011 07:41:39 -0500 (EST) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ao++OAkv1iLQ for ; Sat, 19 Nov 2011 07:41:34 -0500 (EST) Received: from sipsolutions.net (he.sipsolutions.net [78.46.109.217]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by maxx.maxx.shmoo.com (Postfix) with ESMTPS id 990969C208 for ; Sat, 19 Nov 2011 07:41:13 -0500 (EST) Received: by sipsolutions.net with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.77) (envelope-from ) id 1RRkEK-0002cQ-JG for hostap@lists.shmoo.com; Sat, 19 Nov 2011 13:41:12 +0100 Message-Id: <20111119123951.182358879@sipsolutions.net> User-Agent: quilt/0.48-1 Date: Sat, 19 Nov 2011 13:39:16 +0100 From: Johannes Berg To: hostap@lists.shmoo.com Subject: [PATCH v3 06/15] driver_nl80211: use one CB for driver event RX References: <20111119123910.783418920@sipsolutions.net> Content-Disposition: inline; filename=0006-driver_nl80211-use-one-CB-for-driver-event-RX.patch Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com From: Johannes Berg There's no need to clone the CB all the time and then assign it, just use a constant one. Signed-hostap: Johannes Berg --- src/drivers/driver_nl80211.c | 22 ++++++++++++++-------- 1 files changed, 14 insertions(+), 8 deletions(-) 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);