From patchwork Tue Apr 10 08:13:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jia-Ju Bai X-Patchwork-Id: 10332493 X-Patchwork-Delegate: eduardo.valentin@ti.com 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 29D9F6028A for ; Tue, 10 Apr 2018 08:13:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F57B28D07 for ; Tue, 10 Apr 2018 08:13:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 13F5D28D0E; Tue, 10 Apr 2018 08:13:14 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A62CE28D07 for ; Tue, 10 Apr 2018 08:13:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752598AbeDJINM (ORCPT ); Tue, 10 Apr 2018 04:13:12 -0400 Received: from mail-it0-f66.google.com ([209.85.214.66]:56181 "EHLO mail-it0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752596AbeDJINL (ORCPT ); Tue, 10 Apr 2018 04:13:11 -0400 Received: by mail-it0-f66.google.com with SMTP id 142-v6so14682571itl.5; Tue, 10 Apr 2018 01:13:11 -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=qTRKVo3BILEx4dWsXQ8BUFRv+MMaB11DwXpAXw+d79Q=; b=Dq1sNmomZ0u9mBLGsUJMJpjZrLz3zpDTmGSsOKfVvhPT7fhVxV3yRhegwz4IYBx3YJ 3xJmGmuytQyU1JlKEJNfi01mOWaGJPpfmZle1UMlqAqmtr4R4CuS15+q2BCL4Go1zlC7 V4h5PsP+TGMk5UR5Fvb/QWAenX7KTfYnA/ur/aIuBuDLVbebwLedCPEy22FIB0sx/JTf FmKxAEyciP30re2OQyfhA2Q32w5AvbjEpE8w6CGmAVYRU6AFfXiZb30OHqxOgre699+S HJWIN+l1xNOKxhrAaqjGyi5ie8lQRZ7eyjgOc9Oo2jX/yPqxJd/fE1uxEzEz3qr9M/ah LJUg== 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=qTRKVo3BILEx4dWsXQ8BUFRv+MMaB11DwXpAXw+d79Q=; b=DjD9pxU+EDflBzv33VPw1mC3bN8TPGJtRVyVIeUkrphUbH1vqsuqWslAAP3V481/7k B1MrhxIMGz6ci9cj1x2QGNmpa6iq4TsoDKpveI7QwvJjztpa/q2o1CJGlYbXmCkJxRJ4 8bNNzrZzlSGQAhzHxnN/CeALCGztGavqO6cCX3FC97ZKv2bQcDBHnqctugWyRMyoeqdk 1JabLpYdiclzVQArMvkvPIAEWqeS3wzN/X/KP2fSDQUayy3i2fAv/0ejHOe4Btpv2xez PxoMYJt5cRN3V+HlaxI262MiXediQmU0MhXXkUxvS5XyMkuYZoC/LRX70g+pDe1VFKB7 C4BA== X-Gm-Message-State: ALQs6tCv6c32cN84i5vxVgAMq+alUl5rznq7xXrlRnss3H5q03DO9BKT y7vXdNgjVJn1Q+IzmTwetk0= X-Google-Smtp-Source: AIpwx4963bb6BiXSJgP341HaJa9U9PZ9UeT4JVbfKhHsreu5qm0IT72r5SWukyWD8EPEPs1S8oFrzg== X-Received: by 2002:a24:230a:: with SMTP id u10-v6mr1116003itu.49.1523347990912; Tue, 10 Apr 2018 01:13:10 -0700 (PDT) Received: from oslab.tsinghua.edu.cn ([2402:f000:1:4413:8dc7:7954:4991:f324]) by smtp.gmail.com with ESMTPSA id z7sm980537iob.9.2018.04.10.01.13.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Apr 2018 01:13:10 -0700 (PDT) From: Jia-Ju Bai To: rui.zhang@intel.com, edubezval@gmail.com Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH 1/3] thermal: armada_thermal: Replace mdelay with usleep_range in armada370_init_sensor Date: Tue, 10 Apr 2018 16:13:02 +0800 Message-Id: <1523347982-29373-1-git-send-email-baijiaju1990@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP armada370_init_sensor() is never called in atomic context. armada370_init_sensor() is set as ".init_sensor" in struct armada_thermal_data. ".init_sensor" is called armada_thermal_probe(). armada_thermal_probe() is set as ".probe" in struct platform_driver. This function is not called in atomic context. Despite never getting called from atomic context, armada370_init_sensor() calls mdelay() to busily wait. This is not necessary and can be replaced with usleep_range() to avoid busy waiting. This is found by a static analysis tool named DCNS written by myself. And I also manually check it. Signed-off-by: Jia-Ju Bai --- drivers/thermal/armada_thermal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c index ae75328..807fe74 100644 --- a/drivers/thermal/armada_thermal.c +++ b/drivers/thermal/armada_thermal.c @@ -113,7 +113,7 @@ static void armada370_init_sensor(struct platform_device *pdev, reg &= ~PMU_TDC0_START_CAL_MASK; writel(reg, priv->control); - mdelay(10); + usleep_range(10000, 11000); } static void armada375_init_sensor(struct platform_device *pdev,