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,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 16726C4707F for ; Tue, 25 May 2021 10:32:23 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1BC96611CD for ; Tue, 25 May 2021 10:32:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1BC96611CD Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 0805E1735; Tue, 25 May 2021 12:31:30 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0805E1735 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1621938740; bh=+AYxHiIJ3dfjlLK1lNBxCeKhNVMhjtTaVMVEfBDhK4c=; h=References:In-Reply-To:From:Date:Subject:To:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Vzt68GQyvix9b7asPu7itEHxJbsiCtNl0JB19wJFr8l/DXva2VQAbQ3SSG0RZIC+f 64zcSACjxuFk9TDKBWeypjQ7B8w1mZ8AcGP8ewDp/PjsBF/KLV6fCETTesUFvt1cf6 PxqdXDwL9hbzy3glL8enA3e6DaMPa4Yw6fvayOoo= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 9C9A4F80212; Tue, 25 May 2021 12:31:29 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 10724F8026B; Tue, 25 May 2021 12:31:28 +0200 (CEST) Received: from mail-ua1-f48.google.com (mail-ua1-f48.google.com [209.85.222.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 87CDAF80113 for ; Tue, 25 May 2021 12:31:20 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 87CDAF80113 Received: by mail-ua1-f48.google.com with SMTP id h26so3130706uab.13 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=Pl3r/z7YfLlaas5PoWQmmIfkpt6Hw/pUk9bW2t+WZWMyE5dS1quVuXuQl5fmbQsJC/ OdgJYgMW882ubSblVXPHfUQj/lE7LhatFvrqohULuLBHHAM2CAecIvNGk6WMmzTTUkj8 Tnl0ZWAgQ+Q4yWeTBDoPNz5SYuduMBTpq+qdzFuZYStXlrlAUynjHaVRr9hOSwIFbl4o Q1YUVBPhB15duLqPb6QNBds8h4DpyE9emTWDZKVT3seFxBzZkh2QQMV+Vr+eev5FPMOK 1+SUeKoo3hLSiJwngdWIDVqMkNVABkugRMNwxy9sdFmxaH1Jn+cVDRkdwv5Bo2RteHha HtRA== X-Gm-Message-State: AOAM533UrnvjA6EBdp6TXxedLJDrqY8Bn3mJbIbDDU6qpLJz7x7yRgB0 m856dSIxV+IacuKXOvOsA1b6tq/m17hSuNI/BGA= 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 Content-Type: text/plain; charset="UTF-8" Cc: "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , ALSA Development Mailing List , Liam Girdwood , Rob Herring , Mark Brown X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" 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