Skip to content

Commit ffa88e0

Browse files
author
Gustavo Padovan
committed
Bluetooth: Move double negation to macros
Some comparisons needs to double negation(!!) in order to make the value of the field boolean. Add it to the macro makes the code more readable. Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
1 parent 20714bf commit ffa88e0

3 files changed

Lines changed: 10 additions & 10 deletions

File tree

‎include/net/bluetooth/hci_core.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ void hci_conn_del_sysfs(struct hci_conn *conn);
767767
#define lmp_sniffsubr_capable(dev) ((dev)->features[5] & LMP_SNIFF_SUBR)
768768
#define lmp_pause_enc_capable(dev) ((dev)->features[5] & LMP_PAUSE_ENC)
769769
#define lmp_ext_inq_capable(dev) ((dev)->features[6] & LMP_EXT_INQ)
770-
#define lmp_le_br_capable(dev) ((dev)->features[6] & LMP_SIMUL_LE_BR)
770+
#define lmp_le_br_capable(dev) !!((dev)->features[6] & LMP_SIMUL_LE_BR)
771771
#define lmp_ssp_capable(dev) ((dev)->features[6] & LMP_SIMPLE_PAIR)
772772
#define lmp_no_flush_capable(dev) ((dev)->features[6] & LMP_NO_FLUSH)
773773
#define lmp_lsto_capable(dev) ((dev)->features[7] & LMP_LSTO)
@@ -776,8 +776,8 @@ void hci_conn_del_sysfs(struct hci_conn *conn);
776776

777777
/* ----- Extended LMP capabilities ----- */
778778
#define lmp_host_ssp_capable(dev) ((dev)->host_features[0] & LMP_HOST_SSP)
779-
#define lmp_host_le_capable(dev) ((dev)->host_features[0] & LMP_HOST_LE)
780-
#define lmp_host_le_br_capable(dev) ((dev)->host_features[0] & LMP_HOST_LE_BREDR)
779+
#define lmp_host_le_capable(dev) !!((dev)->host_features[0] & LMP_HOST_LE)
780+
#define lmp_host_le_br_capable(dev) !!((dev)->host_features[0] & LMP_HOST_LE_BREDR)
781781

782782
/* ----- HCI protocols ----- */
783783
#define HCI_PROTO_DEFER 0x01

‎net/bluetooth/hci_event.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -794,10 +794,10 @@ static void hci_set_le_support(struct hci_dev *hdev)
794794

795795
if (test_bit(HCI_LE_ENABLED, &hdev->dev_flags)) {
796796
cp.le = 1;
797-
cp.simul = !!lmp_le_br_capable(hdev);
797+
cp.simul = lmp_le_br_capable(hdev);
798798
}
799799

800-
if (cp.le != !!lmp_host_le_capable(hdev))
800+
if (cp.le != lmp_host_le_capable(hdev))
801801
hci_send_cmd(hdev, HCI_OP_WRITE_LE_HOST_SUPPORTED, sizeof(cp),
802802
&cp);
803803
}

‎net/bluetooth/mgmt.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,7 +1225,7 @@ static int set_le(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
12251225
}
12261226

12271227
val = !!cp->val;
1228-
enabled = !!lmp_host_le_capable(hdev);
1228+
enabled = lmp_host_le_capable(hdev);
12291229

12301230
if (!hdev_is_powered(hdev) || val == enabled) {
12311231
bool changed = false;
@@ -1261,7 +1261,7 @@ static int set_le(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
12611261

12621262
if (val) {
12631263
hci_cp.le = val;
1264-
hci_cp.simul = !!lmp_le_br_capable(hdev);
1264+
hci_cp.simul = lmp_le_br_capable(hdev);
12651265
}
12661266

12671267
err = hci_send_cmd(hdev, HCI_OP_WRITE_LE_HOST_SUPPORTED, sizeof(hci_cp),
@@ -2924,13 +2924,13 @@ int mgmt_powered(struct hci_dev *hdev, u8 powered)
29242924
struct hci_cp_write_le_host_supported cp;
29252925

29262926
cp.le = 1;
2927-
cp.simul = !!lmp_le_br_capable(hdev);
2927+
cp.simul = lmp_le_br_capable(hdev);
29282928

29292929
/* Check first if we already have the right
29302930
* host state (host features set)
29312931
*/
2932-
if (cp.le != !!lmp_host_le_capable(hdev) ||
2933-
cp.simul != !!lmp_host_le_br_capable(hdev))
2932+
if (cp.le != lmp_host_le_capable(hdev) ||
2933+
cp.simul != lmp_host_le_br_capable(hdev))
29342934
hci_send_cmd(hdev,
29352935
HCI_OP_WRITE_LE_HOST_SUPPORTED,
29362936
sizeof(cp), &cp);

0 commit comments

Comments
 (0)