gluon-core: primary-mac: load board.json only once

This commit is contained in:
Matthias Schiffer 2020-05-04 23:49:18 +02:00
parent c90b400ce5
commit 0c5b5373bb
No known key found for this signature in database
GPG Key ID: 16EF3F64CB201D9C

View File

@ -12,6 +12,8 @@ local json = require 'jsonc'
local platform = require 'gluon.platform' local platform = require 'gluon.platform'
local util = require 'gluon.util' local util = require 'gluon.util'
local board_data = json.load('/etc/board.json')
local network_data = (board_data or {}).network
local function sysfs(...) local function sysfs(...)
local path = string.format(...) local path = string.format(...)
@ -33,9 +35,9 @@ end
local function board(iface) local function board(iface)
return function() return function()
local data = json.load('/etc/board.json') local ifdata = network_data[iface] or {}
if data and data.network and data.network[iface] then if ifdata.macaddr then
return data.network[iface].macaddr return ifdata.macaddr
end end
end end
end end