All of lore.kernel.org
 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: Tue, 25 May 2021 12:31:08 +0200	[thread overview]
Message-ID: <CAMuHMdXLYvEBE0bVk=8D+GkuaHRUvdTayCQPqTYAkPJEaW8MDQ@mail.gmail.com> (raw)
In-Reply-To: <87tumsoe2p.wl-kuninori.morimoto.gx@renesas.com>

Hi Morimoto-san,

On Mon, May 24, 2021 at 8:12 AM Kuninori Morimoto
<kuninori.morimoto.gx@renesas.com> wrote:
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
>
> Some Renesas SoC doesn't have full CLOCKIN.
> This patch add null_clk, and accepts it.
>
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Thanks for your patch, which is now commit d6956a7dde6fbf84 ("ASoC:
rsnd: add null CLOCKIN support") in asoc/for-next.

]> --- a/sound/soc/sh/rcar/adg.c
> +++ b/sound/soc/sh/rcar/adg.c
> @@ -389,6 +389,30 @@ void rsnd_adg_clk_control(struct rsnd_priv *priv, int enable)
>         }
>  }
>
> +#define NULL_CLK "rsnd_adg_null"
> +static struct clk *rsnd_adg_null_clk_get(struct rsnd_priv *priv)
> +{
> +       static struct clk_hw *hw;
> +       struct device *dev = rsnd_priv_to_dev(priv);
> +
> +       if (!hw) {
> +               struct clk_hw *_hw;
> +               int ret;
> +
> +               _hw = clk_hw_register_fixed_rate_with_accuracy(dev, NULL_CLK, NULL, 0, 0, 0);
> +               if (IS_ERR(_hw))
> +                       return NULL;
> +
> +               ret = of_clk_add_hw_provider(dev->of_node, of_clk_hw_simple_get, _hw);

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?

> +               if (ret < 0)
> +                       clk_hw_unregister_fixed_rate(_hw);
> +
> +               hw = _hw;
> +       }
> +
> +       return clk_hw_get_clk(hw, NULL_CLK);
> +}
> +
>  static void rsnd_adg_get_clkin(struct rsnd_priv *priv,
>                                struct rsnd_adg *adg)
>  {
> @@ -398,7 +422,12 @@ static void rsnd_adg_get_clkin(struct rsnd_priv *priv,
>         for (i = 0; i < CLKMAX; i++) {
>                 struct clk *clk = devm_clk_get(dev, clk_name[i]);
>
> -               adg->clk[i] = IS_ERR(clk) ? NULL : clk;
> +               if (IS_ERR(clk))
> +                       clk = rsnd_adg_null_clk_get(priv);

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);

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?

> +               if (IS_ERR(clk))
> +                       dev_err(dev, "no adg clock (%s)\n", clk_name[i]);
> +
> +               adg->clk[i] = clk;
>         }
>  }

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

WARNING: multiple messages have this Message-ID (diff)
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Cc: "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS"
	<devicetree@vger.kernel.org>,
	ALSA Development Mailing List <alsa-devel@alsa-project.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Rob Herring <robh+dt@kernel.org>, Mark Brown <broonie@kernel.org>
Subject: Re: [PATCH 3/3] ASoC: rsnd: add null CLOCKIN support
Date: Tue, 25 May 2021 12:31:08 +0200	[thread overview]
Message-ID: <CAMuHMdXLYvEBE0bVk=8D+GkuaHRUvdTayCQPqTYAkPJEaW8MDQ@mail.gmail.com> (raw)
In-Reply-To: <87tumsoe2p.wl-kuninori.morimoto.gx@renesas.com>

Hi Morimoto-san,

On Mon, May 24, 2021 at 8:12 AM Kuninori Morimoto
<kuninori.morimoto.gx@renesas.com> wrote:
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
>
> Some Renesas SoC doesn't have full CLOCKIN.
> This patch add null_clk, and accepts it.
>
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Thanks for your patch, which is now commit d6956a7dde6fbf84 ("ASoC:
rsnd: add null CLOCKIN support") in asoc/for-next.

]> --- a/sound/soc/sh/rcar/adg.c
> +++ b/sound/soc/sh/rcar/adg.c
> @@ -389,6 +389,30 @@ void rsnd_adg_clk_control(struct rsnd_priv *priv, int enable)
>         }
>  }
>
> +#define NULL_CLK "rsnd_adg_null"
> +static struct clk *rsnd_adg_null_clk_get(struct rsnd_priv *priv)
> +{
> +       static struct clk_hw *hw;
> +       struct device *dev = rsnd_priv_to_dev(priv);
> +
> +       if (!hw) {
> +               struct clk_hw *_hw;
> +               int ret;
> +
> +               _hw = clk_hw_register_fixed_rate_with_accuracy(dev, NULL_CLK, NULL, 0, 0, 0);
> +               if (IS_ERR(_hw))
> +                       return NULL;
> +
> +               ret = of_clk_add_hw_provider(dev->of_node, of_clk_hw_simple_get, _hw);

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?

> +               if (ret < 0)
> +                       clk_hw_unregister_fixed_rate(_hw);
> +
> +               hw = _hw;
> +       }
> +
> +       return clk_hw_get_clk(hw, NULL_CLK);
> +}
> +
>  static void rsnd_adg_get_clkin(struct rsnd_priv *priv,
>                                struct rsnd_adg *adg)
>  {
> @@ -398,7 +422,12 @@ static void rsnd_adg_get_clkin(struct rsnd_priv *priv,
>         for (i = 0; i < CLKMAX; i++) {
>                 struct clk *clk = devm_clk_get(dev, clk_name[i]);
>
> -               adg->clk[i] = IS_ERR(clk) ? NULL : clk;
> +               if (IS_ERR(clk))
> +                       clk = rsnd_adg_null_clk_get(priv);

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);

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?

> +               if (IS_ERR(clk))
> +                       dev_err(dev, "no adg clock (%s)\n", clk_name[i]);
> +
> +               adg->clk[i] = clk;
>         }
>  }

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-25 10:33 UTC|newest]

Thread overview: 22+ 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:11 ` Kuninori Morimoto
2021-05-24  6:12 ` [PATCH 1/3] ASoC: dt-bindings: renesas: rsnd: tidyup properties Kuninori Morimoto
2021-05-24  6:12   ` 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   ` Kuninori Morimoto
2021-05-24  6:12 ` [PATCH 3/3] ASoC: rsnd: add null CLOCKIN support Kuninori Morimoto
2021-05-24  6:12   ` Kuninori Morimoto
2021-05-25 10:31   ` Geert Uytterhoeven [this message]
2021-05-25 10:31     ` Geert Uytterhoeven
2021-05-25 22:48     ` Kuninori Morimoto
2021-05-25 22:48       ` Kuninori Morimoto
2021-05-26  6:58       ` Geert Uytterhoeven
2021-05-26  6:58         ` Geert Uytterhoeven
2021-05-26 22:06         ` Kuninori Morimoto
2021-05-26 22:06           ` Kuninori Morimoto
2021-05-27  7:30           ` Geert Uytterhoeven
2021-05-27  7:30             ` Geert Uytterhoeven
2021-05-27  9:48             ` Mark Brown
2021-05-27  9:48               ` Mark Brown
2021-05-24 11:59 ` [PATCH 0/3] ASoC: rsnd: add D3 support Mark Brown
2021-05-24 11:59   ` 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='CAMuHMdXLYvEBE0bVk=8D+GkuaHRUvdTayCQPqTYAkPJEaW8MDQ@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.