diff mbox series

[v3] Bluetooth: btusb: re-definition for board_id in struct qca_version

Message ID 305e41a55a4c117da86f786c374a57dc@codeaurora.org (mailing list archive)
State Superseded
Headers show
Series [v3] Bluetooth: btusb: re-definition for board_id in struct qca_version | expand

Commit Message

tjiang@codeaurora.org Nov. 4, 2021, 7:01 a.m. UTC
As qc btsoc will using big-endian for boardID, so align host with it.

Signed-off-by: Tim Jiang <tjiang@codeaurora.org>
---
  drivers/bluetooth/btusb.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

  		switch (le32_to_cpu(ver->ram_version)) {

Comments

Marcel Holtmann Nov. 9, 2021, 9:37 a.m. UTC | #1
Hi Tim,

> As qc btsoc will using big-endian for boardID, so align host with it.
> 
> Signed-off-by: Tim Jiang <tjiang@codeaurora.org>
> ---
> drivers/bluetooth/btusb.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
> index 46d892bbde62..a51b1d641043 100644
> --- a/drivers/bluetooth/btusb.c
> +++ b/drivers/bluetooth/btusb.c
> @@ -2883,7 +2883,7 @@ struct qca_version {
> 	__le32	rom_version;
> 	__le32	patch_version;
> 	__le32	ram_version;
> -	__le16	board_id;
> +	__u8	board_id[2];
> 	__le16	flag;
> 	__u8	reserved[4];
> } __packed;
> @@ -3072,7 +3072,7 @@ static void btusb_generate_qca_nvm_name(char *fwname, size_t max_size,
> 	u16 flag = le16_to_cpu(ver->flag);
> 
> 	if (((flag >> 8) & 0xff) == QCA_FLAG_MULTI_NVM) {
> -		u16 board_id = le16_to_cpu(ver->board_id);
> +		u16 board_id = (ver->board_id[0] << 8) + ver->board_id[1];
> 		const char *variant;
> 
> 		switch (le32_to_cpu(ver->ram_version)) {

explain to me why I would merge this. The commit message is sparse even after I asked to explain things.

I am also not merging this handwaving endian handling. Define it is be16 or le16 and clearly state what it is. If Qualcomm screwed up the memory layout of their NVM, then say that.

Regards

Marcel
tjiang@codeaurora.org Nov. 15, 2021, 10:04 a.m. UTC | #2
Hi Marcel:
   the following is the explanation from qc btsoc team:

The board ID should be split into two bytes.
The 1st byte is chip ID, and the 2nd byte is platform ID.
For example, board ID 0x010A, 0x01 is platform ID. 0x0A is chip ID.
Currently we have several platforms, and platform IDs are continuously 
added.
We would not distinguish different chips if we get these mixed up.
Platform ID:
•             0x00 is for Mobile
•             0x01 is for X86( ID # from 257)
•             0x02 is for Automotive(ID# from 513 )
•             0x03 is for Consumer electronic( ID# from 769)
…


regards.
tim



On 2021-11-09 17:37, Marcel Holtmann wrote:
> Hi Tim,
> 
>> As qc btsoc will using big-endian for boardID, so align host with it.
>> 
>> Signed-off-by: Tim Jiang <tjiang@codeaurora.org>
>> ---
>> drivers/bluetooth/btusb.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>> 
>> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
>> index 46d892bbde62..a51b1d641043 100644
>> --- a/drivers/bluetooth/btusb.c
>> +++ b/drivers/bluetooth/btusb.c
>> @@ -2883,7 +2883,7 @@ struct qca_version {
>> 	__le32	rom_version;
>> 	__le32	patch_version;
>> 	__le32	ram_version;
>> -	__le16	board_id;
>> +	__u8	board_id[2];
>> 	__le16	flag;
>> 	__u8	reserved[4];
>> } __packed;
>> @@ -3072,7 +3072,7 @@ static void btusb_generate_qca_nvm_name(char 
>> *fwname, size_t max_size,
>> 	u16 flag = le16_to_cpu(ver->flag);
>> 
>> 	if (((flag >> 8) & 0xff) == QCA_FLAG_MULTI_NVM) {
>> -		u16 board_id = le16_to_cpu(ver->board_id);
>> +		u16 board_id = (ver->board_id[0] << 8) + ver->board_id[1];
>> 		const char *variant;
>> 
>> 		switch (le32_to_cpu(ver->ram_version)) {
> 
> explain to me why I would merge this. The commit message is sparse
> even after I asked to explain things.
> 
> I am also not merging this handwaving endian handling. Define it is
> be16 or le16 and clearly state what it is. If Qualcomm screwed up the
> memory layout of their NVM, then say that.
> 
> Regards
> 
> Marcel
Marcel Holtmann Nov. 15, 2021, 5:30 p.m. UTC | #3
Hi Tim,

>  the following is the explanation from qc btsoc team:
> 
> The board ID should be split into two bytes.
> The 1st byte is chip ID, and the 2nd byte is platform ID.
> For example, board ID 0x010A, 0x01 is platform ID. 0x0A is chip ID.
> Currently we have several platforms, and platform IDs are continuously added.
> We would not distinguish different chips if we get these mixed up.
> Platform ID:
> •             0x00 is for Mobile
> •             0x01 is for X86( ID # from 257)
> •             0x02 is for Automotive(ID# from 513 )
> •             0x03 is for Consumer electronic( ID# from 769)
> …

then use u8 chip_id and u8 platform_id in the data structure and add description like above when you combine chip_id and platform_id into board_id.

Regards

Marcel
diff mbox series

Patch

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 46d892bbde62..a51b1d641043 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -2883,7 +2883,7 @@  struct qca_version {
  	__le32	rom_version;
  	__le32	patch_version;
  	__le32	ram_version;
-	__le16	board_id;
+	__u8	board_id[2];
  	__le16	flag;
  	__u8	reserved[4];
  } __packed;
@@ -3072,7 +3072,7 @@  static void btusb_generate_qca_nvm_name(char 
*fwname, size_t max_size,
  	u16 flag = le16_to_cpu(ver->flag);

  	if (((flag >> 8) & 0xff) == QCA_FLAG_MULTI_NVM) {
-		u16 board_id = le16_to_cpu(ver->board_id);
+		u16 board_id = (ver->board_id[0] << 8) + ver->board_id[1];
  		const char *variant;