linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/2] Bluetooth: HCI: Fix definition of hci_rp_read_stored_link_key
@ 2021-11-25  0:16 Luiz Augusto von Dentz
  2021-11-25  0:16 ` [PATCH v2 2/2] Bluetooth: HCI: Fix definition of hci_rp_delete_stored_link_key Luiz Augusto von Dentz
  2021-11-25 20:06 ` [PATCH v2 1/2] Bluetooth: HCI: Fix definition of hci_rp_read_stored_link_key Marcel Holtmann
  0 siblings, 2 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2021-11-25  0:16 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

Both max_num_keys and num_key are 2 octects:

BLUETOOTH CORE SPECIFICATION Version 5.3 | Vol 4, Part E
page 1985:

  Max_Num_Keys:
  Size: 2 octets
  Range: 0x0000 to 0xFFFF

  Num_Keys_Read:
  Size: 2 octets
  Range: 0x0000 to 0xFFFF

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
v2: Use __le16 instead of __u16 in hci_rp_read_stored_link_key and update
fields in hci_dev to properly store 2 octects. Also add a patch for
hci_rp_delete_stored_link_key since num_keys is also 2 octecs like
hci_rp_read_stored_link_key.

 include/net/bluetooth/hci.h      | 4 ++--
 include/net/bluetooth/hci_core.h | 4 ++--
 net/bluetooth/hci_event.c        | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 84db6b275231..3c5211c3a790 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -1047,8 +1047,8 @@ struct hci_cp_read_stored_link_key {
 } __packed;
 struct hci_rp_read_stored_link_key {
 	__u8     status;
-	__u8     max_keys;
-	__u8     num_keys;
+	__le16    max_keys;
+	__le16    num_keys;
 } __packed;
 
 #define HCI_OP_DELETE_STORED_LINK_KEY	0x0c12
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 2560cfe80db8..bb07a6d0d597 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -352,8 +352,8 @@ struct hci_dev {
 	__u16		lmp_subver;
 	__u16		voice_setting;
 	__u8		num_iac;
-	__u8		stored_max_keys;
-	__u8		stored_num_keys;
+	__u16		stored_max_keys;
+	__u16		stored_num_keys;
 	__u8		io_capability;
 	__s8		inq_tx_power;
 	__u8		err_data_reporting;
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index efc5458b1345..7452de6895fc 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -256,8 +256,8 @@ static void hci_cc_read_stored_link_key(struct hci_dev *hdev,
 		return;
 
 	if (!rp->status && sent->read_all == 0x01) {
-		hdev->stored_max_keys = rp->max_keys;
-		hdev->stored_num_keys = rp->num_keys;
+		hdev->stored_max_keys = le16_to_cpu(rp->max_keys);
+		hdev->stored_num_keys = le16_to_cpu(rp->num_keys);
 	}
 }
 
-- 
2.33.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] Bluetooth: HCI: Fix definition of hci_rp_delete_stored_link_key
  2021-11-25  0:16 [PATCH v2 1/2] Bluetooth: HCI: Fix definition of hci_rp_read_stored_link_key Luiz Augusto von Dentz
@ 2021-11-25  0:16 ` Luiz Augusto von Dentz
  2021-11-25 20:07   ` Marcel Holtmann
  2021-11-25 20:06 ` [PATCH v2 1/2] Bluetooth: HCI: Fix definition of hci_rp_read_stored_link_key Marcel Holtmann
  1 sibling, 1 reply; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2021-11-25  0:16 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

num_keys is actually 2 octects not 1:

BLUETOOTH CORE SPECIFICATION Version 5.3 | Vol 4, Part E
page 1989:

  Num_Keys_Deleted:
  Size: 2 octets
  0xXXXX	Number of Link Keys Deleted

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
 include/net/bluetooth/hci.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 3c5211c3a790..b557d86396d5 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -1058,7 +1058,7 @@ struct hci_cp_delete_stored_link_key {
 } __packed;
 struct hci_rp_delete_stored_link_key {
 	__u8     status;
-	__u8     num_keys;
+	__le16   num_keys;
 } __packed;
 
 #define HCI_MAX_NAME_LENGTH		248
-- 
2.33.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/2] Bluetooth: HCI: Fix definition of hci_rp_read_stored_link_key
  2021-11-25  0:16 [PATCH v2 1/2] Bluetooth: HCI: Fix definition of hci_rp_read_stored_link_key Luiz Augusto von Dentz
  2021-11-25  0:16 ` [PATCH v2 2/2] Bluetooth: HCI: Fix definition of hci_rp_delete_stored_link_key Luiz Augusto von Dentz
@ 2021-11-25 20:06 ` Marcel Holtmann
  1 sibling, 0 replies; 4+ messages in thread
From: Marcel Holtmann @ 2021-11-25 20:06 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hi Luiz,

> Both max_num_keys and num_key are 2 octects:
> 
> BLUETOOTH CORE SPECIFICATION Version 5.3 | Vol 4, Part E
> page 1985:
> 
>  Max_Num_Keys:
>  Size: 2 octets
>  Range: 0x0000 to 0xFFFF
> 
>  Num_Keys_Read:
>  Size: 2 octets
>  Range: 0x0000 to 0xFFFF
> 
> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> ---
> v2: Use __le16 instead of __u16 in hci_rp_read_stored_link_key and update
> fields in hci_dev to properly store 2 octects. Also add a patch for
> hci_rp_delete_stored_link_key since num_keys is also 2 octecs like
> hci_rp_read_stored_link_key.
> 
> include/net/bluetooth/hci.h      | 4 ++--
> include/net/bluetooth/hci_core.h | 4 ++--
> net/bluetooth/hci_event.c        | 4 ++--
> 3 files changed, 6 insertions(+), 6 deletions(-)

patch has been applied to bluetooth-next tree. However I had to fix some alignment issue.

Regards

Marcel


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 2/2] Bluetooth: HCI: Fix definition of hci_rp_delete_stored_link_key
  2021-11-25  0:16 ` [PATCH v2 2/2] Bluetooth: HCI: Fix definition of hci_rp_delete_stored_link_key Luiz Augusto von Dentz
@ 2021-11-25 20:07   ` Marcel Holtmann
  0 siblings, 0 replies; 4+ messages in thread
From: Marcel Holtmann @ 2021-11-25 20:07 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hi Luiz,

> num_keys is actually 2 octects not 1:
> 
> BLUETOOTH CORE SPECIFICATION Version 5.3 | Vol 4, Part E
> page 1989:
> 
>  Num_Keys_Deleted:
>  Size: 2 octets
>  0xXXXX	Number of Link Keys Deleted
> 
> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> ---
> include/net/bluetooth/hci.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)

patch has been applied to bluetooth-next tree. However I also had to fix the user of this struct.

Regards

Marcel


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-11-25 20:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-25  0:16 [PATCH v2 1/2] Bluetooth: HCI: Fix definition of hci_rp_read_stored_link_key Luiz Augusto von Dentz
2021-11-25  0:16 ` [PATCH v2 2/2] Bluetooth: HCI: Fix definition of hci_rp_delete_stored_link_key Luiz Augusto von Dentz
2021-11-25 20:07   ` Marcel Holtmann
2021-11-25 20:06 ` [PATCH v2 1/2] Bluetooth: HCI: Fix definition of hci_rp_read_stored_link_key Marcel Holtmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).