Skip to content

Commit aacbfc0

Browse files
svenpeter42marcan
authored andcommitted
kboot: swap BD address
Unlike the MAC addresses Bluetooth addresses have to be stored in little-endian byte order (see devicetree/bindings/net/bluetooth.txt) Signed-off-by: Sven Peter <[email protected]>
1 parent 94a1158 commit aacbfc0

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/kboot.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,10 +500,12 @@ static int dt_set_cpus(void)
500500
static struct {
501501
const char *alias;
502502
const char *fdt_property;
503+
bool swap;
503504
} mac_address_devices[] = {
504505
{
505506
.alias = "bluetooth0",
506507
.fdt_property = "local-bd-address",
508+
.swap = true,
507509
},
508510
{
509511
.alias = "ethernet0",
@@ -530,6 +532,14 @@ static int dt_set_mac_addresses(void)
530532
if (ADT_GETPROP_ARRAY(adt, anode, propname, addr) < 0)
531533
continue;
532534

535+
if (mac_address_devices[i].swap) {
536+
for (size_t i = 0; i < sizeof(addr) / 2; ++i) {
537+
uint8_t tmp = addr[i];
538+
addr[i] = addr[sizeof(addr) - i - 1];
539+
addr[sizeof(addr) - i - 1] = tmp;
540+
}
541+
}
542+
533543
const char *path = fdt_get_alias(dt, mac_address_devices[i].alias);
534544
if (path == NULL)
535545
continue;

0 commit comments

Comments
 (0)