Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 27 Mar 2022 20:14:11 GMT
From:      "Bjoern A. Zeeb" <bz@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 4836b8ac0ed3 - stable/13 - LinuxKPI: 802.11: use cfg80211_chandef_create()
Message-ID:  <202203272014.22RKEB0c037370@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by bz:

URL: https://cgit.FreeBSD.org/src/commit/?id=4836b8ac0ed3a3b155a7fb5f2322221f48c81687

commit 4836b8ac0ed3a3b155a7fb5f2322221f48c81687
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2022-03-24 15:43:22 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2022-03-27 18:12:17 +0000

    LinuxKPI: 802.11: use cfg80211_chandef_create()
    
    Rather than manually setting up a chandef and then effectively forcing
    a memcpy, use cfg80211_chandef_create() to do the work for us entirely.
    This works here as we do not store the resulting chandef separately
    for other use.
    
    While here remove a duplicate assignment in cfg80211_chandef_create().
    
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit 4a07abdeb8ce5271996d85f648832e3d7bc741a7)
---
 sys/compat/linuxkpi/common/include/net/cfg80211.h |  2 +-
 sys/compat/linuxkpi/common/src/linux_80211.c      | 14 +++-----------
 2 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/sys/compat/linuxkpi/common/include/net/cfg80211.h b/sys/compat/linuxkpi/common/include/net/cfg80211.h
index 896559247620..64aef659c771 100644
--- a/sys/compat/linuxkpi/common/include/net/cfg80211.h
+++ b/sys/compat/linuxkpi/common/include/net/cfg80211.h
@@ -1166,9 +1166,9 @@ cfg80211_chandef_create(struct cfg80211_chan_def *chandef,
 	KASSERT(chandef != NULL, ("%s: chandef is NULL\n", __func__));
 	KASSERT(chan != NULL, ("%s: chan is NULL\n", __func__));
 
+	memset(chandef, 0, sizeof(*chandef));
 	chandef->chan = chan;
 	chandef->center_freq2 = 0;	/* Set here and only overwrite if needed. */
-        chandef->chan = chan;
 
 	switch (chan_flag) {
 	case NL80211_CHAN_NO_HT:
diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c
index 4805097fcd4f..e9e75488882a 100644
--- a/sys/compat/linuxkpi/common/src/linux_80211.c
+++ b/sys/compat/linuxkpi/common/src/linux_80211.c
@@ -2629,7 +2629,6 @@ lkpi_ic_set_channel(struct ieee80211com *ic)
 	} else {
 		struct ieee80211_channel *c = ic->ic_curchan;
 		struct linuxkpi_ieee80211_channel *chan;
-		struct cfg80211_chan_def chandef;
 
 		if (c == NULL || c == IEEE80211_CHAN_ANYC ||
 		    lhw->ops->config == NULL) {
@@ -2645,16 +2644,12 @@ lkpi_ic_set_channel(struct ieee80211com *ic)
 			return;
 		}
 
-		memset(&chandef, 0, sizeof(chandef));
-		chandef.chan = chan;
-		chandef.width = NL80211_CHAN_WIDTH_20_NOHT;
-		chandef.center_freq1 = chandef.chan->center_freq;
-
 		/* XXX max power for scanning? */
 		IMPROVE();
 
 		hw = LHW_TO_HW(lhw);
-		hw->conf.chandef = chandef;
+		cfg80211_chandef_create(&hw->conf.chandef, chan,
+		    NL80211_CHAN_NO_HT);
 
 		error = lkpi_80211_mo_config(hw, IEEE80211_CONF_CHANGE_CHANNEL);
 		if (error != 0 && error != EOPNOTSUPP) {
@@ -3430,15 +3425,12 @@ linuxkpi_ieee80211_ifattach(struct ieee80211_hw *hw)
 
 		channels = supband->channels;
 		for (i = 0; i < supband->n_channels; i++) {
-			struct cfg80211_chan_def chandef;
 
 			if (channels[i].flags & IEEE80211_CHAN_DISABLED)
 				continue;
 
-			memset(&chandef, 0, sizeof(chandef));
-			cfg80211_chandef_create(&chandef, &channels[i],
+			cfg80211_chandef_create(&hw->conf.chandef, &channels[i],
 			    NL80211_CHAN_NO_HT);
-			hw->conf.chandef = chandef;
 			break;
 		}
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202203272014.22RKEB0c037370>