From patchwork Tue Oct 12 13:25:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12552547 X-Patchwork-Delegate: mkubecek+ethtool@suse.cz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A053C433EF for ; Tue, 12 Oct 2021 13:26:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1FBA96101D for ; Tue, 12 Oct 2021 13:26:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236774AbhJLN2C (ORCPT ); Tue, 12 Oct 2021 09:28:02 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:50645 "EHLO out3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236772AbhJLN2C (ORCPT ); Tue, 12 Oct 2021 09:28:02 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id A813A5C014E; Tue, 12 Oct 2021 09:26:00 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Tue, 12 Oct 2021 09:26:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=6MH5BYG5tURGXGf7Ik6wTUXgfEKG0zCjZVmEnF9GlL0=; b=kApjDgQc QIrxFpgyA8kFWCWBqP1LnEToJ5t0WncLb4CLxmCJrUOzs4/z5yJadBpCd1tO3oT2 3o4A8PKHchnx/gJeJ4VbKfJYTNmxx2IKnBaK3m9NQtyKFNXRNLTkZpgy1E8gDSqd CVgjsfmEJ62AUw9zDoh76CrYxRWGI/XabKbJSoytowZMuEF+dwsVRmUxg8cdqKTA mZyIXMmD4lHoCRiWddT02pL5RMk59A2hKXGPJpKxFHv9ByVyr7+NYq3yC4aJ60EY W+fC33mvkxN8Vb714FbrFMceHLiXvazslimltO48v6ZKKIfLk3T81kjdll2C5gkj 4wke3O/Gndjy7A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvddtkedgiedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepkfguohcuufgthhhimhhmvghluceoihguohhstghhsehiugho shgthhdrohhrgheqnecuggftrfgrthhtvghrnhepudetieevffffveelkeeljeffkefhke ehgfdtffethfelvdejgffghefgveejkefhnecuvehluhhsthgvrhfuihiivgepvdenucfr rghrrghmpehmrghilhhfrhhomhepihguohhstghhsehiughoshgthhdrohhrgh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 12 Oct 2021 09:25:58 -0400 (EDT) From: Ido Schimmel To: netdev@vger.kernel.org Cc: mkubecek@suse.cz, popadrian1996@gmail.com, andrew@lunn.ch, mlxsw@nvidia.com, moshe@nvidia.com, Ido Schimmel Subject: [PATCH ethtool-next 04/14] cmis: Consolidate code between IOCTL and netlink paths Date: Tue, 12 Oct 2021 16:25:15 +0300 Message-Id: <20211012132525.457323-5-idosch@idosch.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211012132525.457323-1-idosch@idosch.org> References: <20211012132525.457323-1-idosch@idosch.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: mkubecek+ethtool@suse.cz From: Ido Schimmel Now that both the netlink and IOCTL paths use the same memory map structure for parsing, the code can be easily consolidated. Signed-off-by: Ido Schimmel --- cmis.c | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/cmis.c b/cmis.c index 2e01446b2315..eb7791dd59df 100644 --- a/cmis.c +++ b/cmis.c @@ -340,6 +340,20 @@ static void cmis_show_vendor_info(const struct cmis_memory_map *map) CMIS_CLEI_END_OFFSET, "CLEI code"); } +static void cmis_show_all_common(const struct cmis_memory_map *map) +{ + cmis_show_identifier(map); + cmis_show_power_info(map); + cmis_show_connector(map); + cmis_show_cbl_asm_len(map); + cmis_show_sig_integrity(map); + cmis_show_mit_compliance(map); + cmis_show_mod_lvl_monitors(map); + cmis_show_link_len(map); + cmis_show_vendor_info(map); + cmis_show_rev_compliance(map); +} + static void cmis_memory_map_init_buf(struct cmis_memory_map *map, const __u8 *id) { @@ -367,17 +381,7 @@ void cmis_show_all_ioctl(const __u8 *id) struct cmis_memory_map map = {}; cmis_memory_map_init_buf(&map, id); - - cmis_show_identifier(&map); - cmis_show_power_info(&map); - cmis_show_connector(&map); - cmis_show_cbl_asm_len(&map); - cmis_show_sig_integrity(&map); - cmis_show_mit_compliance(&map); - cmis_show_mod_lvl_monitors(&map); - cmis_show_link_len(&map); - cmis_show_vendor_info(&map); - cmis_show_rev_compliance(&map); + cmis_show_all_common(&map); } static void @@ -411,15 +415,5 @@ void cmis_show_all_nl(const struct ethtool_module_eeprom *page_zero, struct cmis_memory_map map = {}; cmis_memory_map_init_pages(&map, page_zero, page_one); - - cmis_show_identifier(&map); - cmis_show_power_info(&map); - cmis_show_connector(&map); - cmis_show_cbl_asm_len(&map); - cmis_show_sig_integrity(&map); - cmis_show_mit_compliance(&map); - cmis_show_mod_lvl_monitors(&map); - cmis_show_link_len(&map); - cmis_show_vendor_info(&map); - cmis_show_rev_compliance(&map); + cmis_show_all_common(&map); }