From patchwork Thu Mar 12 06:53:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emmanuel Grumbach X-Patchwork-Id: 5990961 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C7A559FB80 for ; Thu, 12 Mar 2015 06:53:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F00CA20375 for ; Thu, 12 Mar 2015 06:53:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EB37720379 for ; Thu, 12 Mar 2015 06:53:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752205AbbCLGxg (ORCPT ); Thu, 12 Mar 2015 02:53:36 -0400 Received: from mga01.intel.com ([192.55.52.88]:19662 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750977AbbCLGxd (ORCPT ); Thu, 12 Mar 2015 02:53:33 -0400 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP; 11 Mar 2015 23:53:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,387,1422950400"; d="scan'208";a="539775698" Received: from egrumbacbox.jer.intel.com ([10.12.118.74]) by orsmga003.jf.intel.com with ESMTP; 11 Mar 2015 23:52:51 -0700 From: Emmanuel Grumbach To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Emmanuel Grumbach Subject: [PATCH 1/7] mac80211: allow to get wireless_dev structure from ieee80211_vif Date: Thu, 12 Mar 2015 08:53:24 +0200 Message-Id: <1426143210-25635-1-git-send-email-emmanuel.grumbach@intel.com> X-Mailer: git-send-email 1.9.1 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This will allow mac80211 drivers to call cfg80211 APIs with the right handle. Signed-off-by: Emmanuel Grumbach --- include/net/mac80211.h | 13 +++++++++++++ net/mac80211/util.c | 12 ++++++++++++ 2 files changed, 25 insertions(+) diff --git a/include/net/mac80211.h b/include/net/mac80211.h index a7756e4..157c0f1 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -1282,6 +1282,19 @@ static inline bool ieee80211_vif_is_mesh(struct ieee80211_vif *vif) struct ieee80211_vif *wdev_to_ieee80211_vif(struct wireless_dev *wdev); /** + * ieee80211_vif_to_wdev - return a wdev struct from a vif + * @vif: the vif to get the wdev for + * + * This can be used by mac80211 drivers with direct cfg80211 APIs + * (like the vendor commands) that needs to get the wdev for a vif. + * + * Note that this function may return %NULL if the given wdev isn't + * associated with a vif that the driver knows about (e.g. monitor + * or AP_VLAN interfaces.) + */ +struct wireless_dev *ieee80211_vif_to_wdev(struct ieee80211_vif *vif); + +/** * enum ieee80211_key_flags - key flags * * These flags are used for communication about keys between the driver diff --git a/net/mac80211/util.c b/net/mac80211/util.c index 37d85d3..e664b28 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -745,6 +745,18 @@ struct ieee80211_vif *wdev_to_ieee80211_vif(struct wireless_dev *wdev) } EXPORT_SYMBOL_GPL(wdev_to_ieee80211_vif); +struct wireless_dev *ieee80211_vif_to_wdev(struct ieee80211_vif *vif) +{ + struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); + + if (!ieee80211_sdata_running(sdata) || + !(sdata->flags & IEEE80211_SDATA_IN_DRIVER)) + return NULL; + + return &sdata->wdev; +} +EXPORT_SYMBOL_GPL(ieee80211_vif_to_wdev); + /* * Nothing should have been stuffed into the workqueue during * the suspend->resume cycle. Since we can't check each caller