Linux Sound subsystem development
 help / color / mirror / Atom feed
From: Charles Keepax <ckeepax@opensource.cirrus.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: <broonie@kernel.org>, <lgirdwood@gmail.com>,
	<alsa-devel@alsa-project.org>, <patches@opensource.cirrus.com>,
	<linux-sound@vger.kernel.org>
Subject: Re: [PATCH v2 6/7] ASoC: cs42l43: Refactor to use for_each_set_bit()
Date: Mon, 29 Jan 2024 16:27:08 +0000	[thread overview]
Message-ID: <ZbfR3IzRYpP7YCns@ediswmail9.ad.cirrus.com> (raw)
In-Reply-To: <CAHp75Ver-NMTtHmeE9+sdnt1FVH2iGhXQxQf21jjDGOn+6mbhw@mail.gmail.com>

On Thu, Jan 25, 2024 at 09:11:44PM +0200, Andy Shevchenko wrote:
> On Thu, Jan 25, 2024 at 12:31 PM Charles Keepax
> <ckeepax@opensource.cirrus.com> wrote:
> Adding nslots parameter is a good idea, but I still think the code can
> be refactored better (have you checked the code generation, btw? I
> believe my version would be better or not worse).
> 
> > +       for_each_set_bit(slot, &mask, BITS_PER_TYPE(mask)) {
> > +               if (i == nslots) {
> > +                       dev_warn(priv->dev, "Too many channels in TDM mask: %lx\n",
> > +                                mask);
> >                         return;
> > +               }
> >
> > +               slots[i++] = slot;
> >         }
> 
>        i = 0;
>        for_each_set_bit(slot, &mask, CS42L43_ASP_MAX_CHANNELS)
>                slots[i++] = slot;
> 
>        if (hweight_long(mask) >= CS42L43_ASP_MAX_CHANNELS)
>                dev_warn(priv->dev, "Too many channels in TDM mask\n");
> 
> The code is simpler and behaviour is not changed.

I don't think this works, the limit here is on the number of
channels not on the position of those channels. The last parameter
of for_each_set_bits appears to measure against the bit position
not the number of set bits. So for example 0xFC000000 would be a
valid 6 channel mask, but would result in no slot positions being
set in the above code.

Thanks,
Charles

  reply	other threads:[~2024-01-29 16:27 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-25 10:31 [PATCH v2 1/7] ASoC: cs42l43: Tidy up header includes Charles Keepax
2024-01-25 10:31 ` [PATCH v2 2/7] ASoC: cs42l43: Minor code tidy ups Charles Keepax
2024-01-25 10:31 ` [PATCH v2 3/7] ASoC: cs42l43: Check error from device_property_read_u32_array() Charles Keepax
2024-01-25 10:31 ` [PATCH v2 4/7] ASoC: cs42l43: Add pm_ptr around the power ops Charles Keepax
2024-01-25 19:00   ` Andy Shevchenko
2024-01-25 10:31 ` [PATCH v2 5/7] ASoC: cs42l43: Use USEC_PER_MSEC rather than hard coding Charles Keepax
2024-01-25 10:31 ` [PATCH v2 6/7] ASoC: cs42l43: Refactor to use for_each_set_bit() Charles Keepax
2024-01-25 19:11   ` Andy Shevchenko
2024-01-29 16:27     ` Charles Keepax [this message]
2024-01-29 23:45       ` Andy Shevchenko
2024-01-25 10:31 ` [PATCH v2 7/7] ASoC: cs42l43: Use fls to calculate the pre-divider for the PLL Charles Keepax
2024-01-25 19:13 ` [PATCH v2 1/7] ASoC: cs42l43: Tidy up header includes Andy Shevchenko
2024-01-26 21:38 ` 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=ZbfR3IzRYpP7YCns@ediswmail9.ad.cirrus.com \
    --to=ckeepax@opensource.cirrus.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=andy.shevchenko@gmail.com \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-sound@vger.kernel.org \
    --cc=patches@opensource.cirrus.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