From nobody Mon Aug 07 22:45:40 2023 X-Original-To: dev-commits-src-all@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 4RKWch2X1Tz4mSxT; Mon, 7 Aug 2023 22:45:40 +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 4RKWch1gcPz4Nnl; Mon, 7 Aug 2023 22:45:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1691448340; 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=4LYb5teH3mS4yq3N3Wo0r4EpFQJCw23g9uOP5I9RklI=; b=mSM0Xw9o6e1qrrC46jjun0Db2RQRQG3er8vxVbsGp3FJOlMC2Rcgeys5K3Lvivbrqh4Ei0 zr+opGyY0L1c87764oJ0mCPGflTzNju7JkMYOKer9bZC1wutEAqRYAcYYGaIJhM+F8GpCQ 0wixEPe+GFi/hr8ZwEX+Xt5qviyShkb4rUz51OL900dUcHS1K1Qxm24HfCEowLaOwHe1Z2 g7yoL1L9B/rNwrk10iTjdghYPlkqNSHYnmkmCOUq7+e5wWhFjcr0UXFB4mNHPWlJt+0SxE JCWZ37ZF2VsnjoottjnIpYAIHviQK12FrVO1Bg8f666ZSEVI5Je6BHWL8eXnmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1691448340; 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=4LYb5teH3mS4yq3N3Wo0r4EpFQJCw23g9uOP5I9RklI=; b=MR6AMIGyVTeYCxWC18pKkglV+2y/m/uL8M0UPAXFzN1xchDvmkXKS2ZIR/wwME2kHIFvRb oyb9/N+N1UVtFR2YgeAQ/CXanKR0JPSRSHWuLL7FmL+0BWsWKkXatO1u7vVrSoJ2bMoQ4d qq5d+VB5TPts/g4KwR1Rqv/jXUaD3xKiwqiT8qnrOFVYY3h1WGNl/N6tciobQeiY9lLzCd xr3+mRf8O30BHiWQ22H545T9I7N8S5mIq8K6I6G0McwaFkt9r577RCPR2QUN6knnI6/Nfz TeGHbpKOymQ4hLSM3hL+mSF3bcbUkSR6yodQldDB1hq+zWgwp1RAqqhaYuIzyw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1691448340; a=rsa-sha256; cv=none; b=A4bHbSGbWFYnemkJ0Ov1yO7uuDCFPZ1uhGhtzygkKcFlzeTg7rynjEgmGNiC/9FmlJs6Z1 2ChndbaRrQTmmrOBtJMRKRiuWYHmuYZZQ4UFyYTnPXYCGsG5edyUM+D+lXd4vCq3nWDY+N 4pAmARqTvbW5Afc1/XTadNd7/h+fbD82QO7kLGGI+v/4RefvrJwQEJ/+4HKPzQ3ZSbxwHt TwkIdOoD90gyvp/Nmq4zygSTR7usMyWoKvUtojQ25sp7F5n2u/ufhE5bEH/ZlpooXJnjOI 5uPEKP8zAYizbVsF4ZW0acWUWb1ujRJQeit80Yjrd61ZoxAolulPArPNWfnA3Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4RKWch0nY4z19DS; Mon, 7 Aug 2023 22:45:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 377MjeZs058637; Mon, 7 Aug 2023 22:45:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 377MjetB058636; Mon, 7 Aug 2023 22:45:40 GMT (envelope-from git) Date: Mon, 7 Aug 2023 22:45:40 GMT Message-Id: <202308072245.377MjetB058636@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: edd23e4dc013 - main - nvme: Eliminate redundant code List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: edd23e4dc013fe9603138271a2cfaa68732055ba Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=edd23e4dc013fe9603138271a2cfaa68732055ba commit edd23e4dc013fe9603138271a2cfaa68732055ba Author: Warner Losh AuthorDate: 2023-08-07 22:35:15 +0000 Commit: Warner Losh CommitDate: 2023-08-07 22:44:31 +0000 nvme: Eliminate redundant code get_admin_opcode_string and get_io_opcode_string are identical, but start with different tables. Use a helper routine that takes an argument to implement these instead. A future commit will refine this further. Sponsored by: Netflix Reviewed by: chuck, mav, jhb Differential Revision: https://reviews.freebsd.org/D41310 --- sys/dev/nvme/nvme_qpair.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/sys/dev/nvme/nvme_qpair.c b/sys/dev/nvme/nvme_qpair.c index 40c9f6053b95..988c82741592 100644 --- a/sys/dev/nvme/nvme_qpair.c +++ b/sys/dev/nvme/nvme_qpair.c @@ -99,12 +99,8 @@ static struct nvme_opcode_string io_opcode[] = { }; static const char * -get_admin_opcode_string(uint16_t opc) +get_opcode_string(struct nvme_opcode_string *entry, uint16_t opc) { - struct nvme_opcode_string *entry; - - entry = admin_opcode; - while (entry->opc != 0xFFFF) { if (entry->opc == opc) return (entry->str); @@ -114,18 +110,15 @@ get_admin_opcode_string(uint16_t opc) } static const char * -get_io_opcode_string(uint16_t opc) +get_admin_opcode_string(uint16_t opc) { - struct nvme_opcode_string *entry; - - entry = io_opcode; + return (get_opcode_string(admin_opcode, opc)); +} - while (entry->opc != 0xFFFF) { - if (entry->opc == opc) - return (entry->str); - entry++; - } - return (entry->str); +static const char * +get_io_opcode_string(uint16_t opc) +{ + return (get_opcode_string(io_opcode, opc)); } static void