From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Suganath Prabu Subramani <suganath-prabu.subramani@broadcom.com>
Cc: Bjorn Helgaas <helgaas@kernel.org>,
Lukas Wunner <lukas@wunner.de>,
linux-scsi <linux-scsi@vger.kernel.org>,
linux-pci@vger.kernel.org,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
ruscur@russell.cc, sbobroff@linux.ibm.com, oohall@gmail.com,
Sathya Prakash <Sathya.Prakash@broadcom.com>,
Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Subject: Re: [v5 1/4] mpt3sas: Separate out mpt3sas_wait_for_ioc_to_operational
Date: Wed, 17 Oct 2018 11:17:41 +0300 [thread overview]
Message-ID: <CAHp75Veh=CkhD67jb+Qjps-UqtcCBUsA8bWco6kqppm0Q+tcvg@mail.gmail.com> (raw)
In-Reply-To: <1539755947-27014-2-git-send-email-suganath-prabu.subramani@broadcom.com>
On Wed, Oct 17, 2018 at 8:59 AM Suganath Prabu
<suganath-prabu.subramani@broadcom.com> 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
next prev parent reply other threads:[~2018-10-17 8:17 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-17 5:59 [v5 0/4] mpt3sas: Hot-Plug Surprise removal support on IOC Suganath Prabu
2018-10-17 5:59 ` [v5 1/4] mpt3sas: Separate out mpt3sas_wait_for_ioc_to_operational Suganath Prabu
2018-10-17 8:17 ` Andy Shevchenko [this message]
2018-10-17 8:19 ` Andy Shevchenko
[not found] ` <CA+RiK66_gpLvzFyztdQ3BdX11wn2uRfxoF6hhRg1TXoERe7z3Q@mail.gmail.com>
2018-10-18 7:22 ` Andy Shevchenko
2018-10-17 5:59 ` [v5 2/4] mpt3sas: Fix Sync cache command failure during driver unload Suganath Prabu
2018-10-17 8:32 ` Andy Shevchenko
[not found] ` <CA+RiK67067aV9Ky5m8uCGLGcvjbBRxqFVeyB0CsYcvSw7rgqJg@mail.gmail.com>
2018-10-18 7:23 ` Andy Shevchenko
2018-10-17 5:59 ` [v5 3/4] mpt3sas:Fix driver modifying persistent data Suganath Prabu
2018-10-17 8:24 ` Andy Shevchenko
2018-10-18 7:16 ` Suganath Prabu Subramani
2018-10-17 5:59 ` [v5 4/4] mpt3sas: Bump driver version to 27.100.00.00 Suganath Prabu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAHp75Veh=CkhD67jb+Qjps-UqtcCBUsA8bWco6kqppm0Q+tcvg@mail.gmail.com' \
--to=andy.shevchenko@gmail.com \
--cc=Sathya.Prakash@broadcom.com \
--cc=benh@kernel.crashing.org \
--cc=helgaas@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=lukas@wunner.de \
--cc=oohall@gmail.com \
--cc=ruscur@russell.cc \
--cc=sbobroff@linux.ibm.com \
--cc=sreekanth.reddy@broadcom.com \
--cc=suganath-prabu.subramani@broadcom.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).