diff mbox series

[v4,1/5] Bluetooth: btmtk: add the function to get the fw name

Message ID 965cd14922aea67e2750ff2c2ecad773f8ba485a.1715109394.git.sean.wang@kernel.org
State Superseded
Headers show
Series [v4,1/5] Bluetooth: btmtk: add the function to get the fw name | expand

Commit Message

Sean Wang May 7, 2024, 7:21 p.m. UTC
From: Sean Wang <sean.wang@mediatek.com>

Include a shared function to get the firmware name, to prevent repeating
code for similar chipsets.

Signed-off-by: Sean Wang <sean.wang@mediatek.com>
---
v3: first added to the series
v4: rebase onto the latest code and add an additional parameter
    fw_flavor into the function btmtk_fw_get_filename.
---
 drivers/bluetooth/btmtk.c | 18 ++++++++++++++++++
 drivers/bluetooth/btmtk.h |  8 ++++++++
 2 files changed, 26 insertions(+)

Comments

kernel test robot May 8, 2024, 7:12 a.m. UTC | #1
Hi,

kernel test robot noticed the following build warnings:

[auto build test WARNING on bluetooth/master]
[also build test WARNING on bluetooth-next/master linus/master v6.9-rc7 next-20240507]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/sean-wang-kernel-org/Bluetooth-btmtk-apply-the-common-btmtk_fw_get_filename/20240508-032333
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth.git master
patch link:    https://lore.kernel.org/r/965cd14922aea67e2750ff2c2ecad773f8ba485a.1715109394.git.sean.wang%40kernel.org
patch subject: [PATCH v4 1/5] Bluetooth: btmtk: add the function to get the fw name
config: arm64-defconfig (https://download.01.org/0day-ci/archive/20240508/202405081456.v2MvcQ0P-lkp@intel.com/config)
compiler: aarch64-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240508/202405081456.v2MvcQ0P-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202405081456.v2MvcQ0P-lkp@intel.com/

All warnings (new ones prefixed by >>):

   drivers/bluetooth/btmtk.c: In function 'btmtk_fw_get_filename':
>> drivers/bluetooth/btmtk.c:115:35: warning: 'mediatek/BT_RAM_CODE_MT' directive output truncated writing 23 bytes into a region of size 8 [-Wformat-truncation=]
     115 |                          "mediatek/BT_RAM_CODE_MT%04x_1a_%x_hdr.bin",
         |                           ~~~~~~~~^~~~~~~~~~~~~~~
   drivers/bluetooth/btmtk.c:115:26: note: directive argument in the range [1, 256]
     115 |                          "mediatek/BT_RAM_CODE_MT%04x_1a_%x_hdr.bin",
         |                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/bluetooth/btmtk.c:114:17: note: 'snprintf' output between 41 and 43 bytes into a destination of size 8
     114 |                 snprintf(buf, sizeof(size),
         |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~
     115 |                          "mediatek/BT_RAM_CODE_MT%04x_1a_%x_hdr.bin",
         |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     116 |                          dev_id & 0xffff, (fw_ver & 0xff) + 1);
         |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +115 drivers/bluetooth/btmtk.c

   105	
   106	void btmtk_fw_get_filename(char *buf, size_t size, u32 dev_id, u32 fw_ver,
   107				   u32 fw_flavor)
   108	{
   109		if (dev_id == 0x7925)
   110			snprintf(buf, size,
   111				 "mediatek/mt%04x/BT_RAM_CODE_MT%04x_1_%x_hdr.bin",
   112				 dev_id & 0xffff, dev_id & 0xffff, (fw_ver & 0xff) + 1);
   113		else if (dev_id == 0x7961 && fw_flavor)
   114			snprintf(buf, sizeof(size),
 > 115				 "mediatek/BT_RAM_CODE_MT%04x_1a_%x_hdr.bin",
   116				 dev_id & 0xffff, (fw_ver & 0xff) + 1);
   117		else
   118			snprintf(buf, size,
   119				 "mediatek/BT_RAM_CODE_MT%04x_1_%x_hdr.bin",
   120				 dev_id & 0xffff, (fw_ver & 0xff) + 1);
   121	}
   122	EXPORT_SYMBOL_GPL(btmtk_fw_get_filename);
   123
Sean Wang May 8, 2024, 8:38 p.m. UTC | #2
Hi,

On Wed, May 8, 2024 at 7:37 AM Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
>
> Hi Sean,
>
> On Wed, May 8, 2024 at 3:13 AM kernel test robot <lkp@intel.com> wrote:
> >
> > Hi,
> >
> > kernel test robot noticed the following build warnings:
> >
> > [auto build test WARNING on bluetooth/master]
> > [also build test WARNING on bluetooth-next/master linus/master v6.9-rc7 next-20240507]
> > [If your patch is applied to the wrong git tree, kindly drop us a note.
> > And when submitting patch, we suggest to use '--base' as documented in
> > https://git-scm.com/docs/git-format-patch#_base_tree_information]
> >
> > url:    https://github.com/intel-lab-lkp/linux/commits/sean-wang-kernel-org/Bluetooth-btmtk-apply-the-common-btmtk_fw_get_filename/20240508-032333
> > base:   https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth.git master
> > patch link:    https://lore.kernel.org/r/965cd14922aea67e2750ff2c2ecad773f8ba485a.1715109394.git.sean.wang%40kernel.org
> > patch subject: [PATCH v4 1/5] Bluetooth: btmtk: add the function to get the fw name
> > config: arm64-defconfig (https://download.01.org/0day-ci/archive/20240508/202405081456.v2MvcQ0P-lkp@intel.com/config)
> > compiler: aarch64-linux-gcc (GCC) 13.2.0
> > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240508/202405081456.v2MvcQ0P-lkp@intel.com/reproduce)
> >
> > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > the same patch/commit), kindly add following tags
> > | Reported-by: kernel test robot <lkp@intel.com>
> > | Closes: https://lore.kernel.org/oe-kbuild-all/202405081456.v2MvcQ0P-lkp@intel.com/
> >
> > All warnings (new ones prefixed by >>):
> >
> >    drivers/bluetooth/btmtk.c: In function 'btmtk_fw_get_filename':
> > >> drivers/bluetooth/btmtk.c:115:35: warning: 'mediatek/BT_RAM_CODE_MT' directive output truncated writing 23 bytes into a region of size 8 [-Wformat-truncation=]
> >      115 |                          "mediatek/BT_RAM_CODE_MT%04x_1a_%x_hdr.bin",
> >          |                           ~~~~~~~~^~~~~~~~~~~~~~~
> >    drivers/bluetooth/btmtk.c:115:26: note: directive argument in the range [1, 256]
> >      115 |                          "mediatek/BT_RAM_CODE_MT%04x_1a_%x_hdr.bin",
> >          |                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >    drivers/bluetooth/btmtk.c:114:17: note: 'snprintf' output between 41 and 43 bytes into a destination of size 8
> >      114 |                 snprintf(buf, sizeof(size),
> >          |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~
> >      115 |                          "mediatek/BT_RAM_CODE_MT%04x_1a_%x_hdr.bin",
> >          |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >      116 |                          dev_id & 0xffff, (fw_ver & 0xff) + 1);
> >          |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >
> >
> > vim +115 drivers/bluetooth/btmtk.c
> >
> >    105
> >    106  void btmtk_fw_get_filename(char *buf, size_t size, u32 dev_id, u32 fw_ver,
> >    107                             u32 fw_flavor)
> >    108  {
> >    109          if (dev_id == 0x7925)
> >    110                  snprintf(buf, size,
> >    111                           "mediatek/mt%04x/BT_RAM_CODE_MT%04x_1_%x_hdr.bin",
> >    112                           dev_id & 0xffff, dev_id & 0xffff, (fw_ver & 0xff) + 1);
> >    113          else if (dev_id == 0x7961 && fw_flavor)
> >    114                  snprintf(buf, sizeof(size),
> >  > 115                           "mediatek/BT_RAM_CODE_MT%04x_1a_%x_hdr.bin",
> >    116                           dev_id & 0xffff, (fw_ver & 0xff) + 1);
> >    117          else
> >    118                  snprintf(buf, size,
> >    119                           "mediatek/BT_RAM_CODE_MT%04x_1_%x_hdr.bin",
> >    120                           dev_id & 0xffff, (fw_ver & 0xff) + 1);
> >    121  }
> >    122  EXPORT_SYMBOL_GPL(btmtk_fw_get_filename);
> >    123
>
> Could you please fix the above?

No problem, I'll take care of it and send it over later.

                 Sean
>
> --
> Luiz Augusto von Dentz
diff mbox series

Patch

diff --git a/drivers/bluetooth/btmtk.c b/drivers/bluetooth/btmtk.c
index 812fd2a8f853..a0a858a0706d 100644
--- a/drivers/bluetooth/btmtk.c
+++ b/drivers/bluetooth/btmtk.c
@@ -103,6 +103,24 @@  static void btmtk_coredump_notify(struct hci_dev *hdev, int state)
 	}
 }
 
+void btmtk_fw_get_filename(char *buf, size_t size, u32 dev_id, u32 fw_ver,
+			   u32 fw_flavor)
+{
+	if (dev_id == 0x7925)
+		snprintf(buf, size,
+			 "mediatek/mt%04x/BT_RAM_CODE_MT%04x_1_%x_hdr.bin",
+			 dev_id & 0xffff, dev_id & 0xffff, (fw_ver & 0xff) + 1);
+	else if (dev_id == 0x7961 && fw_flavor)
+		snprintf(buf, sizeof(size),
+			 "mediatek/BT_RAM_CODE_MT%04x_1a_%x_hdr.bin",
+			 dev_id & 0xffff, (fw_ver & 0xff) + 1);
+	else
+		snprintf(buf, size,
+			 "mediatek/BT_RAM_CODE_MT%04x_1_%x_hdr.bin",
+			 dev_id & 0xffff, (fw_ver & 0xff) + 1);
+}
+EXPORT_SYMBOL_GPL(btmtk_fw_get_filename);
+
 int btmtk_setup_firmware_79xx(struct hci_dev *hdev, const char *fwname,
 			      wmt_cmd_sync_func_t wmt_cmd_sync)
 {
diff --git a/drivers/bluetooth/btmtk.h b/drivers/bluetooth/btmtk.h
index cbcdb99a22e6..e76b8a358be8 100644
--- a/drivers/bluetooth/btmtk.h
+++ b/drivers/bluetooth/btmtk.h
@@ -160,6 +160,9 @@  int btmtk_register_coredump(struct hci_dev *hdev, const char *name,
 			    u32 fw_version);
 
 int btmtk_process_coredump(struct hci_dev *hdev, struct sk_buff *skb);
+
+void btmtk_fw_get_filename(char *buf, size_t size, u32 dev_id, u32 fw_ver,
+			   u32 fw_flavor);
 #else
 
 static inline int btmtk_set_bdaddr(struct hci_dev *hdev,
@@ -194,4 +197,9 @@  static int btmtk_process_coredump(struct hci_dev *hdev, struct sk_buff *skb)
 {
 	return -EOPNOTSUPP;
 }
+
+static void btmtk_fw_get_filename(char *buf, size_t size, u32 dev_id,
+				  u32 fw_ver, u32 fw_flavor)
+{
+}
 #endif