From: Stanislaw Gruszka <sgruszka@redhat.com>
To: Larry Finger <Larry.Finger@lwfinger.net>
Cc: yhchuang@realtek.com, kvalo@codeaurora.org,
linux-wireless@vger.kernel.org, pkshih@realtek.com,
tehuang@realtek.com
Subject: Re: [PATCH 01/12] rtwlan: main files
Date: Fri, 28 Sep 2018 11:08:03 +0200 [thread overview]
Message-ID: <20180928090803.GB8323@redhat.com> (raw)
In-Reply-To: <a6b6803e-fd18-81f4-6465-d573aa5c9e2a@lwfinger.net>
On Thu, Sep 27, 2018 at 10:40:44AM -0500, Larry Finger wrote:
> On 9/27/18 8:50 AM, Stanislaw Gruszka wrote:
> --snip
>
> >
> > > +#define BIT_LEN_MASK_32(__bitlen) (0xFFFFFFFF >> (32 - (__bitlen)))
> > > +#define BIT_OFFSET_LEN_MASK_32(__bitoffset, __bitlen) \
> > > + (BIT_LEN_MASK_32(__bitlen) << (__bitoffset))
> > > +#define LE_P4BYTE_TO_HOST_4BYTE(__start) (le32_to_cpu(*((__le32 *)(__start))))
> > > +#define LE_BITS_CLEARED_TO_4BYTE(__start, __bitoffset, __bitlen) \
> > > + (LE_P4BYTE_TO_HOST_4BYTE(__start) & \
> > > + (~BIT_OFFSET_LEN_MASK_32(__bitoffset, __bitlen)))
> > > +#define LE_BITS_TO_4BYTE(__start, __bitoffset, __bitlen) \
> > > + ((LE_P4BYTE_TO_HOST_4BYTE(__start) >> (__bitoffset)) & \
> > > + BIT_LEN_MASK_32(__bitlen))
> > > +#define SET_BITS_TO_LE_4BYTE(__start, __bitoffset, __bitlen, __value) \
> > > + do { \
> > > + *((__le32 *)(__start)) = \
> > > + cpu_to_le32( \
> > > + LE_BITS_CLEARED_TO_4BYTE(__start, __bitoffset, __bitlen) | \
> > > + ((((u32)__value) & BIT_LEN_MASK_32(__bitlen)) << (__bitoffset))\
> > > + ); \
> > > + } while (0)
>
> Stanislaw,
>
> I have never loved these macros, and it took a lot of time to get them to be
> endian correct. Could you point me to a method that would overwrite a
> portion of a 32-bit little-endian word that would be correct for both
> little- and big-endian machines? Keep in mind that Kalle hates the use of
> compile tests on __LITTLE_ENDIAN.
Maybe something like this (not tested)
#define SET_LE32(reg, off, len, val) \
((reg & cpu_to_le32(~GENMASK(off + len - 1, off))) | cpu_to_le32(val << off))
?
There are plenty of bitops and endian primitives in kernel, it's
very very unlikly you need custom macros for handle that.
Thanks
Stanislaw
next prev parent reply other threads:[~2018-09-28 9:08 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-21 6:03 [RFC 00/12] rtwlan: mac80211 driver for Realtek 802.11ac wireless network chips yhchuang
2018-09-21 6:03 ` [PATCH 01/12] rtwlan: main files yhchuang
2018-09-27 13:50 ` Stanislaw Gruszka
2018-09-27 15:40 ` Larry Finger
2018-09-28 9:08 ` Stanislaw Gruszka [this message]
2018-10-04 12:32 ` Kalle Valo
2018-09-28 3:20 ` Tony Chuang
2018-09-28 9:29 ` Stanislaw Gruszka
2018-09-28 11:32 ` Tony Chuang
2018-10-02 10:29 ` Stanislaw Gruszka
2018-10-02 15:23 ` Larry Finger
2018-10-03 2:57 ` Tony Chuang
2018-10-03 5:40 ` Larry Finger
2018-10-04 12:39 ` Kalle Valo
2018-10-04 13:42 ` Stanislaw Gruszka
2018-10-04 16:19 ` Larry Finger
2018-10-05 7:51 ` Stanislaw Gruszka
2018-10-06 12:20 ` Kalle Valo
2018-10-06 12:16 ` Kalle Valo
2018-10-04 12:35 ` Kalle Valo
2018-10-02 9:35 ` Tony Chuang
2018-10-02 10:14 ` Stanislaw Gruszka
2018-10-03 3:25 ` Tony Chuang
2018-10-03 6:05 ` Stanislaw Gruszka
2018-10-04 12:30 ` Kalle Valo
2018-09-21 6:03 ` [PATCH 02/12] rtwlan: core files yhchuang
2018-09-21 6:03 ` [PATCH 03/12] rtwlan: hci files yhchuang
2018-09-21 6:03 ` [PATCH 04/12] rtwlan: trx files yhchuang
2018-09-21 6:04 ` [PATCH 05/12] rtwlan: mac files yhchuang
2018-09-21 6:04 ` [PATCH 06/12] rtwlan: fw and efuse files yhchuang
2018-09-21 6:04 ` [PATCH 07/12] rtwlan: phy files yhchuang
2018-09-21 6:04 ` [PATCH 08/12] rtwlan: debug files yhchuang
2018-09-21 6:04 ` [PATCH 09/12] rtwlan: chip files yhchuang
2018-09-21 6:04 ` [PATCH 10/12] rtwlan: 8822B init table yhchuang
2018-09-21 6:04 ` [PATCH 11/12] rtwlan: 8822C " yhchuang
2018-09-21 6:04 ` [PATCH 12/12] rtwlan: Kconfig & Makefile yhchuang
2018-09-22 23:39 ` kbuild test robot
2018-09-23 8:55 ` kbuild test robot
2018-09-21 13:12 ` [RFC 00/12] rtwlan: mac80211 driver for Realtek 802.11ac wireless network chips Stanislaw Gruszka
2018-09-24 11:05 ` Kalle Valo
2018-09-25 11:09 ` Tony Chuang
2018-10-06 11:45 ` Kalle Valo
[not found] ` <CAP71bdW0P8xFeLfGgNeENJf_9+S+DTnK4S=tXZi1FPY7U-AL3A@mail.gmail.com>
2018-09-24 11:08 ` Kalle Valo
2018-09-24 17:09 ` Larry Finger
2018-09-25 11:10 ` Tony Chuang
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=20180928090803.GB8323@redhat.com \
--to=sgruszka@redhat.com \
--cc=Larry.Finger@lwfinger.net \
--cc=kvalo@codeaurora.org \
--cc=linux-wireless@vger.kernel.org \
--cc=pkshih@realtek.com \
--cc=tehuang@realtek.com \
--cc=yhchuang@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).