From 5ec08d841d778c1bb60fe34f8b0ab5fc9c086e11 Mon Sep 17 00:00:00 2001
From: Matthias Schiffer <mschiffer@universe-factory.net>
Date: Wed, 6 May 2020 23:55:42 +0200
Subject: [PATCH] gluon-core: platform: clean up device_supports_mfp()

- Use util.find_phy()
- Stop foreach() as soon as the result is known
---
 package/gluon-core/luasrc/usr/lib/lua/gluon/platform.lua | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/package/gluon-core/luasrc/usr/lib/lua/gluon/platform.lua b/package/gluon-core/luasrc/usr/lib/lua/gluon/platform.lua
index 471389584..8ffcd1cdd 100644
--- a/package/gluon-core/luasrc/usr/lib/lua/gluon/platform.lua
+++ b/package/gluon-core/luasrc/usr/lib/lua/gluon/platform.lua
@@ -66,21 +66,20 @@ function M.device_supports_wpa3()
 end
 
 function M.device_supports_mfp(uci)
-	local idx = 0
 	local supports_mfp = true
 
 	if not M.device_supports_wpa3() then
 		return false
 	end
 
-	uci:foreach('wireless', 'wifi-device', function()
-		local phypath = '/sys/kernel/debug/ieee80211/phy' .. idx .. '/'
+	uci:foreach('wireless', 'wifi-device', function(radio)
+		local phy = util.find_phy(radio)
+		local phypath = '/sys/kernel/debug/ieee80211/' .. phy .. '/'
 
 		if not util.file_contains_line(phypath .. 'hwflags', 'MFP_CAPABLE') then
 			supports_mfp = false
+			return false
 		end
-
-		idx = idx + 1
 	end)
 
 	return supports_mfp
-- 
GitLab