Re: [PATCH v6 1/3] Bluetooth: btmtk: Replace magic numbers with WMT packet flag enum

From: Luiz Augusto von Dentz

Date: Tue Jun 30 2026 - 14:19:53 EST


Hi Chris,

On Tue, Jun 30, 2026 at 8:35 AM Chris Lu <chris.lu@xxxxxxxxxxxx> wrote:
>
> Add BTMTK_WMT_PKT_* enum to represent WMT download packet sequence flags,
> improving code readability. Replace magic numbers (1, 2, 3) in
> btmtk_setup_firmware_79xx() with descriptive enum values:
>
> - BTMTK_WMT_PKT_START (1): First packet of a sequence
> - BTMTK_WMT_PKT_CONTINUE (2): Continuation packet
> - BTMTK_WMT_PKT_END (3): Final packet of a sequence
>
> Signed-off-by: Chris Lu <chris.lu@xxxxxxxxxxxx>
> Reviewed-by: Paul Menzel <pmenzel@xxxxxxxxxxxxx>
> ---
> drivers/bluetooth/btmtk.c | 6 +++---
> drivers/bluetooth/btmtk.h | 6 ++++++
> 2 files changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/bluetooth/btmtk.c b/drivers/bluetooth/btmtk.c
> index 02a96342e964..21c08ee1cdbf 100644
> --- a/drivers/bluetooth/btmtk.c
> +++ b/drivers/bluetooth/btmtk.c
> @@ -230,12 +230,12 @@ int btmtk_setup_firmware_79xx(struct hci_dev *hdev, const char *fwname,
> while (dl_size > 0) {
> dlen = min_t(int, 250, dl_size);
> if (first_block == 1) {
> - flag = 1;
> + flag = BTMTK_WMT_PKT_START;
> first_block = 0;
> } else if (dl_size - dlen <= 0) {
> - flag = 3;
> + flag = BTMTK_WMT_PKT_END;
> } else {
> - flag = 2;
> + flag = BTMTK_WMT_PKT_CONTINUE;
> }
>
> wmt_params.flag = flag;
> diff --git a/drivers/bluetooth/btmtk.h b/drivers/bluetooth/btmtk.h
> index c83c24897c95..51c18dde0a80 100644
> --- a/drivers/bluetooth/btmtk.h
> +++ b/drivers/bluetooth/btmtk.h
> @@ -66,6 +66,12 @@ enum {
> BTMTK_WMT_ON_PROGRESS,
> };
>
> +enum {
> + BTMTK_WMT_PKT_START = 1,
> + BTMTK_WMT_PKT_CONTINUE = 2,
> + BTMTK_WMT_PKT_END = 3,
> +};
> +
> struct btmtk_wmt_hdr {
> u8 dir;
> u8 op;
> --
> 2.45.2

sashiko has quite a few comments for these changes:

https://sashiko.dev/#/patchset/20260630123539.668776-1-chris.lu%40mediatek.com

--
Luiz Augusto von Dentz