Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp315718imm; Thu, 26 Jul 2018 19:59:54 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe1RTcllzofQm7/9byyXYj/2+Z53cRLKYerD96CcDFfvWoch2LnOotUTXdEJI3AXdvooPdc X-Received: by 2002:a17:902:9693:: with SMTP id n19-v6mr4324537plp.212.1532660394076; Thu, 26 Jul 2018 19:59:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532660394; cv=none; d=google.com; s=arc-20160816; b=R2yiDjRtl430P8FYF+foP8MY/jNT3EDv8vla5S1YBW/eDy61rVXxMLHhOA0dSDaAQc V1qCq2zVv1Me3VagdmtRFdxJAUyf0fJV4x8mp4kJDy9B43HrPRPzlmy/SXI7GDh1E3HT DpUO6mLIHlvH8knxefrx6Xrsl8I64J3lvUB+F5UbeoZBege3EthdZ5QLvUtoLWwZK2kb HuqY/OoK+LDk9imI50lopjSmplVpdMeqCf50AN3o0VaKaVqc3fOkUe1V3y3gQFuqM/j1 c1fP5abI2fDtXqw46wMp+jevI3hqiJx4CgrQf6KuN3wxPH0EVcY8w0WQs6BVMUfOAowQ QIfw== 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=HGNmA1HswNv9X/n1diJlSamezB6YadgeU8ab6hh7e24=; b=rGqIFkbrI1SiA1pMpzLH6NoQEkii81VHppxnTi6fBm7Qs/5o45R1f08sCF3xTIc3cS BdlcJt5JNEcluP3uZOdyhNvB+1BC5o9UrjHLTmTozDXJTjgLsWC1252tLNhjJuY52MSM wHl5jWeJLOvNxpwP8oFG1EzFaikAs5jwHsZHIZFEJy8Fd9liBXpXoUhK5Dgo+s5f2pvl rj6JQNMjqHzrpBEJGKWn0E5Sz5kMc8zHE3kZ3Zc25IDRcO/Ai+ZIlqcJCaml5xa0f31x hU68Lf0+V7lkkUsceEmCpe1uG+0FL/RZj17g7ucJ68OJrQk3O78zh+SO15lyZIQ0+ROW nOBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=E3CSxWZI; 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 j15-v6si2794115pgb.472.2018.07.26.19.59.38; Thu, 26 Jul 2018 19:59:54 -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=E3CSxWZI; 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 S1726212AbeG0ESc (ORCPT + 99 others); Fri, 27 Jul 2018 00:18:32 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:34348 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725829AbeG0ESb (ORCPT ); Fri, 27 Jul 2018 00:18:31 -0400 Received: by mail-pf1-f196.google.com with SMTP id k19-v6so1229473pfi.1; Thu, 26 Jul 2018 19:58:50 -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=HGNmA1HswNv9X/n1diJlSamezB6YadgeU8ab6hh7e24=; b=E3CSxWZIEqKL6GVYgpAzNOfYAsXXzseuzwSzNcsOERk1SsbkhleoFuBTj8hnVA4Qq1 wCBT9bhZ5bJnR7rmRRE0noCsptqls7Oz1CbfGYDdOY5iJQ0Yl1YbCrQ3RHqWWanyvOsy BA5d7IWWrRvSa4YNmYSB3F5vrGiDnFEaYYKi7jiQMSCcPHj8dsTsDlbTaO9zx6Wtbt5R F2fMdBhio8R4gtvZ7QmYioXPzaWHS28I9UJoFW0PZlXHhyhezrZQPxUKUk1InyviGyvB 0OOmZo9WX46D9uKqyfgWNbO/FiVihwoHky3uzNroPF1MyS3UYj+q90HQ+WKg+mtcqeys 9ADA== 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=HGNmA1HswNv9X/n1diJlSamezB6YadgeU8ab6hh7e24=; b=PiOuavMBmfA3WWVQBKhXrv/2DsR3l2/5L2Jv+cK6RjRL5sRSWelJsWqBmWQu9u1vtN nOy6N0Omx1Xc6vPIsj6A+kSRyI3gwQbaXwCqPeL28O+05tuDTF4xGqkd+mmy9W89BH5d zLEZ9Vfdx688VGKuJhcF/0WcdQ8CmP4VtOp9XvM60p9doyRRBAozoRR2SfbFSAsoNsGK U92KhPLaPjuHi1XfHv4bSCWrQytfkTKzzBTiwwmgZYbQjWarOLAcw2pNrpEpGWIguDqQ VvdTBVouHnm3LBE/AMgIDTbcMKv5+SCJv65h34vOfrnns6QVuHiv+wUjuhrK9WOuHXOZ vhIA== X-Gm-Message-State: AOUpUlFmfJejzebltJL3y5U0RDNqV93KHQXa7Z55uiA9+tQF8iM88y5A Xh33XnlxZgcv4Tu2j97Rc+8= X-Received: by 2002:a62:ed5:: with SMTP id 82-v6mr4733581pfo.198.1532660330608; Thu, 26 Jul 2018 19:58:50 -0700 (PDT) Received: from localhost.localdomain ([2402:f000:1:4414:6c14:7712:e625:1be4]) by smtp.gmail.com with ESMTPSA id d12-v6sm3626973pfn.118.2018.07.26.19.58.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Jul 2018 19:58:50 -0700 (PDT) From: Jia-Ju Bai To: hans.verkuil@cisco.com, mchehab@kernel.org Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH] media: i2c: adv7842: Replace mdelay() with msleep() and usleep_range() in adv7842_ddr_ram_test() Date: Fri, 27 Jul 2018 10:58:43 +0800 Message-Id: <20180727025843.2378-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 adv7842_ddr_ram_test() is never called in atomic context. It only calls from: adv7842_ddr_ram_test() <- adv7842_command_ram_test() <- adv7842_ioctl() adv7842_ddr_ram_test() calls mdelay() to busily wait, which is not necessary. mdelay() can be replaced with msleep() and usleep_range(). This is found by a static analysis tool named DCNS written by myself. Signed-off-by: Jia-Ju Bai --- drivers/media/i2c/adv7842.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c index fddac32e5051..74ed32f77d5f 100644 --- a/drivers/media/i2c/adv7842.c +++ b/drivers/media/i2c/adv7842.c @@ -3102,7 +3102,7 @@ static int adv7842_ddr_ram_test(struct v4l2_subdev *sd) sdp_write(sd, 0x12, 0x00); /* Disable 3D comb, Frame TBC & 3DNR */ io_write(sd, 0xFF, 0x04); /* Reset memory controller */ - mdelay(5); + usleep_range(5000, 6000); sdp_write(sd, 0x12, 0x00); /* Disable 3D Comb, Frame TBC & 3DNR */ sdp_io_write(sd, 0x2A, 0x01); /* Memory BIST Initialisation */ @@ -3116,12 +3116,12 @@ static int adv7842_ddr_ram_test(struct v4l2_subdev *sd) sdp_io_write(sd, 0x7d, 0x00); /* Memory BIST Initialisation */ sdp_io_write(sd, 0x7e, 0x1a); /* Memory BIST Initialisation */ - mdelay(5); + usleep_range(5000, 6000); sdp_io_write(sd, 0xd9, 0xd5); /* Enable BIST Test */ sdp_write(sd, 0x12, 0x05); /* Enable FRAME TBC & 3D COMB */ - mdelay(20); + msleep(20); for (i = 0; i < 10; i++) { u8 result = sdp_io_read(sd, 0xdb); @@ -3132,7 +3132,7 @@ static int adv7842_ddr_ram_test(struct v4l2_subdev *sd) else pass++; } - mdelay(20); + msleep(20); } v4l2_dbg(1, debug, sd, -- 2.17.0