Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp6067686imd; Wed, 31 Oct 2018 06:25:34 -0700 (PDT) X-Google-Smtp-Source: AJdET5eOZ/HgilM+ndpIItnFUy0h4gkoUaDLurGCkRpaKEv/la72ICAWXDP56eck2cQotD5Pt46i X-Received: by 2002:a17:902:544:: with SMTP id 62-v6mr3269028plf.73.1540992334239; Wed, 31 Oct 2018 06:25:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540992334; cv=none; d=google.com; s=arc-20160816; b=Sj6VFJBSapDzx2aWmXjkdHMjpCxFrSd4fXC0S4rPF8bSUN4+mQlv7nmTsvOXUJLD3t vN3dFqg+wCixzqFtRGFpAq/xYvqo8FOZCBJdqh/FbNq5fhGbBAa/btuzH9AMdxqDGXZf LBWjfmk5ltNjpgeZYfhIF9LLGgZBSB8TQVcesR0vND58apPtxmzEVLz+b13VaYTKEJsF 15igj/0GiqxkSFPkcfNsncHL+ssPQ7e/AfPLvh/b1zlOS6ErwAi5NaN6jPx3Q8V0YzHw y+DA0C4pTKH7I2SCypyzFZLt2Tr8x5DwoltvqLEo5MIZSLh0epVQz7IdkjvQSBYpCmjz Nozg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=lIeXDghr755t8BBCSwmcHa9YGHWcATP9qR2jvztCXFU=; b=BEVC3C+wf35/KMzvAXWd0AYxdL80D+uVXTNg47A0NOv6rCNUJR/ENMKIplDzN4+aGD RpnJ8dbiDKPiaSHMKJkK/3+WlHj7JjeT/P++VedEcdn52odgkH+NjzNnmVgfw1jqCluD piYjUQM5a3yS9MKJa0UwW+6L6hHw2pz0CKT4/Dmavg8+x2WMYUwgN9VXq4979GUkXYDp RMkJKzz9AiS5yJfrtHp+HY+o8LZSJwXpwE2NQT3zr4o+/iCTjlF77RnMOwIc83QrYbBa 47l1fqkUIWI8q/UOauk6BSd8FJE69J/2eFny+kpF5JQgAAiPUdtVX7UJherapUnFSuVD oaUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=XqJ9KU92; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u2-v6si26245716pgr.97.2018.10.31.06.25.19; Wed, 31 Oct 2018 06:25:34 -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=@broadcom.com header.s=google header.b=XqJ9KU92; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729373AbeJaWWi (ORCPT + 99 others); Wed, 31 Oct 2018 18:22:38 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:32950 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729287AbeJaWWh (ORCPT ); Wed, 31 Oct 2018 18:22:37 -0400 Received: by mail-wr1-f66.google.com with SMTP id u1-v6so16513310wrn.0 for ; Wed, 31 Oct 2018 06:24:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lIeXDghr755t8BBCSwmcHa9YGHWcATP9qR2jvztCXFU=; b=XqJ9KU92b8Vrvym64YyhjPvqGCK9SyUfma5Rf39bKUh9IvYEggZF657J5y+vENL24/ fnesR1RBu2FR6eVc2wXZiEalzYMNBG+JfBmTW3ldtbIiyupMIVnJ2PrHJRIIlAEai/ZE YEdY8JMOl8jOoO4Xp/CXfHU8zNmsgn3sc9qIk= 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:in-reply-to :references; bh=lIeXDghr755t8BBCSwmcHa9YGHWcATP9qR2jvztCXFU=; b=PwKhrq/NARoXIdI07OvZqbpo5A/iKc1b/F4oQyjaW3QN7L0BV+alb6Ygu/2qkXn86B mOL9ZYRB7Z5fwNhH/9ougUYGFzgs94GtoUIuWJatIBXpxdgMc1OGu3f8ih+TDwTqfe/m j/cx2jlCA0p8CHgzN3ARf2Oes6AmuqooZxikT7g/2czE+UmDLzhVVD3mvs6qjikirnJ0 /v3hscZ0UZKnlkRhkmAjnGVVa4Lw2tJKwYypd9ab3mhwTrWTFlWf2SVk0QRjyaUubM+R CtyIcAofFDu7sIKicNyqpsRaKRXwaWHbbw+ci0ELLF7fpijYqNUJEYuJP+Q5ADnCgH8V IEIA== X-Gm-Message-State: AGRZ1gJXHizA99c2fqB3yyCHk3hMKhNOXJfIJBVd86fXjkkxU0CacHqk D6bSSk+fAdxjaSLUSMR3FpSNiw== X-Received: by 2002:adf:a512:: with SMTP id i18-v6mr3030268wrb.220.1540992274970; Wed, 31 Oct 2018 06:24:34 -0700 (PDT) Received: from dhcp-10-123-74-106.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id r16-v6sm25202614wrv.21.2018.10.31.06.24.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 31 Oct 2018 06:24:34 -0700 (PDT) From: Suganath Prabu To: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sathya.Prakash@broadcom.com, sreekanth.reddy@broadcom.com, Suganath Prabu Subject: [PATCH v7 3/8] mpt3sas: Refactor mpt3sas_wait_for_ioc function Date: Wed, 31 Oct 2018 18:53:34 +0530 Message-Id: <1540992219-20291-4-git-send-email-suganath-prabu.subramani@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1540992219-20291-1-git-send-email-suganath-prabu.subramani@broadcom.com> References: <1540992219-20291-1-git-send-email-suganath-prabu.subramani@broadcom.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org No functional change. Doing code refactor of function mpt3sas_wait_for_ioc() for better readability. Signed-off-by: Suganath Prabu --- drivers/scsi/mpt3sas/mpt3sas_base.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c index 3b5f28a..f25bc3c 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c @@ -5093,22 +5093,20 @@ mpt3sas_wait_for_ioc(struct MPT3SAS_ADAPTER *ioc, int timeout) int wait_state_count = 0; u32 ioc_state; - ioc_state = mpt3sas_base_get_iocstate(ioc, 1); - while (ioc_state != MPI2_IOC_STATE_OPERATIONAL) { - - if (wait_state_count++ == timeout) { - ioc_err(ioc, "%s: failed due to ioc not operational\n", - __func__); - return -EFAULT; - } - ssleep(1); + do { ioc_state = mpt3sas_base_get_iocstate(ioc, 1); + if (ioc_state == MPI2_IOC_STATE_OPERATIONAL) + break; + ssleep(1); ioc_info(ioc, "%s: waiting for operational state(count=%d)\n", - __func__, wait_state_count); + __func__, ++wait_state_count); + } while (--timeout); + if (!timeout) { + ioc_err(ioc, "%s: failed due to ioc not operational\n", __func__); + return -EFAULT; } if (wait_state_count) ioc_info(ioc, "ioc is operational\n"); - return 0; } -- 1.8.3.1