[PATCH v5 1/4] staging: octeon: ethernet-mem: replace pr_warn with dev_warn in free functions

Ayush Mukkanwar
2026-04-27T15:18:02Z

Replace pr_warn() calls with dev_warn() in the hardware pool free
functions (cvm_oct_free_hw_skbuff and cvm_oct_free_hw_memory)
to include device information in log messages. The struct device
pointer is passed from cvm_oct_remove() through
cvm_oct_mem_empty_fpa() to the internal free functions.

Signed-off-by: Ayush Mukkanwar <ayushmukkanwar@gmail.com>
---
drivers/staging/octeon/ethernet-mem.c | 30 +++++++++++++++------------
drivers/staging/octeon/ethernet-mem.h | 2 +-
drivers/staging/octeon/ethernet.c | 6 +++---
3 files changed, 21 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/octeon/ethernet-mem.c b/drivers/staging/octeon/ethernet-mem.c
index 532594957ebc..501a2f7487c1 100644
--- a/drivers/staging/octeon/ethernet-mem.c
+++ b/drivers/staging/octeon/ethernet-mem.c
@@ -40,11 +40,13 @@ static int cvm_oct_fill_hw_skbuff(int pool, int size, int elements)

/**
* cvm_oct_free_hw_skbuff- free hardware pool skbuffs
+ * @dev: Device for logging
* @pool: Pool to allocate an skbuff for
* @size: Size of the buffer needed for the pool
* @elements: Number of buffers to allocate
*/
-static void cvm_oct_free_hw_skbuff(int pool, int size, int elements)
+static void cvm_oct_free_hw_skbuff(struct device *dev,
+ int pool, int size, int elements)
{
char *memory;

@@ -59,11 +61,11 @@ static void cvm_oct_free_hw_skbuff(int pool, int size, int elements)
} while (memory);

if (elements < 0)
- pr_warn("Freeing of pool %u had too many skbuffs (%d)\n",
- pool, elements);
+ dev_warn(dev, "Freeing of pool %u had too many skbuffs (%d)\n",
+ pool, elements);
else if (elements > 0)
- pr_warn("Freeing of pool %u is missing %d skbuffs\n",
- pool, elements);
+ dev_warn(dev, "Freeing of pool %u is missing %d skbuffs\n",
+ pool, elements);
}

/**
@@ -107,11 +109,13 @@ static int cvm_oct_fill_hw_memory(int pool, int size, int elements)

/**
* cvm_oct_free_hw_memory - Free memory allocated by cvm_oct_fill_hw_memory
+ * @dev: Device for logging
* @pool: FPA pool to free
* @size: Size of each buffer in the pool
* @elements: Number of buffers that should be in the pool
*/
-static void cvm_oct_free_hw_memory(int pool, int size, int elements)
+static void cvm_oct_free_hw_memory(struct device *dev,
+ int pool, int size, int elements)
{
char *memory;
char *fpa;
@@ -127,11 +131,11 @@ static void cvm_oct_free_hw_memory(int pool, int size, int elements)
} while (fpa);

if (elements < 0)
- pr_warn("Freeing of pool %u had too many buffers (%d)\n",
- pool, elements);
+ dev_warn(dev, "Freeing of pool %u had too many buffers (%d)\n",
+ pool, elements);
else if (elements > 0)
- pr_warn("Warning: Freeing of pool %u is missing %d buffers\n",
- pool, elements);
+ dev_warn(dev, "Freeing of pool %u is missing %d buffers\n",
+ pool, elements);
}

int cvm_oct_mem_fill_fpa(int pool, int size, int elements)
@@ -145,10 +149,10 @@ int cvm_oct_mem_fill_fpa(int pool, int size, int elements)
return freed;
}

-void cvm_oct_mem_empty_fpa(int pool, int size, int elements)
+void cvm_oct_mem_empty_fpa(struct device *dev, int pool, int size, int elements)
{
if (pool == CVMX_FPA_PACKET_POOL)
- cvm_oct_free_hw_skbuff(pool, size, elements);
+ cvm_oct_free_hw_skbuff(dev, pool, size, elements);
else
- cvm_oct_free_hw_memory(pool, size, elements);
+ cvm_oct_free_hw_memory(dev, pool, size, elements);
}
diff --git a/drivers/staging/octeon/ethernet-mem.h b/drivers/staging/octeon/ethernet-mem.h
index 692dcdb7154d..591e0bbb6f10 100644
--- a/drivers/staging/octeon/ethernet-mem.h
+++ b/drivers/staging/octeon/ethernet-mem.h
@@ -6,4 +6,4 @@
*/

int cvm_oct_mem_fill_fpa(int pool, int size, int elements);
-void cvm_oct_mem_empty_fpa(int pool, int size, int elements);
+void cvm_oct_mem_empty_fpa(struct device *dev, int pool, int size, int elements);
diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
index eadb74fc14c8..9eed0a89a2f3 100644
--- a/drivers/staging/octeon/ethernet.c
+++ b/drivers/staging/octeon/ethernet.c
@@ -958,12 +958,12 @@ static void cvm_oct_remove(struct platform_device *pdev)
cvmx_ipd_free_ptr();

/* Free the HW pools */
- cvm_oct_mem_empty_fpa(CVMX_FPA_PACKET_POOL, CVMX_FPA_PACKET_POOL_SIZE,
+ cvm_oct_mem_empty_fpa(&pdev->dev, CVMX_FPA_PACKET_POOL, CVMX_FPA_PACKET_POOL_SIZE,
num_packet_buffers);
- cvm_oct_mem_empty_fpa(CVMX_FPA_WQE_POOL, CVMX_FPA_WQE_POOL_SIZE,
+ cvm_oct_mem_empty_fpa(&pdev->dev, CVMX_FPA_WQE_POOL, CVMX_FPA_WQE_POOL_SIZE,
num_packet_buffers);
if (CVMX_FPA_OUTPUT_BUFFER_POOL != CVMX_FPA_PACKET_POOL)
- cvm_oct_mem_empty_fpa(CVMX_FPA_OUTPUT_BUFFER_POOL,
+ cvm_oct_mem_empty_fpa(&pdev->dev, CVMX_FPA_OUTPUT_BUFFER_POOL,
CVMX_FPA_OUTPUT_BUFFER_POOL_SIZE, 128);
}

--
2.53.0