Date: Fri, 21 Jan 2022 02:26:58 GMT From: Alexander Motin <mav@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 02325a44b520 - stable/13 - nvme_ctrlr_enable: Small style nits Message-ID: <202201210226.20L2QwFD001359@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=02325a44b5202ef715bec9c162085d8dc737d442 commit 02325a44b5202ef715bec9c162085d8dc737d442 Author: Warner Losh <imp@FreeBSD.org> AuthorDate: 2021-10-01 16:51:24 +0000 Commit: Alexander Motin <mav@FreeBSD.org> CommitDate: 2022-01-21 02:07:30 +0000 nvme_ctrlr_enable: Small style nits Rewrite the nested if's using the preferred FreeBSD style for branches of ifs that return. NFC. Minor tweaks to the comments to better fit new code layout. Sponsored by: Netflix Reviewed by: mav, chuck (prior rev, but comments rolled in) Differential Revision: https://reviews.freebsd.org/D32245 (cherry picked from commit a245627a4e9553c84eddea07570daaf85c1067b6) --- sys/dev/nvme/nvme_ctrlr.c | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/sys/dev/nvme/nvme_ctrlr.c b/sys/dev/nvme/nvme_ctrlr.c index f22e21eaf54a..10b30c584f71 100644 --- a/sys/dev/nvme/nvme_ctrlr.c +++ b/sys/dev/nvme/nvme_ctrlr.c @@ -303,19 +303,17 @@ nvme_ctrlr_disable(struct nvme_controller *ctrlr) * CSTS.RDY is 0 "has undefined results" So make sure that CSTS.RDY * isn't the desired value. Short circuit if we're already disabled. */ - if (en == 1) { - if (rdy == 0) { - /* EN == 1, wait for RDY == 1 or fail */ - err = nvme_ctrlr_wait_for_ready(ctrlr, 1); - if (err != 0) - return (err); - } - } else { - /* EN == 0 already wait for RDY == 0 */ + if (en == 0) { + /* Wait for RDY == 0 or timeout & fail */ if (rdy == 0) return (0); - else - return (nvme_ctrlr_wait_for_ready(ctrlr, 0)); + return (nvme_ctrlr_wait_for_ready(ctrlr, 0)); + } + if (rdy == 0) { + /* EN == 1, wait for RDY == 1 or timeout & fail */ + err = nvme_ctrlr_wait_for_ready(ctrlr, 1); + if (err != 0) + return (err); } cc &= ~NVME_CC_REG_EN_MASK; @@ -352,15 +350,14 @@ nvme_ctrlr_enable(struct nvme_controller *ctrlr) if (en == 1) { if (rdy == 1) return (0); - else - return (nvme_ctrlr_wait_for_ready(ctrlr, 1)); - } else { - /* EN == 0 already wait for RDY == 0 or fail */ - err = nvme_ctrlr_wait_for_ready(ctrlr, 0); - if (err != 0) - return (err); + return (nvme_ctrlr_wait_for_ready(ctrlr, 1)); } + /* EN == 0 already wait for RDY == 0 or timeout & fail */ + err = nvme_ctrlr_wait_for_ready(ctrlr, 0); + if (err != 0) + return (err); + nvme_mmio_write_8(ctrlr, asq, ctrlr->adminq.cmd_bus_addr); nvme_mmio_write_8(ctrlr, acq, ctrlr->adminq.cpl_bus_addr);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202201210226.20L2QwFD001359>