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:
parent
ede9b0337c
commit
281f27ec38
1 changed files with 10 additions and 12 deletions
|
@ -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 = ¶ms->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;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue