Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp1452538rdh; Fri, 27 Oct 2023 15:06:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEPyMDPxdhDxafzJEOvP3hSyXTa29jDLHJBBtI8rEOfogXS9OmTAS5NiCakEFfFTUqO7O7w X-Received: by 2002:a5b:706:0:b0:da0:c49a:5103 with SMTP id g6-20020a5b0706000000b00da0c49a5103mr3687471ybq.47.1698444380603; Fri, 27 Oct 2023 15:06:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698444380; cv=none; d=google.com; s=arc-20160816; b=npkWOVkGiDDvHMRJyxJGPh7TuYd1VxMVX6Z9ixzjHmLCmVHT5yASVrFvba/Ldoja6f nZP9fLafcBNtzvP8317bTcMcsA28alEaYFuYe+pJq4l7L11gCEINPFDoPE9GkNvth50i pRoxWmRJ4ovuWCKfzdnru+Q6dvmYU5KTZa0KZ+9NGTNSjYgLGDGwy1trK5gQrvC+pXq4 XDJ0uxt5FOTopUkuWQNmDVa63HtcnqmWSCWTEOaiHc6iRZkdwBMBpwalphtXzwvcV4cc x22xHdvRIRsj6Ig+H+6a7rjDQf6CjgbvZ0BtSoFsrL6r9SMdYRkHRVAS2P+hQ4246pG+ wJUA== 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=LDqGU1lZbnWOljJhjK5QPctoYCimsNeknFpCayVMkH0=; fh=KbtZdS+g7EcIXF6IkhyVCA7RdLprHttm0sN0x6fLY0g=; b=ou2N8EkyoGROq107+zhZDpbTPZZkV0TFGzXeCaTXH4uLQZenJxtETHHKqvuM7adWVK 0Ee5x+vMQDaGRvMSWbw6zfwZJyAP1qs6e1FylQMBu+Zw/rdcN+2ybdWHV/OZCc3PqdzZ n8MEG0U9OjAih/6+kzx7HBoTECttuBNS/eq7TdQPywrnqHmqAX59eNQ5rlNyCT3Na3aO ROmBVL6gSRxzWLQC4rBs45IanYDoUIvglYkzBR7V01aYFWbHNYKXji/Lis62JbgBcuzv Je8Al+aVhcHwCaKeBse0wRfAPBJ4tXzxYt33ZlIYPhtd1sVOrv36sVlDcgMPiq2ezsmJ akaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=niMtvX57; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id i139-20020a25d191000000b00d865b810d03si3735069ybg.642.2023.10.27.15.06.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 15:06:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=niMtvX57; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id 1C7A58384F78; Fri, 27 Oct 2023 15:05:55 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346624AbjJ0WFm (ORCPT + 99 others); Fri, 27 Oct 2023 18:05:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229712AbjJ0WFl (ORCPT ); Fri, 27 Oct 2023 18:05:41 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 345151BE for ; Fri, 27 Oct 2023 15:05:38 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-5a7b9e83b70so24403937b3.0 for ; Fri, 27 Oct 2023 15:05:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698444337; x=1699049137; 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=LDqGU1lZbnWOljJhjK5QPctoYCimsNeknFpCayVMkH0=; b=niMtvX57gyjujwstvucVtKV+qWGIXv/RZiYNVMkg1eAOo7s8ZFnWEyOTgXXoGOatYx 9GtL5f7NQ9cdOCmuPdEIxDJYblIPqVXOG6E7oYGWFtnXZwbmO++dHPWxmHdfFFa5/Wji Wi+OTchtUmiRLD1sz5wzTIXauABXTZ4HKNMLgiz7plWbwWDTNh6gd8NsScPaGb750RtS lS9EdlWeeiFOVGFMpM0DWYO03sj6RnL1xwmFBRFt5Ox6RTdSsfIgQ9RjeKYcxGe41oeG /tKWQOychJOEqmrI/nF9PHFdBZOv+KQB4rkBRDr/O3eaUZalDvgg3Mx3usAogPIOreHJ E5tA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698444337; x=1699049137; 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=LDqGU1lZbnWOljJhjK5QPctoYCimsNeknFpCayVMkH0=; b=OOvKkF3jYIdN34TUZxwXFxB35Y/9rh1pl/jOTGAU6acYOXBOSvEFcja47tX2VmNd5r JuI/b8qRdDnVY+7OZH9TK0lQKlc8uQ21viysGxsxdhJDPIgBqZFHX+xZnyBl2Sc4abA0 DivqPyzQhIwcU5nDvghEni5e6kAC5TZvQDCKUQREByFpcttGB2Qo9GL5jh2qYB4aITlR dSxUjyCiiBwPQwGTZ2uaI2kTsEA06aVbNCT1ug+HeZ4MQkGvlPkesg1UqyCo+5PdTmnm 83oQSZfxrQrWE1ne6c6NHiMAKfwd2uBMfI8Zi92xH9VyRd5r8CCevArcrVm0MW5j1Mn9 UgQQ== X-Gm-Message-State: AOJu0YxYx+Gihe6j3Pl7kBf9XKkgApJS/5lO0or0zyq+6KJC186PzZKt pKa42CLdmbj3qzSAbItLCXOAFTTpCjONWLBMew== X-Received: from jstitt-linux1.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:23b5]) (user=justinstitt job=sendgmr) by 2002:a05:690c:84f:b0:5a8:207a:143a with SMTP id bz15-20020a05690c084f00b005a8207a143amr169382ywb.0.1698444337337; Fri, 27 Oct 2023 15:05:37 -0700 (PDT) Date: Fri, 27 Oct 2023 22:05:33 +0000 In-Reply-To: <20231027-ethtool_puts_impl-v3-0-3466ac679304@google.com> Mime-Version: 1.0 References: <20231027-ethtool_puts_impl-v3-0-3466ac679304@google.com> X-Developer-Key: i=justinstitt@google.com; a=ed25519; pk=tC3hNkJQTpNX/gLKxTNQKDmiQl6QjBNCGKJINqAdJsE= X-Developer-Signature: v=1; a=ed25519-sha256; t=1698444334; l=1790; i=justinstitt@google.com; s=20230717; h=from:subject:message-id; bh=C2aJLhld7+He/NhanUu+TBSh3mm30JdYcWWvhqdYpEE=; b=AfZV04Dc5Hq5NuvZos0GZLUC7hu4efQeSkMnA+v2WXw4qwaSx8UWMdEANSs/8b+Z8OxORp/XA 9gfZVq7L8M7B0xzZJ8a2FS7J1UTFxSmVPXAm+Z47MMNan57YnyOAbE3 X-Mailer: b4 0.12.3 Message-ID: <20231027-ethtool_puts_impl-v3-1-3466ac679304@google.com> Subject: [PATCH net-next v3 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,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 fry.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 (fry.vger.email [0.0.0.0]); Fri, 27 Oct 2023 15:05:55 -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..e340ed822cc2 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 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.820.g83a721a137-goog