From nobody Sun Nov 24 20:32:17 2024 Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A2F031E8836; Fri, 1 Nov 2024 21:48:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730497716; cv=none; b=ZBXd0mNYSHEq3zdgbzXFQVVa02BXqINhRUcixwUotIR88rztFrt8pF/hLJcTGcK/RrY5sfrWL949EjzNzfl5zFFE+XWNdqbwbn4CM+nxnZjFRskFc/Ry//9xevIveutldQt+s0SLWLl4KnlijUyUCERB7s9qnMWgsTrQHlE3xWs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730497716; c=relaxed/simple; bh=8sXedxHOlW4bDTZN6PpOHgHvpLJs9HJzgWaAyncbOys=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y2BMpL4ciVhn1vyusYvT63a3tmmympj9PgUuemzxvIYk3fIz4pkbpnM9kTwuqZx+eo8sAk8teytp8YZhtFj85teGJzjU46e48Ht1RnqZllNolIq5lvaSNIFpJMTEt2JFCp6R+0ospztwLGUEFndavgoNVMtWaGMoRgNg/JkGYvk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=JVtAlPPt; arc=none smtp.client-ip=209.85.216.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JVtAlPPt" Received: by mail-pj1-f43.google.com with SMTP id 98e67ed59e1d1-2e3d523a24dso1943367a91.0; Fri, 01 Nov 2024 14:48:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730497714; x=1731102514; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GR67c2FO6ibNJTIwnm+5i2JwWxhhER/sw1jRuBJAxf4=; b=JVtAlPPteyywim0l2R5A33Scgz4pvzqGMizMP0cwTIXUrfIyExgEvja2B+eU9vBJR6 entra85TWAn93JKSjiN3JSijQ3cmzzKZUcQ4a1An5nXYAgtIt8kw99f/loJ6qv4GvhHp HMtmHjcleEPy5oxZOzi82KxJGthtzptS9xStCJjc/mqgIv+/OQJTgECH89eb6m+Tf/dt xBG/SAr1vT45dX3seHxXFCxR2f7Spkjz5XDFdNdBz4nUWmH66f982U3mewjtBULNmZcu FXcPhwx5WzucemkCB2ChH8ZoG7Rf7JMJi9MmtYDdOodG5SyJ1IROQhQ4T56/HweFGilJ GFKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730497714; x=1731102514; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GR67c2FO6ibNJTIwnm+5i2JwWxhhER/sw1jRuBJAxf4=; b=FGjXs9/SnFm9dced+rRGoNrHShCylOhlhfd5IAxq+jQolW5kmQe0vGtABBPLt5QQvT XQ0rD25ymOfv4G6bKCCk+YjRhatFjIvSWdeSbgnvAHEtiVK96O1qDYk7gY8g5uuvo4vZ 0QWIO4EGT/ttCeqUz/I5fAD/pIrm8pBOI1tdloZvEefwlStb+vYydGNGiHHDQZbTnC/z G70gRwwNvCNVq/b31EFGqBHMp8C9jzRZ1Kkdb/PMM2/pHFSzXI7Dt5bCvfDsHKueiCWp +nc3GiGqJMjcK3mBy9erLX4fwV+xAlIjFPUuBzufRH0g3XZTOeCMOIJgXT4e5HN/yaw7 6t5A== X-Forwarded-Encrypted: i=1; AJvYcCUctaKxB6hTrrUwsJbgtw2ARKCLNL/MRuryBnxuoFmNgc8c85EW4E2/FRqPVcOpu3E0YNj8UawOd8FbHt4=@vger.kernel.org X-Gm-Message-State: AOJu0Yx47v+uxiyu0/J9EsCsunqLM1U1aL9Qd1qJ0Cmm0Vj/IinnkM+J WaoRUlaLJBFRW3D+Bd6wNR3jqdx768N9wqJ0dOec+XlfZg39TmCmGA0wgLkn X-Google-Smtp-Source: AGHT+IG+Tpr9D9Z5FljOzVS3fMUx6zOGqMt4YAjpCfoDMRjEQO5vIjLgvCHtBA/MI9+sXWU6IRAmwQ== X-Received: by 2002:a17:90b:17cb:b0:2e2:c835:bc31 with SMTP id 98e67ed59e1d1-2e8f104ca34mr26742401a91.7.1730497713706; Fri, 01 Nov 2024 14:48:33 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-211057cf273sm25120155ad.239.2024.11.01.14.48.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2024 14:48:33 -0700 (PDT) From: Rosen Penev To: netdev@vger.kernel.org Cc: Shay Agroskin , Arthur Kiyanovski , David Arinzon , Noam Dagan , Saeed Bishara , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jian Shen , Salil Mehta , Jijie Shao , linux-kernel@vger.kernel.org (open list) Subject: [PATCH net-next 1/2] net: ena: remove devm from ethtool Date: Fri, 1 Nov 2024 14:48:27 -0700 Message-ID: <20241101214828.289752-2-rosenp@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241101214828.289752-1-rosenp@gmail.com> References: <20241101214828.289752-1-rosenp@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" There's no need for devm bloat here. In addition, these are freed right before the function exits. Also swapped kcalloc order for consistency. Signed-off-by: Rosen Penev Reviewed-by: Shay Agroskin --- drivers/net/ethernet/amazon/ena/ena_ethtool.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/amazon/ena/ena_ethtool.c b/drivers/net/et= hernet/amazon/ena/ena_ethtool.c index e1c622b40a27..fa9d7b8ec00d 100644 --- a/drivers/net/ethernet/amazon/ena/ena_ethtool.c +++ b/drivers/net/ethernet/amazon/ena/ena_ethtool.c @@ -1128,22 +1128,18 @@ static void ena_dump_stats_ex(struct ena_adapter *a= dapter, u8 *buf) return; } =20 - strings_buf =3D devm_kcalloc(&adapter->pdev->dev, - ETH_GSTRING_LEN, strings_num, - GFP_ATOMIC); + strings_buf =3D kcalloc(strings_num, ETH_GSTRING_LEN, GFP_ATOMIC); if (!strings_buf) { netif_err(adapter, drv, netdev, "Failed to allocate strings_buf\n"); return; } =20 - data_buf =3D devm_kcalloc(&adapter->pdev->dev, - strings_num, sizeof(u64), - GFP_ATOMIC); + data_buf =3D kcalloc(strings_num, sizeof(u64), GFP_ATOMIC); if (!data_buf) { netif_err(adapter, drv, netdev, "Failed to allocate data buf\n"); - devm_kfree(&adapter->pdev->dev, strings_buf); + kfree(strings_buf); return; } =20 @@ -1165,8 +1161,8 @@ static void ena_dump_stats_ex(struct ena_adapter *ada= pter, u8 *buf) strings_buf + i * ETH_GSTRING_LEN, data_buf[i]); =20 - devm_kfree(&adapter->pdev->dev, strings_buf); - devm_kfree(&adapter->pdev->dev, data_buf); + kfree(strings_buf); + kfree(data_buf); } =20 void ena_dump_stats_to_buf(struct ena_adapter *adapter, u8 *buf) --=20 2.47.0 From nobody Sun Nov 24 20:32:17 2024 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4D99A1F5827; Fri, 1 Nov 2024 21:48:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730497717; cv=none; b=LzXOULSAx2mMFsWKZ+m327DILJjeIvt1443KCMS5V/Ok+yNIB4ttRTVnUGUaIG6SStqbBmIsK6gDXYCEoYWaz6zxDtLjMQi2J3WjNNSlxcpgp3Qndgcy7mKvZmr4o5N9gudbrc0A/79AczuMVRMzAScabbgDaYIMbLburjyLOeY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730497717; c=relaxed/simple; bh=r7j2WvtsieCpZbMv5XMgyVj6RY6NOBqWFXbpmlBC0Gs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DcOzF79hVTGh7DGJw//AOCeAxebNfzOZPey24+p7lK6p56TAZ8n9COdmee8PrBwpYGIb0L2Prf2NnDTcpu+H2C76xITxGp9gPdvBQmN01jiEaCS2zAxOVaZR3YFu9/fBsywWODBTNRav8guYKav2wI2zDD35wE8RfqnuHdvk8A0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Do/nMTSY; arc=none smtp.client-ip=209.85.214.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Do/nMTSY" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-20cbcd71012so28387655ad.3; Fri, 01 Nov 2024 14:48:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730497715; x=1731102515; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JkCgUid3lALqAkyziGA3/78dlQ1W88S6aeKIVhXq5Qo=; b=Do/nMTSYCOUuHUb6raBXJlra9cnAqXor+XP59lK4xMnvpTP/72rWKxhfB6lix7tRXW JtKYHBKgP7y0MwRv/QZkDQu0ppY87qVyPDhO1g4UFjT7qHIPJzFPJDH4WvOrEB5cscBv azJ9aN54AK1kCYZYFZ6zpKvQ8Tuyois7p80iVaCxjDV1IMoMKmGgrUI0fLJxpnWiaPuJ 2CrCLcSiBJwac6OSd70sKFBWYQgAMRKJmNlo3X3qi7Rww2R3XtTjs7acHlN90dohMHMZ W2UnB02HJ25BY6RKE0tH3BQBu8gnxJjstlAzvEy/NkBTwHj+dUa9vOWS9I9T7MSO+3gF lFJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730497715; x=1731102515; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JkCgUid3lALqAkyziGA3/78dlQ1W88S6aeKIVhXq5Qo=; b=AZIC57rY0sda0mbYUzWGZVvBPyEZFIzTraf2dTBmzqamWuHGBe5z5H7tn5Xr8iF6yl nNLxgg1flAy55v+j10eM/O6BQ0NSv34yuIqU2/kusvlAQckDcolPGzS1ecJAi7+hzfnx 2DRZnyhYgGx1CTd3VYgKk3rcseFYsOh9MX1lQmibEF3EmA9ZmngexRpJV++KyR16juS4 UcWogJDYyngcF6VFIg8NiReaJvrOwChcedvQuUkgJhyrh5P7CIS8MkDnX+YBNxLWwqh6 GocQnXo+xehCHkeg416PeoqYCIlpVhUM3hUet+9O71/+0r+Iryd6xXjcV+PXqIKP/X97 gV3w== X-Forwarded-Encrypted: i=1; AJvYcCUyHJqYx+EvhqvDW37/cu+PwggmQZtWzqHHL9tqnlJAvimqo/dlCqDBLf86RLu65AyZAm5EfDjmd+fP1uE=@vger.kernel.org X-Gm-Message-State: AOJu0YzbifJTAfcoAZ8MV+HHwjeIIGDKSnk7lwUPHSkeKuScpnmcDC4A VxodHTnQBHcViESjDNez/RbWG2OvMdxoe34N+CRoS+rWit54oaJvyAgHmOf7 X-Google-Smtp-Source: AGHT+IF7TeB8qbK2O90WipxhJ5So7uylLqr58H+sqar5PQ2+2Kz9JTR8a/Tonh8MQjF4WjwptrcObQ== X-Received: by 2002:a17:902:ce91:b0:20c:7a0b:74a3 with SMTP id d9443c01a7336-2111af0aa80mr59481315ad.24.1730497715423; Fri, 01 Nov 2024 14:48:35 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-211057cf273sm25120155ad.239.2024.11.01.14.48.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2024 14:48:35 -0700 (PDT) From: Rosen Penev To: netdev@vger.kernel.org Cc: Shay Agroskin , Arthur Kiyanovski , David Arinzon , Noam Dagan , Saeed Bishara , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jian Shen , Salil Mehta , Jijie Shao , linux-kernel@vger.kernel.org (open list) Subject: [PATCH net-next 2/2] net: ena: simplify some pointer addition Date: Fri, 1 Nov 2024 14:48:28 -0700 Message-ID: <20241101214828.289752-3-rosenp@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241101214828.289752-1-rosenp@gmail.com> References: <20241101214828.289752-1-rosenp@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use ethtool_sprintf to simplify the code. Because strings_buf is separate from buf, it needs to be incremented separately. Signed-off-by: Rosen Penev --- drivers/net/ethernet/amazon/ena/ena_ethtool.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/amazon/ena/ena_ethtool.c b/drivers/net/et= hernet/amazon/ena/ena_ethtool.c index fa9d7b8ec00d..96fa55a88faf 100644 --- a/drivers/net/ethernet/amazon/ena/ena_ethtool.c +++ b/drivers/net/ethernet/amazon/ena/ena_ethtool.c @@ -1120,7 +1120,7 @@ static void ena_dump_stats_ex(struct ena_adapter *ada= pter, u8 *buf) u8 *strings_buf; u64 *data_buf; int strings_num; - int i, rc; + int i; =20 strings_num =3D ena_get_sw_stats_count(adapter); if (strings_num <=3D 0) { @@ -1149,17 +1149,16 @@ static void ena_dump_stats_ex(struct ena_adapter *a= dapter, u8 *buf) /* If there is a buffer, dump stats, otherwise print them to dmesg */ if (buf) for (i =3D 0; i < strings_num; i++) { - rc =3D snprintf(buf, ETH_GSTRING_LEN + sizeof(u64), - "%s %llu\n", - strings_buf + i * ETH_GSTRING_LEN, - data_buf[i]); - buf +=3D rc; + ethtool_sprintf(&buf, "%s %llu\n", strings_buf, + data_buf[i]); + strings_buf +=3D ETH_GSTRING_LEN; } else - for (i =3D 0; i < strings_num; i++) + for (i =3D 0; i < strings_num; i++) { netif_err(adapter, drv, netdev, "%s: %llu\n", - strings_buf + i * ETH_GSTRING_LEN, - data_buf[i]); + strings_buf, data_buf[i]); + strings_buf +=3D ETH_GSTRING_LEN; + } =20 kfree(strings_buf); kfree(data_buf); --=20 2.47.0