On Thu, 2023-05-25 at 19:07 +0300, Kalle Valo wrote: > > Ping-Ke Shih <pkshih@xxxxxxxxxxx> writes: > > > The register-based H2C/C2H are used to exchange commands and events with > > firmware. The exchange data is limited, but it is relatively simple, > > because it can work before HCI initialization. To make these code clean, > > use struct to access them. This patch doesn't change logic at all. > > > > Signed-off-by: Ping-Ke Shih <pkshih@xxxxxxxxxxx> > > [...] > > > --- a/drivers/net/wireless/realtek/rtw89/fw.h > > +++ b/drivers/net/wireless/realtek/rtw89/fw.h > > @@ -18,15 +18,51 @@ enum rtw89_fw_dl_status { > > RTW89_FWDL_WCPU_FW_INIT_RDY = 7 > > }; > > > > -#define RTW89_GET_C2H_HDR_FUNC(info) \ > > - u32_get_bits(info, GENMASK(6, 0)) > > -#define RTW89_GET_C2H_HDR_LEN(info) \ > > - u32_get_bits(info, GENMASK(11, 8)) > > +struct rtw89_c2hreg_hdr { > > + u32 w0; > > +}; > > Why this is u32? Shouldn't it be __le32? > > > +#define RTW89_C2HREG_HDR_FUNC_MASK GENMASK(6, 0) > > +#define RTW89_C2HREG_HDR_ACK BIT(7) > > +#define RTW89_C2HREG_HDR_LEN_MASK GENMASK(11, 8) > > +#define RTW89_C2HREG_HDR_SEQ_MASK GENMASK(15, 12) > > + > > +struct rtw89_c2hreg_phycap { > > + u32 w0; > > + u32 w1; > > + u32 w2; > > + u32 w3; > > +} __packed; > > Here as well? And I saw more in the patch. > > Of course these were already there so isn't a problem introduced by this > patchset, but I started wondering if we are missing some little endian > types? > I had the same question as yours when I did this conversion, but they are correct because we access these H2C commands/C2H events via registers which are CPU order. A bug I found is that use struct bit-field to access these data. This will cause big-endian machine wrong, and I fix them by this patch as well. I hope we don't miss something. Ping-Ke