linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kalle Valo <kvalo@kernel.org>
To: Ping-Ke Shih <pkshih@realtek.com>
Cc: <linux-wireless@vger.kernel.org>
Subject: Re: [PATCH] wifi: rtw89: add counters of register-based H2C/C2H
Date: Wed, 15 Mar 2023 11:52:22 +0200	[thread overview]
Message-ID: <87r0tqmje1.fsf@kernel.org> (raw)
In-Reply-To: <20230310035943.49020-1-pkshih@realtek.com> (Ping-Ke Shih's message of "Fri, 10 Mar 2023 11:59:43 +0800")

Ping-Ke Shih <pkshih@realtek.com> writes:

> The register-based H2C/C2H are used to exchange information between driver
> and firmware, but only apply to narrow area because its data size is
> smaller than regular packet-based H2C/C2H.
>
> This kind of H2C/C2H must be paired. To identify if any H2C/C2H is missing,
> update counters to help diagnose this kind of problems.
>
> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>

[...]

> +static inline void
> +rtw89_write8_mask_add(struct rtw89_dev *rtwdev, u32 addr, u32 mask, u8 add)
> +{
> +	u32 shift;
> +	u8 orig, set;
> +	u8 data;
> +
> +	mask &= 0xff;
> +	shift = __ffs(mask);
> +
> +	orig = rtw89_read8(rtwdev, addr);
> +	data = ((orig & mask) >> shift) + add;
> +	set = (orig & ~mask) | ((data << shift) & mask);
> +	rtw89_write8(rtwdev, addr, set);
> +}

This function has a lot of shifting etc which feels like reinventing the
wheel, doesn't linux/bitfield.h contain what you need? For example,
u32_get_bits() and u32_replace_bits()?

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

  reply	other threads:[~2023-03-15  9:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-10  3:59 [PATCH] wifi: rtw89: add counters of register-based H2C/C2H Ping-Ke Shih
2023-03-15  9:52 ` Kalle Valo [this message]
2023-03-15 11:56   ` Ping-Ke Shih
2023-03-17  7:17     ` Kalle Valo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r0tqmje1.fsf@kernel.org \
    --to=kvalo@kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=pkshih@realtek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).