From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: Vinod Koul <vkoul@kernel.org>
Cc: alsa-devel@alsa-project.org, tiwai@suse.de, broonie@kernel.org,
gregkh@linuxfoundation.org,
Bard liao <yung-chuan.liao@linux.intel.com>,
Rander Wang <rander.wang@linux.intel.com>,
Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>,
Kai Vehmanen <kai.vehmanen@linux.intel.com>,
Sanyog Kale <sanyog.r.kale@intel.com>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 2/3] soundwire: SDCA: add helper macro to access controls
Date: Mon, 14 Sep 2020 09:44:58 -0500 [thread overview]
Message-ID: <11feabb2-dc8b-7acc-6e4d-0903fc435b00@linux.intel.com> (raw)
In-Reply-To: <20200914050825.GA2968@vkoul-mobl>
> For LSB bits, I dont think this is an issue. I expect it to work, for example:
> #define CONTROL_LSB_MASK GENMASK(2, 0)
> foo |= u32_encode_bits(control, CONTROL_LSB_MASK);
>
> would mask the control value and program that in specific bitfeild.
>
> But for MSB bits, I am not sure above will work so, you may need to extract
> the bits and then use, for example:
> #define CONTROL_MSB_BITS GENMASK(5, 3)
> #define CONTROL_MSB_MASK GENMASK(17, 15)
>
> control = FIELD_GET(CONTROL_MSB_BITS, control);
> foo |= u32_encode_bits(control, CONTROL_MSB_MASK);
>
>> If you have a better suggestion that the FIELD_PREP/FIELD_GET use, I am all
>> ears. At the end of the day, the mapping is pre-defined and we don't have
>> any degree of freedom. What I do want is that this macro/inline function is
>> shared by all codec drivers so that we don't have different interpretations
>> of how the address is constructed.
>
> Absolutely, this need to be defined here and used by everyone else.
Compare:
#define SDCA_CONTROL_MSB_BITS GENMASK(5, 3)
#define SDCA_CONTROL_MSB_MASK GENMASK(17, 15)
#define SDCA_CONTROL_LSB_MASK GENMASK(2, 0)
foo |= u32_encode_bits(control, SDCA_CONTROL_LSB_MASK);
control = FIELD_GET(SDCA_CONTROL_MSB_BITS, control);
foo |= u32_encode_bits(control, SDCA_CONTROL_MSB_MASK);
with the original proposal:
foo |= FIELD_GET(GENMASK(2, 0), control))
foo |= FIELD_PREP(GENMASK(17, 15), FIELD_GET(GENMASK(5, 3), control))
it gets worse when the LSB positions don't match, you need another
variable and an additional mask.
I don't see how this improves readability? I get that hard-coding magic
numbers is a bad thing in general, but in this case there are limited
benefits to the use of additional defines.
next prev parent reply other threads:[~2020-09-14 15:44 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20200901162225.33343-1-pierre-louis.bossart@linux.intel.com>
2020-09-01 16:22 ` [PATCH v2 1/3] regmap: sdw: add required header files Pierre-Louis Bossart
2020-09-01 16:22 ` [PATCH v2 2/3] soundwire: SDCA: add helper macro to access controls Pierre-Louis Bossart
2020-09-04 5:02 ` Vinod Koul
2020-09-08 13:33 ` Pierre-Louis Bossart
2020-09-09 7:55 ` Vinod Koul
[not found] ` <184867c2-9f0c-bffe-2eb7-e9c5735614b0@linux.intel.com>
2020-09-10 6:22 ` Vinod Koul
[not found] ` <adf51127-2813-cdf0-e5a6-f5ec3b0d33fa@linux.intel.com>
2020-09-11 7:06 ` Vinod Koul
2020-09-11 14:50 ` Pierre-Louis Bossart
2020-09-14 5:08 ` Vinod Koul
2020-09-14 14:44 ` Pierre-Louis Bossart [this message]
2020-09-16 12:35 ` Vinod Koul
2020-09-16 13:11 ` Pierre-Louis Bossart
2020-09-01 16:22 ` [PATCH v2 3/3] regmap: sdw: add support for SoundWire 1.2 MBQ Pierre-Louis Bossart
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=11feabb2-dc8b-7acc-6e4d-0903fc435b00@linux.intel.com \
--to=pierre-louis.bossart@linux.intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=guennadi.liakhovetski@linux.intel.com \
--cc=kai.vehmanen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rander.wang@linux.intel.com \
--cc=sanyog.r.kale@intel.com \
--cc=tiwai@suse.de \
--cc=vkoul@kernel.org \
--cc=yung-chuan.liao@linux.intel.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