From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 82D47C47085 for ; Tue, 25 May 2021 10:33:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 66180613F4 for ; Tue, 25 May 2021 10:33:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232596AbhEYKe2 (ORCPT ); Tue, 25 May 2021 06:34:28 -0400 Received: from mail-ua1-f54.google.com ([209.85.222.54]:44622 "EHLO mail-ua1-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232220AbhEYKcw (ORCPT ); Tue, 25 May 2021 06:32:52 -0400 Received: by mail-ua1-f54.google.com with SMTP id 68so2366602uao.11 for ; Tue, 25 May 2021 03:31:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=caJKpR22UE+yWdNX3qHv38WZNk5LVcxR9KLK7ev4RjQ=; b=qbvjkoC6XlBDQffJJnOJdVuoqibNOvaJ/o55B4KDzeVTgUXOahVe95N/776OIIRp8L ogj9eF66jQzwv1NE5EUbk5PzMgLWb8uHVMFqlj9E4+qbNqL2zzoHoW+QeEtl+1JYhYI+ XDjZVPpUqhF3px97reV9CFPd08QfOl4SrE/bZu1G3WxUtcbsztiy+V/YpH5+j0/YP9dR vBR5f3bKCad7aj7omAljpEw4fQsnuumBn3BK9lGFLQJPnSvQOZEyKFPZFQKAOqqzX1LT ode7EdGBcc7n5tbQe9D6NwcZIfFe8PDiKoHQtWUyxaWzzWgeCuOn2RSv4egDmkKen+rQ ZK0g== X-Gm-Message-State: AOAM531QX6xlXGbtnMEIgcUOLvp7/vA9AS2MTvWmnToaBpz5rCup8vSn S1qayGtxPQ13VUXSOuCatRrEy4IU2bscRRaCbZbblCUna3M= X-Google-Smtp-Source: ABdhPJwblKYwm9RJW3XSVKWE+5kVk7eMvDJLF/P2KKmUb0AT/32MauXQN1zZLxKBYw6+qox7pESabyebTfYSEjgBWcc= X-Received: by 2002:ab0:7705:: with SMTP id z5mr25244439uaq.2.1621938679481; Tue, 25 May 2021 03:31:19 -0700 (PDT) MIME-Version: 1.0 References: <87y2c4oe3y.wl-kuninori.morimoto.gx@renesas.com> <87tumsoe2p.wl-kuninori.morimoto.gx@renesas.com> In-Reply-To: <87tumsoe2p.wl-kuninori.morimoto.gx@renesas.com> From: Geert Uytterhoeven Date: Tue, 25 May 2021 12:31:08 +0200 Message-ID: Subject: Re: [PATCH 3/3] ASoC: rsnd: add null CLOCKIN support To: Kuninori Morimoto Cc: Liam Girdwood , Mark Brown , Rob Herring , Jaroslav Kysela , ALSA Development Mailing List , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Hi Morimoto-san, On Mon, May 24, 2021 at 8:12 AM Kuninori Morimoto wrote: > From: Kuninori Morimoto > > Some Renesas SoC doesn't have full CLOCKIN. > This patch add null_clk, and accepts it. > > Signed-off-by: Kuninori Morimoto 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