From patchwork Wed Oct 31 13:23:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suganath Prabu S X-Patchwork-Id: 10662659 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B914713BF for ; Wed, 31 Oct 2018 13:25:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A9D0B284BD for ; Wed, 31 Oct 2018 13:25:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9D48D25F31; Wed, 31 Oct 2018 13:25:12 +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,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 4113525F31 for ; Wed, 31 Oct 2018 13:25:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729365AbeJaWWi (ORCPT ); Wed, 31 Oct 2018 18:22:38 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:35635 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729364AbeJaWWh (ORCPT ); Wed, 31 Oct 2018 18:22:37 -0400 Received: by mail-wr1-f67.google.com with SMTP id w5-v6so16494088wrt.2 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=bxPc5vSbBMdBJOFDHpZqLoSmr99NqYYZJFDbCweCm2lK2d0+hcJv1xkzxR37FteBdL k3bbwTKY4MsIDY2uVzKi619JEgMAQTsiVhb/K3oYV5iMkRyBPbMbzkvOSrLYSZcQWEs4 jTMKqyzkfj1CYEgW+zW8onpzj6jyV0RAi3rXRNSqhxvkCqH7ATk1DwdCSSo29nsHTWoQ /VkJvuPgmFBX3X1ZNNEOknv41S/PdS9V/x+0f8Qk0LTZ1yTEC4FLeATm2xZ+amcPmcUu XdmkDlydbpUAKndlqChbS2IyDP2Pr56NBOy38Ak6lJHGRzHhYLKIOzR9IXsPwJdGzqSq Qrzg== X-Gm-Message-State: AGRZ1gLvEBYwD5/tDCNImjsdOQfSdYT5Br78p66VNUUCBrM83AUDBaZI RScDvdNGGhhJX7lkE8HEHV3GUVTJXnE= X-Google-Smtp-Source: AJdET5e1jzSIewOx/boEP+EtfoMJL4eGI72JZn2yUCFN0t5ZO2jZW1W0D7Y0X7CN4BWIMWk3Rs4q5Q== 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-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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; }