[PATCH] staging: octeon: replace printk_ratelimited() with net_ratelimit() helpers
From: Rareș-Mihai Vladu
Date: Fri Dec 04 2026 - 11:08:16 EST
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@xxxxxxxxx>
---
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