Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp749810rdh; Thu, 26 Oct 2023 14:57:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHekg1xMX4Psc5flozYZ2IqJzAaa5qvDP+f3HnteRxl/MvTT4zxXn1KlbS4G5Z2QMiCwsSB X-Received: by 2002:a17:906:ef07:b0:9c6:3c94:69fa with SMTP id f7-20020a170906ef0700b009c63c9469famr615841ejs.44.1698357451186; Thu, 26 Oct 2023 14:57:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698357451; cv=none; d=google.com; s=arc-20160816; b=DyfJv7l6fJaJX/vHGzks9NBRSEiPcLjXazTCUWA3mFbaXeSbm6Bz19sXX8lY/SWFQl g5AyKqymWDy4FEPkUrO8e9Bt9zQj25TmaABLK7o1lI8cxv6ibkmoiN5r6qwwee08vCuX 8a8hfG/eF1+QjCzsV4C/DZ+an20NolBC/QE5ViepDiQgWbwdimZoJAz6gJvRlm4W9IIg nrNv00a2MFe/J2ul7WpWEybJOlqDviDTHzMavALwG+lyNNUPijzOmrJh+S6xH3n31r5G cOKtBR/peXgrThH8Ltj7YgQ7u6pt36z69TJQRpMkIIYbTfyLL3ExUWayZWhg9mPslxLd rQAg== 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=BGnfO5yo1brrl3JG1fuz3XeacVop9nGYIXct/GsCbHA=; fh=KbtZdS+g7EcIXF6IkhyVCA7RdLprHttm0sN0x6fLY0g=; b=iIb5OqHrtZWRwnGyISEy0oulBYDDZPhZ+msfHZnpj6ehPgVuZmN3dzrwHsXt0UYhll bdeqxq1d/EKYOTvwI/rz9lMhSiC45ObTfzdza+I6pNyuDki3jgXoHmLy8rBUNGhumYxd Pb4iUMAeLzH/QOEsoqT18Wmxa1GhpfnqwwxTmHl19xg5fWfoWdMLairDd7fyn1if6wcV JzNjjK1BwfHCrp4FoXGjV6hs5bfS6WIGHwd9kpM1Oq4Zl/acm3rijroOAIdKqayuouYq 7YD6VBdRU0E0kS0cg1Rb1t4rXsi4MPqK6BJDgCta9hN/7T6qxcC5ai7ZeYXmHZ4LfAAX Pmww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=YPj55n2C; 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 f27-20020a170906739b00b009b282bc797esi144073ejl.225.2023.10.26.14.57.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 14:57:31 -0700 (PDT) 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=YPj55n2C; 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 ACA77825F17A; Thu, 26 Oct 2023 14:56:48 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344887AbjJZV4Y (ORCPT + 99 others); Thu, 26 Oct 2023 17:56:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231977AbjJZV4U (ORCPT ); Thu, 26 Oct 2023 17:56:20 -0400 Received: from mail-oi1-x24a.google.com (mail-oi1-x24a.google.com [IPv6:2607:f8b0:4864:20::24a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 913CE1B2 for ; Thu, 26 Oct 2023 14:56:15 -0700 (PDT) Received: by mail-oi1-x24a.google.com with SMTP id 5614622812f47-3b2e7ae47d1so2122896b6e.0 for ; Thu, 26 Oct 2023 14:56:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698357375; x=1698962175; 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=BGnfO5yo1brrl3JG1fuz3XeacVop9nGYIXct/GsCbHA=; b=YPj55n2CVrwECELqBp1BWiRdDeiahWrh09vlZ9y4NuNIM4rkt4JjSTqAD3G14/dtDN s9qy7TH1VNXFRWZRxvyV8chlR75DGWEb8DHwpyan3CMTpFapkWaO+0Vdbwaff7HzQotA 2wsba9jbSdhe9m3ytUGelfD2m5nszW3EMaTmjhwE7kjyctQaGJ6wSpPY1JBk/8mOG4IK e0Lfr3qz3Krsqf3x0jI5dko8CEbdQ2TdfXUaIyhK86nUQpuN36EuhYopTbPE+gGu2CYu kqY2vs8KI8byVCUOC064QBGruHUGWvdsrbkg7r9XFBZpMXhKyWNgBjL0Pb4SEaK2emWS v6SA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698357375; x=1698962175; 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=BGnfO5yo1brrl3JG1fuz3XeacVop9nGYIXct/GsCbHA=; b=nEHHRft6MscZpBCpFisGe19KRRUkQ33MSXxkuXqmbAPZTDXRbrxUciuSyP9AK1FJza mkqpT8rlAX1uq+q4VOqoppB2fEtA1b4YZMW4Q+PVXiI4He9hSIOgA9wxGf81bTWQurB8 0B4Qw070hq8wk6MdO8oggjNVpmFwjHZwzy5ynE1UGfIUu0/nagL/ERX2r29DxezB3C9Y 89CjDaI9HhUNmFgDTzuu4m3WJq5yGGH2WO00m/1bAsMNDMMhx46BZqCsVYkVclF5GmdT DWclecXrd5Ktmr0LDCFqQoWLuc9EjYo3JqKnLnwHiJ/+pH3dGkjEPos5VZwvh3+d7+wR nIZA== X-Gm-Message-State: AOJu0YwDlVnDdNMItCHR2aDhoHwQLEanJI4pUcIRTZE+sFY5riSyUFvs MTYPn1mjG/qZK6dVsHPS9njBsUm3IerLIl48JA== X-Received: from jstitt-linux1.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:23b5]) (user=justinstitt job=sendgmr) by 2002:a05:6808:f01:b0:3ad:f860:b315 with SMTP id m1-20020a0568080f0100b003adf860b315mr220107oiw.2.1698357374848; Thu, 26 Oct 2023 14:56:14 -0700 (PDT) Date: Thu, 26 Oct 2023 21:56:07 +0000 In-Reply-To: <20231026-ethtool_puts_impl-v2-0-0d67cbdd0538@google.com> Mime-Version: 1.0 References: <20231026-ethtool_puts_impl-v2-0-0d67cbdd0538@google.com> X-Developer-Key: i=justinstitt@google.com; a=ed25519; pk=tC3hNkJQTpNX/gLKxTNQKDmiQl6QjBNCGKJINqAdJsE= X-Developer-Signature: v=1; a=ed25519-sha256; t=1698357372; l=2655; i=justinstitt@google.com; s=20230717; h=from:subject:message-id; bh=8djdPmMRDp1kcBXDhs8ygPXLuTfgtvGs7Yo95u6cw0k=; b=oxdmPg9KABeZlWyohpoRER6suttzISQsU1pFrM2utjhSx+ViWnRXf8IVNcElP/r+ITJcWQj9E seeyc13ojC5BXu0aQZG5KcerhesMEYloY+EmDxWK7pulBdKUNUGMRBN X-Mailer: b4 0.12.3 Message-ID: <20231026-ethtool_puts_impl-v2-1-0d67cbdd0538@google.com> Subject: [PATCH next v2 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 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]); Thu, 26 Oct 2023 14:56:49 -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 | 34 +++++++++++++++++++++++----------- net/ethtool/ioctl.c | 7 +++++++ 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index 226a36ed5aa1..7129dd2e227c 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -1053,22 +1053,34 @@ 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; + u32 speed; __ETHTOOL_DECLARE_LINK_MODE_MASK(caps); - const u32 *cap_arr; - u32 arr_size; + const u32 *cap_arr; + u32 arr_size; }; -#define ETHTOOL_FORCED_SPEED_MAP(prefix, value) \ -{ \ - .speed = SPEED_##value, \ - .cap_arr = prefix##_##value, \ - .arr_size = ARRAY_SIZE(prefix##_##value), \ -} +#define ETHTOOL_FORCED_SPEED_MAP(prefix, value) \ + { \ + .speed = SPEED_##value, .cap_arr = prefix##_##value, \ + .arr_size = ARRAY_SIZE(prefix##_##value), \ + } -void -ethtool_forced_speed_maps_init(struct ethtool_forced_speed_map *maps, u32 size); +void ethtool_forced_speed_maps_init(struct ethtool_forced_speed_map *maps, + u32 size); #endif /* _LINUX_ETHTOOL_H */ 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