Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1312697rdb; Wed, 6 Dec 2023 15:16:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IFqXrjpD8mfnutuWHbTL9o4pEUkwq732vUwIPIXfXzWzHHXSXhVSjhN9tkwTy40zq/7UO5I X-Received: by 2002:a17:903:10a:b0:1d0:9153:3861 with SMTP id y10-20020a170903010a00b001d091533861mr1150419plc.28.1701904606317; Wed, 06 Dec 2023 15:16:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701904606; cv=none; d=google.com; s=arc-20160816; b=Ev1dMUtkRT/4WkWwa3gEdysQiCRtWtXyXcTwSmOZ3TOKFxzYlFMYwuWrFpYz/rJcvO DYiWLrsForxGApORXpzrZmPsPNkfp8mSgD8ffGBtlpSzVmlOMpqenao3W/kQZMBPMe7k 3S8CJ7PnZw42PCMkwZ0lhgHlZGk18CdrHRdz0I4Ab6YByWwq+xGMm1g5u/nM5qc9S/TR ajGE1qMjlbU3QCpP4n8ZYjdQSKeHAPG/pF/9aQb3xAL3F90fwsShER/Gye/XAeBICvZb BlpPAWOs6ayNH05VJvnmZmjqRNmUMeKHk/ECudtaJqssfBk5GW6shOtj0eb++A6lPVQd ZYVQ== 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=/7eYcPC4ZNNyPcPPs0B5tDplF0arxw3r0vINNNou0rY=; fh=KbtZdS+g7EcIXF6IkhyVCA7RdLprHttm0sN0x6fLY0g=; b=gllJ0T5YDgSocv3UR560oW5LakJQrvCqKpeZYTUIwS/CQyy1Nfk351+g3owOTpmJT1 lt9Re4whu3QEZRhn7lWAff7Q4dgJAP+D66X3cFH84s3TlXDUvnK37Y+Z/7NW0pc2fvk0 WXmYHE53Em3bLyMLqGeI8J3yJEZINACHP/HQBkMpbtvPWr3bxImfIpykdTST7RAN48cC lVcd7u9d/NSDb9Y7CbFrJa4B/N013+kq0JJC7SlI6ZFD5rUiM90V2a62DiPqL2+Oke+d RPcvBHZuKcoln1q9zPgt0PyOuJkoSYjc3KqoNs7frFRM3mSZbpiF3Kk4pQqlGwLGAxzS 7uJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="sMUeie/T"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id g8-20020a1709029f8800b001cfd0495291si507183plq.524.2023.12.06.15.16.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 15:16:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="sMUeie/T"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id 032F5807442E; Wed, 6 Dec 2023 15:16:34 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229669AbjLFXQM (ORCPT + 99 others); Wed, 6 Dec 2023 18:16:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229545AbjLFXQK (ORCPT ); Wed, 6 Dec 2023 18:16:10 -0500 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 820C5B9 for ; Wed, 6 Dec 2023 15:16:16 -0800 (PST) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-db5508d1beeso391710276.2 for ; Wed, 06 Dec 2023 15:16:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701904575; x=1702509375; 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=/7eYcPC4ZNNyPcPPs0B5tDplF0arxw3r0vINNNou0rY=; b=sMUeie/TxdytzC0EyT11QWi1TqTtiv7KCTs1F2vLmUUvPKNA3+1MHFo8ECW+0gQuDE FGrgdZKGK5mXQgkF0N3JiSLvKO8tpQOIB57JLCG5IVy5dr2vVv0ExU3Dag2Cc4oBIBIO w/cH95O1oPlvluIpATmAsxenVr7mFomU63BqYiRGLaEhWeb2hJ636GO8lubtsDfdFFoi GPOL2tQwV93VnqmywBBpFaNAULN0UoCFhfkKv5prvpkXq19sWI7zyorVZ+rdTYem5m4T dXsDaLXPtC3Dh2JOad1duSQIah/wCHYYUcV3IoFhwj2y0Uk/TTCrnZPORweSADcEy6Ho vDrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701904575; x=1702509375; 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=/7eYcPC4ZNNyPcPPs0B5tDplF0arxw3r0vINNNou0rY=; b=bGBol5UTuZEdsDO/0cq8Cq1WCdtF3+T9fiUO9jkFFYyxRaU053g5U5lMM0Idw8F44U WztkZqyOqzSAWIld1PvFQjW9IXIBAvxTM+wVrxA21FzYQGhxm91TRXcoJXWvjwdLbQm6 5jQpEjZoNf8SIC7We2uP9JMxDNUPMBDmj9fovUYGb6Ich+c4Q7YD4exFLDRmNEdqcg3P /ehmd2QSdPmbwgmvajSuvjuO4vxv2D6NCcnAFms/hnn7b2vpUdb/F2WxGiVaH7Qc6JhU jv338k3wYsLgN6tzuOY5rmuFWXGD/8HoMsTelSIMgiztXCgWMBRm3paKySYGsl6+PFvK EubQ== X-Gm-Message-State: AOJu0YxuErh/0qOICxy2/EG1romutnD66P9K5ma0pmycJBcRik5MsRt3 i5SPuFha0Yq+gJvyezpbWZJ6OKxdGVaqVke3Cw== X-Received: from jstitt-linux1.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:23b5]) (user=justinstitt job=sendgmr) by 2002:a25:dac7:0:b0:da0:3117:f35 with SMTP id n190-20020a25dac7000000b00da031170f35mr28652ybf.3.1701904575576; Wed, 06 Dec 2023 15:16:15 -0800 (PST) Date: Wed, 06 Dec 2023 23:16:10 +0000 In-Reply-To: <20231206-ethtool_puts_impl-v5-0-5a2528e17bf8@google.com> Mime-Version: 1.0 References: <20231206-ethtool_puts_impl-v5-0-5a2528e17bf8@google.com> X-Developer-Key: i=justinstitt@google.com; a=ed25519; pk=tC3hNkJQTpNX/gLKxTNQKDmiQl6QjBNCGKJINqAdJsE= X-Developer-Signature: v=1; a=ed25519-sha256; t=1701904573; l=1840; i=justinstitt@google.com; s=20230717; h=from:subject:message-id; bh=UMdetIL2ZsPIkSodqhw2fM21NHJVjCu0lRImFuNhVoM=; b=a8rMnXfVVQ5gsxHWG4WRMwOLxZgflqXZtNuKx26vv4DwYvvCtCiYjl3f1frOjV/Ul2kaxq5g/ b/UOv678JKCDASVokxG5GJifAnU7/kqRxdhcwfRkrD8RUfcsmiZOfyF X-Mailer: b4 0.12.3 Message-ID: <20231206-ethtool_puts_impl-v5-1-5a2528e17bf8@google.com> Subject: [PATCH net-next v5 1/3] ethtool: Implement ethtool_puts() From: justinstitt@google.com 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 groat.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 (groat.vger.email [0.0.0.0]); Wed, 06 Dec 2023 15:16:34 -0800 (PST) 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 689028257fcc..2480a4e4a331 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 without a trailing newline. 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.43.0.rc2.451.g8631bc7472-goog