From patchwork Thu Nov 10 14:38:17 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 124887 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 5D0CD1007D1 for ; Fri, 11 Nov 2011 01:38:37 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 63B759D2A6; Thu, 10 Nov 2011 09:38:34 -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 Nt3U6VLs-8+Y; Thu, 10 Nov 2011 09:38:34 -0500 (EST) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 4F8639D2A7; Thu, 10 Nov 2011 09:38:30 -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 C05219D2A7 for ; Thu, 10 Nov 2011 09:38:29 -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 T2nqGk30z-oR for ; Thu, 10 Nov 2011 09:38:26 -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 0FD639D2A6 for ; Thu, 10 Nov 2011 09:38:26 -0500 (EST) Received: by sipsolutions.net with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.77) (envelope-from ) id 1ROVlo-0005zr-Ph for hostap@lists.shmoo.com; Thu, 10 Nov 2011 15:38:24 +0100 Subject: [PATCH] driver_nl80211: get rid of family/cache objects From: Johannes Berg To: "hostap@lists.shmoo.com" Date: Thu, 10 Nov 2011 15:38:17 +0100 Message-ID: <1320935897.3967.69.camel@jlt3.sipsolutions.net> 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 All we really need is the family ID, and we can get that with genl_ctrl_resolve() and then don't need to worry about family/cache objects. Signed-hostap: Johannes Berg --- src/drivers/driver_nl80211.c | 30 ++++-------------------------- 1 files changed, 4 insertions(+), 26 deletions(-) diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index 3c98ee0..77a9e50 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -109,23 +109,11 @@ static void nl80211_handle_destroy(struct nl_handle *handle) nl_handle_destroy(handle); } - -static inline int __genl_ctrl_alloc_cache(struct nl_handle *h, - struct nl_cache **cache) -{ - struct nl_cache *tmp = genl_ctrl_alloc_cache(h); - if (!tmp) - return -ENOMEM; - *cache = tmp; - return 0; -} -#define genl_ctrl_alloc_cache __genl_ctrl_alloc_cache #endif /* CONFIG_LIBNL20 */ struct nl80211_handles { struct nl_handle *handle; - struct nl_cache *cache; }; @@ -148,12 +136,6 @@ static int nl_create_handles(struct nl80211_handles *handles, struct nl_cb *cb, goto err; } - if (genl_ctrl_alloc_cache(handles->handle, &handles->cache) < 0) { - wpa_printf(MSG_ERROR, "nl80211: Failed to allocate generic " - "netlink cache (%s)", dbg); - goto err; - } - return 0; err: nl80211_handle_destroy(handles->handle); @@ -165,7 +147,6 @@ static void nl_destroy_handles(struct nl80211_handles *handles) { if (handles->handle == NULL) return; - nl_cache_free(handles->cache); nl80211_handle_destroy(handles->handle); handles->handle = NULL; } @@ -191,7 +172,7 @@ struct nl80211_global { struct netlink_data *netlink; struct nl_cb *nl_cb; struct nl80211_handles nl; - struct genl_family *nl80211; + int nl80211_id; int ioctl_sock; /* socket for ioctl() use */ struct nl80211_handles nl_event; @@ -525,7 +506,7 @@ nla_put_failure: static void * nl80211_cmd(struct wpa_driver_nl80211_data *drv, struct nl_msg *msg, int flags, uint8_t cmd) { - return genlmsg_put(msg, 0, 0, genl_family_get_id(drv->global->nl80211), + return genlmsg_put(msg, 0, 0, drv->global->nl80211_id, 0, flags, cmd, 0); } @@ -2539,9 +2520,8 @@ static int wpa_driver_nl80211_init_nl_global(struct nl80211_global *global) if (nl_create_handles(&global->nl, global->nl_cb, "nl")) goto err; - global->nl80211 = genl_ctrl_search_by_name(global->nl.cache, - "nl80211"); - if (global->nl80211 == NULL) { + global->nl80211_id = genl_ctrl_resolve(global->nl.handle, "nl80211"); + if (global->nl80211_id < 0) { wpa_printf(MSG_ERROR, "nl80211: 'nl80211' generic netlink not " "found"); goto err; @@ -7999,8 +7979,6 @@ static void nl80211_global_deinit(void *priv) if (global->netlink) netlink_deinit(global->netlink); - if (global->nl80211) - genl_family_put(global->nl80211); nl_destroy_handles(&global->nl); if (global->nl_event.handle) {