Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1204476pxf; Fri, 9 Apr 2021 02:41:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxBCjr6L8BNMg+ZqAtt/wWu0eUjLM9so5SdhZpyYaOrdhqAd/2G/XvaToDjhe9RM7Fs6hMt X-Received: by 2002:a17:90a:f8c:: with SMTP id 12mr13074235pjz.92.1617961273985; Fri, 09 Apr 2021 02:41:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617961273; cv=none; d=google.com; s=arc-20160816; b=gx3FuBMDGJPtc8h73WYyEtAQlEUMo2MlDDvZvt1a7zMbl5sKGGK0xi5E0ju5DAaieH 0loYGLZS8aXvR4LqNLn2vEM9X5X/edDX80h892gHsxGFsDyxU4ECGMQRj1scDdnmuz0i zD1RbL9MKh4oleLMbepJKZjudbFKKbJmSN1/GWSsKOsbEFJnbFfLKpfpo703xk2UT8kd u/OZ7i726hymivX3gz1qRLjvGbwj0kEhUjERpudoDJMLq33iuHpJ5bNIsFTFPpqBP9RZ SkB5wVVypXklEx91BTlVFRzVY9lbPSDH0OHOPc+WLU+kAN8xsPiZe1rEGffBFDUIIp26 i9rA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:cc:to:from; bh=s+Z8kYL95P3mqacdNHFv74QxzhzPXDeRaWEu808sEa4=; b=yHxrhnMiy82HDac+bSHrUAu+yX42Kd60ftRcizr/Yp+4tI3xqmWzIXjiUPDqRTmqMq 9eVYckqgX/bdHPhHUy4oQcLK+jwZT27vd6kuS8KEa87I7H3j/3596nNMfEtTjWxxhzY7 VxIlyAHAK1Lkp6pfC7i6UyQS1WwmqbvpIGl+gr1lhpjnbKxdnxoMQbDOHXw2CesDgRnu JMm5nojV461t1ldua40xXD6Mp3ws9lAX2jMRRjesrlCRfdWR/PsHuSHp3FvsTbhoRL/E L97id3E/IZbOgsQoMsCCsaDAcU61XflUkS/QZ8r5pcBNbDnuizICig4CyPMtMXLDbhOB CDXg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v20si2399168pjt.103.2021.04.09.02.41.01; Fri, 09 Apr 2021 02:41:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232813AbhDIJku (ORCPT + 99 others); Fri, 9 Apr 2021 05:40:50 -0400 Received: from paleale.coelho.fi ([176.9.41.70]:44254 "EHLO farmhouse.coelho.fi" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232762AbhDIJkt (ORCPT ); Fri, 9 Apr 2021 05:40:49 -0400 Received: from 91-156-6-193.elisa-laajakaista.fi ([91.156.6.193] helo=kveik.ger.corp.intel.com) by farmhouse.coelho.fi with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94) (envelope-from ) id 1lUncv-000ELR-Ri; Fri, 09 Apr 2021 12:40:35 +0300 From: Luca Coelho To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org Date: Fri, 9 Apr 2021 12:40:19 +0300 Message-Id: X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210409094028.356611-1-luca@coelho.fi> References: <20210409094028.356611-1-luca@coelho.fi> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on farmhouse.coelho.fi X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, TVD_RCVD_IP autolearn=ham autolearn_force=no version=3.4.5-pre1 Subject: [PATCH 06/15] mac80211: make ieee80211_vif_to_wdev work when the vif isn't in the driver Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Emmanuel Grumbach This will allow the low level driver to get the wdev during the add_interface flow. In order to do that, remove a few checks from there and do not return NULL for vifs that were not yet added to the driver. Note that all the current callers of this helper function assume that the vif already exists: - The callers from the drivers already have a vif pointer. Before this change, ieee80211_vif_to_wdev would return NULL in some cases, but those callers don't even check they get a non-NULL pointer from ieee80211_vif_to_wdev. - The callers from net/mac80211/cfg.c assume the vif is already added to the driver as well. So, this change has no impact on existing callers of this helper function. Signed-off-by: Emmanuel Grumbach Signed-off-by: Luca Coelho --- include/net/mac80211.h | 5 +---- net/mac80211/util.c | 10 +--------- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/include/net/mac80211.h b/include/net/mac80211.h index 2d1d629e5d14..d28f5087c8fa 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -1768,10 +1768,7 @@ struct ieee80211_vif *wdev_to_ieee80211_vif(struct wireless_dev *wdev); * * 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.) + * This can also be useful to get the netdev associated to a vif. */ struct wireless_dev *ieee80211_vif_to_wdev(struct ieee80211_vif *vif); diff --git a/net/mac80211/util.c b/net/mac80211/util.c index f080fcf60e45..7e36b7363564 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -888,18 +888,10 @@ EXPORT_SYMBOL_GPL(wdev_to_ieee80211_vif); struct wireless_dev *ieee80211_vif_to_wdev(struct ieee80211_vif *vif) { - struct ieee80211_sub_if_data *sdata; - if (!vif) return NULL; - sdata = vif_to_sdata(vif); - - if (!ieee80211_sdata_running(sdata) || - !(sdata->flags & IEEE80211_SDATA_IN_DRIVER)) - return NULL; - - return &sdata->wdev; + return &vif_to_sdata(vif)->wdev; } EXPORT_SYMBOL_GPL(ieee80211_vif_to_wdev); -- 2.31.0