Linux wireless drivers development
 help / color / mirror / Atom feed
From: Kalle Valo <kvalo@codeaurora.org>
To: torvalds@linux-foundation.org, akpm@linux-foundation.org,
	gregkh@linuxfoundation.org, davem@davemloft.net
Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
	dinan.gunawardena@netronome.com,
	Jakub Kicinski <jakub.kicinski@netronome.com>
Subject: Re: [PATCHv6 1/2] add basic register-field manipulation macros
Date: Wed, 17 Aug 2016 13:31:21 +0300	[thread overview]
Message-ID: <8737m3bsau.fsf@kamboji.qca.qualcomm.com> (raw)
In-Reply-To: <1471360704-10507-2-git-send-email-jakub.kicinski@netronome.com> (Jakub Kicinski's message of "Tue, 16 Aug 2016 16:18:23 +0100")

Jakub Kicinski <jakub.kicinski@netronome.com> writes:

> Common approach to accessing register fields is to define
> structures or sets of macros containing mask and shift pair.
> Operations on the register are then performed as follows:
>
>  field = (reg >> shift) & mask;
>
>  reg &= ~(mask << shift);
>  reg |= (field & mask) << shift;
>
> Defining shift and mask separately is tedious.  Ivo van Doorn
> came up with an idea of computing them at compilation time
> based on a single shifted mask (later refined by Felix) which
> can be used like this:
>
>  #define REG_FIELD 0x000ff000
>
>  field = FIELD_GET(REG_FIELD, reg);
>
>  reg &= ~REG_FIELD;
>  reg |= FIELD_PUT(REG_FIELD, field);
>
> FIELD_{GET,PUT} macros take care of finding out what the
> appropriate shift is based on compilation time ffs operation.
>
> GENMASK can be used to define registers (which is usually
> less error-prone and easier to match with datasheets).
>
> This approach is the most convenient I've seen so to limit code
> multiplication let's move the macros to a global header file.
> Attempts to use static inlines instead of macros failed due
> to false positive triggering of BUILD_BUG_ON()s, especially with
> GCC < 6.0.
>
> Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
> Reviewed-by: Dinan Gunawardena <dinan.gunawardena@netronome.com>

Are people ok with this? I think they are useful and I can take these
through my tree, but I would prefer to get an ack from other maintainers
first. Dave? Andrew?

Full patches here:

https://patchwork.kernel.org/patch/9284153/

https://patchwork.kernel.org/patch/9284155/

-- 
Kalle Valo

  reply	other threads:[~2016-08-17 10:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-16 15:18 [PATCHv6 0/2] register-field manipulation macros Jakub Kicinski
2016-08-16 15:18 ` [PATCHv6 1/2] add basic " Jakub Kicinski
2016-08-17 10:31   ` Kalle Valo [this message]
2016-08-17 16:33     ` Linus Torvalds
2016-08-17 17:11       ` Jakub Kicinski
2016-08-17 17:16         ` Linus Torvalds
2016-08-18 17:11           ` [RFC (v7)] " Jakub Kicinski
2016-08-18 17:28             ` Linus Torvalds
2016-08-19  9:09               ` Kalle Valo
2016-08-16 15:18 ` [PATCHv6 2/2] mt7601u: use linux/bitfield.h Jakub Kicinski

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=8737m3bsau.fsf@kamboji.qca.qualcomm.com \
    --to=kvalo@codeaurora.org \
    --cc=akpm@linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=dinan.gunawardena@netronome.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jakub.kicinski@netronome.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=torvalds@linux-foundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox