[PATCH v2] mac80211: fix ieee80211_set_antenna() return value

From: Christoph Rudorff

Date: Fri Nov 06 2026 - 07:25:14 EST


Actually ieee80211_set_antenna() returns -EOPNOTSUPP in case the device is
"started". That is confusing. Return -EBUSY instead. That makes clear that
the device must be stopped beforehand.

Given an active wifi device:

$ iw phy0 set antenna 0x3
command failed: Operation not supported (-95)

expected output:
command failed: Device or resource busy (-16)

drv_set_antenna() later on will check if the driver supports it.

Fixes: 15d967532148 ("mac80211: Add antenna configuration")
Signed-off-by: Christoph Rudorff <chris@xxxxxxxxxxx>
---
I was confused that none of my wifi devices can set_antenna.

Given a fresh inserted usb wifi device:

$ iw phy0 set antenna 0x3
command failed: Operation not supported (-95)

$ rfkill block wlan
$ iw phy0 set antenna 0x3

Oh, wonder, it works!

expected output:
$ iw phy0 set antenna 0x3
command failed: Device or resource busy (-16)

So fix the return value of ieee80211_set_antenna() and later on
drv_set_antenna() checks if the driver supports it.

This is a good candidate for backport. The patch is just a one liner.
---
Changes in v2:
- accelerated commit messages
- Link to v1: https://patch.msgid.link/20261016-fix-set-antenna-v1-1-e071d66f7f89@xxxxxxxxxxx

To: Johannes Berg <johannes@xxxxxxxxxxxxxxxx>
To: "John W. Linville" <linville@xxxxxxxxxxxxx>
To: Bruno Randolf <br1@xxxxxxxxxxx>
Cc: linux-wireless@xxxxxxxxxxxxxxx
Cc: linux-kernel@xxxxxxxxxxxxxxx
---
net/mac80211/cfg.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index a1753335eb9d..87a9ead7c638 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -4920,7 +4920,7 @@ static int ieee80211_set_antenna(struct wiphy *wiphy, int radio_idx,
int ret;

if (local->started)
- return -EOPNOTSUPP;
+ return -EBUSY;

ret = drv_set_antenna(local, tx_ant, rx_ant);
if (ret)

---
base-commit: 79a907609d53d5cd645b42c11550d295d43abf99
change-id: 20261016-fix-set-antenna-50205dc86cb6

Best regards,
--
Christoph Rudorff <chris@xxxxxxxxxxx>