From: Maxime Ripard <maxime.ripard@bootlin.com>
To: "Rojewski, Cezary" <cezary.rojewski@intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>,
Liam Girdwood <lgirdwood@gmail.com>,
Rob Herring <robh+dt@kernel.org>,
Marcus Cooper <codekipper@gmail.com>,
Chen-Yu Tsai <wens@csie.org>, Mark Brown <broonie@kernel.org>,
Frank Rowand <frowand.list@gmail.com>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>
Subject: Re: [alsa-devel] [PATCH v2] ASoC: sun4i-i2s: Change SR and WSS computation
Date: Thu, 6 Jun 2019 13:06:47 +0200 [thread overview]
Message-ID: <20190606110647.iojplb27mdo276xk@flea> (raw)
In-Reply-To: <3BD9CEE4EBD5E74B98FE2D277EB60E0B38FF8117@IRSMSX104.ger.corp.intel.com>
[-- Attachment #1.1: Type: text/plain, Size: 1582 bytes --]
Hi,
On Wed, Jun 05, 2019 at 04:36:28PM +0000, Rojewski, Cezary wrote:
> >+static s8 sun4i_i2s_get_sr(const struct sun4i_i2s *i2s, int width)
> >+{
> >+ if (width < 16 || width > 24)
> >+ return -EINVAL;
> >+
> >+ if (width % 4)
> >+ return -EINVAL;
> >+
> >+ return (width - 16) / 4;
> >+}
> >+
> >+static s8 sun4i_i2s_get_wss(const struct sun4i_i2s *i2s, int width)
> >+{
> >+ if (width < 16 || width > 32)
> >+ return -EINVAL;
> >+
> >+ if (width % 4)
> >+ return -EINVAL;
> >+
> >+ return (width - 16) / 4;
> >+}
> >+
> >+static s8 sun8i_i2s_get_sr_wss(const struct sun4i_i2s *i2s, int width)
> >+{
> >+ if (width % 4)
> >+ return -EINVAL;
> >+
>
> In the two above you start with boundary check before mod yet in
> this one the order is reversed. Keeping the same order should prove
> more cohesive.
Indeed, I'll fix this.
>
> >+ if (width < 8 || width > 32)
> >+ return -EINVAL;
> >+
> >+ return (width - 8) / 4 + 1;
> >+}
> >+
>
> Other, probably less welcome suggestion is introduction of unified
> function which ones listed here would simply invoke. All of these
> "computations" differ in fact only in: min and max boundary. The +1
> for _sr_wss is negligible, you can append it on return.
It's not just about the min and max boundaries. It's also the offset
at which to start with (16 vs 8), and the offset to apply to the
result (0 vs 1).
That's 4 parameters out of 5 that are different. For something that
trivial, I don't think it's worth it to put it in common.
Maxime
--
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
[-- Attachment #2: Type: text/plain, Size: 176 bytes --]
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-06-06 11:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-05 10:08 [PATCH v2] ASoC: sun4i-i2s: Change SR and WSS computation Maxime Ripard
2019-06-05 16:36 ` [alsa-devel] " Rojewski, Cezary
2019-06-06 11:06 ` Maxime Ripard [this message]
2019-06-06 11:49 ` Rojewski, Cezary
2019-06-06 21:27 ` Applied "ASoC: sun4i-i2s: Change SR and WSS computation" to the asoc tree Mark Brown
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=20190606110647.iojplb27mdo276xk@flea \
--to=maxime.ripard@bootlin.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=cezary.rojewski@intel.com \
--cc=codekipper@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=frowand.list@gmail.com \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=robh+dt@kernel.org \
--cc=wens@csie.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;
as well as URLs for NNTP newsgroup(s).