From patchwork Thu Jun 8 05:27:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 13271616 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id C90DEC7EE2E for ; Thu, 8 Jun 2023 05:29:01 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 736DA6C1; Thu, 8 Jun 2023 07:28:09 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 736DA6C1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1686202139; bh=pUsSeN+HfDRdU0OEQ7xNBDLWDoa5UUMnpmd+LQ/GiM8=; h=From:To:Cc:Subject:Date:List-Id:List-Archive:List-Help:List-Owner: List-Post:List-Subscribe:List-Unsubscribe:From; b=pXcpAP/DB5VrKTEe5+uAC9n0q67hEhj0m7YLl2QEl6MQvQTM0fY2Qc9ZBSBSyN2rO CcUuslD3mZPnG3YUmCRs1Pvspx+Vgc585S84I0F9ZgAWx8ExVTXm3uZy7PqHbCoFuS iQkLgrOAfKAXqrIqqaDkaQ0T5Jl9wc+fdHFmRghE= Received: by alsa1.perex.cz (Postfix, from userid 50401) id F1D1EF80290; Thu, 8 Jun 2023 07:27:38 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id E982DF80199; Thu, 8 Jun 2023 07:27:37 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 76E93F80199; Thu, 8 Jun 2023 07:27:32 +0200 (CEST) Received: from smtp.smtpout.orange.fr (smtp-16.smtpout.orange.fr [80.12.242.16]) (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 664FBF800ED for ; Thu, 8 Jun 2023 07:27:27 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 664FBF800ED Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=wanadoo.fr header.i=@wanadoo.fr header.a=rsa-sha256 header.s=t20230301 header.b=Lg2L8LSF Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id 78BAqQV8E5y9n78BAqmbdj; Thu, 08 Jun 2023 07:27:26 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1686202046; bh=NC7exZWD31sFeAwipTt4OgnGAif/dXKMSn2/zIDOEiQ=; h=From:To:Cc:Subject:Date; b=Lg2L8LSFWbJeuTvjlyjI7VHKdR4+wJ2HclIeWo3/25PD6YibOWY2yYSUShhHI1oWf sa8/rcyF2vvXwO7SzG8DxnsSyf6H/GhxIN2SA10AsHw5b8W517fKLASoy0REEGghXt NqBs3z5eXSIsEnKjA3O7cGa9Eg4wT5a/FW8b1P6qF87R7dTPE6EmCf1E/xEvjEFglQ wCUwwY8oP6iBpl4s8SCWBRfW5f3jIo72jTdCW5ToXjY7tun/qA8co4TvDA8eYRvYsD vilvFZG9NqFNXK2ijn8QKcUsmFogds4Lc3VXEIfvhq+6lBYJMU50Y2QRHmrrZVngqX O8hBytCNDkVHg== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Thu, 08 Jun 2023 07:27:26 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Thierry Reding , Jonathan Hunter Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , alsa-devel@alsa-project.org, linux-tegra@vger.kernel.org Subject: [PATCH] ASoC: tegra: Simplify code around clk_get_rate() handling Date: Thu, 8 Jun 2023 07:27:22 +0200 Message-Id: <53f928290f08f50ff43031e17fe1d88443c2c441.1686202022.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Message-ID-Hash: A3OPWK7OJEWDV5WPTASVFW4DOOEJ2G2L X-Message-ID-Hash: A3OPWK7OJEWDV5WPTASVFW4DOOEJ2G2L X-MailFrom: christophe.jaillet@wanadoo.fr X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: clk_get_rate() returns an unsigned long, so there is no point in storing it in a long, and test for negative values. So, turn 'parent_rate' into an unsigned long, simplify the sanity check, the error message and the return value, in case of error (i.e. 0). Doing so also turns 'i' and 'valid_rates' into unsigned long, but it is fine and harmless. Signed-off-by: Christophe JAILLET --- sound/soc/tegra/tegra20_i2s.c | 9 ++++----- sound/soc/tegra/tegra20_spdif.c | 9 ++++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/sound/soc/tegra/tegra20_i2s.c b/sound/soc/tegra/tegra20_i2s.c index e1a0f50969c1..d38b58305c6b 100644 --- a/sound/soc/tegra/tegra20_i2s.c +++ b/sound/soc/tegra/tegra20_i2s.c @@ -273,13 +273,12 @@ static int tegra20_i2s_filter_rates(struct snd_pcm_hw_params *params, struct snd_soc_dai *dai = rule->private; struct tegra20_i2s *i2s = dev_get_drvdata(dai->dev); struct clk *parent = clk_get_parent(i2s->clk_i2s); - long i, parent_rate, valid_rates = 0; + unsigned long i, parent_rate, valid_rates = 0; parent_rate = clk_get_rate(parent); - if (parent_rate <= 0) { - dev_err(dai->dev, "Can't get parent clock rate: %ld\n", - parent_rate); - return parent_rate ?: -EINVAL; + if (!parent_rate) { + dev_err(dai->dev, "Can't get parent clock rate\n"); + return -EINVAL; } for (i = 0; i < ARRAY_SIZE(tegra20_i2s_rates); i++) { diff --git a/sound/soc/tegra/tegra20_spdif.c b/sound/soc/tegra/tegra20_spdif.c index 86bef54dfdf2..d034803695a0 100644 --- a/sound/soc/tegra/tegra20_spdif.c +++ b/sound/soc/tegra/tegra20_spdif.c @@ -187,13 +187,12 @@ static int tegra20_spdif_filter_rates(struct snd_pcm_hw_params *params, struct tegra20_spdif *spdif = dev_get_drvdata(dai->dev); struct clk *parent = clk_get_parent(spdif->clk_spdif_out); static const unsigned int rates[] = { 32000, 44100, 48000 }; - long i, parent_rate, valid_rates = 0; + unsigned long i, parent_rate, valid_rates = 0; parent_rate = clk_get_rate(parent); - if (parent_rate <= 0) { - dev_err(dai->dev, "Can't get parent clock rate: %ld\n", - parent_rate); - return parent_rate ?: -EINVAL; + if (!parent_rate) { + dev_err(dai->dev, "Can't get parent clock rate\n"); + return -EINVAL; } for (i = 0; i < ARRAY_SIZE(rates); i++) {