Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp371001imm; Wed, 17 Oct 2018 01:18:38 -0700 (PDT) X-Google-Smtp-Source: ACcGV63QVQcKGFymcQfws6/T6kQvY5aeB02r0XYKVgaEIccBMaKWX5cODBE77tGTQxUu8+6Sy7LU X-Received: by 2002:a63:e216:: with SMTP id q22-v6mr23302089pgh.206.1539764318328; Wed, 17 Oct 2018 01:18:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539764318; cv=none; d=google.com; s=arc-20160816; b=Dp0oK7Wz7smFdh1C4yXln5mBpTVt8hGhVdD+QvkYBo5+3KjaQHwZzNxJeBy/UAfhKI sX0vX9Jvwr6rGfkFQC5u1Id1EnK4nvEcgLzhP6cg9z6MaI8E05H9+auPaRyvN+BTkRrh 9/RH5Xmu9Oy2shr53ira+mZ5+/pFIHulPjpK1QCIje+6USJWUySDThJr9n0gVQcE3Dz2 cTlLbwootus8W1F2U7/NoZLMU/EK3kQ9qxc007ZXNGrVq1T5sCtW4pWe0IgDGFTDhzJT uBYTTEk0uuK8agW0W1VZz7NOR/HSultUrIT9Ya0ZjUykJTQ9sSLjIgvj4uQ21IoOtfhI Sv0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=eq/Q4iqmrqnB+n1tF28+AEQk6nyh68BnrOd2wA/vhH4=; b=ivtQEUMaF+MeXcHmRTFsdHpcu6Nnkl+B1p5uuYeGqQx6TmpNRFqnEHbz02L9+l+hbV i+BwJ0tJfVm0t3XVXYwGKPEJacSg/WzIeiEZsV0UAFUTiFmTA0PDovWzMpZ+dSWVAmkC SB8Lz3RBFTwGWbtVIl/+TKaORkcvDcrZqEqMaWX3Crd4u7S/7E/BVmvbQ8CiEgiMxMap iAr17wfnTasAIAjsRCc9UUWoaAoFS6QjD7lavvXVIAevgPLI4TJUElGCnYM9ymURfG54 I6dGCj+Ey8OdYkRG5ikfgMtrBggCtuwq2knxdyP+iggtOzrO4OAeNPjLodd97PuHyT7B Rh/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=BK2xOmXI; 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 r6-v6si18405910pfc.253.2018.10.17.01.18.22; Wed, 17 Oct 2018 01:18:38 -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=BK2xOmXI; 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 S1727254AbeJQQM0 (ORCPT + 99 others); Wed, 17 Oct 2018 12:12:26 -0400 Received: from mail-qk1-f195.google.com ([209.85.222.195]:34117 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727008AbeJQQM0 (ORCPT ); Wed, 17 Oct 2018 12:12:26 -0400 Received: by mail-qk1-f195.google.com with SMTP id p6-v6so15960502qkg.1; Wed, 17 Oct 2018 01:17:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=eq/Q4iqmrqnB+n1tF28+AEQk6nyh68BnrOd2wA/vhH4=; b=BK2xOmXIBYE7U0osl2Eud36DzY1FuLiv8DY5LnaQPD5tVVD40HO4JcigJ5kwMTgaaf 1LoS2P4bRX+JWa96s1yx8Eu5PAzFC0bj+novmpvYWqJzwvzwqKON5/APRtRdJVpof6bW NtECLPPabL0rYrNNjt12M23hOOh556f/eKM0pHqhox0bcp/YcWyCb87CyvJfKFmD7NgH /wSz2swtlvq2RWnCaJYh49SA8QbAcYrrqMYxsiD+NeJutDw8eKSfag0Ie7nIf4GChTQh F+3dnAJ/p1UDT+I6f4lZmvkjXAA/NnaDxm3iBDowS9qVIuq/BDuOZxmekGJRePUS49qK 5zJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=eq/Q4iqmrqnB+n1tF28+AEQk6nyh68BnrOd2wA/vhH4=; b=b0/T8UASVaIRuUoK9xL5qZL2RSo56MPsshTyRGeXYt5IYi0RRlNYmRpGsDuuOZzRhR R9loy8nxftQjRkCMJCaMKI0KGTee0puITUuSPZnBtpbhxgcylXnTqLbsUHbR8r0U4RKu y6tu6YJdujlVuBom4xmewKzdHWXGD3JwMAxvJgwIsTFme2LxjfntS8OV8nK8DkhQE+Uk 6TaYP7einrV16KqG9yEKC76PXkt47rrd8LyX0+wEsGApIviukkkAvH0FEChMtDwfzeOX Sd4dZhHkVZFRtqtD5I3Zbu7Is2hnA8RCaEOafP3q4cWJykpFkbRjrU41U5eZyk6vTbXx kFtA== X-Gm-Message-State: ABuFfoiyEBoWFFC0Vj4+vuSsCzyoVXfCqer1Gwof3QvScZGmSPfYQtMF edLiC5Wy9WzIPP+tlf9a7eZOLYSP6Q/JyWEo9kZLiUIWcvA= X-Received: by 2002:a37:4787:: with SMTP id u129-v6mr24070614qka.301.1539764273079; Wed, 17 Oct 2018 01:17:53 -0700 (PDT) MIME-Version: 1.0 References: <1539755947-27014-1-git-send-email-suganath-prabu.subramani@broadcom.com> <1539755947-27014-2-git-send-email-suganath-prabu.subramani@broadcom.com> In-Reply-To: <1539755947-27014-2-git-send-email-suganath-prabu.subramani@broadcom.com> From: Andy Shevchenko Date: Wed, 17 Oct 2018 11:17:41 +0300 Message-ID: Subject: Re: [v5 1/4] mpt3sas: Separate out mpt3sas_wait_for_ioc_to_operational To: Suganath Prabu Subramani Cc: Bjorn Helgaas , Lukas Wunner , linux-scsi , linux-pci@vger.kernel.org, Linux Kernel Mailing List , Benjamin Herrenschmidt , ruscur@russell.cc, sbobroff@linux.ibm.com, oohall@gmail.com, Sathya Prakash , Sreekanth Reddy Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 17, 2018 at 8:59 AM Suganath Prabu wrote: > > No functional changes. This section of code > "wait for IOC to be operational" is used in many places > across the driver, and hence moved this code in to > a function "mpt3sas_wait_for_ioc_to_operational()" > + ioc_state = mpt3sas_base_get_iocstate(ioc, 1); > + while (ioc_state != MPI2_IOC_STATE_OPERATIONAL) { > + Do we need this blank line? > + if (wait_state_count++ == timeout) { > + ioc_err(ioc, "%s: failed due to ioc not operational\n", > + __func__); > + return -EFAULT; > + } > + ssleep(1); > + ioc_state = mpt3sas_base_get_iocstate(ioc, 1); > + ioc_info(ioc, "%s: waiting for operational state(count=%d)\n", > + __func__, wait_state_count); > + } I understand this is part of existing code, but can you consider to modify it to something like do { ioc_state = mpt3sas_base_get_iocstate(ioc, 1); if (ioc_state == MPI2_IOC_STATE_OPERATIONAL) break; ioc_info(ioc, "%s: waiting for operational state(count=%d)\n", __func__, ++wait_state_count); while (timeout--); if (!timeout) { ioc_err(ioc, "%s: failed due to ioc not operational\n", __func__); return -EFAULT; } Less lines, more understandable in my view. > + rc = mpt3sas_wait_for_ioc_to_operational(ioc, > + IOC_OPERATIONAL_WAIT_COUNT); This can be one line (yes, I aware that is 82 characters, but it improves readability from my p.o.v.). > + rc = mpt3sas_wait_for_ioc_to_operational(ioc, > + IOC_OPERATIONAL_WAIT_COUNT); Ditto. > u16 smid; > - u32 ioc_state; > Mpi2ConfigRequest_t *config_request; > int r; > u8 retry_count, issue_host_reset = 0; > - u16 wait_state_count; > + Usually we don't split definition block. > struct config_request mem; > u32 ioc_status = UINT_MAX; > + ret = mpt3sas_wait_for_ioc_to_operational(ioc, > + IOC_OPERATIONAL_WAIT_COUNT); One line? > + rc = mpt3sas_wait_for_ioc_to_operational(ioc, > + IOC_OPERATIONAL_WAIT_COUNT); Ditto. > + rc = mpt3sas_wait_for_ioc_to_operational(ioc, > + IOC_OPERATIONAL_WAIT_COUNT); Ditto. > + rc = mpt3sas_wait_for_ioc_to_operational(ioc, > + IOC_OPERATIONAL_WAIT_COUNT); Ditto. -- With Best Regards, Andy Shevchenko