diff mbox series

[4/4] Bluetooth: btintel: Add helper function to help controller type

Message ID 20200611114526.13594-5-kiran.k@intel.com (mailing list archive)
State New, archived
Headers show
Series Add support for new generation Intel controllers | expand

Commit Message

K, Kiran June 11, 2020, 11:45 a.m. UTC
From: Raghuram Hegde <raghuram.hegde@intel.com>

As the firmware download flow for new generation controller changes
from legacy controller, this function helps in deciding the download
flow to be used

Signed-off-by: Raghuram Hegde <raghuram.hegde@intel.com>
Signed-off-by: Chethan T N <chethan.tumkur.narayan@intel.com>
Signed-off-by: Kiran K <kiran.k@intel.com>
Signed-off-by: Amit K Bag <amit.k.bag@intel.com>
---
 drivers/bluetooth/btintel.c | 51 +++++++++++++++++++++++++++++++++++++
 drivers/bluetooth/btintel.h |  3 +++
 2 files changed, 54 insertions(+)

Comments

kernel test robot June 12, 2020, 11:26 a.m. UTC | #1
Hi Kiran,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on bluetooth-next/master]
[also build test WARNING on next-20200611]
[cannot apply to bluetooth/master v5.7]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Kiran-K/Add-support-for-new-generation-Intel-controllers/20200611-194619
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git master
config: nds32-randconfig-r014-20200612 (attached as .config)
compiler: nds32le-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=nds32 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>, old ones prefixed by <<):

In file included from ./arch/nds32/include/generated/asm/bug.h:1,
from include/linux/bug.h:5,
from include/linux/thread_info.h:12,
from include/asm-generic/preempt.h:5,
from ./arch/nds32/include/generated/asm/preempt.h:1,
from include/linux/preempt.h:78,
from include/linux/spinlock.h:51,
from include/linux/seqlock.h:36,
from include/linux/time.h:6,
from include/linux/stat.h:19,
from include/linux/module.h:13,
from drivers/bluetooth/btintel.c:9:
include/linux/dma-mapping.h: In function 'dma_map_resource':
arch/nds32/include/asm/memory.h:82:32: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]
82 | #define pfn_valid(pfn)  ((pfn) >= PHYS_PFN_OFFSET && (pfn) < (PHYS_PFN_OFFSET + max_mapnr))
|                                ^~
include/asm-generic/bug.h:139:27: note: in definition of macro 'WARN_ON_ONCE'
139 |  int __ret_warn_once = !!(condition);            |                           ^~~~~~~~~
include/linux/dma-mapping.h:352:19: note: in expansion of macro 'pfn_valid'
352 |  if (WARN_ON_ONCE(pfn_valid(PHYS_PFN(phys_addr))))
|                   ^~~~~~~~~
drivers/bluetooth/btintel.c: At top level:
drivers/bluetooth/btintel.c:229:6: warning: no previous prototype for 'btintel_boot_info' [-Wmissing-prototypes]
229 | void btintel_boot_info(struct hci_dev *hdev,
|      ^~~~~~~~~~~~~~~~~
drivers/bluetooth/btintel.c:252:6: warning: no previous prototype for 'btintel_boot_info_tlv' [-Wmissing-prototypes]
252 | void btintel_boot_info_tlv(struct hci_dev *hdev,
|      ^~~~~~~~~~~~~~~~~~~~~
drivers/bluetooth/btintel.c:385:6: warning: no previous prototype for 'btintel_get_fw_name' [-Wmissing-prototypes]
385 | bool btintel_get_fw_name(struct intel_version *ver,
|      ^~~~~~~~~~~~~~~~~~~
drivers/bluetooth/btintel.c:439:6: warning: no previous prototype for 'btintel_get_fw_name_tlv' [-Wmissing-prototypes]
439 | void btintel_get_fw_name_tlv(struct intel_version_tlv *ver,
|      ^~~~~~~~~~~~~~~~~~~~~~~
<<                  from drivers/bluetooth/btintel.c:9:
>> drivers/bluetooth/btintel.c:485:5: warning: no previous prototype for 'btintel_read_version_tlv' [-Wmissing-prototypes]
485 | int btintel_read_version_tlv(struct hci_dev *hdev, bool *is_tlv_format,
|     ^~~~~~~~~~~~~~~~~~~~~~~~

vim +/btintel_read_version_tlv +485 drivers/bluetooth/btintel.c

   484	
 > 485	int btintel_read_version_tlv(struct hci_dev *hdev, bool *is_tlv_format,
   486				     struct sk_buff **skb_out)
   487	{
   488		u8 param;
   489		u8 status;
   490		u8 tlv_check_octet;
   491		u8 *data;
   492		struct sk_buff *skb;
   493	
   494		param = 0xFF;
   495		skb_out = NULL;
   496	
   497		skb = __hci_cmd_sync(hdev,  0xfc05, 1, &param, HCI_CMD_TIMEOUT);
   498		if (IS_ERR(skb)) {
   499			bt_dev_err(hdev, "Intel read version command failed (%ld)",
   500				   PTR_ERR(skb));
   501			return PTR_ERR(skb);
   502		}
   503	
   504		/* Check status */
   505		data = skb->data;
   506		status = *data;
   507		if (status) {
   508			bt_dev_err(hdev, "Intel Read Version failed (%02x)",
   509				   status);
   510			kfree_skb(skb);
   511			return -bt_to_errno(status);
   512		}
   513	
   514		/* There are two variants of HCI_Intel_Read_Version_Command_Complete
   515		 * depending on SKU type (legacy and TLV format).If the skb->len
   516		 * parameter is equal to INTEL_VERSION_LEN  and the first octet
   517		 * after the status parameter is 0x37 then it's the legacy format,
   518		 * otherwise it's TLV format
   519		 */
   520	
   521		/* Fetch the octet after status */
   522		tlv_check_octet = *(data + 1);
   523	
   524		if (skb->len == INTEL_VERSION_LEN && tlv_check_octet == 0x37) {
   525			bt_dev_dbg(hdev, "Using Legacy Intel Version command");
   526			*is_tlv_format = false;
   527		} else {
   528			bt_dev_dbg(hdev, "Using TLV format Version command");
   529			*is_tlv_format = true;
   530		}
   531		*skb_out = skb;
   532		return 0;
   533	}
   534	EXPORT_SYMBOL_GPL(btintel_read_version_tlv);
   535	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c
index ae60527e1abd..93a0e5a2e927 100644
--- a/drivers/bluetooth/btintel.c
+++ b/drivers/bluetooth/btintel.c
@@ -482,6 +482,57 @@  int btintel_read_version(struct hci_dev *hdev, struct intel_version *ver)
 }
 EXPORT_SYMBOL_GPL(btintel_read_version);
 
+int btintel_read_version_tlv(struct hci_dev *hdev, bool *is_tlv_format,
+			     struct sk_buff **skb_out)
+{
+	u8 param;
+	u8 status;
+	u8 tlv_check_octet;
+	u8 *data;
+	struct sk_buff *skb;
+
+	param = 0xFF;
+	skb_out = NULL;
+
+	skb = __hci_cmd_sync(hdev,  0xfc05, 1, &param, HCI_CMD_TIMEOUT);
+	if (IS_ERR(skb)) {
+		bt_dev_err(hdev, "Intel read version command failed (%ld)",
+			   PTR_ERR(skb));
+		return PTR_ERR(skb);
+	}
+
+	/* Check status */
+	data = skb->data;
+	status = *data;
+	if (status) {
+		bt_dev_err(hdev, "Intel Read Version failed (%02x)",
+			   status);
+		kfree_skb(skb);
+		return -bt_to_errno(status);
+	}
+
+	/* There are two variants of HCI_Intel_Read_Version_Command_Complete
+	 * depending on SKU type (legacy and TLV format).If the skb->len
+	 * parameter is equal to INTEL_VERSION_LEN  and the first octet
+	 * after the status parameter is 0x37 then it's the legacy format,
+	 * otherwise it's TLV format
+	 */
+
+	/* Fetch the octet after status */
+	tlv_check_octet = *(data + 1);
+
+	if (skb->len == INTEL_VERSION_LEN && tlv_check_octet == 0x37) {
+		bt_dev_dbg(hdev, "Using Legacy Intel Version command");
+		*is_tlv_format = false;
+	} else {
+		bt_dev_dbg(hdev, "Using TLV format Version command");
+		*is_tlv_format = true;
+	}
+	*skb_out = skb;
+	return 0;
+}
+EXPORT_SYMBOL_GPL(btintel_read_version_tlv);
+
 /* ------- REGMAP IBT SUPPORT ------- */
 
 #define IBT_REG_MODE_8BIT  0x00
diff --git a/drivers/bluetooth/btintel.h b/drivers/bluetooth/btintel.h
index fa4b1b801b13..de2d104cb86d 100644
--- a/drivers/bluetooth/btintel.h
+++ b/drivers/bluetooth/btintel.h
@@ -6,6 +6,9 @@ 
  *  Copyright (C) 2015  Intel Corporation
  */
 
+/* Length of intel_version structure*/
+#define INTEL_VERSION_LEN	10
+
 struct intel_version {
 	u8 status;
 	u8 hw_platform;