mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-11-16 08:44:38 +08:00
Move inquiry response TX power reading to hciops
This commit is contained in:
parent
c0af129926
commit
7dedff7168
@ -860,6 +860,25 @@ static int hciops_write_inq_mode(int index, uint8_t mode)
|
||||
return err;
|
||||
}
|
||||
|
||||
static int hciops_read_inq_tx_pwr(int index)
|
||||
{
|
||||
int dd, err;
|
||||
|
||||
dd = hci_open_dev(index);
|
||||
if (dd < 0)
|
||||
return -errno;
|
||||
|
||||
if (hci_send_cmd(dd, OGF_HOST_CTL,
|
||||
OCF_READ_INQ_RESPONSE_TX_POWER_LEVEL, 0, NULL) < 0)
|
||||
err = -errno;
|
||||
else
|
||||
err = 0;
|
||||
|
||||
hci_close_dev(dd);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static struct btd_adapter_ops hci_ops = {
|
||||
.setup = hciops_setup,
|
||||
.cleanup = hciops_cleanup,
|
||||
@ -883,6 +902,7 @@ static struct btd_adapter_ops hci_ops = {
|
||||
.read_bdaddr = hciops_read_bdaddr,
|
||||
.set_event_mask = hciops_set_event_mask,
|
||||
.write_inq_mode = hciops_write_inq_mode,
|
||||
.read_inq_tx_pwr = hciops_read_inq_tx_pwr,
|
||||
};
|
||||
|
||||
static int hciops_init(void)
|
||||
|
@ -1916,18 +1916,10 @@ static int adapter_setup(struct btd_adapter *adapter, const char *mode)
|
||||
struct hci_dev *dev = &adapter->dev;
|
||||
uint8_t events[8] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00 };
|
||||
uint8_t inqmode;
|
||||
int err , dd;
|
||||
int err;
|
||||
char name[MAX_NAME_LENGTH + 1];
|
||||
uint8_t cls[3];
|
||||
|
||||
dd = hci_open_dev(adapter->dev_id);
|
||||
if (dd < 0) {
|
||||
err = -errno;
|
||||
error("Can't open device hci%d: %s (%d)", adapter->dev_id,
|
||||
strerror(errno), errno);
|
||||
return err;
|
||||
}
|
||||
|
||||
if (dev->lmp_ver > 1) {
|
||||
if (dev->features[5] & LMP_SNIFF_SUBR)
|
||||
events[5] |= 0x20;
|
||||
@ -1963,19 +1955,17 @@ static int adapter_setup(struct btd_adapter *adapter, const char *mode)
|
||||
|
||||
inqmode = get_inquiry_mode(dev);
|
||||
if (inqmode < 1)
|
||||
goto done;
|
||||
return 0;
|
||||
|
||||
err = adapter_ops->write_inq_mode(adapter->dev_id, inqmode);
|
||||
if (err < 0) {
|
||||
error("Can't write inquiry mode for %s: %s (%d)",
|
||||
adapter->path, strerror(-err), -err);
|
||||
hci_close_dev(dd);
|
||||
return err;
|
||||
}
|
||||
|
||||
if (dev->features[7] & LMP_INQ_TX_PWR)
|
||||
hci_send_cmd(dd, OGF_HOST_CTL,
|
||||
OCF_READ_INQ_RESPONSE_TX_POWER_LEVEL, 0, NULL);
|
||||
adapter_ops->read_inq_tx_pwr(adapter->dev_id);
|
||||
|
||||
if (read_local_name(&adapter->bdaddr, name) < 0)
|
||||
expand_name(name, MAX_NAME_LENGTH, main_opts.name,
|
||||
@ -1994,12 +1984,11 @@ static int adapter_setup(struct btd_adapter *adapter, const char *mode)
|
||||
if (class)
|
||||
memcpy(cls, &class, 3);
|
||||
else
|
||||
goto done;
|
||||
return 0;
|
||||
}
|
||||
|
||||
btd_adapter_set_class(adapter, cls[1], cls[0]);
|
||||
done:
|
||||
hci_close_dev(dd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -194,6 +194,7 @@ struct btd_adapter_ops {
|
||||
int (*read_bdaddr) (int index, bdaddr_t *bdaddr);
|
||||
int (*set_event_mask) (int index, uint8_t *events, size_t count);
|
||||
int (*write_inq_mode) (int index, uint8_t mode);
|
||||
int (*read_inq_tx_pwr) (int index);
|
||||
};
|
||||
|
||||
int btd_register_adapter_ops(struct btd_adapter_ops *btd_adapter_ops);
|
||||
|
Loading…
Reference in New Issue
Block a user