All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ping-Ke Shih <pkshih@realtek.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: "linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>
Subject: RE: [PATCH rtw-next 2/2] wifi: rtw89: avoid to use not consecutive mask in __write_ctrl()
Date: Wed, 19 Nov 2025 01:15:50 +0000	[thread overview]
Message-ID: <c19306a1d41f4946801cf1c5b70c8528@realtek.com> (raw)
In-Reply-To: <CAMuHMdUx6qY66bCcGsm1YHK3=H+=Td6YM_gsXJ=UgjAYJpGo0Q@mail.gmail.com>

Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> Hi Ping-Ke,
> 
> On Mon, 17 Nov 2025 at 04:30, Ping-Ke Shih <pkshih@realtek.com> wrote:
> > The power value and enable bit fields can be not consecutive mask, but
> > normally we expect mask argument of rtw89_mac_txpwr_write32_mask() is
> > consecutive bit mask. Therefore, change the code accordingly.
> >
> > Cc: Geert Uytterhoeven <geert@linux-m68k.org>
> > Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
> 
> Thanks for your patch!
> 
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
> 
> > --- a/drivers/net/wireless/realtek/rtw89/mac.h
> > +++ b/drivers/net/wireless/realtek/rtw89/mac.h
> > @@ -1456,6 +1456,26 @@ static inline int rtw89_mac_txpwr_write32_mask(struct rtw89_dev *rtwdev,
> >         return 0;
> >  }
> >
> > +static inline
> > +void rtw89_mac_write_txpwr_ctrl(struct rtw89_dev *rtwdev, u32 reg, u32 mask, u32 val,
> > +                               u32 mask_en, bool cond)
> > +{
> > +       u32 wrt = u32_encode_bits(val, mask);
> 
> Nit: you could do without this variable...
> 
> > +       u32 val32;
> > +       int ret;
> > +
> > +       if (cond)
> > +               wrt |= mask_en;
> > +
> > +       ret = rtw89_mac_txpwr_read32(rtwdev, RTW89_PHY_0, reg, &val32);
> > +       if (ret)
> > +               return;
> > +
> > +       val32 &= ~(mask | mask_en);
> > +       val32 |= wrt;
> 
> val32 |= u32_encode_bits(val, mask);
> if (cond)
>         cal32 |= mask_en;

With this change, ARCH arm is failed to build (x86 is well):

In file included from /build/rtw89/core.h:9,
                 from /build/rtw89/coex.h:8,
                 from /build/rtw89/rtw8851b.c:5:
In function 'field_multiplier',
    inlined from 'field_mask' at ./include/linux/bitfield.h:170:17,
    inlined from 'u32_encode_bits' at ./include/linux/bitfield.h:200:1,
    inlined from 'rtw89_mac_write_txpwr_ctrl' at /build/rtw89/mac.h:1468:11:
./include/linux/bitfield.h:165:17: error: call to '__bad_mask' declared with attribute error: bad bitfield mask
  165 |                 __bad_mask();
      |                 ^~~~~~~~~~~~
In function 'field_multiplier',

> 
> > +       rtw89_mac_txpwr_write32(rtwdev, RTW89_PHY_0, reg, val32);
> 
> As this calls mac->get_txpwr_cr() a second time, perhaps it is better to
> open-code rtw89_mac_txpwr_read32() and rtw89_mac_txpwr_write32()
> in this function?

This function isn't in hot path, and using rtw89_mac_txpwr_read32() and
rtw89_mac_txpwr_write32() is clearer than open-code, so I'd keep it as was.

Then I don't plan to send v2. 



  reply	other threads:[~2025-11-19  1:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-17  3:29 [PATCH rtw-next 0/2] wifi: rtw89: adjust code to fit coming field_prep() Ping-Ke Shih
2025-11-17  3:29 ` [PATCH rtw-next 1/2] wifi: rtw89: 8852a: correct field mask of reset DAC/ADC FIFO Ping-Ke Shih
2025-11-18 10:24   ` Geert Uytterhoeven
2025-11-19  0:44     ` Ping-Ke Shih
2025-11-19  8:35       ` Geert Uytterhoeven
2025-11-17  3:29 ` [PATCH rtw-next 2/2] wifi: rtw89: avoid to use not consecutive mask in __write_ctrl() Ping-Ke Shih
2025-11-18 10:40   ` Geert Uytterhoeven
2025-11-19  1:15     ` Ping-Ke Shih [this message]
2025-11-19  8:38       ` Geert Uytterhoeven
2025-11-19  8:53         ` Ping-Ke Shih
2025-12-12  2:09           ` Ping-Ke Shih

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=c19306a1d41f4946801cf1c5b70c8528@realtek.com \
    --to=pkshih@realtek.com \
    --cc=geert@linux-m68k.org \
    --cc=linux-wireless@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.