mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Rareș-Mihai Vladu" <vladurares@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org,
	"Rareș-Mihai Vladu" <vladurares@gmail.com>
Subject: [PATCH] staging: octeon: replace printk_ratelimited() with net_ratelimit() helpers
Date: Fri,  4 Dec 2026 16:07:22 +0000	[thread overview]
Message-ID: <20261204160722.3749740-1-vladurares@gmail.com> (raw)

The rx, tx and rgmii code use printk_ratelimited() without a log
level, so these messages are printed at the default level.

In tx and rgmii a net_device is available, so use netdev_err() and
netdev_info() guarded by net_ratelimit(). This also prints the
interface name, so the "%s: " prefix with dev->name is dropped. In rx
there is no net_device at these points, so use net_warn_ratelimited().

Note that net_ratelimit() uses one shared ratelimit state for
networking, instead of a separate state for each call site.

linux/ratelimit.h is no longer used in these files, so remove it.

Found by grepping the driver for printk_ratelimited(). Compile tested
with COMPILE_TEST on x86_64, with W=1 and sparse.

Signed-off-by: Rareș-Mihai Vladu <vladurares@gmail.com>
---
 drivers/staging/octeon/ethernet-rgmii.c |  5 ++---
 drivers/staging/octeon/ethernet-rx.c    | 13 ++++++-------
 drivers/staging/octeon/ethernet-tx.c    | 13 ++++++-------
 3 files changed, 14 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/octeon/ethernet-rgmii.c b/drivers/staging/octeon/ethernet-rgmii.c
index 0c4fac31540a..9360715bc24f 100644
--- a/drivers/staging/octeon/ethernet-rgmii.c
+++ b/drivers/staging/octeon/ethernet-rgmii.c
@@ -9,7 +9,6 @@
 #include <linux/netdevice.h>
 #include <linux/interrupt.h>
 #include <linux/phy.h>
-#include <linux/ratelimit.h>
 #include <net/dst.h>
 
 #include "octeon-ethernet.h"
@@ -83,8 +82,8 @@ static void cvm_oct_check_preamble_errors(struct net_device *dev)
 			 * disable preamble checking and do it in software.
 			 */
 			cvm_oct_set_hw_preamble(priv, false);
-			printk_ratelimited("%s: Using 10Mbps with software preamble removal\n",
-					   dev->name);
+			if (net_ratelimit())
+				netdev_info(dev, "Using 10Mbps with software preamble removal\n");
 		}
 	} else {
 		/*
diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
index 5ca30f5b046d..ddd8361236da 100644
--- a/drivers/staging/octeon/ethernet-rx.c
+++ b/drivers/staging/octeon/ethernet-rx.c
@@ -17,7 +17,6 @@
 #include <linux/ip.h>
 #include <linux/string.h>
 #include <linux/prefetch.h>
-#include <linux/ratelimit.h>
 #include <linux/smp.h>
 #include <linux/interrupt.h>
 #include <net/dst.h>
@@ -124,15 +123,15 @@ static inline int cvm_oct_check_rcv_error(struct cvmx_wqe *work)
 				return 0;
 			}
 
-			printk_ratelimited("Port %d unknown preamble, packet dropped\n",
-					   port);
+			net_warn_ratelimited("Port %d unknown preamble, packet dropped\n",
+					     port);
 			cvm_oct_free_work(work);
 			return 1;
 		}
 	}
 
-	printk_ratelimited("Port %d receive error code %d, packet dropped\n",
-			   port, work->word2.snoip.err_code);
+	net_warn_ratelimited("Port %d receive error code %d, packet dropped\n",
+			     port, work->word2.snoip.err_code);
 	cvm_oct_free_work(work);
 	return 1;
 }
@@ -361,8 +360,8 @@ static int cvm_oct_poll(struct oct_rx_group *rx_group, int budget)
 			 * Drop any packet received for a device that
 			 * doesn't exist.
 			 */
-			printk_ratelimited("Port %d not controlled by Linux, packet dropped\n",
-					   port);
+			net_warn_ratelimited("Port %d not controlled by Linux, packet dropped\n",
+					     port);
 			dev_kfree_skb_irq(skb);
 		}
 		/*
diff --git a/drivers/staging/octeon/ethernet-tx.c b/drivers/staging/octeon/ethernet-tx.c
index 44534b94aec2..fbddaa4f6aab 100644
--- a/drivers/staging/octeon/ethernet-tx.c
+++ b/drivers/staging/octeon/ethernet-tx.c
@@ -11,7 +11,6 @@
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/ip.h>
-#include <linux/ratelimit.h>
 #include <linux/string.h>
 #include <linux/interrupt.h>
 #include <net/dst.h>
@@ -431,8 +430,8 @@ netdev_tx_t cvm_oct_xmit(struct sk_buff *skb, struct net_device *dev)
 						 priv->queue + qos,
 						 pko_command, hw_buffer,
 						 CVMX_PKO_LOCK_NONE))) {
-		printk_ratelimited("%s: Failed to send the packet\n",
-				   dev->name);
+		if (net_ratelimit())
+			netdev_err(dev, "Failed to send the packet\n");
 		queue_type = QUEUE_DROP;
 	}
 skip_xmit:
@@ -512,8 +511,8 @@ netdev_tx_t cvm_oct_xmit_pow(struct sk_buff *skb, struct net_device *dev)
 	struct cvmx_wqe *work = cvmx_fpa_alloc(CVMX_FPA_WQE_POOL);
 
 	if (unlikely(!work)) {
-		printk_ratelimited("%s: Failed to allocate a work queue entry\n",
-				   dev->name);
+		if (net_ratelimit())
+			netdev_err(dev, "Failed to allocate a work queue entry\n");
 		dev->stats.tx_dropped++;
 		dev_kfree_skb_any(skb);
 		return 0;
@@ -522,8 +521,8 @@ netdev_tx_t cvm_oct_xmit_pow(struct sk_buff *skb, struct net_device *dev)
 	/* Get a packet buffer */
 	packet_buffer = cvmx_fpa_alloc(CVMX_FPA_PACKET_POOL);
 	if (unlikely(!packet_buffer)) {
-		printk_ratelimited("%s: Failed to allocate a packet buffer\n",
-				   dev->name);
+		if (net_ratelimit())
+			netdev_err(dev, "Failed to allocate a packet buffer\n");
 		cvmx_fpa_free(work, CVMX_FPA_WQE_POOL, 1);
 		dev->stats.tx_dropped++;
 		dev_kfree_skb_any(skb);
-- 
2.43.0


             reply	other threads:[~2026-12-04 16:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 16:07 Rareș-Mihai Vladu [this message]
2026-12-05 20:52 ` Ellian Costa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261204160722.3749740-1-vladurares@gmail.com \
    --to=vladurares@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®