From nobody Fri Jan 21 02:26:58 2022 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 6A480196904D; Fri, 21 Jan 2022 02:27:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Jg3DN6NVCz4nwS; Fri, 21 Jan 2022 02:27:00 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642732022; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=653Aqvol/htoq6REfVFFpOFiV87Ueg2Jqt8ket5LBnc=; b=i5FrVRz93giWEopKnCwXVrlwDMdvPskHE1j/S2NF+06ljjr5SXCYcSP7oUJ6GP0+VgmOse Zpb9cQureDr1aOVIl519gKN8mbIKFWstWQB7iMygyR1j2NDk2QihJ6QXcXNIFuMq6oZH5y C9KSSWzenTJLiLnSvvpidO5q5x1uix/PlHWMuh2Fh9EEatD/iXN48+OYgVvIL9Qv/slsG1 5av4ZmxndAUUKDuVDYw+HUOMkFBb6tMKtJaA3G/U1rNo9KSTgzT4/cZ4KqWJmBinX96A7Y FWPYmwkWVmiN31vTjkfgLSx0pVwpy0JAnMfaph/OjbbLWIDlTFjQ8lx6eAvtdA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 66C6413CAF; Fri, 21 Jan 2022 02:26:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 20L2QwkV001360; Fri, 21 Jan 2022 02:26:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20L2QwFD001359; Fri, 21 Jan 2022 02:26:58 GMT (envelope-from git) Date: Fri, 21 Jan 2022 02:26:58 GMT Message-Id: <202201210226.20L2QwFD001359@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alexander Motin Subject: git: 02325a44b520 - stable/13 - nvme_ctrlr_enable: Small style nits List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 02325a44b5202ef715bec9c162085d8dc737d442 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642732022; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=653Aqvol/htoq6REfVFFpOFiV87Ueg2Jqt8ket5LBnc=; b=bDsp3BHTr1LwhcWNlWIB+bOjPazgYfQ8X/mJ7UnXbV7CnMo2NX1/pzIt3GIl6kMHHgV2mA nTOKkkBlA9U2PhaDkTl7GcFbDm1qlT5rT6SY220CquRjGnEl0BgEUHEOD/Yp4QGw3K2OVW aTTaaH/sR7OuLAq/Tq5NOkenJuQY8qd682ZrOiiKOel7bxyY85fzeADYb1C19iHtIwUTuH fN/fvTFWEyj4eACLN18RKMviqFzEJTD6Ks3Y9cj9JCra+tbR881TuguV/5eW4ntPs3x2Zy VgQbKXbwDHR7WHRWt3pel3/1Hc4m5SWhX/zJMUYc3JO4Q06ST5R5pjs0DaaXQA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1642732022; a=rsa-sha256; cv=none; b=D0F/exByPuBljouVrO+35YQHf3m/XRMhaXOi+q/xMHuIfRirzMx+jmQKNR7thuw5qL8De8 fMofXozvO4zC3H9jQvJcUNCpQTZuoO21uFcb+hZ8PlfxxvZmZk/6FW+3dzxeTXgliH7He7 56adZXC06or9WT6yKoUF3MiHzT/iwEZJy8fHfumhpo9kF11g0nw+XSXAYthLE0G0oo+Ibl sV+yaG5qht77dtPNWlfa3zcYRimCAyyReCpcU5djqTDa1fd5peqvnUt3JZgg4JZyTWm5Si +Ry8ZlqEoctL+ZGf4FK4g/y913/7CM79+3DDm6px7Eur3RsKUJBUOfpouwhgrg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=02325a44b5202ef715bec9c162085d8dc737d442 commit 02325a44b5202ef715bec9c162085d8dc737d442 Author: Warner Losh AuthorDate: 2021-10-01 16:51:24 +0000 Commit: Alexander Motin 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);