sunxi: board: extract creating a unique sid into a helper function
Refactor setup_environment() so we can use the created sid for a Bluetooth address too. Signed-off-by: Andre Heider <a.heider@gmail.com> Acked-by: Maxime Ripard <mripard@kernel.org> Reviewed-by: Andre Przywara <andre.przywara@arm.com> [rebased] Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
This commit is contained in:
parent
ec9cdaaa13
commit
928f4f4868
@ -789,20 +789,14 @@ static void parse_spl_header(const uint32_t spl_addr)
|
||||
env_set_hex("fel_scriptaddr", spl->fel_script_address);
|
||||
}
|
||||
|
||||
/*
|
||||
* Note this function gets called multiple times.
|
||||
* It must not make any changes to env variables which already exist.
|
||||
*/
|
||||
static void setup_environment(const void *fdt)
|
||||
static bool get_unique_sid(unsigned int *sid)
|
||||
{
|
||||
char serial_string[17] = { 0 };
|
||||
unsigned int sid[4];
|
||||
uint8_t mac_addr[6];
|
||||
char ethaddr[16];
|
||||
int i, ret;
|
||||
if (sunxi_get_sid(sid) != 0)
|
||||
return false;
|
||||
|
||||
if (!sid[0])
|
||||
return false;
|
||||
|
||||
ret = sunxi_get_sid(sid);
|
||||
if (ret == 0 && sid[0] != 0) {
|
||||
/*
|
||||
* The single words 1 - 3 of the SID have quite a few bits
|
||||
* which are the same on many models, so we take a crc32
|
||||
@ -824,6 +818,24 @@ static void setup_environment(const void *fdt)
|
||||
if ((sid[3] & 0xffffff) == 0)
|
||||
sid[3] |= 0x800000;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Note this function gets called multiple times.
|
||||
* It must not make any changes to env variables which already exist.
|
||||
*/
|
||||
static void setup_environment(const void *fdt)
|
||||
{
|
||||
char serial_string[17] = { 0 };
|
||||
unsigned int sid[4];
|
||||
uint8_t mac_addr[6];
|
||||
char ethaddr[16];
|
||||
int i;
|
||||
|
||||
if (!get_unique_sid(sid))
|
||||
return;
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
sprintf(ethaddr, "ethernet%d", i);
|
||||
if (!fdt_get_alias(fdt, ethaddr))
|
||||
@ -854,7 +866,6 @@ static void setup_environment(const void *fdt)
|
||||
|
||||
env_set("serial#", serial_string);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int misc_init_r(void)
|
||||
|
Loading…
Reference in New Issue
Block a user