devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Cc: Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>, Rob Herring <robh+dt@kernel.org>,
	Jaroslav Kysela <perex@perex.cz>,
	ALSA Development Mailing List <alsa-devel@alsa-project.org>,
	"open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" 
	<devicetree@vger.kernel.org>
Subject: Re: [PATCH 3/3] ASoC: rsnd: add null CLOCKIN support
Date: Wed, 26 May 2021 08:58:53 +0200	[thread overview]
Message-ID: <CAMuHMdVhnKeztftOJEZhSg8bXArzUDXAmHSMPVfbMamV3ihw+g@mail.gmail.com> (raw)
In-Reply-To: <87zgwimnuu.wl-kuninori.morimoto.gx@renesas.com>

Hi Morimoto-san,

On Wed, May 26, 2021 at 12:48 AM Kuninori Morimoto
<kuninori.morimoto.gx@renesas.com> wrote:
> > I'm not such a big fan of creating dummy clocks.
> > And what if a future SoC lacks two CLOCKIN pins? Then you'll try to
> > register a second dummy clock with the same name, which will fail,
> > presumably?
>
> I think current code will reuse same null_clk for these.

Oh right, I missed the static clk_hw pointer.
What if you unload the snd-soc-rcar.ko module?

> > This should only be done when the clock does not exist, not in case
> > of other errors (e.g. -EPROBE_DEFER, which isn't handled yet)?
> >
> > As devm_clk_get_optional() already checks for existence, you could use:
> >
> >     struct clk *clk = devm_clk_get_optional(dev, clk_name[i]);
> >     if (!clk)
> >             clk = rsnd_adg_null_clk_get(priv);
>
> Ah, indeed.
> Thanks. I will fix it.
>
> > But in light of the above (avoiding dummy clocks), it might be more
> > robust to make sure all code can handle adg->clk[i] = NULL?
>
> The reason why I don't use adg->clk[i] = NULL is it is using this macro
>
>         #define for_each_rsnd_clk(pos, adg, i)          \
>                 for (i = 0;                             \
>                      (i < CLKMAX) &&                    \
>                      ((pos) = adg->clk[i]);             \
>                      i++)
>
> The loop will stop at (A) if it was
>
>         adg->clk[0] = audio_clk_a;
>         adg->clk[1] = audio_clk_b;
> (A)     adg->clk[2] = NULL
>         adg->clk[3] = audio_clk_i;

If you use this macro everywhere, that is easily handled by the
following variant:

    #define for_each_rsnd_clk(pos, adg, i)          \
            for (i = 0; (pos) = adg->clk[i], i < CLKMAX; i++)            \
                    if (pos) {                      \
                            continue;               \
                    } else

There are several existing examples of such a construct.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

  reply	other threads:[~2021-05-26  6:59 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-24  6:11 [PATCH 0/3] ASoC: rsnd: add D3 support Kuninori Morimoto
2021-05-24  6:12 ` [PATCH 1/3] ASoC: dt-bindings: renesas: rsnd: tidyup properties Kuninori Morimoto
2021-05-24  6:12 ` [PATCH 2/3] ASoC: rsnd: tidyup loop on rsnd_adg_clk_query() Kuninori Morimoto
2021-05-24  6:12 ` [PATCH 3/3] ASoC: rsnd: add null CLOCKIN support Kuninori Morimoto
2021-05-25 10:31   ` Geert Uytterhoeven
2021-05-25 22:48     ` Kuninori Morimoto
2021-05-26  6:58       ` Geert Uytterhoeven [this message]
2021-05-26 22:06         ` Kuninori Morimoto
2021-05-27  7:30           ` Geert Uytterhoeven
2021-05-27  9:48             ` Mark Brown
2021-05-24 11:59 ` [PATCH 0/3] ASoC: rsnd: add D3 support 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=CAMuHMdVhnKeztftOJEZhSg8bXArzUDXAmHSMPVfbMamV3ihw+g@mail.gmail.com \
    --to=geert@linux-m68k.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=kuninori.morimoto.gx@renesas.com \
    --cc=lgirdwood@gmail.com \
    --cc=perex@perex.cz \
    --cc=robh+dt@kernel.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).