From patchwork Mon Apr 9 00:33:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 10329009 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5C56E6020F for ; Mon, 9 Apr 2018 00:41:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4CC7A289F0 for ; Mon, 9 Apr 2018 00:41:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4112F289E0; Mon, 9 Apr 2018 00:41:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 61A9B289E0 for ; Mon, 9 Apr 2018 00:41:52 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 174E92673D4; Mon, 9 Apr 2018 02:34:49 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 9DF5E2673D6; Mon, 9 Apr 2018 02:34:46 +0200 (CEST) Received: from mail-pf0-f195.google.com (mail-pf0-f195.google.com [209.85.192.195]) by alsa0.perex.cz (Postfix) with ESMTP id 9BF642673C7 for ; Mon, 9 Apr 2018 02:34:44 +0200 (CEST) Received: by mail-pf0-f195.google.com with SMTP id p15so4745602pff.11 for ; Sun, 08 Apr 2018 17:34:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=nKSTyIvXdFL/ZHXoRP3Of0Gs3cEwnAJaFOoAqdpWiZc=; b=mT+EuQAlz0Su77xyefoQy+xKsEgFqYEl75TsHoZdB3Qo70x+TXT6/0A8TwLOxpnkbv nqP18svX8PzfQl98ZbJeH/JYOAyiIon3awfsuS9bFiGKp7xAJOl0QlkOB2hSFGOaMPsp jQmaLZbhB0RB9fqSiaoixzu6nr1K9uhU6FCAb06WcUQjlCMttZRe+yojgSwPS/odmM/0 Bu3E9DxFqsHm1HrbzkVh8DtmuLd53G1xBuOeAcBQGY9kNMgMX0tmHc2AkVU5EBie8yyQ u1jrrqRM1ZgJLtIqV/4XwUK8JVV/pcI5qDvyLntgsIpNvbdodglXxYAdYBKLBm0DV0VO wdFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=nKSTyIvXdFL/ZHXoRP3Of0Gs3cEwnAJaFOoAqdpWiZc=; b=twl0MA1C+c+y4JiRRVUrZx06RuQz1MyPQeSmndNimthLnEEMqs27WE1IdVcFe8S+oG huGXdmDJiAHKfu/G7IInenuDOfCkN/wQcwaqx+4YDY17VCyTcc1t5EM3dAijRjLuEKAC GGZNCyVAxZZ4Fq4Yn8aGFI8FfvaGWYnyH3FX5/qjhqf8+mZzIif7qpVKAZZN23fPTx6O j0ZHhSj0o8XTZGLW25XUOmCYaOHU79J3pkmjq2YNA8oPxCk5xODsQ5eSzmsahKFz63w1 +PB4dCV18IwgMpd8e8kyur1+ZdaVsTlCEwvo1AItsOAiDDGM0MuRvLiULUvy9TlJZLRn n6+g== X-Gm-Message-State: ALQs6tBMAc9QCzSNX5e1hxg+9o2qwq+b2qG8tUR/Hd5un+q8ujGzFK52 6RnYGjPYnbGDaq3MpQwlq4U= X-Google-Smtp-Source: AIpwx49cy/6Y0GkzIwma+Jr+2ipIS5dQk0yypnO6yXpDY1r9xqaAj1NPnKFnI9+Xte18+FiQAEtiOw== X-Received: by 10.101.101.216 with SMTP id y24mr16213353pgv.43.1523234082307; Sun, 08 Apr 2018 17:34:42 -0700 (PDT) Received: from Asurada-CZ80.localdomain (c-73-231-2-134.hsd1.ca.comcast.net. [73.231.2.134]) by smtp.gmail.com with ESMTPSA id 199sm29624872pfy.51.2018.04.08.17.34.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 08 Apr 2018 17:34:41 -0700 (PDT) From: Nicolin Chen To: broonie@kernel.org Date: Sun, 8 Apr 2018 17:33:54 -0700 Message-Id: <1523234034-33018-1-git-send-email-nicoleotsuka@gmail.com> X-Mailer: git-send-email 2.7.4 Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, tiwai@suse.com, lgirdwood@gmail.com, fabio.estevam@nxp.com, linuxppc-dev@lists.ozlabs.org Subject: [alsa-devel] [PATCH] ASoC: fsl_esai: Add freq check in set_dai_sysclk() X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP The freq parameter indicates the physical frequency of an actual input clock or a desired frequency of an output clock for HCKT/R. It should never be passed 0. This might cause Division-by-zero. So this patch adds a check to fix it. Signed-off-by: Nicolin Chen Reviewed-by: Fabio Estevam --- sound/soc/fsl/fsl_esai.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sound/soc/fsl/fsl_esai.c b/sound/soc/fsl/fsl_esai.c index da8fd98..d79e99e 100644 --- a/sound/soc/fsl/fsl_esai.c +++ b/sound/soc/fsl/fsl_esai.c @@ -226,6 +226,12 @@ static int fsl_esai_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned long clk_rate; int ret; + if (freq == 0) { + dev_err(dai->dev, "%sput freq of HCK%c should not be 0Hz\n", + in ? "in" : "out", tx ? 'T' : 'R'); + return -EINVAL; + } + /* Bypass divider settings if the requirement doesn't change */ if (freq == esai_priv->hck_rate[tx] && dir == esai_priv->hck_dir[tx]) return 0;