drivers: bluetooth: fix and clean up BlueNRG HCI setup() function

If no public address was set, it should just do nothing instead of
erroring. The function should also be static and there's no need to copy
the address struct.

Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
This commit is contained in:
Armin Brauns 2023-11-30 15:26:44 +00:00 committed by Johan Hedberg
commit 281f27ec38

View file

@ -243,22 +243,20 @@ static int bt_spi_send_aci_config(uint8_t offset, const uint8_t *value, size_t v
return bt_hci_cmd_send(BLUENRG_ACI_WRITE_CONFIG_DATA, buf); return bt_hci_cmd_send(BLUENRG_ACI_WRITE_CONFIG_DATA, buf);
} }
int bt_spi_bluenrg_setup(const struct bt_hci_setup_params *params) static int bt_spi_bluenrg_setup(const struct bt_hci_setup_params *params)
{ {
int ret; int ret;
const bt_addr_t addr = params->public_addr; const bt_addr_t *addr = &params->public_addr;
if (bt_addr_eq(&addr, BT_ADDR_NONE) || bt_addr_eq(&addr, BT_ADDR_ANY)) { if (!bt_addr_eq(addr, BT_ADDR_NONE) && !bt_addr_eq(addr, BT_ADDR_ANY)) {
return -EINVAL; ret = bt_spi_send_aci_config(
} BLUENRG_CONFIG_PUBADDR_OFFSET,
addr->val, sizeof(addr->val));
ret = bt_spi_send_aci_config( if (ret != 0) {
BLUENRG_CONFIG_PUBADDR_OFFSET, LOG_ERR("Failed to set BlueNRG public address (%d)", ret);
addr.val, sizeof(addr.val)); return ret;
}
if (ret != 0) {
LOG_ERR("Failed to set BlueNRG public address (%d)", ret);
return ret;
} }
return 0; return 0;