Received: by 10.213.65.68 with SMTP id h4csp3869553imn; Tue, 10 Apr 2018 06:02:05 -0700 (PDT) X-Google-Smtp-Source: AIpwx48/qwyrtB2bsRreF9/2gMlAEu1894jReP8qx01gkDpMe6J+TpWKBuBDSywH/ULv0Hrq5zsU X-Received: by 2002:a17:902:28c4:: with SMTP id f62-v6mr342119plb.19.1523365325841; Tue, 10 Apr 2018 06:02:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523365325; cv=none; d=google.com; s=arc-20160816; b=SQNvh1MN0ukSF/I9uRQfS3lzmouj4Ko48RwMVywOB31rZgVjQNMnBSXcEHcoRSK/73 KTuhnQW+wor5Eua13zT4SxUX8Ve9M98tvkf4PiT1yKpn2l6csftsiF94MhhLbyhanGqP FijOYLguZmlxWMSF33h+KfJfe6eNlXBTZS3gcncAC+Nc9reN0tSAbjOh1LO5NPyv1RnR jAoYPPqnfDaAtq5EKRc+T+2kx1MNJdSim2mqSNMJYrvSgJwpIEecageKIvnWnXBGdA1O siS34GfYRUd+llnPoe4wlsPKAiC/wPvwo3LcpEKKZ7oavZscR5RWsOlW7uMlF3Le3vx0 Y1+Q== 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=vQmo+4GuIECyDtdR7pgAz+4vV+BYHAIXUiK+YH60fd0=; b=nHJY0dxGvtRlrHktjS4rivh/89gPjI1XQVhRKj8gUkYPChLV6RaHWXN/Vz7mIIQLzE lLQ+G5nXzqd8fDIwJMRKvfezd3GYA/gVVXhTlKvQv95Q0laMQapqS7+6JYs7e0nv9oEz JDQHfr3zW0Xao3lhQ9YEdWoimZBOyTquU9JmLtAunKKT3Asgdjx2GsVHOBbYvqNwx0l/ Sk+2MeVOiL3y+hVh377FmCJVU7nSZG1SpRkcJkbKnGEHZfw/wDNurySOCbURwy+k3Ntw 8rugedPivd+cJ1HZ3FoSQ4KBup36vhqK5gPc17Xf9gOS83ud/1Ppg4O/GFq5Vxfz55oo l+uQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DUuJ6osg; 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 c23si1804204pgn.186.2018.04.10.06.01.27; Tue, 10 Apr 2018 06:02:05 -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=DUuJ6osg; 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 S1753241AbeDJM6H (ORCPT + 99 others); Tue, 10 Apr 2018 08:58:07 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:35000 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753164AbeDJM6E (ORCPT ); Tue, 10 Apr 2018 08:58:04 -0400 Received: by mail-pl0-f65.google.com with SMTP id 61-v6so7464043plb.2; Tue, 10 Apr 2018 05:58:04 -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=vQmo+4GuIECyDtdR7pgAz+4vV+BYHAIXUiK+YH60fd0=; b=DUuJ6osgC88/PnnYAU4OJ7cQ8Rr9qEx6E9xq64PRm7IGLu4NgCt+PPVzFTXJplWFs3 nCQslpdsYEE+JLNPAJ6mgvu1yB98nCCs2BoEzg8Xp4LeEyouC2Icd5RXZPFBY8UkdLq6 UAfXg2kwFIrbCkEBkJCoMjgydsOaocMppXRKXy46YXxQmeLLZYoZS3x7M4FhMJI8OwE+ 0xQ0kRIseRuRRHQLmEHwBjPCLYsQLf3mEBc7MBRGVy3vM2kiLOou09EcWTyNq2VvP7YQ A4OximvegyGz7s62odUmwKiOfMmitDMqmshqiB7C9CQNOuqfFEhwDPNBnUBczmEgEF71 Eiaw== 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=vQmo+4GuIECyDtdR7pgAz+4vV+BYHAIXUiK+YH60fd0=; b=lsAC/TSXfpR6hk4u5ckMLxZvzzgcjMPZOorxJURgcwd6yYZfpTbg1HVS8FUvvJ94fV g/GMKwdozb4YMyrpo/ZM9+YVgui8yf3Cd69u3sWTSeO1cbRUqqWpmUeLdJxBjZEN8y3P zBKtwrC0nJMoy0B5X6h1SmlRjYWBrejm4B87GmwtMApDxBe9YzUbdbLQldbewW0PP22g hMUP+dOu+dvtyQVyUQnVR5edN4haQ/T/WBKSt62NQiiLltGiTiaFMBzpLWBhmSsfMuYw y0oxcHxFuISAZcggT9S69Yq+u6vbA5VrEh7dRTmoRANlYJMnvk/7S7tSS6L1SVENd6YR 4uzg== X-Gm-Message-State: ALQs6tBh7hh0NcB3x6pEH0Afmh/dm92Vou5qTF7F80M4WogF5ls2i6i8 QXMMzxHF3o0T4xG4iwYHL2o= X-Received: by 2002:a17:902:ba94:: with SMTP id k20-v6mr306966pls.193.1523365083830; Tue, 10 Apr 2018 05:58:03 -0700 (PDT) Received: from oslab.tsinghua.edu.cn ([2402:f000:1:4413:8dc7:7954:4991:f324]) by smtp.gmail.com with ESMTPSA id p71sm7845778pfl.89.2018.04.10.05.58.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Apr 2018 05:58:03 -0700 (PDT) From: Jia-Ju Bai To: dvhart@infradead.org, andy@infradead.org Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH] platform: x86: intel_scu_ipc: Replace mdelay with usleep_range in intel_scu_ipc_i2c_cntrl Date: Tue, 10 Apr 2018 20:57:56 +0800 Message-Id: <1523365076-31461-1-git-send-email-baijiaju1990@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org intel_scu_ipc_i2c_cntrl() calls mutex_lock(), which indicates this function is not called in atomic context. Despite never getting called from atomic context, intel_scu_ipc_i2c_cntrl() 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/platform/x86/intel_scu_ipc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/intel_scu_ipc.c b/drivers/platform/x86/intel_scu_ipc.c index 2c85f75..75c8fef 100644 --- a/drivers/platform/x86/intel_scu_ipc.c +++ b/drivers/platform/x86/intel_scu_ipc.c @@ -584,11 +584,11 @@ int intel_scu_ipc_i2c_cntrl(u32 addr, u32 *data) if (cmd == IPC_I2C_READ) { writel(addr, scu->i2c_base + IPC_I2C_CNTRL_ADDR); /* Write not getting updated without delay */ - mdelay(1); + usleep_range(1000, 2000); *data = readl(scu->i2c_base + I2C_DATA_ADDR); } else if (cmd == IPC_I2C_WRITE) { writel(*data, scu->i2c_base + I2C_DATA_ADDR); - mdelay(1); + usleep_range(1000, 2000); writel(addr, scu->i2c_base + IPC_I2C_CNTRL_ADDR); } else { dev_err(scu->dev, -- 1.9.1