Message ID | 1548937297-14660-25-git-send-email-yhchuang@realtek.com (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Kalle Valo |
Headers | show |
Series | rtw88: major fixes for 8822c to have stable functionalities | expand |
Hi, On Thu, Jan 31, 2019 at 08:21:37PM +0800, yhchuang@realtek.com wrote: > From: Yan-Hsuan Chuang <yhchuang@realtek.com> > > The inlined rtw_write32s_mask has to check range of addr with > BUILD_BUG_ON. But with some variants of gcc version the function might > not get inlined, and it will have no idea to know how to do, then > results in a compile error. Turn it into a macro to make sure the values > are known when compile time. > > Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> > --- > drivers/net/wireless/realtek/rtw88/rtw8822b.c | 10 ---------- > drivers/net/wireless/realtek/rtw88/rtw8822b.h | 15 +++++++++++++++ > 2 files changed, 15 insertions(+), 10 deletions(-) > ... > diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822b.h b/drivers/net/wireless/realtek/rtw88/rtw8822b.h > index 311fe8a..4cf193b1 100644 > --- a/drivers/net/wireless/realtek/rtw88/rtw8822b.h > +++ b/drivers/net/wireless/realtek/rtw88/rtw8822b.h > @@ -97,6 +97,21 @@ struct rtw8822b_efuse { > }; > }; > > +static inline void > +_rtw_write32s_mask(struct rtw_dev *rtwdev, u32 addr, u32 mask, u32 data) > +{ > + rtw_write32_mask(rtwdev, addr, mask, data); > + rtw_write32_mask(rtwdev, addr + 0x200, mask, data); > +} > + > +/* 0xC00-0xCFF and 0xE00-0xEFF have the same layout */ Feels like this belongs with _rtw_write32s_mask() now, not here? > +#define rtw_write32s_mask(rtwdev, addr, mask, data) \ > + do { \ > + BUILD_BUG_ON(addr < 0xC00 || addr >= 0xD00); \ You probably want parentheses around the 'addr'. You *probably* won't run into trouble with this particular macro, but if the caller is doing the wrong kinds of comparisons or arithmetic, this might not work they way you want. Brian > + \ > + _rtw_write32s_mask(rtwdev, addr, mask, data); \ > + } while (0) > + > /* phy status page0 */ > #define GET_PHY_STAT_P0_PWDB(phy_stat) \ > le32_get_bits(*((__le32 *)(phy_stat) + 0x00), GENMASK(15, 8)) > -- > 2.7.4 >
> From: Brian Norris [mailto:briannorris@chromium.org] > > Hi, > > > > > +static inline void > > +_rtw_write32s_mask(struct rtw_dev *rtwdev, u32 addr, u32 mask, u32 > data) > > +{ > > + rtw_write32_mask(rtwdev, addr, mask, data); > > + rtw_write32_mask(rtwdev, addr + 0x200, mask, data); > > +} > > + > > +/* 0xC00-0xCFF and 0xE00-0xEFF have the same layout */ > > Feels like this belongs with _rtw_write32s_mask() now, not here? Yeah. > > > +#define rtw_write32s_mask(rtwdev, addr, mask, data) \ > > + do { \ > > + BUILD_BUG_ON(addr < 0xC00 || addr >= 0xD00); \ > > You probably want parentheses around the 'addr'. You *probably* won't > run into trouble with this particular macro, but if the caller is doing > the wrong kinds of comparisons or arithmetic, this might not work they > way you want. Should add parentheses to protect in case of some coding mistakes. Thanks > > Brian > > > + \ > > + _rtw_write32s_mask(rtwdev, addr, mask, data); \ > > + } while (0) > > + > > /* phy status page0 */ > > #define GET_PHY_STAT_P0_PWDB(phy_stat) > \ > > le32_get_bits(*((__le32 *)(phy_stat) + 0x00), GENMASK(15, 8)) > > -- Yan-Hsuan
diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822b.c b/drivers/net/wireless/realtek/rtw88/rtw8822b.c index c0e5d1f..22b880a 100644 --- a/drivers/net/wireless/realtek/rtw88/rtw8822b.c +++ b/drivers/net/wireless/realtek/rtw88/rtw8822b.c @@ -224,16 +224,6 @@ static int rtw8822b_mac_init(struct rtw_dev *rtwdev) return 0; } -static inline void -rtw_write32s_mask(struct rtw_dev *rtwdev, u32 addr, u32 mask, u32 data) -{ - BUILD_BUG_ON(addr < 0xC00 || addr >= 0xD00); - - rtw_write32_mask(rtwdev, addr, mask, data); - /* 0xC00-0xCFF and 0xE00-0xEFF have the same layout */ - rtw_write32_mask(rtwdev, addr + 0x200, mask, data); -} - static void rtw8822b_set_channel_rfe_efem(struct rtw_dev *rtwdev, u8 channel) { struct rtw_hal *hal = &rtwdev->hal; diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822b.h b/drivers/net/wireless/realtek/rtw88/rtw8822b.h index 311fe8a..4cf193b1 100644 --- a/drivers/net/wireless/realtek/rtw88/rtw8822b.h +++ b/drivers/net/wireless/realtek/rtw88/rtw8822b.h @@ -97,6 +97,21 @@ struct rtw8822b_efuse { }; }; +static inline void +_rtw_write32s_mask(struct rtw_dev *rtwdev, u32 addr, u32 mask, u32 data) +{ + rtw_write32_mask(rtwdev, addr, mask, data); + rtw_write32_mask(rtwdev, addr + 0x200, mask, data); +} + +/* 0xC00-0xCFF and 0xE00-0xEFF have the same layout */ +#define rtw_write32s_mask(rtwdev, addr, mask, data) \ + do { \ + BUILD_BUG_ON(addr < 0xC00 || addr >= 0xD00); \ + \ + _rtw_write32s_mask(rtwdev, addr, mask, data); \ + } while (0) + /* phy status page0 */ #define GET_PHY_STAT_P0_PWDB(phy_stat) \ le32_get_bits(*((__le32 *)(phy_stat) + 0x00), GENMASK(15, 8))