Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp567119imm; Fri, 27 Jul 2018 02:03:30 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeqB60BW5h2BwH5B4t8AbhstpoJMXCdeSzHKhwNsHu6HZCFg2XaLB2Wt3Ns6tTTKegBESoN X-Received: by 2002:a65:4d05:: with SMTP id i5-v6mr5214521pgt.58.1532682210121; Fri, 27 Jul 2018 02:03:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532682210; cv=none; d=google.com; s=arc-20160816; b=nTf8vq0W1GTwsNyCvdb08yp5auhu92t9OFgKK98IbQvkGx9hpEOyaf7AdS1p1ksUog 2Cae+me836ct+tblpQEtXeSwSmSe2DhSDiAzrG0M88PKs7zZxNQCVjjuggscEQGg+NAk 1NpEBH+7qmRgkUdwvY3iOJM4CikQnoEX0jruNbKc+5ysQtdVur6yR05TvOB7ou9yiNjs MhaRHD+41IOon0mtl3cpHwO6qPMx03x/2fmNyNqbxQyOpuEq1Iuu9xVG7CgbRWY+LdKv YvX70m3KuYWqi7Pf9z2Xu2Rw3uABpmWWxFMNkBbWeMlWV5Eje0KgJbjSHY+yo7fgP+yJ FsQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=HFJoAeEclLfp/RuuuQufAkXi8dKMns+XQRSmDVIcCF4=; b=taMvSFzPDPgSiZArVJIVDz/NUoa3YvVED3UaIbbXC4qCj4EA7hUYRqC+1evm/v6+LS MjsKPZKZproaWTliCNpZt+NT44fFt0ehRJMcuxApV/FLoqQeg+IM2T/183V7j3G/c/bb fu7WkVeQVyUCzFPRgYiTG+YSOzbhZNyaINptFH6r1gRvprcgZ+ZtHQ0KOMvSVEgOHaTU rpLUQCYy5Mw9IxroKy1iY4IQPK0Rb1R+amUbYokkJliLy2Rlr+w1oykQsKNUrNz+rP5/ nDIhQW6ucMlOph79nEbOKEmzxIP6JqY/cKnAXicY3AX2hSdefOpzYTOUIBoLyjPL9zm2 KNBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=THFL7OKr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z3-v6si3516697pgh.557.2018.07.27.02.03.15; Fri, 27 Jul 2018 02:03:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=THFL7OKr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730182AbeG0KWp (ORCPT + 99 others); Fri, 27 Jul 2018 06:22:45 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:35535 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729445AbeG0KWo (ORCPT ); Fri, 27 Jul 2018 06:22:44 -0400 Received: by mail-pl0-f65.google.com with SMTP id w3-v6so2051808plq.2 for ; Fri, 27 Jul 2018 02:01:49 -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=HFJoAeEclLfp/RuuuQufAkXi8dKMns+XQRSmDVIcCF4=; b=THFL7OKrtIDqCud9eAVUb/XK3euV1STiFVTJa8rn7iquN1XSpw+UujWz0Wb9tRGOGd nparnOR3Y1LOysxrtzuPG+cTnHgWqduk2LzrMBNbPXg8EJHx7gA0Rrs9HMZeG/NvXIEH vXrK/qYZMlAhLGtN9z650z1XJu8Bz/LYRGCx2+wbQw8Ra8uLxSeVNQstCKN/jbEj/NV2 9kril6RsGEnT7MYhID00uXmojGavswfoE76VoqlrVAJ6SX8MAoPHaQsIlY3WXmfs8ovC qqztX6sNFu6hi7xtQEmKpQJ3ctwRRI077Nidyh9FhI1DEN14qhc+98TESpVv6oL17rDm FzsQ== 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=HFJoAeEclLfp/RuuuQufAkXi8dKMns+XQRSmDVIcCF4=; b=IS+p+eMT9QTL7zohMu1t8xCgaIAeyf/VETYdFOoPO02bGUuFx6hf7H15QYZNQnt7WU TvQb+no0+Ii1uQ2PyF9DSNFC+socaXbamCJNYnZ8+tQys1NdWpj0UNn+hbYAYhq0ryGu VogPcE/VDcFc5iwepi1WqeY+wZJpRuVPJp3EtfublRzCEv+IemJ+7PnYpUyL7cr4dI3x MdQR2EX69sEK2db0eUICcvWpIMYt2S2IH7Zr4eobljJSZSiv/o/f8CrKd8zD8c7V8zhw XEJ3X6gjjvfSEQnH0jNYDPrYRD0A79FQgpP4HMbIX3d+s46ADLFOZ+AidVlDEKSh+MUr AEVg== X-Gm-Message-State: AOUpUlHgJCNHxCZi/Qitv0EC0453CpN1xmIKTnAZ8NwQdrFbbDAr3wYz 0XJRQH+Oyy1glbqWKJ4bbV6QBLmzp64= X-Received: by 2002:a17:902:280b:: with SMTP id e11-v6mr5211612plb.298.1532682109536; Fri, 27 Jul 2018 02:01:49 -0700 (PDT) Received: from localhost.localdomain ([2402:f000:1:4414:8ca7:1cde:b1e6:2647]) by smtp.gmail.com with ESMTPSA id q25-v6sm6442270pfk.96.2018.07.27.02.01.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Jul 2018 02:01:49 -0700 (PDT) From: Jia-Ju Bai To: perex@perex.cz, tiwai@suse.com, bhumirks@gmail.com Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH] sound: pci: cthw20k2: Replace mdelay() with msleep() and usleep_range() Date: Fri, 27 Jul 2018 17:01:43 +0800 Message-Id: <20180727090143.18686-1-baijiaju1990@gmail.com> X-Mailer: git-send-email 2.17.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org hw_pll_init(), hw_dac_stop(), hw_dac_start() and hw_adc_init() are never called in atomic context. They call mdelay() to busily wait, which is not necessary. mdelay() can be replaced with msleep(). This is found by a static analysis tool named DCNS written by myself. Signed-off-by: Jia-Ju Bai --- sound/pci/ctxfi/cthw20k2.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sound/pci/ctxfi/cthw20k2.c b/sound/pci/ctxfi/cthw20k2.c index b866d6b2c923..3c966fafc754 100644 --- a/sound/pci/ctxfi/cthw20k2.c +++ b/sound/pci/ctxfi/cthw20k2.c @@ -1316,12 +1316,12 @@ static int hw_pll_init(struct hw *hw, unsigned int rsr) set_field(&pllctl, PLLCTL_FD, 48000 == rsr ? 16 - 4 : 147 - 4); set_field(&pllctl, PLLCTL_RD, 48000 == rsr ? 1 - 1 : 10 - 1); hw_write_20kx(hw, PLL_CTL, pllctl); - mdelay(40); + msleep(40); pllctl = hw_read_20kx(hw, PLL_CTL); set_field(&pllctl, PLLCTL_FD, 48000 == rsr ? 16 - 2 : 147 - 2); hw_write_20kx(hw, PLL_CTL, pllctl); - mdelay(40); + msleep(40); for (i = 0; i < 1000; i++) { pllstat = hw_read_20kx(hw, PLL_STAT); @@ -1584,7 +1584,7 @@ static void hw_dac_stop(struct hw *hw) data = hw_read_20kx(hw, GPIO_DATA); data &= 0xFFFFFFFD; hw_write_20kx(hw, GPIO_DATA, data); - mdelay(10); + usleep_range(10000, 11000); } static void hw_dac_start(struct hw *hw) @@ -1593,7 +1593,7 @@ static void hw_dac_start(struct hw *hw) data = hw_read_20kx(hw, GPIO_DATA); data |= 0x2; hw_write_20kx(hw, GPIO_DATA, data); - mdelay(50); + msleep(50); } static void hw_dac_reset(struct hw *hw) @@ -1864,11 +1864,11 @@ static int hw_adc_init(struct hw *hw, const struct adc_conf *info) hw_write_20kx(hw, GPIO_DATA, data); } - mdelay(10); + usleep_range(10000, 11000); /* Return the ADC to normal operation. */ data |= (0x1 << 15); hw_write_20kx(hw, GPIO_DATA, data); - mdelay(50); + msleep(50); /* I2C write to register offset 0x0B to set ADC LRCLK polarity */ /* invert bit, interface format to I2S, word length to 24-bit, */ -- 2.17.0