Received: by 2002:a05:7412:5112:b0:ee:8f30:e15d with SMTP id fm18csp592499rdb; Thu, 2 Nov 2023 11:57:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFI2ZAQIzQSU03WpvlVVc8w+OMSW0xUBnzEq7R5Ob/CCtbBOiPBMJHZzXz7Q4Y1lRAEEZqW X-Received: by 2002:a17:902:e84c:b0:1cc:51ee:5faf with SMTP id t12-20020a170902e84c00b001cc51ee5fafmr421292plg.7.1698951424380; Thu, 02 Nov 2023 11:57:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698951424; cv=none; d=google.com; s=arc-20160816; b=PLixglmhYyrXmHBW+D5k0W2TuzbPLEGFUpvlt0gst+eBdkdO+xXtDZwt2f3jmGyw6Z R1oRu3ZuN1M4kzGNx2bSLYVMdfioWyapAaSjnXE6bQEldic/IhYFIB3gYbrXIZQyyzjm SHDBhJvCzmtzD7dxplnkDCr9gnDYHuXjapSmS+2owBPVfTfsK2P3VzpNCkOwix5jOXfq XHLOHvdeRKROzRFrXKniNEMdjc1idToSPDqXgqAgFG+SV4NboCHAjJbY7fnIPZSj2oLf hqNGwvEryVdBxBmBzwJdT8xXH98DE24iudW/ENxmnb0mtKEaoz/v97i6W0co9/CjQMEx ZaKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=K1MFejYfcIlhp5L6UBckhhQYL5s7bmRsL3b92h+ON2U=; fh=KbtZdS+g7EcIXF6IkhyVCA7RdLprHttm0sN0x6fLY0g=; b=KHt/lnuuE3iN1mSib+m4Tfm/UyY/AYLN9tj/dYE03jOVs0v4H9KUa2wd8q0NqmBsgP 2gsJISC/Bf9pdWLRcSWhpeVRVTw8gMV7FsnxATG2sKLhcSRU/1rjIly8thDO0pOLHX+d 84pZosQGm7EiPCfs6Uf3/R9hFFw7QD2hgogrxJm/JbMVq3giTVGfI977+cUcEzBrjXwV OvN3akL+ilwAzanljFXzaB6XriQOzxC1ttmKdZ7b6ih+Vq6ziuv0mZ4Lc5c9yTyRR2le ewQAa9TxE5FLJfuaIcquxj0ov9ZPgtaYgkW+17PmEPCn5Z4Bb4/E67FgWxrkX7TSlI04 sYyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Iignz9zw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id q11-20020a170902dacb00b001ca119ef46csi107216plx.478.2023.11.02.11.56.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 11:57:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Iignz9zw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id E7CF2822742C; Thu, 2 Nov 2023 11:56:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377214AbjKBS4D (ORCPT + 99 others); Thu, 2 Nov 2023 14:56:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229703AbjKBSz7 (ORCPT ); Thu, 2 Nov 2023 14:55:59 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 160A5184 for ; Thu, 2 Nov 2023 11:55:51 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-5af9b0850fdso17755977b3.1 for ; Thu, 02 Nov 2023 11:55:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698951350; x=1699556150; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=K1MFejYfcIlhp5L6UBckhhQYL5s7bmRsL3b92h+ON2U=; b=Iignz9zw+EjFYVG0WTLlv6bu4Q6K2OBUdMYTf9SNuBsdBgb9ijqpMdbi1sxXtG2xT6 0aFSNJ0BZ8fHw2Ziq1o2S/1y76vI67IKTEExz69AV9EIstysr+dgkfN/YNd0wIstHd2E WvUqxBtKaWJKa6O07F7CGqQDp/9ZWGEglKbYEhApjWGXQFkvSMzR8SuHyQiWpIKpDbx7 x3kYROKODF4Vc4o5dvylEk525Aatr42k674XcTwm7OmEldDwY8qtPd53vXpGUVCGYHff 6H6sRKk6bJ/ui8xJ7mRdvgJlIZzAnIixRbbzjChXIOdBnfV6r1Ehg+Og80Tc1cR+ATdO O9Pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698951350; x=1699556150; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=K1MFejYfcIlhp5L6UBckhhQYL5s7bmRsL3b92h+ON2U=; b=S/9JxT2VOHUibhTYGjIj7apL8lE+3epRNf7fHCylFdotMpOe+hx9N9nzyn6VrJwzeS oCX7xFLhMu2AyyEfBx4qIdGEvvUyNlB9fxeBW4vmeIPC9SnUJENAT9sgVv/v4JZxqoPa x//YPKHWMj04LfOaPUJ2afX33YzmenQTK0W5leZSYnGJn81Nuu/v2I8cphkVPLWX/0su PaKc56fGL5Dv97SDll1DBfKVHLnPf4L0vCnOBLnagsThDFBhik2dXJhaXnLVH1D1iXOz 98G0MC6eSsMCwa/5D+z73No2FzUO8hTK0cDbQ9Rz6Hu3OPtX/Ly5T7mVi/kcxkolgear XLKQ== X-Gm-Message-State: AOJu0YzjIVcXvE6qOLULCvY6w8eDSL2jYhlrSCBzPebBl23lTx1Rj8l9 hULUePwt4gdcLTlKenofAQ+gZ9/EoOLjyb3M7g== X-Received: from jstitt-linux1.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:23b5]) (user=justinstitt job=sendgmr) by 2002:a25:e7d5:0:b0:da1:aff2:bfbc with SMTP id e204-20020a25e7d5000000b00da1aff2bfbcmr316486ybh.2.1698951350112; Thu, 02 Nov 2023 11:55:50 -0700 (PDT) Date: Thu, 02 Nov 2023 18:55:42 +0000 In-Reply-To: <20231102-ethtool_puts_impl-v4-0-14e1e9278496@google.com> Mime-Version: 1.0 References: <20231102-ethtool_puts_impl-v4-0-14e1e9278496@google.com> X-Developer-Key: i=justinstitt@google.com; a=ed25519; pk=tC3hNkJQTpNX/gLKxTNQKDmiQl6QjBNCGKJINqAdJsE= X-Developer-Signature: v=1; a=ed25519-sha256; t=1698951347; l=1809; i=justinstitt@google.com; s=20230717; h=from:subject:message-id; bh=CSBVoPDv8bUcjz46YxS9QitvpQ3NGLvmBs8lKX6nt0Y=; b=ahqS7od7MuaYQgDwf1xLYrlZa/EPl4vCGCgO9aqOLDD54X4Mk82mLZTadznG6MV4/eOfOwtgq gVYFH7WrWL5BPoocw4PUQQAzqFcybf4biUS6+am4p7pCOnSg+h+I6qg X-Mailer: b4 0.12.3 Message-ID: <20231102-ethtool_puts_impl-v4-1-14e1e9278496@google.com> Subject: [PATCH net-next v4 1/3] ethtool: Implement ethtool_puts() From: Justin Stitt To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shay Agroskin , Arthur Kiyanovski , David Arinzon , Noam Dagan , Saeed Bishara , Rasesh Mody , Sudarsana Kalluru , GR-Linux-NIC-Dev@marvell.com, Dimitris Michailidis , Yisen Zhuang , Salil Mehta , Jesse Brandeburg , Tony Nguyen , Louis Peens , Shannon Nelson , Brett Creeley , drivers@pensando.io, "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Ronak Doshi , VMware PV-Drivers Reviewers , Andy Whitcroft , Joe Perches , Dwaipayan Ray , Lukas Bulwahn , Hauke Mehrtens , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "=?utf-8?q?Ar=C4=B1n=C3=A7_=C3=9CNAL?=" , Daniel Golle , Landen Chao , DENG Qingfang , Sean Wang , Matthias Brugger , AngeloGioacchino Del Regno , Linus Walleij , "=?utf-8?q?Alvin_=C5=A0ipraga?=" , Wei Fang , Shenwei Wang , Clark Wang , NXP Linux Team , Lars Povlsen , Steen Hegelund , Daniel Machon , UNGLinuxDriver@microchip.com, Jiawen Wu , Mengyuan Lou , Heiner Kallweit , Russell King , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Nick Desaulniers , Nathan Chancellor , Kees Cook , intel-wired-lan@lists.osuosl.org, oss-drivers@corigine.com, linux-hyperv@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, bpf@vger.kernel.org, Justin Stitt Content-Type: text/plain; charset="utf-8" X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 02 Nov 2023 11:56:36 -0700 (PDT) Use strscpy() to implement ethtool_puts(). Functionally the same as ethtool_sprintf() when it's used with two arguments or with just "%s" format specifier. Signed-off-by: Justin Stitt --- include/linux/ethtool.h | 13 +++++++++++++ net/ethtool/ioctl.c | 7 +++++++ 2 files changed, 20 insertions(+) diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index 226a36ed5aa1..7fc0826d443f 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -1053,6 +1053,19 @@ static inline int ethtool_mm_frag_size_min_to_add(u32 val_min, u32 *val_add, */ extern __printf(2, 3) void ethtool_sprintf(u8 **data, const char *fmt, ...); +/** + * ethtool_puts - Write string to ethtool string data + * @data: Pointer to a pointer to the start of string to update + * @str: String to write + * + * Write string to *data. Update *data to point at start of + * next string. + * + * Prefer this function to ethtool_sprintf() when given only + * two arguments or if @fmt is just "%s". + */ +extern void ethtool_puts(u8 **data, const char *str); + /* Link mode to forced speed capabilities maps */ struct ethtool_forced_speed_map { u32 speed; diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c index 0b0ce4f81c01..abdf05edf804 100644 --- a/net/ethtool/ioctl.c +++ b/net/ethtool/ioctl.c @@ -1991,6 +1991,13 @@ __printf(2, 3) void ethtool_sprintf(u8 **data, const char *fmt, ...) } EXPORT_SYMBOL(ethtool_sprintf); +void ethtool_puts(u8 **data, const char *str) +{ + strscpy(*data, str, ETH_GSTRING_LEN); + *data += ETH_GSTRING_LEN; +} +EXPORT_SYMBOL(ethtool_puts); + static int ethtool_phys_id(struct net_device *dev, void __user *useraddr) { struct ethtool_value id; -- 2.42.0.869.gea05f2083d-goog